MCPcopy
hub / github.com/apache/casbin / testHasRole

Function testHasRole

rbac_api_test.go:60–71  ·  view source on GitHub ↗
(t *testing.T, e *Enforcer, name string, role string, res bool, domain ...string)

Source from the content-addressed store, hash-verified

58}
59
60func 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
73func TestRoleAPI(t *testing.T) {
74 e, _ := NewEnforcer("examples/rbac_model.conf", "examples/rbac_policy.csv")

Callers 2

TestRoleAPIFunction · 0.85
TestRoleAPI_DomainsFunction · 0.85

Calls 2

HasRoleForUserMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…