From 772b861a7012b1cf6362759f828b53d38bed0532 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Tue, 26 Mar 2024 16:54:48 +0800 Subject: [PATCH] [10.x] Test Improvements (#50763) Add tests to verify using `auth()->logoutOtherDevices()` will rehash the password. Signed-off-by: Mior Muhammad Zaki --- .../Auth/RehashOnLogoutOtherDevicesTest.php | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tests/Integration/Auth/RehashOnLogoutOtherDevicesTest.php diff --git a/tests/Integration/Auth/RehashOnLogoutOtherDevicesTest.php b/tests/Integration/Auth/RehashOnLogoutOtherDevicesTest.php new file mode 100644 index 000000000000..8e704ff33345 --- /dev/null +++ b/tests/Integration/Auth/RehashOnLogoutOtherDevicesTest.php @@ -0,0 +1,46 @@ +post('logout', function (Request $request) { + auth()->logoutOtherDevices($request->input('password')); + + return response()->noContent(); + })->middleware(['web', 'auth']); + } + + public function testItRehashThePasswordUsingLogoutOtherDevices() + { + $this->withoutExceptionHandling(); + + $user = UserFactory::new()->create(); + + $password = $user->password; + + $this->actingAs($user); + + $this->post('logout', [ + 'password' => 'password', + ])->assertStatus(204); + + $user->refresh(); + + $this->assertNotSame($password, $user->password); + } +}