()
| 628 | /// entries and never spin infinitely. |
| 629 | #[test] |
| 630 | fn resolve_inheritance_bounded() { |
| 631 | let store = RoleStore::new(); |
| 632 | // Build a valid chain of exactly MAX_ROLE_INHERITANCE_DEPTH roles. |
| 633 | store |
| 634 | .create_role("root", TenantId::new(1), None, None) |
| 635 | .unwrap(); |
| 636 | let mut prev = "root".to_string(); |
| 637 | for i in 1..MAX_ROLE_INHERITANCE_DEPTH { |
| 638 | let name = format!("node{i}"); |
| 639 | store |
| 640 | .create_role(&name, TenantId::new(1), Some(&prev), None) |
| 641 | .unwrap(); |
| 642 | prev = name; |
| 643 | } |
| 644 | let chain = store.resolve_inheritance(&Role::Custom(prev)).unwrap(); |
| 645 | assert!( |
| 646 | chain.len() <= MAX_ROLE_INHERITANCE_DEPTH, |
| 647 | "chain length {} exceeds MAX_ROLE_INHERITANCE_DEPTH {}", |
| 648 | chain.len(), |
| 649 | MAX_ROLE_INHERITANCE_DEPTH |
| 650 | ); |
| 651 | } |
| 652 | } |
nothing calls this directly
no test coverage detected