Add tests for throttled platform session middleware.
Deploy Ladill Queue / deploy (push) Successful in 39s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-06-30 16:51:53 +00:00
co-authored by Cursor
parent d2803fafb5
commit 6e7255b9f5
@@ -0,0 +1,58 @@
<?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);
}
}