2016-05-31 03:33:30 +05:30
|
|
|
<?php
|
2019-02-21 01:28:52 +05:30
|
|
|
namespace api\tests\functional;
|
2016-05-31 03:33:30 +05:30
|
|
|
|
2019-02-21 01:28:52 +05:30
|
|
|
use api\tests\_pages\AuthenticationRoute;
|
|
|
|
use api\tests\FunctionalTester;
|
2016-05-31 03:33:30 +05:30
|
|
|
|
|
|
|
class RefreshTokenCest {
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function testRefreshInvalidToken(FunctionalTester $I): void {
|
2016-05-31 03:33:30 +05:30
|
|
|
$route = new AuthenticationRoute($I);
|
|
|
|
|
|
|
|
$I->wantTo('get error.refresh_token_not_exist if passed token is invalid');
|
|
|
|
$route->refreshToken('invalid-token');
|
|
|
|
$I->canSeeResponseCodeIs(200);
|
|
|
|
$I->canSeeResponseContainsJson([
|
|
|
|
'success' => false,
|
|
|
|
'errors' => [
|
|
|
|
'refresh_token' => 'error.refresh_token_not_exist',
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function testRefreshToken(FunctionalTester $I): void {
|
2016-05-31 03:33:30 +05:30
|
|
|
$route = new AuthenticationRoute($I);
|
|
|
|
|
|
|
|
$I->wantTo('get new access_token by my refresh_token');
|
|
|
|
$route->refreshToken('SOutIr6Seeaii3uqMVy3Wan8sKFVFrNz');
|
|
|
|
$I->canSeeResponseCodeIs(200);
|
|
|
|
$I->canSeeAuthCredentials(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|