MCPcopy
hub / github.com/apache/casbin / TestConditional

Function TestConditional

rbac_api_test.go:700–713  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

698}
699
700func TestConditional(t *testing.T) {
701 e, _ := NewEnforcer("examples/rbac_with_domains_conditional_model.conf", "examples/rbac_with_domains_conditional_policy.csv")
702 g, _ := e.GetNamedGroupingPolicy("g")
703 for _, gp := range g {
704 e.AddNamedDomainLinkConditionFunc("g", gp[0], gp[1], gp[2], util.TimeMatchFunc)
705 }
706
707 testDomainEnforce(t, e, "alice", "domain1", "service1", "/list", true)
708 testDomainEnforce(t, e, "bob", "domain2", "service2", "/broadcast", true)
709 testDomainEnforce(t, e, "jack", "domain1", "service1", "/list", false)
710 testGetImplicitRolesInDomain(t, e, "alice", "domain1", []string{"test1"})
711 testGetRolesInDomain(t, e, "alice", "domain1", []string{"test1"})
712 testGetUsersInDomain(t, e, "test1", "domain1", []string{"alice"})
713}
714
715func TestMaxHierarchyLevelConsistency(t *testing.T) {
716 // Test consistency behavior under different maxHierarchyLevel values

Callers

nothing calls this directly

Calls 7

NewEnforcerFunction · 0.85
testDomainEnforceFunction · 0.85
testGetRolesInDomainFunction · 0.85
testGetUsersInDomainFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…