mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Удалена зависимость от yiisoft/yii2-codeception в пользу интегрированного в Codeception генератора REST адресов
Реорганизованы объекты Pages для Functional тестов Исправлены не переименованные тесты, оставшиеся после последнего рефакторинга
This commit is contained in:
@ -6,7 +6,7 @@ use tests\codeception\api\_pages\AccountsRoute;
|
||||
use tests\codeception\api\functional\_steps\OauthSteps;
|
||||
use tests\codeception\api\FunctionalTester;
|
||||
|
||||
class AccountBanCest {
|
||||
class AccountsBanCest {
|
||||
|
||||
/**
|
||||
* @var AccountsRoute
|
@ -2,24 +2,24 @@
|
||||
namespace tests\codeception\api\functional;
|
||||
|
||||
use OTPHP\TOTP;
|
||||
use tests\codeception\api\_pages\TwoFactorAuthRoute;
|
||||
use tests\codeception\api\_pages\AccountsRoute;
|
||||
use tests\codeception\api\FunctionalTester;
|
||||
|
||||
class TwoFactorAuthDisableCest {
|
||||
class AccountsDisableTwoFactorAuthCest {
|
||||
|
||||
/**
|
||||
* @var TwoFactorAuthRoute
|
||||
* @var AccountsRoute
|
||||
*/
|
||||
private $route;
|
||||
|
||||
public function _before(FunctionalTester $I) {
|
||||
$this->route = new TwoFactorAuthRoute($I);
|
||||
$this->route = new AccountsRoute($I);
|
||||
}
|
||||
|
||||
public function testFails(FunctionalTester $I) {
|
||||
$accountId = $I->amAuthenticated('AccountWithEnabledOtp');
|
||||
|
||||
$this->route->disable($accountId);
|
||||
$this->route->disableTwoFactorAuth($accountId);
|
||||
$I->canSeeResponseContainsJson([
|
||||
'success' => false,
|
||||
'errors' => [
|
||||
@ -28,7 +28,7 @@ class TwoFactorAuthDisableCest {
|
||||
],
|
||||
]);
|
||||
|
||||
$this->route->disable($accountId, '123456', 'invalid_password');
|
||||
$this->route->disableTwoFactorAuth($accountId, '123456', 'invalid_password');
|
||||
$I->canSeeResponseContainsJson([
|
||||
'success' => false,
|
||||
'errors' => [
|
||||
@ -38,7 +38,7 @@ class TwoFactorAuthDisableCest {
|
||||
]);
|
||||
|
||||
$accountId = $I->amAuthenticated('AccountWithOtpSecret');
|
||||
$this->route->disable($accountId, '123456', 'invalid_password');
|
||||
$this->route->disableTwoFactorAuth($accountId, '123456', 'invalid_password');
|
||||
$I->canSeeResponseContainsJson([
|
||||
'success' => false,
|
||||
'errors' => [
|
||||
@ -50,7 +50,7 @@ class TwoFactorAuthDisableCest {
|
||||
public function testSuccessEnable(FunctionalTester $I) {
|
||||
$accountId = $I->amAuthenticated('AccountWithEnabledOtp');
|
||||
$totp = TOTP::create('BBBB');
|
||||
$this->route->disable($accountId, $totp->now(), 'password_0');
|
||||
$this->route->disableTwoFactorAuth($accountId, $totp->now(), 'password_0');
|
||||
$I->canSeeResponseCodeIs(200);
|
||||
$I->canSeeResponseIsJson();
|
||||
$I->canSeeResponseContainsJson([
|
@ -2,24 +2,24 @@
|
||||
namespace tests\codeception\api\functional;
|
||||
|
||||
use OTPHP\TOTP;
|
||||
use tests\codeception\api\_pages\TwoFactorAuthRoute;
|
||||
use tests\codeception\api\_pages\AccountsRoute;
|
||||
use tests\codeception\api\FunctionalTester;
|
||||
|
||||
class TwoFactorAuthEnableCest {
|
||||
class AccountsEnableTwoFactorAuthCest {
|
||||
|
||||
/**
|
||||
* @var TwoFactorAuthRoute
|
||||
* @var AccountsRoute
|
||||
*/
|
||||
private $route;
|
||||
|
||||
public function _before(FunctionalTester $I) {
|
||||
$this->route = new TwoFactorAuthRoute($I);
|
||||
$this->route = new AccountsRoute($I);
|
||||
}
|
||||
|
||||
public function testFails(FunctionalTester $I) {
|
||||
$accountId = $I->amAuthenticated('AccountWithOtpSecret');
|
||||
|
||||
$this->route->enable($accountId);
|
||||
$this->route->enableTwoFactorAuth($accountId);
|
||||
$I->canSeeResponseContainsJson([
|
||||
'success' => false,
|
||||
'errors' => [
|
||||
@ -28,7 +28,7 @@ class TwoFactorAuthEnableCest {
|
||||
],
|
||||
]);
|
||||
|
||||
$this->route->enable($accountId, '123456', 'invalid_password');
|
||||
$this->route->enableTwoFactorAuth($accountId, '123456', 'invalid_password');
|
||||
$I->canSeeResponseContainsJson([
|
||||
'success' => false,
|
||||
'errors' => [
|
||||
@ -38,7 +38,7 @@ class TwoFactorAuthEnableCest {
|
||||
]);
|
||||
|
||||
$accountId = $I->amAuthenticated('AccountWithEnabledOtp');
|
||||
$this->route->enable($accountId, '123456', 'invalid_password');
|
||||
$this->route->enableTwoFactorAuth($accountId, '123456', 'invalid_password');
|
||||
$I->canSeeResponseContainsJson([
|
||||
'success' => false,
|
||||
'errors' => [
|
||||
@ -50,7 +50,7 @@ class TwoFactorAuthEnableCest {
|
||||
public function testSuccessEnable(FunctionalTester $I) {
|
||||
$accountId = $I->amAuthenticated('AccountWithOtpSecret');
|
||||
$totp = TOTP::create('AAAA');
|
||||
$this->route->enable($accountId, $totp->now(), 'password_0');
|
||||
$this->route->enableTwoFactorAuth($accountId, $totp->now(), 'password_0');
|
||||
$I->canSeeResponseCodeIs(200);
|
||||
$I->canSeeResponseIsJson();
|
||||
$I->canSeeResponseContainsJson([
|
@ -6,7 +6,7 @@ use tests\codeception\api\_pages\AccountsRoute;
|
||||
use tests\codeception\api\functional\_steps\OauthSteps;
|
||||
use tests\codeception\api\FunctionalTester;
|
||||
|
||||
class AccountPardonCest {
|
||||
class AccountsPardonCest {
|
||||
|
||||
/**
|
||||
* @var AccountsRoute
|
@ -1,23 +1,23 @@
|
||||
<?php
|
||||
namespace tests\codeception\api\functional;
|
||||
|
||||
use tests\codeception\api\_pages\TwoFactorAuthRoute;
|
||||
use tests\codeception\api\_pages\AccountsRoute;
|
||||
use tests\codeception\api\FunctionalTester;
|
||||
|
||||
class TwoFactorAuthCredentialsCest {
|
||||
class AccountsTwoFactorAuthCredentialsCest {
|
||||
|
||||
/**
|
||||
* @var TwoFactorAuthRoute
|
||||
* @var AccountsRoute
|
||||
*/
|
||||
private $route;
|
||||
|
||||
public function _before(FunctionalTester $I) {
|
||||
$this->route = new TwoFactorAuthRoute($I);
|
||||
$this->route = new AccountsRoute($I);
|
||||
}
|
||||
|
||||
public function testGetCredentials(FunctionalTester $I) {
|
||||
$accountId = $I->amAuthenticated();
|
||||
$this->route->credentials($accountId);
|
||||
$this->route->getTwoFactorAuthCredentials($accountId);
|
||||
$I->canSeeResponseCodeIs(200);
|
||||
$I->canSeeResponseIsJson();
|
||||
$I->canSeeResponseJsonMatchesJsonPath('$.secret');
|
Reference in New Issue
Block a user