(t *testing.T)
| 411 | } |
| 412 | |
| 413 | func 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 | |
| 442 | type testCustomRoleManager struct{} |
| 443 |
nothing calls this directly
no test coverage detected
searching dependent graphs…