[v9.1.x] RBAC: Fix resolver issue on wildcard resulting in wrong status code (#54692)

* RBAC: Fix resolver issue on wildcard resulting in wrong status code for endpoints (#54208)

* RBAC: Test evaluation before attaching mutator

* RBAC: Return error if no resolver is found for scope

* RBAC: Sync changes to evaluation in mock

* RBAC: Check for resolver not found error and just fail the evaluation in that case

(cherry picked from commit 552d3fec8d)
This commit is contained in:
Karl Persson
2022-09-06 09:08:49 +02:00
committed by GitHub
parent 6e300048ed
commit 843ca0a355
6 changed files with 51 additions and 26 deletions
@@ -44,10 +44,11 @@ func extractRawPermissionsHelper(perms []accesscontrol.Permission) []accesscontr
}
type evaluatingPermissionsTestCase struct {
desc string
user userTestCase
endpoints []endpointTestCase
evalResult bool
desc string
user userTestCase
endpoints []endpointTestCase
evalResult bool
expectedErr error
}
type userTestCase struct {
@@ -85,7 +86,8 @@ func TestEvaluatingPermissions(t *testing.T) {
endpoints: []endpointTestCase{
{evaluator: accesscontrol.EvalPermission(accesscontrol.ActionUsersCreate, accesscontrol.ScopeGlobalUsersAll)},
},
evalResult: false,
evalResult: false,
expectedErr: accesscontrol.ErrResolverNotFound,
},
}
for _, tc := range testCases {
@@ -109,7 +111,7 @@ func TestEvaluatingPermissions(t *testing.T) {
for _, endpoint := range tc.endpoints {
result, err := ac.Evaluate(context.Background(), user, endpoint.evaluator)
require.NoError(t, err)
assert.ErrorIs(t, err, tc.expectedErr)
assert.Equal(t, tc.evalResult, result)
}
})