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

Function TestRBACModelWithDomainsAtRuntimeMockAdapter

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

Source from the content-addressed store, hash-verified

224}
225
226func TestRBACModelWithDomainsAtRuntimeMockAdapter(t *testing.T) {
227 adapter := fileadapter.NewAdapterMock("examples/rbac_with_domains_policy.csv")
228 e, _ := NewEnforcer("examples/rbac_with_domains_model.conf", adapter)
229
230 _, _ = e.AddPolicy("admin", "domain3", "data1", "read")
231 _, _ = e.AddGroupingPolicy("alice", "admin", "domain3")
232
233 testDomainEnforce(t, e, "alice", "domain3", "data1", "read", true)
234
235 testDomainEnforce(t, e, "alice", "domain1", "data1", "read", true)
236 _, _ = e.RemoveFilteredPolicy(1, "domain1", "data1")
237 testDomainEnforce(t, e, "alice", "domain1", "data1", "read", false)
238
239 testDomainEnforce(t, e, "bob", "domain2", "data2", "read", true)
240 _, _ = e.RemovePolicy("admin", "domain2", "data2", "read")
241 testDomainEnforce(t, e, "bob", "domain2", "data2", "read", false)
242}
243
244func TestRBACModelWithDomainTokenRename(t *testing.T) {
245 // Test that renaming the domain token from "dom" to another name (e.g., "dom1")

Callers

nothing calls this directly

Calls 6

AddPolicyMethod · 0.95
AddGroupingPolicyMethod · 0.95
RemoveFilteredPolicyMethod · 0.95
RemovePolicyMethod · 0.95
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…