2016-02-24 04:04:01 +05:30
|
|
|
<?php
|
|
|
|
namespace tests\codeception\api\functional;
|
|
|
|
|
|
|
|
use Codeception\Specify;
|
2016-02-26 04:15:21 +05:30
|
|
|
use tests\codeception\api\_pages\AccountsRoute;
|
2016-02-24 04:04:01 +05:30
|
|
|
use tests\codeception\api\FunctionalTester;
|
|
|
|
|
2016-02-26 04:15:21 +05:30
|
|
|
class AccountsCurrentCest {
|
2016-02-24 04:04:01 +05:30
|
|
|
|
|
|
|
/**
|
2016-02-26 04:15:21 +05:30
|
|
|
* @var AccountsRoute
|
2016-02-24 04:04:01 +05:30
|
|
|
*/
|
|
|
|
private $route;
|
|
|
|
|
|
|
|
public function _before(FunctionalTester $I) {
|
2016-02-26 04:15:21 +05:30
|
|
|
$this->route = new AccountsRoute($I);
|
2016-02-24 04:04:01 +05:30
|
|
|
}
|
|
|
|
|
2016-05-10 17:37:32 +05:30
|
|
|
public function testCurrent(FunctionalTester $I) {
|
2016-02-24 04:04:01 +05:30
|
|
|
$I->loggedInAsActiveAccount();
|
|
|
|
|
|
|
|
$this->route->current();
|
|
|
|
$I->canSeeResponseCodeIs(200);
|
|
|
|
$I->canSeeResponseIsJson();
|
|
|
|
$I->canSeeResponseContainsJson([
|
|
|
|
'id' => 1,
|
|
|
|
'username' => 'Admin',
|
|
|
|
'email' => 'admin@ely.by',
|
2016-05-13 14:33:00 +05:30
|
|
|
'lang' => 'en',
|
2016-02-24 04:04:01 +05:30
|
|
|
'shouldChangePassword' => false,
|
2016-05-13 14:33:00 +05:30
|
|
|
'isActive' => true,
|
|
|
|
'hasMojangUsernameCollision' => false,
|
2016-02-24 04:04:01 +05:30
|
|
|
]);
|
2016-05-13 14:33:00 +05:30
|
|
|
$I->canSeeResponseJsonMatchesJsonPath('$.passwordChangedAt');
|
2016-02-24 04:04:01 +05:30
|
|
|
}
|
|
|
|
|
2016-05-30 23:41:22 +05:30
|
|
|
public function testExpiredCurrent(FunctionalTester $I) {
|
|
|
|
// Устанавливаем заведомо истёкший токен
|
|
|
|
$I->amBearerAuthenticated(
|
|
|
|
'eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJodHRwOlwvXC9sb2NhbGhvc3QiLCJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3QiLCJpYXQiO' .
|
|
|
|
'jE0NjQ2Mjc1NDUsImV4cCI6MTQ2NDYzMTE0NSwianRpIjoxfQ.9c1mm0BK-cuW1qh15F12s2Fh37IN43YeeZeU4DFtlrE'
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->route->current();
|
|
|
|
$I->canSeeResponseCodeIs(401);
|
|
|
|
$I->canSeeResponseIsJson();
|
|
|
|
$I->canSeeResponseContainsJson([
|
|
|
|
'name' => 'Unauthorized',
|
|
|
|
'message' => 'Token expired',
|
|
|
|
'code' => 0,
|
|
|
|
'status' => 401,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2016-02-24 04:04:01 +05:30
|
|
|
}
|