Skip to content

Commit 9a84637

Browse files
committed
formatting
1 parent 48e7b90 commit 9a84637

File tree

4 files changed

+7
-176
lines changed

4 files changed

+7
-176
lines changed

tests/Feature/Auth/AuthenticationTest.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,6 @@ public function test_users_with_two_factor_enabled_are_redirected_to_two_factor_
6161
$this->assertGuest();
6262
}
6363

64-
public function test_users_without_two_factor_enabled_login_normally()
65-
{
66-
$user = User::factory()->create();
67-
68-
$response = $this->post(route('login'), [
69-
'email' => $user->email,
70-
'password' => 'password',
71-
]);
72-
73-
$this->assertAuthenticated();
74-
$response->assertRedirect(route('dashboard', absolute: false));
75-
$response->assertSessionMissing('login.id');
76-
}
77-
7864
public function test_users_can_not_authenticate_with_invalid_password()
7965
{
8066
$user = User::factory()->create();

tests/Feature/Auth/PasswordConfirmationTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public function test_confirm_password_screen_can_be_rendered()
1818
$response = $this->actingAs($user)->get(route('password.confirm'));
1919

2020
$response->assertStatus(200);
21+
2122
$response->assertInertia(fn (Assert $page) => $page
2223
->component('auth/ConfirmPassword')
2324
);

tests/Feature/Auth/TwoFactorChallengeTest.php

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class TwoFactorChallengeTest extends TestCase
1212
{
1313
use RefreshDatabase;
1414

15-
public function test_two_factor_challenge_redirects_when_not_authenticated(): void
15+
public function test_two_factor_challenge_redirects_to_login_when_not_authenticated(): void
1616
{
1717
if (! Features::canManageTwoFactorAuthentication()) {
1818
$this->markTestSkipped('Two-factor authentication is not enabled.');
@@ -23,7 +23,7 @@ public function test_two_factor_challenge_redirects_when_not_authenticated(): vo
2323
$response->assertRedirect(route('login'));
2424
}
2525

26-
public function test_two_factor_challenge_renders_correct_inertia_component(): void
26+
public function test_two_factor_challenge_can_be_rendered(): void
2727
{
2828
if (! Features::canManageTwoFactorAuthentication()) {
2929
$this->markTestSkipped('Two-factor authentication is not enabled.');
@@ -53,41 +53,4 @@ public function test_two_factor_challenge_renders_correct_inertia_component(): v
5353
->component('auth/TwoFactorChallenge')
5454
);
5555
}
56-
57-
public function test_two_factor_authentication_is_rate_limited(): void
58-
{
59-
if (! Features::enabled(Features::twoFactorAuthentication())) {
60-
$this->markTestSkipped('Two-factor authentication is not enabled.');
61-
}
62-
63-
Features::twoFactorAuthentication([
64-
'confirm' => true,
65-
'confirmPassword' => true,
66-
]);
67-
68-
$user = User::factory()->create();
69-
70-
$user->forceFill([
71-
'two_factor_secret' => encrypt(implode(range('A', 'P'))),
72-
'two_factor_recovery_codes' => encrypt(json_encode(['recovery-code-1', 'recovery-code-2'])),
73-
'two_factor_confirmed_at' => now(),
74-
])->save();
75-
76-
$this->post(route('login'), [
77-
'email' => $user->email,
78-
'password' => 'password',
79-
]);
80-
81-
foreach (range(0, 4) as $ignored) {
82-
$this->post(route('two-factor.login.store'), [
83-
'code' => '000000',
84-
])->assertSessionHasErrors('code');
85-
}
86-
87-
$response = $this->post(route('two-factor.login.store'), [
88-
'code' => '000000',
89-
]);
90-
91-
$response->assertTooManyRequests();
92-
}
9356
}

tests/Feature/Settings/TwoFactorAuthenticationTest.php

Lines changed: 4 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class TwoFactorAuthenticationTest extends TestCase
1212
{
1313
use RefreshDatabase;
1414

15-
public function test_two_factor_settings_page_is_displayed()
15+
public function test_two_factor_settings_page_can_be_rendered()
1616
{
1717
if (! Features::canManageTwoFactorAuthentication()) {
1818
$this->markTestSkipped('Two-factor authentication is not enabled.');
@@ -34,7 +34,7 @@ public function test_two_factor_settings_page_is_displayed()
3434
);
3535
}
3636

37-
public function test_two_factor_settings_page_requires_password_confirmation()
37+
public function test_two_factor_settings_page_requires_password_confirmation_when_enabled()
3838
{
3939
if (! Features::canManageTwoFactorAuthentication()) {
4040
$this->markTestSkipped('Two-factor authentication is not enabled.');
@@ -53,7 +53,7 @@ public function test_two_factor_settings_page_requires_password_confirmation()
5353
$response->assertRedirect(route('password.confirm'));
5454
}
5555

56-
public function test_two_factor_settings_page_does_not_requires_password_confirmation_if_that_feature_is_disabled()
56+
public function test_two_factor_settings_page_does_not_requires_password_confirmation_when_disabled()
5757
{
5858
if (! Features::canManageTwoFactorAuthentication()) {
5959
$this->markTestSkipped('Two-factor authentication is not enabled.');
@@ -74,7 +74,7 @@ public function test_two_factor_settings_page_does_not_requires_password_confirm
7474
);
7575
}
7676

77-
public function test_two_factor_settings_page_returns_forbidden_when_two_factor_is_disabled()
77+
public function test_two_factor_settings_page_returns_forbidden_response_when_two_factor_is_disabled()
7878
{
7979
if (! Features::canManageTwoFactorAuthentication()) {
8080
$this->markTestSkipped('Two-factor authentication is not enabled.');
@@ -89,123 +89,4 @@ public function test_two_factor_settings_page_returns_forbidden_when_two_factor_
8989
->get(route('two-factor.show'))
9090
->assertForbidden();
9191
}
92-
93-
public function test_controller_sets_confirming_data_when_enabling_two_factor_with_confirmation()
94-
{
95-
if (! Features::canManageTwoFactorAuthentication()) {
96-
$this->markTestSkipped('Two-factor authentication is not enabled.');
97-
}
98-
99-
Features::twoFactorAuthentication([
100-
'confirm' => true,
101-
'confirmPassword' => false,
102-
]);
103-
104-
$user = User::factory()->create();
105-
106-
$this->actingAs($user)
107-
->withSession(['auth.password_confirmed_at' => time()])
108-
->withSession(['two_factor_empty_at' => time() - 10])
109-
->post(route('two-factor.enable'));
110-
111-
$this->get(route('two-factor.show'))
112-
->assertOk();
113-
114-
$this->assertNotNull(session('two_factor_confirming_at'));
115-
}
116-
117-
public function test_user_can_view_setting_page_when_confirm_disabled()
118-
{
119-
if (! Features::canManageTwoFactorAuthentication()) {
120-
$this->markTestSkipped('Two-factor authentication is not enabled.');
121-
}
122-
123-
Features::twoFactorAuthentication([
124-
'confirm' => false,
125-
'confirmPassword' => false,
126-
]);
127-
128-
$user = User::factory()->create();
129-
130-
$this->actingAs($user)
131-
->get(route('two-factor.show'))
132-
->assertOk()
133-
->assertInertia(fn (Assert $page) => $page
134-
->component('settings/TwoFactor')
135-
->where('requiresConfirmation', false)
136-
);
137-
}
138-
139-
public function test_controller_sets_empty_session_data_when_transitioning_to_disabled_state()
140-
{
141-
if (! Features::canManageTwoFactorAuthentication()) {
142-
$this->markTestSkipped('Two-factor authentication is not enabled.');
143-
}
144-
145-
Features::twoFactorAuthentication([
146-
'confirm' => true,
147-
'confirmPassword' => false,
148-
]);
149-
150-
$user = User::factory()->create();
151-
152-
$this->actingAs($user)
153-
->get(route('two-factor.show'))
154-
->assertSessionHas('two_factor_empty_at');
155-
}
156-
157-
public function test_controller_removes_confirming_session_data_when_cleanup_triggered()
158-
{
159-
if (! Features::canManageTwoFactorAuthentication()) {
160-
$this->markTestSkipped('Two-factor authentication is not enabled.');
161-
}
162-
163-
Features::twoFactorAuthentication([
164-
'confirm' => true,
165-
'confirmPassword' => false,
166-
]);
167-
168-
$user = User::factory()->create();
169-
170-
$user->forceFill([
171-
'two_factor_secret' => encrypt('test-secret'),
172-
'two_factor_recovery_codes' => encrypt(json_encode(['code1', 'code2'])),
173-
])->save();
174-
175-
$this->actingAs($user)
176-
->withSession(['two_factor_confirming_at' => time() - 100])
177-
->get(route('two-factor.show'))
178-
->assertSessionMissing('two_factor_confirming_at')
179-
->assertSessionHas('two_factor_empty_at');
180-
}
181-
182-
public function test_two_factor_authentication_disabled_when_confirmation_abandoned_between_requests()
183-
{
184-
if (! Features::canManageTwoFactorAuthentication()) {
185-
$this->markTestSkipped('Two-factor authentication is not enabled.');
186-
}
187-
188-
Features::twoFactorAuthentication([
189-
'confirm' => true,
190-
'confirmPassword' => false,
191-
]);
192-
193-
$user = User::factory()->create();
194-
195-
$user->forceFill([
196-
'two_factor_secret' => encrypt('test-secret'),
197-
'two_factor_recovery_codes' => encrypt(json_encode(['code1', 'code2'])),
198-
'two_factor_confirmed_at' => null,
199-
])->save();
200-
201-
$this->actingAs($user)
202-
->withSession(['two_factor_confirming_at' => time() - 100])
203-
->get(route('two-factor.show'));
204-
205-
$this->assertDatabaseHas('users', [
206-
'id' => $user->id,
207-
'two_factor_secret' => null,
208-
'two_factor_recovery_codes' => null,
209-
]);
210-
}
21192
}

0 commit comments

Comments
 (0)