diff --git a/tests/Feature/Authentication/LoginTest.php b/tests/Feature/Authentication/LoginTest.php index 85bbc78ad..891781f96 100644 --- a/tests/Feature/Authentication/LoginTest.php +++ b/tests/Feature/Authentication/LoginTest.php @@ -1,6 +1,6 @@ create(['username' => 'username_here']); $this->withServerVariables(['REMOTE_ADDR' => '127.0.0.100']) @@ -27,6 +28,39 @@ class LoginTest extends TestCase ]); } + + public function testLoginThrottleConfigIsRespected() + { + + // Why do we need this? The app should already be set up + User::factory()->create(['username' => 'username_here']); + + config(['auth.passwords.users.throttle.max_attempts' => 1]); + config(['auth.passwords.users.throttle.lockout_duration' => 1]); + + for ($i = 0; $i < 2; ++$i) { + $this->from('/login') + ->withServerVariables(['REMOTE_ADDR' => '127.0.0.100']) + ->post('/login', [ + 'username' => 'invalid username', + 'password' => 'invalid password', + ]); + } + + + $response = $this->from('/login') + ->withServerVariables(['REMOTE_ADDR' => '127.0.0.100']) + ->post('/login', [ + 'username' => 'invalid username', + 'password' => 'invalid password', + ]) + ->assertSessionHasErrors(['username']) + ->assertStatus(302) + ->assertRedirect('/login'); + + $this->followRedirects($response)->assertSee(trans('auth.throttle', ['minutes' => 1])); + } + public function testLogsSuccessfulLogin() { User::factory()->create(['username' => 'username_here']);