3
0
mirror of https://github.com/snipe/snipe-it.git synced 2026-06-13 10:33:24 +00:00
Files
snipe-it/tests/Feature/Authentication/TwoFactorRateLimitTest.php
2026-05-26 13:31:33 +01:00

32 lines
771 B
PHP

<?php
namespace Tests\Feature\Authentication;
use App\Models\User;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class TwoFactorRateLimitTest extends TestCase
{
#[Test]
public function post_two_factor_is_rate_limited(): void
{
config(['auth.two_factor.max_attempts_per_min' => 3]);
$user = User::factory()->create([
'two_factor_secret' => 'JBSWY3DPEHPK3PXP',
'two_factor_enrolled' => 1,
]);
$this->actingAs($user);
for ($i = 0; $i < 3; $i++) {
$this->post('/two-factor', ['two_factor_secret' => '000000'])
->assertRedirect();
}
$this->post('/two-factor', ['two_factor_secret' => '000000'])
->assertStatus(429);
}
}