Konsolidierter, bereinigter Stand der Wissensbasis (docs/). Frischer Wurzel-Commit, um urheberrechtlich problematische Volltexte aus der Historie zu entfernen (die bisherige Historie bestand aus einem einzigen Initial-Commit). Enthaltene Änderungen (vgl. docs/_Steuerung/CHANGELOG.md, 2026-05-29): - Copyright-Hygiene: 25 Volltext-/Übersetzungsdateien (Sharp 14 Kap., Wala 11 Kap.) entfernt; je Quelle _Fundstellen-Index.md als Provenienzbeleg; Quellnachweise + Steuerungsdateien angepasst. - Konsistenz-Korrekturen: Reichweite 000-013 (Scorecard-Regeln), Rule-ID MW-WK-DIFF-101, Quellnachweis-Dateiverweis, Dok.000 v2.0.2. - Dateinamen-Normalisierung: Startdatei ohne Leerzeichen. Originale (Wala/Sharp E-Books) privat außerhalb des Repos archiviert. Co-authored-by: Cursor <cursoragent@cursor.com>
113 lines
No EOL
3.3 KiB
PHP
113 lines
No EOL
3.3 KiB
PHP
<?php
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Support\Facades\Hash;
|
|
use Laravel\Fortify\Features;
|
|
use Livewire\Livewire;
|
|
|
|
beforeEach(function () {
|
|
$this->skipUnlessFortifyHas(Features::twoFactorAuthentication());
|
|
|
|
Features::twoFactorAuthentication([
|
|
'confirm' => true,
|
|
'confirmPassword' => true,
|
|
]);
|
|
Features::passkeys([
|
|
'confirmPassword' => true,
|
|
]);
|
|
});
|
|
|
|
test('security settings page can be rendered', function () {
|
|
$user = User::factory()->create();
|
|
|
|
$response = $this->actingAs($user)
|
|
->withSession(['auth.password_confirmed_at' => time()])
|
|
->get(route('security.edit'));
|
|
|
|
$response->assertOk();
|
|
|
|
$response->assertSee('Passkeys');
|
|
$response->assertSee('No passkeys yet');
|
|
$response->assertSee('Two-factor authentication');
|
|
$response->assertSee('Enable 2FA');
|
|
});
|
|
|
|
test('security settings page requires password confirmation when enabled', function () {
|
|
$user = User::factory()->create();
|
|
|
|
$response = $this->actingAs($user)
|
|
->get(route('security.edit'));
|
|
|
|
$response->assertRedirect(route('password.confirm'));
|
|
});
|
|
|
|
test('security settings page renders without two factor when feature is disabled', function () {
|
|
config(['fortify.features' => []]);
|
|
|
|
$user = User::factory()->create();
|
|
|
|
$this->actingAs($user)
|
|
->withSession(['auth.password_confirmed_at' => time()])
|
|
->get(route('security.edit'))
|
|
->assertOk()
|
|
->assertSee('Update password')
|
|
->assertDontSee('Manage your passkeys for passwordless sign-in')
|
|
->assertDontSee('Add a passkey to sign in without a password')
|
|
->assertDontSee('Two-factor authentication');
|
|
});
|
|
|
|
test('two factor authentication disabled when confirmation abandoned between requests', function () {
|
|
$user = User::factory()->create();
|
|
|
|
$user->forceFill([
|
|
'two_factor_secret' => encrypt('test-secret'),
|
|
'two_factor_recovery_codes' => encrypt(json_encode(['code1', 'code2'])),
|
|
'two_factor_confirmed_at' => null,
|
|
])->save();
|
|
|
|
$this->actingAs($user);
|
|
|
|
$component = Livewire::test('pages::settings.security');
|
|
|
|
$component->assertSet('twoFactorEnabled', false);
|
|
|
|
$this->assertDatabaseHas('users', [
|
|
'id' => $user->id,
|
|
'two_factor_secret' => null,
|
|
'two_factor_recovery_codes' => null,
|
|
]);
|
|
});
|
|
|
|
test('password can be updated', function () {
|
|
$user = User::factory()->create([
|
|
'password' => Hash::make('password'),
|
|
]);
|
|
|
|
$this->actingAs($user);
|
|
|
|
$response = Livewire::test('pages::settings.security')
|
|
->set('current_password', 'password')
|
|
->set('password', 'new-password')
|
|
->set('password_confirmation', 'new-password')
|
|
->call('updatePassword');
|
|
|
|
$response->assertHasNoErrors();
|
|
|
|
expect(Hash::check('new-password', $user->refresh()->password))->toBeTrue();
|
|
});
|
|
|
|
test('correct password must be provided to update password', function () {
|
|
$user = User::factory()->create([
|
|
'password' => Hash::make('password'),
|
|
]);
|
|
|
|
$this->actingAs($user);
|
|
|
|
$response = Livewire::test('pages::settings.security')
|
|
->set('current_password', 'wrong-password')
|
|
->set('password', 'new-password')
|
|
->set('password_confirmation', 'new-password')
|
|
->call('updatePassword');
|
|
|
|
$response->assertHasErrors(['current_password']);
|
|
}); |