2017-09-19 22:36:16 +05:30
|
|
|
<?php
|
2020-06-12 02:57:02 +05:30
|
|
|
declare(strict_types=1);
|
|
|
|
|
2019-02-21 01:28:52 +05:30
|
|
|
namespace api\tests\functional\accounts;
|
2017-09-19 22:36:16 +05:30
|
|
|
|
2019-02-21 01:28:52 +05:30
|
|
|
use api\tests\_pages\AccountsRoute;
|
|
|
|
use api\tests\FunctionalTester;
|
2017-09-19 22:36:16 +05:30
|
|
|
|
2017-10-01 05:59:00 +05:30
|
|
|
class GetCest {
|
2017-09-19 22:36:16 +05:30
|
|
|
|
2020-06-12 02:57:02 +05:30
|
|
|
private AccountsRoute $route;
|
2017-09-19 22:36:16 +05:30
|
|
|
|
|
|
|
public function _before(FunctionalTester $I) {
|
|
|
|
$this->route = new AccountsRoute($I);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetInfo(FunctionalTester $I) {
|
|
|
|
$accountId = $I->amAuthenticated();
|
|
|
|
|
|
|
|
$this->route->get($accountId);
|
|
|
|
$I->canSeeResponseCodeIs(200);
|
|
|
|
$I->canSeeResponseIsJson();
|
|
|
|
$I->canSeeResponseContainsJson([
|
|
|
|
'id' => 1,
|
|
|
|
'uuid' => 'df936908-b2e1-544d-96f8-2977ec213022',
|
|
|
|
'username' => 'Admin',
|
|
|
|
'isOtpEnabled' => false,
|
|
|
|
'email' => 'admin@ely.by',
|
|
|
|
'lang' => 'en',
|
|
|
|
'isActive' => true,
|
2020-06-12 02:57:02 +05:30
|
|
|
'isDeleted' => false,
|
2017-09-19 22:36:16 +05:30
|
|
|
'hasMojangUsernameCollision' => false,
|
|
|
|
'shouldAcceptRules' => false,
|
|
|
|
'elyProfileLink' => 'http://ely.by/u1',
|
2019-01-24 21:59:46 +05:30
|
|
|
]);
|
|
|
|
$I->canSeeResponseJsonMatchesJsonPath('$.passwordChangedAt');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetInfoAboutCurrentUser(FunctionalTester $I) {
|
|
|
|
$I->wantTo('get info about user with 0 id, e.g. current');
|
|
|
|
$I->amAuthenticated();
|
|
|
|
|
|
|
|
$this->route->get(0);
|
|
|
|
$I->canSeeResponseCodeIs(200);
|
|
|
|
$I->canSeeResponseIsJson();
|
|
|
|
$I->canSeeResponseContainsJson([
|
|
|
|
'id' => 1,
|
|
|
|
'uuid' => 'df936908-b2e1-544d-96f8-2977ec213022',
|
|
|
|
'username' => 'Admin',
|
|
|
|
'isOtpEnabled' => false,
|
|
|
|
'email' => 'admin@ely.by',
|
|
|
|
'lang' => 'en',
|
|
|
|
'isActive' => true,
|
2020-06-12 02:57:02 +05:30
|
|
|
'isDeleted' => false,
|
2019-01-24 21:59:46 +05:30
|
|
|
'hasMojangUsernameCollision' => false,
|
|
|
|
'shouldAcceptRules' => false,
|
|
|
|
'elyProfileLink' => 'http://ely.by/u1',
|
2017-09-19 22:36:16 +05:30
|
|
|
]);
|
|
|
|
$I->canSeeResponseJsonMatchesJsonPath('$.passwordChangedAt');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetWithNotAcceptedLatestRules(FunctionalTester $I) {
|
|
|
|
$accountId = $I->amAuthenticated('Veleyaba');
|
|
|
|
|
|
|
|
$this->route->get($accountId);
|
|
|
|
$I->canSeeResponseCodeIs(200);
|
|
|
|
$I->canSeeResponseIsJson();
|
|
|
|
$I->canSeeResponseContainsJson([
|
|
|
|
'id' => 9,
|
|
|
|
'uuid' => '410462d3-8e71-47cc-bac6-64f77f88cf80',
|
|
|
|
'username' => 'Veleyaba',
|
|
|
|
'email' => 'veleyaba@gmail.com',
|
|
|
|
'isOtpEnabled' => false,
|
|
|
|
'lang' => 'en',
|
|
|
|
'isActive' => true,
|
2020-06-12 02:57:02 +05:30
|
|
|
'isDeleted' => false,
|
2017-09-19 22:36:16 +05:30
|
|
|
'hasMojangUsernameCollision' => false,
|
|
|
|
'shouldAcceptRules' => true,
|
|
|
|
'elyProfileLink' => 'http://ely.by/u9',
|
|
|
|
]);
|
|
|
|
$I->canSeeResponseJsonMatchesJsonPath('$.passwordChangedAt');
|
|
|
|
}
|
|
|
|
|
2020-06-12 02:57:02 +05:30
|
|
|
public function testGetInfoFromAccountMarkedForDeleting(FunctionalTester $I) {
|
|
|
|
// We're setting up a known expired token
|
|
|
|
$id = $I->amAuthenticated('DeletedAccount');
|
|
|
|
|
|
|
|
$I->sendGET("/api/v1/accounts/{$id}");
|
|
|
|
$I->canSeeResponseCodeIs(200);
|
|
|
|
$I->canSeeResponseContainsJson([
|
|
|
|
'id' => $id,
|
|
|
|
'isActive' => true,
|
|
|
|
'isDeleted' => true,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2017-09-19 22:36:16 +05:30
|
|
|
public function testGetInfoWithExpiredToken(FunctionalTester $I) {
|
2019-07-15 04:29:56 +05:30
|
|
|
// We're setting up a known expired token
|
2017-09-19 22:36:16 +05:30
|
|
|
$I->amBearerAuthenticated(
|
2017-12-04 17:32:58 +05:30
|
|
|
'eyJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE0NjQ2Mjc1NDUsImV4cCI6MTQ2NDYzMTE0NSwic3ViIjoiZWx5fDEiLCJlbHktc' .
|
|
|
|
'2NvcGVzIjoiYWNjb3VudHNfd2ViX3VzZXIifQ.v1u8V5wk2RkWmnZtH3jZvM3zO1Gpgbp2DQFfLfy8jHY'
|
2017-09-19 22:36:16 +05:30
|
|
|
);
|
|
|
|
|
|
|
|
$this->route->get(1);
|
|
|
|
$I->canSeeResponseCodeIs(401);
|
|
|
|
$I->canSeeResponseIsJson();
|
|
|
|
$I->canSeeResponseContainsJson([
|
|
|
|
'name' => 'Unauthorized',
|
|
|
|
'message' => 'Token expired',
|
|
|
|
'code' => 0,
|
|
|
|
'status' => 401,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetInfoNotCurrentAccount(FunctionalTester $I) {
|
|
|
|
$I->amAuthenticated();
|
|
|
|
|
|
|
|
$this->route->get(10);
|
|
|
|
$I->canSeeResponseCodeIs(403);
|
|
|
|
$I->canSeeResponseIsJson();
|
|
|
|
$I->canSeeResponseContainsJson([
|
|
|
|
'name' => 'Forbidden',
|
|
|
|
'message' => 'You are not allowed to perform this action.',
|
|
|
|
'code' => 0,
|
|
|
|
'status' => 403,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|