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

Function TestRBACModelWithDifferentTypesOfRoles

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

Source from the content-addressed store, hash-verified

411}
412
413func TestRBACModelWithDifferentTypesOfRoles(t *testing.T) {
414 e, _ := NewEnforcer("examples/rbac_with_different_types_of_roles_model.conf", "examples/rbac_with_different_types_of_roles_policy.csv")
415
416 g, err := e.GetNamedGroupingPolicy("g")
417 if err != nil {
418 t.Error(err)
419 }
420
421 for _, gp := range g {
422 if len(gp) != 5 {
423 t.Error("g parameters' num isn't 5")
424 return
425 }
426 e.AddNamedDomainLinkConditionFunc("g", gp[0], gp[1], gp[2], util.TimeMatchFunc)
427 }
428 testEnforce(t, e, "alice", "data1", "read", true)
429 testEnforce(t, e, "alice", "data1", "write", true)
430 testEnforce(t, e, "alice", "data2", "read", false)
431 testEnforce(t, e, "alice", "data2", "write", false)
432 testEnforce(t, e, "bob", "data1", "read", false)
433 testEnforce(t, e, "bob", "data1", "write", false)
434 testEnforce(t, e, "bob", "data2", "read", true)
435 testEnforce(t, e, "bob", "data2", "write", false)
436 testEnforce(t, e, "carol", "data1", "read", false)
437 testEnforce(t, e, "carol", "data1", "write", false)
438 testEnforce(t, e, "carol", "data2", "read", false)
439 testEnforce(t, e, "carol", "data2", "write", false)
440}
441
442type testCustomRoleManager struct{}
443

Callers

nothing calls this directly

Calls 5

NewEnforcerFunction · 0.85
testEnforceFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…