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

Function testHasPermission

rbac_api_test.go:207–219  ·  view source on GitHub ↗
(t *testing.T, e *Enforcer, name string, permission []string, res bool)

Source from the content-addressed store, hash-verified

205}
206
207func testHasPermission(t *testing.T, e *Enforcer, name string, permission []string, res bool) {
208 t.Helper()
209 myRes, err := e.HasPermissionForUser(name, permission...)
210 if err != nil {
211 t.Error(err.Error())
212 }
213
214 t.Log(name, " has permission ", util.ArrayToString(permission), ": ", myRes)
215
216 if res != myRes {
217 t.Error(name, " has permission ", util.ArrayToString(permission), ": ", myRes, ", supposed to be ", res)
218 }
219}
220
221func testGetNamedPermissionsForUser(t *testing.T, e *Enforcer, ptype string, name string, res [][]string, domain ...string) {
222 t.Helper()

Callers 1

TestPermissionAPIFunction · 0.85

Calls 3

ArrayToStringFunction · 0.92
HasPermissionForUserMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…