Skip to content

A free open source IT asset/license management system

Added test

snipe6c47f1c07f56
diff --git a/tests/Feature/Authentication/LoginTest.php b/tests/Feature/Authentication/LoginTest.php
index 85bbc78ad4..891781f96f 100644
--- a/tests/Feature/Authentication/LoginTest.php
+++ b/tests/Feature/Authentication/LoginTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Tests\Feature\Authentication;
+namespace Feature\Authentication;
use App\Models\User;
use Tests\TestCase;
@@ -9,6 +9,7 @@ class LoginTest extends TestCase
{
public function testLogsFailedLoginAttempt()
{
+
User::factory()->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']);