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

Function TestDomainMatchModel

model_test.go:670–684  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

668}
669
670func TestDomainMatchModel(t *testing.T) {
671 e, _ := NewEnforcer("examples/rbac_with_domain_pattern_model.conf", "examples/rbac_with_domain_pattern_policy.csv")
672 e.AddNamedDomainMatchingFunc("g", "keyMatch2", util.KeyMatch2)
673
674 testDomainEnforce(t, e, "alice", "domain1", "data1", "read", true)
675 testDomainEnforce(t, e, "alice", "domain1", "data1", "write", true)
676 testDomainEnforce(t, e, "alice", "domain1", "data2", "read", false)
677 testDomainEnforce(t, e, "alice", "domain1", "data2", "write", false)
678 testDomainEnforce(t, e, "alice", "domain2", "data2", "read", true)
679 testDomainEnforce(t, e, "alice", "domain2", "data2", "write", true)
680 testDomainEnforce(t, e, "bob", "domain2", "data1", "read", false)
681 testDomainEnforce(t, e, "bob", "domain2", "data1", "write", false)
682 testDomainEnforce(t, e, "bob", "domain2", "data2", "read", true)
683 testDomainEnforce(t, e, "bob", "domain2", "data2", "write", true)
684}
685
686func TestAllMatchModel(t *testing.T) {
687 e, _ := NewEnforcer("examples/rbac_with_all_pattern_model.conf", "examples/rbac_with_all_pattern_policy.csv")

Callers

nothing calls this directly

Calls 3

NewEnforcerFunction · 0.85
testDomainEnforceFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…