|
7 | 7 | use Illuminate\Support\Facades\Auth;
|
8 | 8 | use Illuminate\Support\Facades\Schema;
|
9 | 9 | use Laravel\Fortify\Contracts\LoginViewResponse;
|
| 10 | +use Laravel\Fortify\Features; |
10 | 11 | use Laravel\Fortify\FortifyServiceProvider;
|
11 | 12 | use Laravel\Fortify\LoginRateLimiter;
|
12 | 13 | use Laravel\Fortify\TwoFactorAuthenticatable;
|
@@ -70,6 +71,37 @@ public function test_user_is_redirected_to_challenge_when_using_two_factor_authe
|
70 | 71 | $response->assertRedirect('/two-factor-challenge');
|
71 | 72 | }
|
72 | 73 |
|
| 74 | + public function test_user_can_authenticate_when_two_factor_challenge_is_disabled() |
| 75 | + { |
| 76 | + app('config')->set('auth.providers.users.model', TestTwoFactorAuthenticationSessionUser::class); |
| 77 | + |
| 78 | + $features = app('config')->get('fortify.features'); |
| 79 | + |
| 80 | + unset($features[array_search(Features::twoFactorAuthentication(), $features)]); |
| 81 | + |
| 82 | + app('config')->set('fortify.features', $features); |
| 83 | + |
| 84 | + $this->loadLaravelMigrations(['--database' => 'testbench']); |
| 85 | + |
| 86 | + Schema::table('users', function ($table) { |
| 87 | + $table->text('two_factor_secret')->nullable(); |
| 88 | + }); |
| 89 | + |
| 90 | + TestTwoFactorAuthenticationSessionUser::forceCreate([ |
| 91 | + 'name' => 'Taylor Otwell', |
| 92 | + |
| 93 | + 'password' => bcrypt('secret'), |
| 94 | + 'two_factor_secret' => 'test-secret', |
| 95 | + ]); |
| 96 | + |
| 97 | + $response = $this->withoutExceptionHandling()->post('/login', [ |
| 98 | + |
| 99 | + 'password' => 'secret', |
| 100 | + ]); |
| 101 | + |
| 102 | + $response->assertRedirect('/home'); |
| 103 | + } |
| 104 | + |
73 | 105 | public function test_validation_exception_returned_on_failure()
|
74 | 106 | {
|
75 | 107 | $this->loadLaravelMigrations(['--database' => 'testbench']);
|
|
0 commit comments