- $user = $this->getNormalUser();
- $password = $user->password;
- $this->asAdmin()
- ->visit('/settings/users')
- ->click($user->name)
- ->seePageIs('/settings/users/' . $user->id)
- ->see($user->email)
- ->type('Barry Scott', '#name')
- ->press('Save')
- ->seePageIs('/settings/users')
- ->seeInDatabase('users', ['id' => $user->id, 'name' => 'Barry Scott', 'password' => $password])
- ->notSeeInDatabase('users', ['name' => $user->name]);
+ $this->asAdmin()->get('/')->assertOk();
+ $this->post('/logout')->assertRedirect('/');
+ $this->get('/')->assertRedirect('/login');
+ }
+
+ public function test_mfa_session_cleared_on_logout()
+ {
+ $user = $this->getEditor();
+ $mfaSession = $this->app->make(MfaSession::class);
+
+ $mfaSession->markVerifiedForUser($user);
+ $this->assertTrue($mfaSession->isVerifiedForUser($user));
+
+ $this->asAdmin()->post('/logout');
+ $this->assertFalse($mfaSession->isVerifiedForUser($user));
+ }
+
+ public function test_reset_password_flow()
+ {
+ Notification::fake();
+
+ $this->get('/login')
+ ->assertElementContains('a[href="' . url('/password/email') . '"]', 'Forgot Password?');
+
+ $this->get('/password/email')
+ ->assertElementContains('form[action="' . url('/password/email') . '"]', 'Send Reset Link');
+
+ $resp = $this->post('/password/email', [
+ ]);
+ $resp->assertRedirect('/password/email');
+
+ $resp = $this->get('/password/email');
+ $resp->assertSee('A password reset link will be sent to
[email protected] if that email address is found in the system.');
+
+ $this->assertDatabaseHas('password_resets', [
+ ]);
+
+ /** @var User $user */
+
+ Notification::assertSentTo($user, ResetPassword::class);
+ $n = Notification::sent($user, ResetPassword::class);
+
+ $this->get('/password/reset/' . $n->first()->token)
+ ->assertOk()
+ ->assertSee('Reset Password');
+
+ $resp = $this->post('/password/reset', [
+ 'password' => 'randompass',
+ 'password_confirmation' => 'randompass',
+ 'token' => $n->first()->token,
+ ]);
+ $resp->assertRedirect('/');
+
+ $this->get('/')->assertSee('Your password has been successfully reset');