Middleware always returns 403 when using $this->actingAs($user, 'api') in unit tests. #2603
Unanswered
sprobejames
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Try changing default guard config(['auth.default.guard' => 'api']) Or set a testing bearer token laravel-permission/tests/TestCase.php Line 276 in 0e593bb |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The
$user = $authGuard->user();
in Spatie\Permission\Middleware\RoleMiddleware is alwaysnull
when using$this->actingAs($user, 'api')->json('GET', '/some-route');
in feature testing. However, if the url is tested directly using postman with bearer token, it works.Is there a way to test role/permission in route middleware using the
$this->actingAs($user, api)
method?Beta Was this translation helpful? Give feedback.
All reactions