(t *testing.T)
| 308 | } |
| 309 | |
| 310 | func TestImplicitRoleAPI(t *testing.T) { |
| 311 | e, _ := NewEnforcer("examples/rbac_model.conf", "examples/rbac_with_hierarchy_policy.csv") |
| 312 | |
| 313 | testGetPermissions(t, e, "alice", [][]string{{"alice", "data1", "read"}}) |
| 314 | testGetPermissions(t, e, "bob", [][]string{{"bob", "data2", "write"}}) |
| 315 | |
| 316 | testGetImplicitRoles(t, e, "alice", []string{"admin", "data1_admin", "data2_admin"}) |
| 317 | testGetImplicitRoles(t, e, "bob", []string{}) |
| 318 | |
| 319 | e, _ = NewEnforcer("examples/rbac_with_pattern_model.conf", "examples/rbac_with_pattern_policy.csv") |
| 320 | |
| 321 | e.GetRoleManager().AddMatchingFunc("matcher", util.KeyMatch) |
| 322 | e.AddNamedMatchingFunc("g2", "matcher", util.KeyMatch) |
| 323 | |
| 324 | // testGetImplicitRoles(t, e, "cathy", []string{"/book/1/2/3/4/5", "pen_admin", "/book/*", "book_group"}) |
| 325 | testGetImplicitRoles(t, e, "cathy", []string{"/book/1/2/3/4/5", "pen_admin"}) |
| 326 | testGetRoles(t, e, []string{"/book/1/2/3/4/5", "pen_admin"}, "cathy") |
| 327 | } |
| 328 | |
| 329 | func testGetImplicitPermissions(t *testing.T, e *Enforcer, name string, res [][]string, domain ...string) { |
| 330 | t.Helper() |
nothing calls this directly
no test coverage detected
searching dependent graphs…