initial prototype based on nat-as-server
Some checks failed
PHPUnit / test (push) Has been cancelled
Some checks failed
PHPUnit / test (push) Has been cancelled
This commit is contained in:
40
tests/Integration/SessionLogoutTest.php
Normal file
40
tests/Integration/SessionLogoutTest.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Integration;
|
||||
|
||||
use Tests\Support\DatabaseSeeder;
|
||||
use Tests\Support\QdbTestCase;
|
||||
|
||||
final class SessionLogoutTest extends QdbTestCase
|
||||
{
|
||||
public function testSessionValidWithToken(): void
|
||||
{
|
||||
$login = $this->api()->loginWebAndGetToken(
|
||||
DatabaseSeeder::ADMIN_USERNAME,
|
||||
DatabaseSeeder::PASSWORD
|
||||
);
|
||||
$res = $this->api()->withToken($login['token'], 'GET', 'session');
|
||||
$this->assertApiOk($res);
|
||||
$this->assertTrue($res['data']['valid']);
|
||||
}
|
||||
|
||||
public function testSessionRejectsMissingToken(): void
|
||||
{
|
||||
$res = $this->api()->request('GET', 'session');
|
||||
$this->assertApiError($res, 'UNAUTHORIZED', 401);
|
||||
}
|
||||
|
||||
public function testLogoutRevokesToken(): void
|
||||
{
|
||||
$login = $this->api()->loginWebAndGetToken(
|
||||
DatabaseSeeder::SUPERVISOR_USERNAME,
|
||||
DatabaseSeeder::PASSWORD
|
||||
);
|
||||
$del = $this->api()->withToken($login['token'], 'DELETE', 'logout');
|
||||
$this->assertApiOk($del);
|
||||
$check = $this->api()->withToken($login['token'], 'GET', 'session');
|
||||
$this->assertApiError($check, 'UNAUTHORIZED', 401);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user