Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
- Laravel 13 mit Filament 5 (Admin), Inertia 3 + Vue 3 + Vuetify 4 (Material 3) - Anmeldung über Fortify (Login, Passwort vergessen/ändern), keine Selbstregistrierung - Profil mit Profilbild (WebP in festen Größen), Personenseiten, Header mit Avatar-Menü - Material-3-Farbschema aus der Primärfarbe, hell/dunkel/System pro Person - Basis-Branding (Portalname, Logo, Primärfarbe) im Admin unter „Erscheinungsbild“ - Benutzerverwaltung im Admin, Zugang vorläufig über is_admin - vendor/ (ohne Dev-Pakete) und Frontend-Build mitversioniert, Dev-Pakete in vendor-dev/ - PHPUnit-Tests gegen MySQL/MariaDB, Forgejo-CI-Matrix, Docker-Entwicklungsumgebung - VERSION, CHANGELOG.md und CONTRIBUTING.md mit Release-Ablauf Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
90 lines
3 KiB
PHP
90 lines
3 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Auth;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Auth\Notifications\ResetPassword;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\Hash;
|
|
use Illuminate\Support\Facades\Notification;
|
|
use Inertia\Testing\AssertableInertia as Assert;
|
|
use Tests\TestCase;
|
|
|
|
class PasswordTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_reset_link_is_sent(): void
|
|
{
|
|
Notification::fake();
|
|
$user = User::factory()->create();
|
|
|
|
$this->post('/forgot-password', ['email' => $user->email])->assertSessionHas('status');
|
|
|
|
Notification::assertSentTo($user, ResetPassword::class);
|
|
}
|
|
|
|
public function test_password_can_be_reset_with_valid_token(): void
|
|
{
|
|
Notification::fake();
|
|
$user = User::factory()->create();
|
|
$this->post('/forgot-password', ['email' => $user->email]);
|
|
|
|
Notification::assertSentTo($user, ResetPassword::class, function (ResetPassword $notification) use ($user) {
|
|
$this->get('/reset-password/'.$notification->token.'?email='.urlencode($user->email))
|
|
->assertInertia(fn (Assert $page) => $page
|
|
->component('Auth/ResetPassword')
|
|
->where('email', $user->email));
|
|
|
|
$this->post('/reset-password', [
|
|
'token' => $notification->token,
|
|
'email' => $user->email,
|
|
'password' => 'NeuesPasswort123',
|
|
'password_confirmation' => 'NeuesPasswort123',
|
|
])->assertSessionHasNoErrors();
|
|
|
|
return Hash::check('NeuesPasswort123', $user->fresh()->password);
|
|
});
|
|
}
|
|
|
|
public function test_own_password_can_be_changed(): void
|
|
{
|
|
$user = User::factory()->create();
|
|
|
|
$this->actingAs($user)
|
|
->put('/user/password', [
|
|
'current_password' => 'password',
|
|
'password' => 'NeuesPasswort123',
|
|
'password_confirmation' => 'NeuesPasswort123',
|
|
])
|
|
->assertSessionHasNoErrors();
|
|
|
|
$this->assertTrue(Hash::check('NeuesPasswort123', $user->fresh()->password));
|
|
}
|
|
|
|
public function test_changing_password_requires_current_password(): void
|
|
{
|
|
$user = User::factory()->create();
|
|
|
|
$this->actingAs($user)
|
|
->put('/user/password', [
|
|
'current_password' => 'falsch',
|
|
'password' => 'NeuesPasswort123',
|
|
'password_confirmation' => 'NeuesPasswort123',
|
|
])
|
|
->assertSessionHasErrorsIn('updatePassword', 'current_password');
|
|
}
|
|
|
|
public function test_weak_passwords_are_rejected(): void
|
|
{
|
|
$user = User::factory()->create();
|
|
|
|
$this->actingAs($user)
|
|
->put('/user/password', [
|
|
'current_password' => 'password',
|
|
'password' => 'kurz',
|
|
'password_confirmation' => 'kurz',
|
|
])
|
|
->assertSessionHasErrorsIn('updatePassword', 'password');
|
|
}
|
|
}
|