2016-09-01 10:31:43 +03:00
|
|
|
<?php
|
2019-06-18 02:33:20 +03:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2019-02-20 22:58:52 +03:00
|
|
|
namespace api\tests\functional\authserver;
|
2016-09-01 10:31:43 +03:00
|
|
|
|
2019-02-20 22:58:52 +03:00
|
|
|
use api\tests\functional\_steps\AuthserverSteps;
|
2019-02-23 02:11:57 +03:00
|
|
|
use Ramsey\Uuid\Uuid;
|
2016-09-01 10:31:43 +03:00
|
|
|
|
|
|
|
class InvalidateCest {
|
|
|
|
|
|
|
|
public function invalidate(AuthserverSteps $I) {
|
|
|
|
$I->wantTo('invalidate my token');
|
2017-01-24 02:00:08 +03:00
|
|
|
[$accessToken, $clientToken] = $I->amAuthenticated();
|
2019-12-04 21:10:15 +03:00
|
|
|
$I->sendPOST('/api/authserver/authentication/invalidate', [
|
2016-09-01 10:31:43 +03:00
|
|
|
'accessToken' => $accessToken,
|
|
|
|
'clientToken' => $clientToken,
|
|
|
|
]);
|
|
|
|
$I->canSeeResponseCodeIs(200);
|
|
|
|
$I->canSeeResponseEquals('');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function wrongArguments(AuthserverSteps $I) {
|
|
|
|
$I->wantTo('get error on wrong amount of arguments');
|
2019-12-04 21:10:15 +03:00
|
|
|
$I->sendPOST('/api/authserver/authentication/invalidate', [
|
2016-09-01 10:31:43 +03:00
|
|
|
'key' => 'value',
|
|
|
|
]);
|
|
|
|
$I->canSeeResponseCodeIs(400);
|
|
|
|
$I->canSeeResponseIsJson();
|
|
|
|
$I->canSeeResponseContainsJson([
|
|
|
|
'error' => 'IllegalArgumentException',
|
|
|
|
'errorMessage' => 'credentials can not be null.',
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function wrongAccessTokenOrClientToken(AuthserverSteps $I) {
|
|
|
|
$I->wantTo('invalidate by wrong client and access token');
|
2019-12-04 21:10:15 +03:00
|
|
|
$I->sendPOST('/api/authserver/authentication/invalidate', [
|
2016-09-01 10:31:43 +03:00
|
|
|
'accessToken' => Uuid::uuid4()->toString(),
|
|
|
|
'clientToken' => Uuid::uuid4()->toString(),
|
|
|
|
]);
|
|
|
|
$I->canSeeResponseCodeIs(200);
|
|
|
|
$I->canSeeResponseEquals('');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|