@@ -201,7 +201,7 @@ func (s *MethodTestSuite) NoActorErrorTest(callMethod func(ctx context.Context)
201
201
// Asserts that the error returned is a NotAuthorizedError.
202
202
func (s * MethodTestSuite ) NotAuthorizedErrorTest (ctx context.Context , az * coderdtest.FakeAuthorizer , callMethod func (ctx context.Context ) ([]reflect.Value , error )) {
203
203
s .Run ("NotAuthorized" , func () {
204
- az .AlwaysReturn = xerrors .New ("Always fail authz" )
204
+ az .AlwaysReturn = rbac . ForbiddenWithInternal ( xerrors .New ("Always fail authz" ), rbac. Subject {}, "" , rbac. Object {}, nil )
205
205
206
206
// If we have assertions, that means the method should FAIL
207
207
// if RBAC will disallow the request. The returned error should
@@ -211,6 +211,7 @@ func (s *MethodTestSuite) NotAuthorizedErrorTest(ctx context.Context, az *coderd
211
211
// This is unfortunate, but if we are using `Filter` the error returned will be nil. So filter out
212
212
// any case where the error is nil and the response is an empty slice.
213
213
if err != nil || ! hasEmptySliceResponse (resp ) {
214
+ s .ErrorContainsf (err , "unauthorized" , "error string should have a good message" )
214
215
s .Errorf (err , "method should an error with disallow authz" )
215
216
s .ErrorIsf (err , sql .ErrNoRows , "error should match sql.ErrNoRows" )
216
217
s .ErrorAs (err , & dbauthz.NotAuthorizedError {}, "error should be NotAuthorizedError" )
0 commit comments