accounts/tests/codeception/api/_pages/AccountsRoute.php
ErickSkrauch dd2c4bc413 Объединены сущности для авторизации посредством JWT токенов и токенов, выданных через oAuth2.
Все действия, связанные с аккаунтами, теперь вызываются через url `/api/v1/accounts/<id>/<action>`.
Добавлена вменяемая система разграничения прав на основе RBAC.
Теперь oAuth2 токены генерируются как случайная строка в 40 символов длинной, а не UUID.
Исправлен баг с неправильным временем жизни токена в ответе успешного запроса аутентификации.
Теперь все unit тесты можно успешно прогнать без наличия интернета.
2017-09-19 20:06:17 +03:00

78 lines
2.4 KiB
PHP

<?php
namespace tests\codeception\api\_pages;
use yii\codeception\BasePage;
/**
* @property \tests\codeception\api\FunctionalTester $actor
*/
class AccountsRoute extends BasePage {
public function get(int $accountId) {
$this->route = "/v1/accounts/{$accountId}";
$this->actor->sendGET($this->getUrl());
}
public function changePassword(int $accountId, $currentPassword = null, $newPassword = null, $newRePassword = null) {
$this->route = "/v1/accounts/{$accountId}/password";
$this->actor->sendPOST($this->getUrl(), [
'password' => $currentPassword,
'newPassword' => $newPassword,
'newRePassword' => $newRePassword,
]);
}
public function changeUsername(int $accountId, $currentPassword = null, $newUsername = null) {
$this->route = "/v1/accounts/{$accountId}/username";
$this->actor->sendPOST($this->getUrl(), [
'password' => $currentPassword,
'username' => $newUsername,
]);
}
public function changeEmailInitialize(int $accountId, $password = '') {
$this->route = "/v1/accounts/{$accountId}/email-verification";
$this->actor->sendPOST($this->getUrl(), [
'password' => $password,
]);
}
public function changeEmailSubmitNewEmail(int $accountId, $key = null, $email = null) {
$this->route = "/v1/accounts/{$accountId}/new-email-verification";
$this->actor->sendPOST($this->getUrl(), [
'key' => $key,
'email' => $email,
]);
}
public function changeEmail(int $accountId, $key = null) {
$this->route = "/v1/accounts/{$accountId}/email";
$this->actor->sendPOST($this->getUrl(), [
'key' => $key,
]);
}
public function changeLanguage(int $accountId, $lang = null) {
$this->route = "/v1/accounts/{$accountId}/language";
$this->actor->sendPOST($this->getUrl(), [
'lang' => $lang,
]);
}
public function acceptRules(int $accountId) {
$this->route = "/v1/accounts/{$accountId}/rules";
$this->actor->sendPOST($this->getUrl());
}
public function ban(int $accountId) {
$this->route = "/v1/accounts/{$accountId}/ban";
$this->actor->sendPOST($this->getUrl());
}
public function pardon($accountId) {
$this->route = "/v1/accounts/{$accountId}/ban";
$this->actor->sendDELETE($this->getUrl());
}
}