(t *testing.T, e *Enforcer, name string, role string, res bool, domain ...string)
| 58 | } |
| 59 | |
| 60 | func testHasRole(t *testing.T, e *Enforcer, name string, role string, res bool, domain ...string) { |
| 61 | t.Helper() |
| 62 | myRes, err := e.HasRoleForUser(name, role, domain...) |
| 63 | if err != nil { |
| 64 | t.Error("HasRoleForUser returned an error: ", err.Error()) |
| 65 | } |
| 66 | t.Log(name, " has role ", role, ": ", myRes) |
| 67 | |
| 68 | if res != myRes { |
| 69 | t.Error(name, " has role ", role, ": ", myRes, ", supposed to be ", res) |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | func TestRoleAPI(t *testing.T) { |
| 74 | e, _ := NewEnforcer("examples/rbac_model.conf", "examples/rbac_policy.csv") |
no test coverage detected
searching dependent graphs…