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:
Codex Agent
2025-09-30 21:09:52 +02:00
parent 21c9391e2c
commit d1733686a6
114 changed files with 2867 additions and 2411 deletions

View File

@@ -0,0 +1,113 @@
<?php
namespace Tests\Feature\Auth;
use App\Models\User;
use App\Notifications\VerifyEmail;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Notification;
use Tests\TestCase;
use Illuminate\Support\Facades\Auth;
class LoginTest extends TestCase
{
use RefreshDatabase;
public function test_successful_login_with_valid_credentials()
{
$user = User::factory()->create([
'email' => 'valid@example.com',
'password' => bcrypt('password'),
'email_verified_at' => now(),
]);
$response = $this->post(route('login.store'), [
'login' => 'valid@example.com',
'password' => 'password',
]);
$this->assertAuthenticated();
$response->assertRedirect(route('dashboard', absolute: false));
$this->assertEquals('valid@example.com', Auth::user()->email);
}
public function test_successful_login_with_username()
{
$user = User::factory()->create([
'username' => 'validuser',
'password' => bcrypt('password'),
'email_verified_at' => now(),
]);
$response = $this->post(route('login.store'), [
'login' => 'validuser',
'password' => 'password',
]);
$this->assertAuthenticated();
$response->assertRedirect(route('dashboard', absolute: false));
$this->assertEquals('validuser', Auth::user()->username);
}
public function test_login_fails_with_invalid_credentials()
{
User::factory()->create([
'email' => 'invalid@example.com',
'password' => bcrypt('password'),
]);
$response = $this->post(route('login.store'), [
'login' => 'invalid@example.com',
'password' => 'wrongpassword',
]);
$this->assertGuest();
$response->assertStatus(302);
$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' => 'unverified@example.com',
'password' => bcrypt('password'),
'email_verified_at' => null,
]);
$response = $this->post(route('login.store'), [
'login' => 'unverified@example.com',
'password' => 'password',
]);
$this->assertAuthenticated();
$response->assertRedirect(route('verification.notice', absolute: false));
}
public function test_rate_limiting_on_failed_logins()
{
$user = User::factory()->create([
'email' => 'ratelimit@example.com',
'password' => bcrypt('password'),
]);
// Simulate 5 failed attempts
for ($i = 0; $i < 5; $i++) {
$response = $this->post(route('login.store'), [
'login' => 'ratelimit@example.com',
'password' => 'wrongpassword',
]);
$response->assertStatus(302);
$response->assertSessionHasErrors(['login' => 'Diese Anmeldedaten wurden nicht gefunden.']);
}
$response = $this->post(route('login.store'), [
'login' => 'ratelimit@example.com',
'password' => 'wrongpassword',
]);
$this->assertGuest();
$response->assertStatus(302);
$response->assertSessionHasErrors(['login' => 'Zu viele Login-Versuche. Bitte versuche es in :seconds Sekunden erneut.']);
}
}