mirror of
https://github.com/elyby/accounts.git
synced 2024-12-25 22:59:53 +05:30
Добавлена возможность получить права на смену ника/пароля пользователя и тесты под это дело.
This commit is contained in:
parent
8e79d1dd1c
commit
35e7ae2447
@ -30,6 +30,8 @@ class ScopeStorage extends AbstractStorage implements ScopeInterface {
|
||||
];
|
||||
|
||||
private const CLIENT_CREDENTIALS_PERMISSIONS_INTERNAL = [
|
||||
P::CHANGE_ACCOUNT_USERNAME,
|
||||
P::CHANGE_ACCOUNT_PASSWORD,
|
||||
P::BLOCK_ACCOUNT,
|
||||
P::OBTAIN_EXTENDED_ACCOUNT_INFO,
|
||||
P::ESCAPE_IDENTITY_VERIFICATION,
|
||||
|
@ -4,6 +4,7 @@ namespace tests\codeception\api\functional;
|
||||
use common\models\Account;
|
||||
use tests\codeception\api\_pages\AccountsRoute;
|
||||
use tests\codeception\api\_pages\AuthenticationRoute;
|
||||
use tests\codeception\api\functional\_steps\OauthSteps;
|
||||
use tests\codeception\api\FunctionalTester;
|
||||
|
||||
class AccountsChangePasswordCest {
|
||||
@ -29,11 +30,7 @@ class AccountsChangePasswordCest {
|
||||
$id = $I->amAuthenticated();
|
||||
|
||||
$this->route->changePassword($id, 'password_0', 'new-password', 'new-password');
|
||||
$I->canSeeResponseCodeIs(200);
|
||||
$I->canSeeResponseIsJson();
|
||||
$I->canSeeResponseContainsJson([
|
||||
'success' => true,
|
||||
]);
|
||||
$this->assertSuccessResponse($I);
|
||||
|
||||
$I->notLoggedIn();
|
||||
|
||||
@ -45,4 +42,20 @@ class AccountsChangePasswordCest {
|
||||
]);
|
||||
}
|
||||
|
||||
public function testChangePasswordInternal(OauthSteps $I) {
|
||||
$accessToken = $I->getAccessTokenByClientCredentialsGrant(['change_account_password', 'escape_identity_verification']);
|
||||
$I->amBearerAuthenticated($accessToken);
|
||||
|
||||
$this->route->changePassword(1, null, 'new-password-1', 'new-password-1');
|
||||
$this->assertSuccessResponse($I);
|
||||
}
|
||||
|
||||
private function assertSuccessResponse(FunctionalTester $I): void {
|
||||
$I->canSeeResponseCodeIs(200);
|
||||
$I->canSeeResponseIsJson();
|
||||
$I->canSeeResponseContainsJson([
|
||||
'success' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ namespace tests\codeception\api\functional;
|
||||
|
||||
use common\models\Account;
|
||||
use tests\codeception\api\_pages\AccountsRoute;
|
||||
use tests\codeception\api\functional\_steps\OauthSteps;
|
||||
use tests\codeception\api\FunctionalTester;
|
||||
|
||||
class AccountsChangeUsernameCest {
|
||||
@ -28,11 +29,7 @@ class AccountsChangeUsernameCest {
|
||||
$id = $I->amAuthenticated();
|
||||
|
||||
$this->route->changeUsername($id, 'password_0', 'bruce_wayne');
|
||||
$I->canSeeResponseCodeIs(200);
|
||||
$I->canSeeResponseIsJson();
|
||||
$I->canSeeResponseContainsJson([
|
||||
'success' => true,
|
||||
]);
|
||||
$this->assertSuccessResponse($I);
|
||||
}
|
||||
|
||||
public function testChangeUsernameNotAvailable(FunctionalTester $I) {
|
||||
@ -50,4 +47,23 @@ class AccountsChangeUsernameCest {
|
||||
]);
|
||||
}
|
||||
|
||||
public function testChangeUsernameInternal(OauthSteps $I) {
|
||||
$accessToken = $I->getAccessTokenByClientCredentialsGrant(['change_account_username', 'escape_identity_verification']);
|
||||
$I->amBearerAuthenticated($accessToken);
|
||||
|
||||
$this->route->changeUsername(1, null, 'im_batman');
|
||||
$this->assertSuccessResponse($I);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FunctionalTester $I
|
||||
*/
|
||||
private function assertSuccessResponse(FunctionalTester $I): void {
|
||||
$I->canSeeResponseCodeIs(200);
|
||||
$I->canSeeResponseIsJson();
|
||||
$I->canSeeResponseContainsJson([
|
||||
'success' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user