massive improvements to tests, streamlined and synced migrations, fixed a lot of wrong or old table field references. implemented a lot of pages in react for website frontend
This commit is contained in:
@@ -5,6 +5,7 @@ namespace Tests\Feature\Auth;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
|
||||
class AuthenticationTest extends TestCase
|
||||
{
|
||||
@@ -22,7 +23,20 @@ class AuthenticationTest extends TestCase
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->post(route('login.store'), [
|
||||
'email' => $user->email,
|
||||
'login' => $user->email,
|
||||
'password' => 'password',
|
||||
]);
|
||||
|
||||
$this->assertAuthenticated();
|
||||
$response->assertRedirect(route('dashboard', absolute: false));
|
||||
}
|
||||
|
||||
public function test_users_can_authenticate_with_username()
|
||||
{
|
||||
$user = User::factory()->create(['username' => 'testuser']);
|
||||
|
||||
$response = $this->post(route('login.store'), [
|
||||
'login' => 'testuser',
|
||||
'password' => 'password',
|
||||
]);
|
||||
|
||||
@@ -34,12 +48,29 @@ class AuthenticationTest extends TestCase
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$this->post(route('login.store'), [
|
||||
'email' => $user->email,
|
||||
$response = $this->post(route('login.store'), [
|
||||
'login' => $user->email,
|
||||
'password' => 'wrong-password',
|
||||
]);
|
||||
|
||||
$this->assertGuest();
|
||||
$response->assertRedirect(route('login', absolute: false));
|
||||
$response->assertSessionHasErrors(['login' => 'Diese Anmeldedaten wurden nicht gefunden.']);
|
||||
}
|
||||
|
||||
public function test_login_redirects_unverified_user_to_verification_notice()
|
||||
{
|
||||
$user = User::factory()->create([
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
|
||||
$response = $this->post(route('login.store'), [
|
||||
'login' => $user->email,
|
||||
'password' => 'password',
|
||||
]);
|
||||
|
||||
$this->assertAuthenticated();
|
||||
$response->assertRedirect(route('verification.notice', absolute: false));
|
||||
}
|
||||
|
||||
public function test_users_can_logout()
|
||||
@@ -49,7 +80,7 @@ class AuthenticationTest extends TestCase
|
||||
$response = $this->actingAs($user)->post(route('logout'));
|
||||
|
||||
$this->assertGuest();
|
||||
$response->assertRedirect(route('home'));
|
||||
$response->assertRedirect('/');
|
||||
}
|
||||
|
||||
public function test_users_are_rate_limited()
|
||||
@@ -57,23 +88,20 @@ class AuthenticationTest extends TestCase
|
||||
$user = User::factory()->create();
|
||||
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$this->post(route('login.store'), [
|
||||
'email' => $user->email,
|
||||
$response = $this->post(route('login.store'), [
|
||||
'login' => $user->email,
|
||||
'password' => 'wrong-password',
|
||||
])->assertStatus(302)->assertSessionHasErrors([
|
||||
'email' => 'These credentials do not match our records.',
|
||||
]);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHasErrors(['login' => 'Diese Anmeldedaten wurden nicht gefunden.']);
|
||||
}
|
||||
|
||||
$response = $this->post(route('login.store'), [
|
||||
'email' => $user->email,
|
||||
'login' => $user->email,
|
||||
'password' => 'wrong-password',
|
||||
]);
|
||||
|
||||
$response->assertSessionHasErrors('email');
|
||||
|
||||
$errors = session('errors');
|
||||
|
||||
$this->assertStringContainsString('Too many login attempts', $errors->first('email'));
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHasErrors(['login' => 'Zu viele Login-Versuche. Bitte versuche es in :seconds Sekunden erneut.']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user