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

Function testGetImplicitResourcesForUser

rbac_api_test.go:424–448  ·  view source on GitHub ↗
(t *testing.T, e *Enforcer, res [][]string, user string, domain ...string)

Source from the content-addressed store, hash-verified

422}
423
424func testGetImplicitResourcesForUser(t *testing.T, e *Enforcer, res [][]string, user string, domain ...string) {
425 t.Helper()
426 myRes, _ := e.GetImplicitResourcesForUser(user, domain...)
427 t.Log("Implicit resources for user: ", user, ": ", myRes)
428
429 lessFunc := func(arr [][]string) func(int, int) bool {
430 return func(i, j int) bool {
431 policy1, policy2 := arr[i], arr[j]
432 for k := range policy1 {
433 if policy1[k] == policy2[k] {
434 continue
435 }
436 return policy1[k] < policy2[k]
437 }
438 return true
439 }
440 }
441
442 sort.Slice(res, lessFunc(res))
443 sort.Slice(myRes, lessFunc(myRes))
444
445 if !util.Array2DEquals(res, myRes) {
446 t.Error("Implicit resources for user: ", user, ": ", myRes, ", supposed to be ", res)
447 }
448}
449
450func TestGetImplicitResourcesForUser(t *testing.T) {
451 e, _ := NewEnforcer("examples/rbac_with_pattern_model.conf", "examples/rbac_with_pattern_policy.csv")

Callers 1

Calls 3

Array2DEqualsFunction · 0.92
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…