MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / resolve_inheritance_bounded

Function resolve_inheritance_bounded

nodedb/src/control/security/role.rs:630–651  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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}

Callers

nothing calls this directly

Calls 3

create_roleMethod · 0.80
to_stringMethod · 0.80
resolve_inheritanceMethod · 0.80

Tested by

no test coverage detected