Fix: RBAC handle error no resolver found (#55676)
* Fix: Handle error no resolver found * Fix test not to expect the error
This commit is contained in:
@@ -2,6 +2,7 @@ package ossaccesscontrol
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/grafana/grafana/pkg/api/routing"
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
@@ -101,6 +102,9 @@ func (ac *OSSAccessControlService) Evaluate(ctx context.Context, user *models.Si
|
||||
|
||||
resolvedEvaluator, err := evaluator.MutateScopes(ctx, ac.scopeResolvers.GetScopeAttributeMutator(user.OrgId))
|
||||
if err != nil {
|
||||
if errors.Is(err, accesscontrol.ErrResolverNotFound) {
|
||||
return false, nil
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
return resolvedEvaluator.Evaluate(user.Permissions[user.OrgId]), nil
|
||||
|
||||
@@ -87,7 +87,7 @@ func TestEvaluatingPermissions(t *testing.T) {
|
||||
{evaluator: accesscontrol.EvalPermission(accesscontrol.ActionUsersCreate, accesscontrol.ScopeGlobalUsersAll)},
|
||||
},
|
||||
evalResult: false,
|
||||
expectedErr: accesscontrol.ErrResolverNotFound,
|
||||
expectedErr: nil,
|
||||
},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
|
||||
Reference in New Issue
Block a user