diff --git a/tests/Feature/EnsurePlatformSessionTest.php b/tests/Feature/EnsurePlatformSessionTest.php new file mode 100644 index 0000000..be27491 --- /dev/null +++ b/tests/Feature/EnsurePlatformSessionTest.php @@ -0,0 +1,58 @@ + 'auth.ladill.com']); + + $user = User::create([ + 'public_id' => 'session-test-001', + 'name' => 'Tester', + 'email' => 'session-test@example.com', + 'password' => bcrypt('password'), + ]); + + Http::fake(); + + $this->actingAs($user) + ->withSession(['platform_session_verified_at' => time()]) + ->get(route('qms.dashboard')) + ->assertRedirect(); + + Http::assertNothingSent(); + } + + public function test_pings_auth_when_verification_expired(): void + { + config(['app.auth_domain' => 'auth.ladill.com']); + + $user = User::create([ + 'public_id' => 'session-test-002', + 'name' => 'Tester', + 'email' => 'session-test-2@example.com', + 'password' => bcrypt('password'), + ]); + + Http::fake([ + 'https://auth.ladill.com/sso/ping' => Http::response('', 204), + ]); + + $this->actingAs($user) + ->withSession(['platform_session_verified_at' => time() - 120]) + ->withHeader('Cookie', 'laravel_session=fake-session-id') + ->get(route('qms.dashboard')) + ->assertRedirect(); + + Http::assertSentCount(1); + } +}