File: RehashOnLogoutOtherDevicesTest.php

package info (click to toggle)
php-laravel-framework 10.48.29%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 19,188 kB
  • sloc: php: 232,347; sh: 167; makefile: 46
file content (46 lines) | stat: -rw-r--r-- 1,230 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php

namespace Illuminate\Tests\Integration\Auth;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\Request;
use Orchestra\Testbench\Attributes\WithConfig;
use Orchestra\Testbench\Attributes\WithMigration;
use Orchestra\Testbench\Factories\UserFactory;
use Orchestra\Testbench\TestCase;

#[WithMigration]
#[WithEnv('BCRYPT_ROUNDS', 12)]
#[WithConfig('app.key', 'base64:IUHRqAQ99pZ0A1MPjbuv1D6ff3jxv0GIvS2qIW4JNU4=')]
class RehashOnLogoutOtherDevicesTest extends TestCase
{
    use RefreshDatabase;

    protected function defineRoutes($router)
    {
        $router->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);
    }
}