2016-09-01 13:01:43 +05:30
|
|
|
<?php
|
2019-06-18 05:03:20 +05:30
|
|
|
declare(strict_types=1);
|
|
|
|
|
2019-02-21 01:28:52 +05:30
|
|
|
namespace api\tests\functional\authserver;
|
2016-09-01 13:01:43 +05:30
|
|
|
|
2019-02-21 01:28:52 +05:30
|
|
|
use api\tests\functional\_steps\AuthserverSteps;
|
2019-02-23 04:41:57 +05:30
|
|
|
use Ramsey\Uuid\Uuid;
|
2016-09-01 13:01:43 +05:30
|
|
|
|
|
|
|
class InvalidateCest {
|
|
|
|
|
|
|
|
public function invalidate(AuthserverSteps $I) {
|
|
|
|
$I->wantTo('invalidate my token');
|
2017-01-24 04:30:08 +05:30
|
|
|
[$accessToken, $clientToken] = $I->amAuthenticated();
|
2019-12-04 23:40:15 +05:30
|
|
|
$I->sendPOST('/api/authserver/authentication/invalidate', [
|
2016-09-01 13:01:43 +05:30
|
|
|
'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 23:40:15 +05:30
|
|
|
$I->sendPOST('/api/authserver/authentication/invalidate', [
|
2016-09-01 13:01:43 +05:30
|
|
|
'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 23:40:15 +05:30
|
|
|
$I->sendPOST('/api/authserver/authentication/invalidate', [
|
2016-09-01 13:01:43 +05:30
|
|
|
'accessToken' => Uuid::uuid4()->toString(),
|
|
|
|
'clientToken' => Uuid::uuid4()->toString(),
|
|
|
|
]);
|
|
|
|
$I->canSeeResponseCodeIs(200);
|
|
|
|
$I->canSeeResponseEquals('');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|