Skip to content

Commit b11e530

Browse files
committed
Fix Laravel 9 compatibility by checking sanctum attribute instead of session state
Changed 'authentication works when APP_URL matches request domain' test to check for the 'sanctum' attribute instead of session state. The session->isStarted() check behaves differently in Laravel 9's test environment, causing false failures. The sanctum attribute is set directly in the middleware pipeline and is more reliable across Laravel versions for verifying the middleware actually ran.
1 parent 1b336a7 commit b11e530

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tests/Feature/Authorization/ApiAuthenticationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@
4949
test('authentication works when APP_URL matches request domain', function () {
5050
config(['app.url' => 'http://example.com']);
5151

52-
// Auth callback that requires session to be started (proving session middleware was applied)
52+
// Auth callback that checks for sanctum attribute (proving middleware pipeline ran)
5353
LogViewer::auth(function ($request) {
54-
if (! $request->hasSession() || ! $request->session()->isStarted()) {
54+
if (! $request->attributes->get('sanctum')) {
5555
return false;
5656
}
5757

0 commit comments

Comments
 (0)