Initial commit of the L'Ami Fiduciaire SaaS platform built on Laravel 12, Vue 3, Inertia.js 2, and Tailwind CSS 4. Story 0.1 (rename folders to declarations in database) is implemented and code-reviewed: migration, rollback, and 6 Pest tests all passing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
79 lines
2.3 KiB
PHP
79 lines
2.3 KiB
PHP
<?php
|
|
|
|
use App\Models\User;
|
|
use Inertia\Testing\AssertableInertia as Assert;
|
|
use Laravel\Fortify\Features;
|
|
|
|
test('two factor settings page can be rendered', function () {
|
|
if (! Features::canManageTwoFactorAuthentication()) {
|
|
$this->markTestSkipped('Two-factor authentication is not enabled.');
|
|
}
|
|
|
|
Features::twoFactorAuthentication([
|
|
'confirm' => true,
|
|
'confirmPassword' => true,
|
|
]);
|
|
|
|
$user = User::factory()->create();
|
|
|
|
$this->actingAs($user)
|
|
->withSession(['auth.password_confirmed_at' => time()])
|
|
->get(route('two-factor.show'))
|
|
->assertInertia(fn (Assert $page) => $page
|
|
->component('settings/TwoFactor')
|
|
->where('twoFactorEnabled', false),
|
|
);
|
|
});
|
|
|
|
test('two factor settings page requires password confirmation when enabled', function () {
|
|
if (! Features::canManageTwoFactorAuthentication()) {
|
|
$this->markTestSkipped('Two-factor authentication is not enabled.');
|
|
}
|
|
|
|
$user = User::factory()->create();
|
|
|
|
Features::twoFactorAuthentication([
|
|
'confirm' => true,
|
|
'confirmPassword' => true,
|
|
]);
|
|
|
|
$response = $this->actingAs($user)
|
|
->get(route('two-factor.show'));
|
|
|
|
$response->assertRedirect(route('password.confirm'));
|
|
});
|
|
|
|
test('two factor settings page does not requires password confirmation when disabled', function () {
|
|
if (! Features::canManageTwoFactorAuthentication()) {
|
|
$this->markTestSkipped('Two-factor authentication is not enabled.');
|
|
}
|
|
|
|
$user = User::factory()->create();
|
|
|
|
Features::twoFactorAuthentication([
|
|
'confirm' => true,
|
|
'confirmPassword' => false,
|
|
]);
|
|
|
|
$this->actingAs($user)
|
|
->get(route('two-factor.show'))
|
|
->assertOk()
|
|
->assertInertia(fn (Assert $page) => $page
|
|
->component('settings/TwoFactor'),
|
|
);
|
|
});
|
|
|
|
test('two factor settings page returns forbidden response when two factor is disabled', function () {
|
|
if (! Features::canManageTwoFactorAuthentication()) {
|
|
$this->markTestSkipped('Two-factor authentication is not enabled.');
|
|
}
|
|
|
|
config(['fortify.features' => []]);
|
|
|
|
$user = User::factory()->create();
|
|
|
|
$this->actingAs($user)
|
|
->withSession(['auth.password_confirmed_at' => time()])
|
|
->get(route('two-factor.show'))
|
|
->assertForbidden();
|
|
}); |