Skip to content

Commit

Permalink
✅ add tests for too many login attempts (#2733)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKrisKrisu authored Jul 5, 2024
1 parent 2094253 commit 87559da
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/Feature/Frontend/AuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,25 @@ public function testLoginWithWrongCredentials(): void {
$this->assertGuest();
}

public function testTooManyLoginAttempts(): void {
$user = User::factory()->create();
$this->assertGuest();
for ($i = 0; $i < 5; $i++) {
$response = $this->post(route('login', [
'login' => $user->username,
'password' => 'wrong password',
]));
$response->assertRedirectToRoute('login');
$this->assertGuest();
}
$response = $this->post(route('login', [
'login' => $user->username,
'password' => 'wrong password',
]));
$response->assertSessionHasErrors('login');
$this->assertGuest();
}

public function testSuccessfulRegistration(): void {
$this->assertGuest();
$this->assertDatabaseMissing('users', ['username' => 'alice123']);
Expand Down

0 comments on commit 87559da

Please sign in to comment.