mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Объединены сущности для авторизации посредством JWT токенов и токенов, выданных через oAuth2.
Все действия, связанные с аккаунтами, теперь вызываются через url `/api/v1/accounts/<id>/<action>`. Добавлена вменяемая система разграничения прав на основе RBAC. Теперь oAuth2 токены генерируются как случайная строка в 40 символов длинной, а не UUID. Исправлен баг с неправильным временем жизни токена в ответе успешного запроса аутентификации. Теперь все unit тесты можно успешно прогнать без наличия интернета.
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
namespace tests\codeception\api\unit\modules\internal\models;
|
||||
|
||||
use api\modules\internal\helpers\Error as E;
|
||||
use api\modules\internal\models\BanForm;
|
||||
use api\modules\accounts\models\BanAccountForm;
|
||||
use common\models\Account;
|
||||
use tests\codeception\api\unit\TestCase;
|
||||
|
||||
@ -11,13 +11,13 @@ class BanFormTest extends TestCase {
|
||||
public function testValidateAccountActivity() {
|
||||
$account = new Account();
|
||||
$account->status = Account::STATUS_ACTIVE;
|
||||
$form = new BanForm($account);
|
||||
$form = new BanAccountForm($account);
|
||||
$form->validateAccountActivity();
|
||||
$this->assertEmpty($form->getErrors('account'));
|
||||
|
||||
$account = new Account();
|
||||
$account->status = Account::STATUS_BANNED;
|
||||
$form = new BanForm($account);
|
||||
$form = new BanAccountForm($account);
|
||||
$form->validateAccountActivity();
|
||||
$this->assertEquals([E::ACCOUNT_ALREADY_BANNED], $form->getErrors('account'));
|
||||
}
|
||||
@ -32,8 +32,8 @@ class BanFormTest extends TestCase {
|
||||
->method('save')
|
||||
->willReturn(true);
|
||||
|
||||
$model = new BanForm($account);
|
||||
$this->assertTrue($model->ban());
|
||||
$model = new BanAccountForm($account);
|
||||
$this->assertTrue($model->performAction());
|
||||
$this->assertEquals(Account::STATUS_BANNED, $account->status);
|
||||
$this->tester->canSeeAmqpMessageIsCreated('events');
|
||||
}
|
||||
@ -42,14 +42,14 @@ class BanFormTest extends TestCase {
|
||||
$account = new Account();
|
||||
$account->id = 3;
|
||||
|
||||
$model = new BanForm($account);
|
||||
$model = new BanAccountForm($account);
|
||||
$model->createTask();
|
||||
$message = json_decode($this->tester->grabLastSentAmqpMessage('events')->body, true);
|
||||
$this->assertSame(3, $message['accountId']);
|
||||
$this->assertSame(-1, $message['duration']);
|
||||
$this->assertSame('', $message['message']);
|
||||
|
||||
$model = new BanForm($account);
|
||||
$model = new BanAccountForm($account);
|
||||
$model->duration = 123;
|
||||
$model->message = 'test';
|
||||
$model->createTask();
|
||||
|
@ -2,7 +2,7 @@
|
||||
namespace tests\codeception\api\unit\modules\internal\models;
|
||||
|
||||
use api\modules\internal\helpers\Error as E;
|
||||
use api\modules\internal\models\PardonForm;
|
||||
use api\modules\accounts\models\PardonAccountForm;
|
||||
use common\models\Account;
|
||||
use tests\codeception\api\unit\TestCase;
|
||||
|
||||
@ -11,13 +11,13 @@ class PardonFormTest extends TestCase {
|
||||
public function testValidateAccountBanned() {
|
||||
$account = new Account();
|
||||
$account->status = Account::STATUS_BANNED;
|
||||
$form = new PardonForm($account);
|
||||
$form = new PardonAccountForm($account);
|
||||
$form->validateAccountBanned();
|
||||
$this->assertEmpty($form->getErrors('account'));
|
||||
|
||||
$account = new Account();
|
||||
$account->status = Account::STATUS_ACTIVE;
|
||||
$form = new PardonForm($account);
|
||||
$form = new PardonAccountForm($account);
|
||||
$form->validateAccountBanned();
|
||||
$this->assertEquals([E::ACCOUNT_NOT_BANNED], $form->getErrors('account'));
|
||||
}
|
||||
@ -33,8 +33,8 @@ class PardonFormTest extends TestCase {
|
||||
->willReturn(true);
|
||||
|
||||
$account->status = Account::STATUS_BANNED;
|
||||
$model = new PardonForm($account);
|
||||
$this->assertTrue($model->pardon());
|
||||
$model = new PardonAccountForm($account);
|
||||
$this->assertTrue($model->performAction());
|
||||
$this->assertEquals(Account::STATUS_ACTIVE, $account->status);
|
||||
$this->tester->canSeeAmqpMessageIsCreated('events');
|
||||
}
|
||||
@ -43,7 +43,7 @@ class PardonFormTest extends TestCase {
|
||||
$account = new Account();
|
||||
$account->id = 3;
|
||||
|
||||
$model = new PardonForm($account);
|
||||
$model = new PardonAccountForm($account);
|
||||
$model->createTask();
|
||||
$message = json_decode($this->tester->grabLastSentAmqpMessage('events')->body, true);
|
||||
$this->assertSame(3, $message['accountId']);
|
||||
|
Reference in New Issue
Block a user