Files
ladill-queue/tests/Feature/EnsurePlatformSessionTest.php
T
isaaccladandCursor 6e7255b9f5
Deploy Ladill Queue / deploy (push) Successful in 39s
Add tests for throttled platform session middleware.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 16:51:53 +00:00

59 lines
1.6 KiB
PHP

<?php
namespace Tests\Feature;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
class EnsurePlatformSessionTest extends TestCase
{
use RefreshDatabase;
public function test_skips_auth_ping_when_recently_verified(): void
{
config(['app.auth_domain' => '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);
}
}