The Laravel 13 upgrade pulled Pint 1.27.1 to 1.29.3, which changed the laravel preset's default rules. composer lint and the CI lint job fail without this, so it is required rather than cosmetic. Formatting only, applied by `vendor/bin/pint`. The rules that fired were fully_qualified_strict_types, ordered_imports, single_blank_line_at_eof, unary_operator_spaces, not_operator_with_successor_space, braces_position, single_line_empty_body, single_line_after_imports and no_extra_blank_lines. Kept separate from the upgrade commit to keep that diff reviewable. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
71 lines
2.0 KiB
PHP
71 lines
2.0 KiB
PHP
<?php
|
|
|
|
use App\Models\User;
|
|
use Laravel\Fortify\Features;
|
|
use Livewire\Livewire;
|
|
|
|
beforeEach(function () {
|
|
if (! Features::canManageTwoFactorAuthentication()) {
|
|
$this->markTestSkipped('Two-factor authentication is not enabled.');
|
|
}
|
|
|
|
Features::twoFactorAuthentication([
|
|
'confirm' => true,
|
|
'confirmPassword' => true,
|
|
]);
|
|
});
|
|
|
|
test('two factor settings page can be rendered', function () {
|
|
$user = User::factory()->create();
|
|
|
|
$this->actingAs($user)
|
|
->withSession(['auth.password_confirmed_at' => time()])
|
|
->get(route('two-factor.show'))
|
|
->assertOk()
|
|
->assertSee('Two Factor Authentication')
|
|
->assertSee('Disabled');
|
|
});
|
|
|
|
test('two factor settings page requires password confirmation when enabled', function () {
|
|
$user = User::factory()->create();
|
|
|
|
$response = $this->actingAs($user)
|
|
->get(route('two-factor.show'));
|
|
|
|
$response->assertRedirect(route('password.confirm'));
|
|
});
|
|
|
|
test('two factor settings page returns forbidden response when two factor is disabled', function () {
|
|
config(['fortify.features' => []]);
|
|
|
|
$user = User::factory()->create();
|
|
|
|
$response = $this->actingAs($user)
|
|
->withSession(['auth.password_confirmed_at' => time()])
|
|
->get(route('two-factor.show'));
|
|
|
|
$response->assertForbidden();
|
|
});
|
|
|
|
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.two-factor');
|
|
|
|
$component->assertSet('twoFactorEnabled', false);
|
|
|
|
$this->assertDatabaseHas('users', [
|
|
'id' => $user->id,
|
|
'two_factor_secret' => null,
|
|
'two_factor_recovery_codes' => null,
|
|
]);
|
|
});
|