MCPcopy Index your code
hub / github.com/apache/casbin / TestImplicitUserAPI

Function TestImplicitUserAPI

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

Source from the content-addressed store, hash-verified

407}
408
409func TestImplicitUserAPI(t *testing.T) {
410 e, _ := NewEnforcer("examples/rbac_model.conf", "examples/rbac_with_hierarchy_policy.csv")
411
412 testGetImplicitUsers(t, e, []string{"alice"}, "data1", "read")
413 testGetImplicitUsers(t, e, []string{"alice"}, "data1", "write")
414 testGetImplicitUsers(t, e, []string{"alice"}, "data2", "read")
415 testGetImplicitUsers(t, e, []string{"alice", "bob"}, "data2", "write")
416
417 e.ClearPolicy()
418 _, _ = e.AddPolicy("admin", "data1", "read")
419 _, _ = e.AddPolicy("bob", "data1", "read")
420 _, _ = e.AddGroupingPolicy("alice", "admin")
421 testGetImplicitUsers(t, e, []string{"alice", "bob"}, "data1", "read")
422}
423
424func testGetImplicitResourcesForUser(t *testing.T, e *Enforcer, res [][]string, user string, domain ...string) {
425 t.Helper()

Callers

nothing calls this directly

Calls 5

ClearPolicyMethod · 0.95
AddPolicyMethod · 0.95
AddGroupingPolicyMethod · 0.95
NewEnforcerFunction · 0.85
testGetImplicitUsersFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…