(t *testing.T, e *Enforcer, res [][]string, user string, domain ...string)
| 422 | } |
| 423 | |
| 424 | func 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 | |
| 450 | func TestGetImplicitResourcesForUser(t *testing.T) { |
| 451 | e, _ := NewEnforcer("examples/rbac_with_pattern_model.conf", "examples/rbac_with_pattern_policy.csv") |
no test coverage detected
searching dependent graphs…