Rework tests structure. Upgrade codeception to 2.5.3. Merge params configuration into app configuration.

This commit is contained in:
ErickSkrauch 2019-02-20 22:58:52 +03:00
parent 2eacc581be
commit b05dc6816e
248 changed files with 1503 additions and 1339 deletions

4
.gitignore vendored
View File

@ -23,3 +23,7 @@ npm-debug*
# PHP-CS-Fixer # PHP-CS-Fixer
.php_cs .php_cs
.php_cs.cache .php_cs.cache
# Codeception
codeception.yml
*/codeception.yml

26
api/codeception.dist.yml Normal file
View File

@ -0,0 +1,26 @@
namespace: api\tests
actor_suffix: Tester
paths:
tests: tests
log: tests/_output
data: tests/_data
helpers: tests/_support
settings:
bootstrap: _bootstrap.php
colors: true
memory_limit: 1024M
coverage:
enabled: true
remote: true
whitelist:
include:
- ./*
exclude:
- aop/*
- config/*
- runtime/*
- tests/*
- web/*
- codeception.dist.yml
- codeception.yml
c3url: 'http://localhost/api/web/index.php'

View File

@ -1,7 +1,4 @@
<?php <?php
use api\components\ReCaptcha\Validator;
use GuzzleHttp\Client;
return [ return [
'components' => [ 'components' => [
'user' => [ 'user' => [
@ -12,18 +9,13 @@ return [
'secret' => 'private-key', 'secret' => 'private-key',
], ],
], ],
'modules' => [
'authserver' => [
'host' => 'localhost',
],
],
'params' => [ 'params' => [
'authserverHost' => 'authserver.ely.by', 'authserverHost' => 'localhost',
], ],
'container' => [ 'container' => [
'definitions' => [ 'definitions' => [
Validator::class => function() { api\components\ReCaptcha\Validator::class => function() {
return new class(new Client()) extends Validator { return new class(new GuzzleHttp\Client()) extends api\components\ReCaptcha\Validator {
protected function validateValue($value) { protected function validateValue($value) {
return null; return null;
} }

View File

@ -1,15 +1,12 @@
<?php <?php
$params = array_merge(
require __DIR__ . '/../../common/config/params.php',
require __DIR__ . '/params.php'
);
return [ return [
'id' => 'accounts-site-api', 'id' => 'accounts-site-api',
'basePath' => dirname(__DIR__), 'basePath' => dirname(__DIR__),
'bootstrap' => ['log', 'authserver', 'internal'], 'bootstrap' => ['log', 'authserver', 'internal', 'mojang'],
'controllerNamespace' => 'api\controllers', 'controllerNamespace' => 'api\controllers',
'params' => $params, 'params' => [
'authserverHost' => getenv('AUTHSERVER_HOST'),
],
'components' => [ 'components' => [
'user' => [ 'user' => [
'class' => api\components\User\Component::class, 'class' => api\components\User\Component::class,
@ -79,10 +76,7 @@ return [
], ],
], ],
'modules' => [ 'modules' => [
'authserver' => [ 'authserver' => api\modules\authserver\Module::class,
'class' => api\modules\authserver\Module::class,
'host' => $params['authserverHost'],
],
'session' => api\modules\session\Module::class, 'session' => api\modules\session\Module::class,
'mojang' => api\modules\mojang\Module::class, 'mojang' => api\modules\mojang\Module::class,
'internal' => api\modules\internal\Module::class, 'internal' => api\modules\internal\Module::class,

View File

@ -1,4 +0,0 @@
<?php
return [
'authserverHost' => getenv('AUTHSERVER_HOST'),
];

View File

@ -1,7 +1,4 @@
<?php <?php
/**
* @var array $params
*/
return [ return [
// Oauth module routes // Oauth module routes
'/oauth2/v1/<action>' => 'oauth/authorization/<action>', '/oauth2/v1/<action>' => 'oauth/authorization/<action>',
@ -46,8 +43,4 @@ return [
'/mojang/profiles/<username>' => 'mojang/api/uuid-by-username', '/mojang/profiles/<username>' => 'mojang/api/uuid-by-username',
'/mojang/profiles/<uuid>/names' => 'mojang/api/usernames-by-uuid', '/mojang/profiles/<uuid>/names' => 'mojang/api/usernames-by-uuid',
'POST /mojang/profiles' => 'mojang/api/uuids-by-usernames', 'POST /mojang/profiles' => 'mojang/api/uuids-by-usernames',
"//{$params['authserverHost']}/mojang/api/users/profiles/minecraft/<username>" => 'mojang/api/uuid-by-username',
"//{$params['authserverHost']}/mojang/api/user/profiles/<uuid>/names" => 'mojang/api/usernames-by-uuid',
"POST //{$params['authserverHost']}/mojang/api/profiles/minecraft" => 'mojang/api/uuids-by-usernames',
]; ];

View File

@ -1,9 +1,10 @@
<?php <?php
declare(strict_types=1);
namespace api\modules\authserver; namespace api\modules\authserver;
use Yii; use Yii;
use yii\base\BootstrapInterface; use yii\base\BootstrapInterface;
use yii\base\InvalidConfigException;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
class Module extends \yii\base\Module implements BootstrapInterface { class Module extends \yii\base\Module implements BootstrapInterface {
@ -12,18 +13,6 @@ class Module extends \yii\base\Module implements BootstrapInterface {
public $defaultRoute = 'index'; public $defaultRoute = 'index';
/**
* @var string базовый домен, запросы на который этот модуль должен обрабатывать
*/
public $host = 'authserver.ely.by';
public function init() {
parent::init();
if ($this->host === null) {
throw new InvalidConfigException('base domain must be specified');
}
}
public function beforeAction($action) { public function beforeAction($action) {
if (!parent::beforeAction($action)) { if (!parent::beforeAction($action)) {
return false; return false;
@ -35,11 +24,12 @@ class Module extends \yii\base\Module implements BootstrapInterface {
} }
/** /**
* @param \yii\base\Application $app the application currently running * @param \yii\base\Application $app
*/ */
public function bootstrap($app) { public function bootstrap($app) {
$legacyHost = $app->params['authserverHost'];
$app->getUrlManager()->addRules([ $app->getUrlManager()->addRules([
"//$this->host/$this->id/auth/<action>" => "$this->id/authentication/<action>", "//{$legacyHost}/authserver/auth/<action>" => "{$this->id}/authentication/<action>",
], false); ], false);
} }
@ -59,7 +49,7 @@ class Module extends \yii\base\Module implements BootstrapInterface {
* @throws NotFoundHttpException * @throws NotFoundHttpException
*/ */
protected function checkHost() { protected function checkHost() {
if (parse_url(Yii::$app->request->getHostInfo(), PHP_URL_HOST) !== $this->host) { if (parse_url(Yii::$app->request->getHostInfo(), PHP_URL_HOST) !== Yii::$app->params['authserverHost']) {
throw new NotFoundHttpException(); throw new NotFoundHttpException();
} }
} }

View File

@ -1,10 +1,26 @@
<?php <?php
declare(strict_types=1);
namespace api\modules\mojang; namespace api\modules\mojang;
class Module extends \yii\base\Module { use yii\base\BootstrapInterface;
class Module extends \yii\base\Module implements BootstrapInterface {
public $id = 'mojang'; public $id = 'mojang';
public $defaultRoute = 'api'; public $defaultRoute = 'api';
/**
* @param \yii\base\Application $app
*/
public function bootstrap($app): void {
$legacyHost = $app->params['authserverHost'];
$app->getUrlManager()->addRules([
"//{$legacyHost}/mojang/api/users/profiles/minecraft/<username>" => "{$this->id}/api/uuid-by-username",
"//{$legacyHost}/mojang/api/user/profiles/<uuid>/names" => "{$this->id}/api/usernames-by-uuid",
"POST //{$legacyHost}/mojang/api/profiles/minecraft" => "{$this->id}/api/uuids-by-usernames",
]);
}
} }

View File

@ -55,7 +55,10 @@ class AuthorizationController extends Controller {
} }
private function createOauthProcess(): OauthProcess { private function createOauthProcess(): OauthProcess {
return new OauthProcess(Yii::$app->oauth->authServer); $server = Yii::$app->oauth->authServer;
$server->setRequest(null); // Enforce request recreation (test environment bug)
return new OauthProcess($server);
} }
} }

3
api/tests/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
functional.suite.yml
unit.suite.yml
_support/_generated

10
api/tests/_bootstrap.php Normal file
View File

@ -0,0 +1,10 @@
<?php
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test');
defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', __DIR__ . '/../../');
require_once YII_APP_BASE_PATH . '/vendor/autoload.php';
require_once YII_APP_BASE_PATH . '/vendor/yiisoft/yii2/Yii.php';
require_once YII_APP_BASE_PATH . '/common/config/bootstrap.php';
require_once __DIR__ . '/../config/bootstrap.php';

View File

@ -1,14 +1,14 @@
<?php <?php
namespace tests\codeception\api\_pages; namespace api\tests\_pages;
class AccountsRoute extends BasePage { class AccountsRoute extends BasePage {
public function get(int $accountId) { public function get(int $accountId) {
$this->getActor()->sendGET("/v1/accounts/{$accountId}"); $this->getActor()->sendGET("/api/v1/accounts/{$accountId}");
} }
public function changePassword(int $accountId, $currentPassword = null, $newPassword = null, $newRePassword = null) { public function changePassword(int $accountId, $currentPassword = null, $newPassword = null, $newRePassword = null) {
$this->getActor()->sendPOST("/v1/accounts/{$accountId}/password", [ $this->getActor()->sendPOST("/api/v1/accounts/{$accountId}/password", [
'password' => $currentPassword, 'password' => $currentPassword,
'newPassword' => $newPassword, 'newPassword' => $newPassword,
'newRePassword' => $newRePassword, 'newRePassword' => $newRePassword,
@ -16,65 +16,65 @@ class AccountsRoute extends BasePage {
} }
public function changeUsername(int $accountId, $currentPassword = null, $newUsername = null) { public function changeUsername(int $accountId, $currentPassword = null, $newUsername = null) {
$this->getActor()->sendPOST("/v1/accounts/{$accountId}/username", [ $this->getActor()->sendPOST("/api/v1/accounts/{$accountId}/username", [
'password' => $currentPassword, 'password' => $currentPassword,
'username' => $newUsername, 'username' => $newUsername,
]); ]);
} }
public function changeEmailInitialize(int $accountId, $password = '') { public function changeEmailInitialize(int $accountId, $password = '') {
$this->getActor()->sendPOST("/v1/accounts/{$accountId}/email-verification", [ $this->getActor()->sendPOST("/api/v1/accounts/{$accountId}/email-verification", [
'password' => $password, 'password' => $password,
]); ]);
} }
public function changeEmailSubmitNewEmail(int $accountId, $key = null, $email = null) { public function changeEmailSubmitNewEmail(int $accountId, $key = null, $email = null) {
$this->getActor()->sendPOST("/v1/accounts/{$accountId}/new-email-verification", [ $this->getActor()->sendPOST("/api/v1/accounts/{$accountId}/new-email-verification", [
'key' => $key, 'key' => $key,
'email' => $email, 'email' => $email,
]); ]);
} }
public function changeEmail(int $accountId, $key = null) { public function changeEmail(int $accountId, $key = null) {
$this->getActor()->sendPOST("/v1/accounts/{$accountId}/email", [ $this->getActor()->sendPOST("/api/v1/accounts/{$accountId}/email", [
'key' => $key, 'key' => $key,
]); ]);
} }
public function changeLanguage(int $accountId, $lang = null) { public function changeLanguage(int $accountId, $lang = null) {
$this->getActor()->sendPOST("/v1/accounts/{$accountId}/language", [ $this->getActor()->sendPOST("/api/v1/accounts/{$accountId}/language", [
'lang' => $lang, 'lang' => $lang,
]); ]);
} }
public function acceptRules(int $accountId) { public function acceptRules(int $accountId) {
$this->getActor()->sendPOST("/v1/accounts/{$accountId}/rules"); $this->getActor()->sendPOST("/api/v1/accounts/{$accountId}/rules");
} }
public function getTwoFactorAuthCredentials(int $accountId) { public function getTwoFactorAuthCredentials(int $accountId) {
$this->getActor()->sendGET("/v1/accounts/{$accountId}/two-factor-auth"); $this->getActor()->sendGET("/api/v1/accounts/{$accountId}/two-factor-auth");
} }
public function enableTwoFactorAuth(int $accountId, $totp = null, $password = null) { public function enableTwoFactorAuth(int $accountId, $totp = null, $password = null) {
$this->getActor()->sendPOST("/v1/accounts/{$accountId}/two-factor-auth", [ $this->getActor()->sendPOST("/api/v1/accounts/{$accountId}/two-factor-auth", [
'totp' => $totp, 'totp' => $totp,
'password' => $password, 'password' => $password,
]); ]);
} }
public function disableTwoFactorAuth(int $accountId, $totp = null, $password = null) { public function disableTwoFactorAuth(int $accountId, $totp = null, $password = null) {
$this->getActor()->sendDELETE("/v1/accounts/{$accountId}/two-factor-auth", [ $this->getActor()->sendDELETE("/api/v1/accounts/{$accountId}/two-factor-auth", [
'totp' => $totp, 'totp' => $totp,
'password' => $password, 'password' => $password,
]); ]);
} }
public function ban(int $accountId) { public function ban(int $accountId) {
$this->getActor()->sendPOST("/v1/accounts/{$accountId}/ban"); $this->getActor()->sendPOST("/api/v1/accounts/{$accountId}/ban");
} }
public function pardon(int $accountId) { public function pardon(int $accountId) {
$this->getActor()->sendDELETE("/v1/accounts/{$accountId}/ban"); $this->getActor()->sendDELETE("/api/v1/accounts/{$accountId}/ban");
} }
} }

View File

@ -1,5 +1,5 @@
<?php <?php
namespace tests\codeception\api\_pages; namespace api\tests\_pages;
class AuthenticationRoute extends BasePage { class AuthenticationRoute extends BasePage {
@ -21,22 +21,22 @@ class AuthenticationRoute extends BasePage {
$params['totp'] = $rememberMeOrToken; $params['totp'] = $rememberMeOrToken;
} }
$this->getActor()->sendPOST('/authentication/login', $params); $this->getActor()->sendPOST('/api/authentication/login', $params);
} }
public function logout() { public function logout() {
$this->getActor()->sendPOST('/authentication/logout'); $this->getActor()->sendPOST('/api/authentication/logout');
} }
public function forgotPassword($login = null, $token = null) { public function forgotPassword($login = null, $token = null) {
$this->getActor()->sendPOST('/authentication/forgot-password', [ $this->getActor()->sendPOST('/api/authentication/forgot-password', [
'login' => $login, 'login' => $login,
'totp' => $token, 'totp' => $token,
]); ]);
} }
public function recoverPassword($key = null, $newPassword = null, $newRePassword = null) { public function recoverPassword($key = null, $newPassword = null, $newRePassword = null) {
$this->getActor()->sendPOST('/authentication/recover-password', [ $this->getActor()->sendPOST('/api/authentication/recover-password', [
'key' => $key, 'key' => $key,
'newPassword' => $newPassword, 'newPassword' => $newPassword,
'newRePassword' => $newRePassword, 'newRePassword' => $newRePassword,
@ -44,7 +44,7 @@ class AuthenticationRoute extends BasePage {
} }
public function refreshToken($refreshToken = null) { public function refreshToken($refreshToken = null) {
$this->getActor()->sendPOST('/authentication/refresh-token', [ $this->getActor()->sendPOST('/api/authentication/refresh-token', [
'refresh_token' => $refreshToken, 'refresh_token' => $refreshToken,
]); ]);
} }

View File

@ -0,0 +1,26 @@
<?php
namespace api\tests\_pages;
class AuthserverRoute extends BasePage {
public function authenticate($params) {
$this->getActor()->sendPOST('/api/authserver/authentication/authenticate', $params);
}
public function refresh($params) {
$this->getActor()->sendPOST('/api/authserver/authentication/refresh', $params);
}
public function validate($params) {
$this->getActor()->sendPOST('/api/authserver/authentication/validate', $params);
}
public function invalidate($params) {
$this->getActor()->sendPOST('/api/authserver/authentication/invalidate', $params);
}
public function signout($params) {
$this->getActor()->sendPOST('/api/authserver/authentication/signout', $params);
}
}

View File

@ -1,7 +1,7 @@
<?php <?php
namespace tests\codeception\api\_pages; namespace api\tests\_pages;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class BasePage { class BasePage {

View File

@ -0,0 +1,10 @@
<?php
namespace api\tests\_pages;
class IdentityInfoRoute extends BasePage {
public function info() {
$this->getActor()->sendGET('/api/account/v1/info');
}
}

View File

@ -0,0 +1,10 @@
<?php
namespace api\tests\_pages;
class InternalRoute extends BasePage {
public function info(string $param, string $value) {
$this->getActor()->sendGET('/api/internal/accounts/info', [$param => $value]);
}
}

View File

@ -1,19 +1,19 @@
<?php <?php
namespace tests\codeception\api\_pages; namespace api\tests\_pages;
class MojangApiRoute extends BasePage { class MojangApiRoute extends BasePage {
public function usernameToUuid($username, $at = null) { public function usernameToUuid($username, $at = null) {
$params = $at === null ? [] : ['at' => $at]; $params = $at === null ? [] : ['at' => $at];
$this->getActor()->sendGET("/mojang/profiles/{$username}", $params); $this->getActor()->sendGET("/api/mojang/profiles/{$username}", $params);
} }
public function usernamesByUuid($uuid) { public function usernamesByUuid($uuid) {
$this->getActor()->sendGET("/mojang/profiles/{$uuid}/names"); $this->getActor()->sendGET("/api/mojang/profiles/{$uuid}/names");
} }
public function uuidsByUsernames($uuids) { public function uuidsByUsernames($uuids) {
$this->getActor()->sendPOST('/mojang/profiles', $uuids); $this->getActor()->sendPOST('/api/mojang/profiles', $uuids);
} }
} }

View File

@ -0,0 +1,42 @@
<?php
namespace api\tests\_pages;
class OauthRoute extends BasePage {
public function validate(array $queryParams): void {
$this->getActor()->sendGET('/api/oauth2/v1/validate', $queryParams);
}
public function complete(array $queryParams = [], array $postParams = []): void {
$this->getActor()->sendPOST('/api/oauth2/v1/complete?' . http_build_query($queryParams), $postParams);
}
public function issueToken(array $postParams = []): void {
$this->getActor()->sendPOST('/api/oauth2/v1/token', $postParams);
}
public function createClient(string $type, array $postParams): void {
$this->getActor()->sendPOST('/api/v1/oauth2/' . $type, $postParams);
}
public function updateClient(string $clientId, array $params): void {
$this->getActor()->sendPUT('/api/v1/oauth2/' . $clientId, $params);
}
public function deleteClient(string $clientId): void {
$this->getActor()->sendDELETE('/api/v1/oauth2/' . $clientId);
}
public function resetClient(string $clientId, bool $regenerateSecret = false): void {
$this->getActor()->sendPOST("/api/v1/oauth2/$clientId/reset" . ($regenerateSecret ? '?regenerateSecret' : ''));
}
public function getClient(string $clientId): void {
$this->getActor()->sendGET("/api/v1/oauth2/$clientId");
}
public function getPerAccount(int $accountId): void {
$this->getActor()->sendGET("/api/v1/accounts/$accountId/oauth2/clients");
}
}

View File

@ -0,0 +1,10 @@
<?php
namespace api\tests\_pages;
class OptionsRoute extends BasePage {
public function get() {
$this->getActor()->sendGET('/api/options');
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace api\tests\_pages;
class SessionServerRoute extends BasePage {
public function join($params) {
$this->getActor()->sendPOST('/api/minecraft/session/join', $params);
}
public function joinLegacy(array $params) {
$this->getActor()->sendGET('/api/minecraft/session/legacy/join', $params);
}
public function hasJoined(array $params) {
$this->getActor()->sendGET('/api/minecraft/session/hasJoined', $params);
}
public function hasJoinedLegacy(array $params) {
$this->getActor()->sendGET('/api/minecraft/session/legacy/hasJoined', $params);
}
public function profile($profileUuid) {
$this->getActor()->sendGET("/api/minecraft/session/profile/{$profileUuid}");
}
}

View File

@ -1,18 +1,18 @@
<?php <?php
namespace tests\codeception\api\_pages; namespace api\tests\_pages;
class SignupRoute extends BasePage { class SignupRoute extends BasePage {
public function register(array $registrationData) { public function register(array $registrationData) {
$this->getActor()->sendPOST('/signup', $registrationData); $this->getActor()->sendPOST('/api/signup', $registrationData);
} }
public function sendRepeatMessage($email = '') { public function sendRepeatMessage($email = '') {
$this->getActor()->sendPOST('/signup/repeat-message', ['email' => $email]); $this->getActor()->sendPOST('/api/signup/repeat-message', ['email' => $email]);
} }
public function confirm($key = '') { public function confirm($key = '') {
$this->getActor()->sendPOST('/signup/confirm', [ $this->getActor()->sendPOST('/api/signup/confirm', [
'key' => $key, 'key' => $key,
]); ]);
} }

View File

@ -1,28 +1,16 @@
<?php <?php
namespace tests\codeception\api; declare(strict_types=1);
namespace api\tests;
use api\tests\_generated\FunctionalTesterActions;
use Codeception\Actor; use Codeception\Actor;
use common\models\Account; use common\models\Account;
use InvalidArgumentException; use InvalidArgumentException;
use Yii; use Yii;
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class FunctionalTester extends Actor { class FunctionalTester extends Actor {
use _generated\FunctionalTesterActions; use FunctionalTesterActions;
public function amAuthenticated(string $asUsername = 'admin') { public function amAuthenticated(string $asUsername = 'admin') {
/** @var Account $account */ /** @var Account $account */
@ -37,11 +25,12 @@ class FunctionalTester extends Actor {
return $account->id; return $account->id;
} }
public function notLoggedIn() { public function notLoggedIn(): void {
$this->haveHttpHeader('Authorization', null); $this->haveHttpHeader('Authorization', null);
Yii::$app->user->logout();
} }
public function canSeeAuthCredentials($expectRefresh = false) { public function canSeeAuthCredentials($expectRefresh = false): void {
$this->canSeeResponseJsonMatchesJsonPath('$.access_token'); $this->canSeeResponseJsonMatchesJsonPath('$.access_token');
$this->canSeeResponseJsonMatchesJsonPath('$.expires_in'); $this->canSeeResponseJsonMatchesJsonPath('$.expires_in');
if ($expectRefresh) { if ($expectRefresh) {

View File

@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace api\tests;
use api\tests\_generated\UnitTesterActions;
use Codeception\Actor;
class UnitTester extends Actor {
use UnitTesterActions;
}

View File

@ -0,0 +1,8 @@
<?php
use common\config\ConfigLoader;
use yii\helpers\ArrayHelper;
return ArrayHelper::merge(ConfigLoader::load('api'), [
]);

View File

@ -0,0 +1,8 @@
<?php
use common\config\ConfigLoader;
use yii\helpers\ArrayHelper;
return ArrayHelper::merge(ConfigLoader::load('api'), [
]);

View File

@ -0,0 +1,20 @@
suite_namespace: api\tests\functional
actor: FunctionalTester
modules:
enabled:
- Asserts
- Filesystem
- Yii2:
configFile: tests/config/functional.php
entryScript: /api/web/index.php
recreateApplication: true
transaction: false
- common\tests\_support\FixtureHelper
- common\tests\_support\Mockery
- REST:
depends: Yii2
- Redis:
host: redis
port: 6379
database: 0
cleanupBefore: 'test'

View File

@ -1,7 +1,8 @@
<?php <?php
namespace tests\codeception\api; namespace api\tests\functional;
use tests\codeception\api\_pages\SignupRoute; use api\tests\_pages\SignupRoute;
use api\tests\FunctionalTester;
class EmailConfirmationCest { class EmailConfirmationCest {

View File

@ -1,12 +1,12 @@
<?php <?php
namespace tests\codeception\api\functional; namespace api\tests\functional;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class FeedbackCest { class FeedbackCest {
public function testFeedbackWithoutAuth(FunctionalTester $I) { public function testFeedbackWithoutAuth(FunctionalTester $I) {
$I->sendPOST('/feedback', [ $I->sendPOST('/api/feedback', [
'subject' => 'Test', 'subject' => 'Test',
'email' => 'email@ely.by', 'email' => 'email@ely.by',
'type' => 0, 'type' => 0,
@ -21,7 +21,7 @@ class FeedbackCest {
public function testFeedbackWithAuth(FunctionalTester $I) { public function testFeedbackWithAuth(FunctionalTester $I) {
$I->amAuthenticated(); $I->amAuthenticated();
$I->sendPOST('/feedback', [ $I->sendPOST('/api/feedback', [
'subject' => 'Test', 'subject' => 'Test',
'email' => 'email@ely.by', 'email' => 'email@ely.by',
'type' => 0, 'type' => 0,

View File

@ -1,8 +1,8 @@
<?php <?php
namespace codeception\api\functional; namespace api\tests\functional;
use tests\codeception\api\_pages\AuthenticationRoute; use api\tests\_pages\AuthenticationRoute;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class ForgotPasswordCest { class ForgotPasswordCest {

View File

@ -1,8 +1,9 @@
<?php <?php
namespace tests\codeception\api; namespace api\tests\functional;
use api\tests\FunctionalTester;
use OTPHP\TOTP; use OTPHP\TOTP;
use tests\codeception\api\_pages\AuthenticationRoute; use api\tests\_pages\AuthenticationRoute;
class LoginCest { class LoginCest {

View File

@ -1,7 +1,8 @@
<?php <?php
namespace tests\codeception\api; namespace api\tests\functional;
use tests\codeception\api\_pages\AuthenticationRoute; use api\tests\_pages\AuthenticationRoute;
use api\tests\FunctionalTester;
class LogoutCest { class LogoutCest {

View File

@ -1,8 +1,8 @@
<?php <?php
namespace codeception\api\functional; namespace api\tests\functional;
use tests\codeception\api\_pages\OptionsRoute; use api\tests\_pages\OptionsRoute;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class OptionsCest { class OptionsCest {

View File

@ -1,9 +1,9 @@
<?php <?php
namespace codeception\api\functional; namespace api\tests\functional;
use tests\codeception\api\_pages\AccountsRoute; use api\tests\_pages\AccountsRoute;
use tests\codeception\api\_pages\AuthenticationRoute; use api\tests\_pages\AuthenticationRoute;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class RecoverPasswordCest { class RecoverPasswordCest {

View File

@ -1,8 +1,8 @@
<?php <?php
namespace codeception\api\functional; namespace api\tests\functional;
use tests\codeception\api\_pages\AuthenticationRoute; use api\tests\_pages\AuthenticationRoute;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class RefreshTokenCest { class RefreshTokenCest {

View File

@ -1,9 +1,9 @@
<?php <?php
namespace tests\codeception\api\functional; namespace api\tests\functional;
use Codeception\Example; use Codeception\Example;
use tests\codeception\api\_pages\SignupRoute; use api\tests\_pages\SignupRoute;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class RegisterCest { class RegisterCest {

View File

@ -1,8 +1,8 @@
<?php <?php
namespace tests\codeception\api\functional; namespace api\tests\functional;
use tests\codeception\api\_pages\SignupRoute; use api\tests\_pages\SignupRoute;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class RepeatAccountActivationCest { class RepeatAccountActivationCest {

View File

@ -1,13 +1,15 @@
<?php <?php
namespace tests\codeception\api\functional\_steps; declare(strict_types=1);
namespace api\tests\functional\_steps;
use Ramsey\Uuid\Uuid; use Ramsey\Uuid\Uuid;
use tests\codeception\api\_pages\AuthserverRoute; use api\tests\_pages\AuthserverRoute;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class AuthserverSteps extends FunctionalTester { class AuthserverSteps extends FunctionalTester {
public function amAuthenticated(string $asUsername = 'admin', string $password = 'password_0') { public function amAuthenticated(string $asUsername = 'admin', string $password = 'password_0'): array {
$route = new AuthserverRoute($this); $route = new AuthserverRoute($this);
$clientToken = Uuid::uuid4()->toString(); $clientToken = Uuid::uuid4()->toString();
$route->authenticate([ $route->authenticate([

View File

@ -1,9 +1,9 @@
<?php <?php
namespace tests\codeception\api\functional\_steps; namespace api\tests\functional\_steps;
use api\components\OAuth2\Storage\ScopeStorage as S; use api\components\OAuth2\Storage\ScopeStorage as S;
use tests\codeception\api\_pages\OauthRoute; use api\tests\_pages\OauthRoute;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class OauthSteps extends FunctionalTester { class OauthSteps extends FunctionalTester {

View File

@ -1,10 +1,10 @@
<?php <?php
namespace tests\codeception\api\functional\_steps; namespace api\tests\functional\_steps;
use common\rbac\Permissions as P; use common\rbac\Permissions as P;
use Faker\Provider\Uuid; use Faker\Provider\Uuid;
use tests\codeception\api\_pages\SessionServerRoute; use api\tests\_pages\SessionServerRoute;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class SessionServerSteps extends FunctionalTester { class SessionServerSteps extends FunctionalTester {

View File

@ -1,8 +1,8 @@
<?php <?php
namespace tests\codeception\api\functional\accounts; namespace api\tests\functional\accounts;
use tests\codeception\api\_pages\AccountsRoute; use api\tests\_pages\AccountsRoute;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class AcceptRulesCest { class AcceptRulesCest {

View File

@ -1,10 +1,10 @@
<?php <?php
namespace tests\codeception\api\functional\accounts; namespace api\tests\functional\accounts;
use common\rbac\Permissions as P; use common\rbac\Permissions as P;
use tests\codeception\api\_pages\AccountsRoute; use api\tests\_pages\AccountsRoute;
use tests\codeception\api\functional\_steps\OauthSteps; use api\tests\functional\_steps\OauthSteps;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class BanCest { class BanCest {

View File

@ -1,8 +1,8 @@
<?php <?php
namespace tests\codeception\api\functional\accounts; namespace api\tests\functional\accounts;
use tests\codeception\api\_pages\AccountsRoute; use api\tests\_pages\AccountsRoute;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class ChangeEmailConfirmNewEmailCest { class ChangeEmailConfirmNewEmailCest {

View File

@ -1,8 +1,8 @@
<?php <?php
namespace tests\codeception\api\functional\accounts; namespace api\tests\functional\accounts;
use tests\codeception\api\_pages\AccountsRoute; use api\tests\_pages\AccountsRoute;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class ChangeEmailInitializeCest { class ChangeEmailInitializeCest {

View File

@ -1,9 +1,9 @@
<?php <?php
namespace tests\codeception\api\functional\accounts; namespace api\tests\functional\accounts;
use tests\codeception\api\_pages\AccountsRoute; use api\tests\_pages\AccountsRoute;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
use tests\codeception\common\helpers\Mock; use common\tests\helpers\Mock;
use yii\validators\EmailValidator; use yii\validators\EmailValidator;
class ChangeEmailSubmitNewEmailCest { class ChangeEmailSubmitNewEmailCest {

View File

@ -1,8 +1,8 @@
<?php <?php
namespace tests\codeception\api\functional\accounts; namespace api\tests\functional\accounts;
use tests\codeception\api\_pages\AccountsRoute; use api\tests\_pages\AccountsRoute;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class ChangeLangCest { class ChangeLangCest {

View File

@ -1,11 +1,11 @@
<?php <?php
namespace tests\codeception\api\functional\accounts; namespace api\tests\functional\accounts;
use common\models\Account; use common\models\Account;
use tests\codeception\api\_pages\AccountsRoute; use api\tests\_pages\AccountsRoute;
use tests\codeception\api\_pages\AuthenticationRoute; use api\tests\_pages\AuthenticationRoute;
use tests\codeception\api\functional\_steps\OauthSteps; use api\tests\functional\_steps\OauthSteps;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class ChangePasswordCest { class ChangePasswordCest {

View File

@ -1,10 +1,10 @@
<?php <?php
namespace tests\codeception\api\functional\accounts; namespace api\tests\functional\accounts;
use common\models\Account; use common\models\Account;
use tests\codeception\api\_pages\AccountsRoute; use api\tests\_pages\AccountsRoute;
use tests\codeception\api\functional\_steps\OauthSteps; use api\tests\functional\_steps\OauthSteps;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class ChangeUsernameCest { class ChangeUsernameCest {

View File

@ -1,9 +1,9 @@
<?php <?php
namespace tests\codeception\api\functional\accounts; namespace api\tests\functional\accounts;
use OTPHP\TOTP; use OTPHP\TOTP;
use tests\codeception\api\_pages\AccountsRoute; use api\tests\_pages\AccountsRoute;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class DisableTwoFactorAuthCest { class DisableTwoFactorAuthCest {

View File

@ -1,9 +1,9 @@
<?php <?php
namespace tests\codeception\api\functional\accounts; namespace api\tests\functional\accounts;
use OTPHP\TOTP; use OTPHP\TOTP;
use tests\codeception\api\_pages\AccountsRoute; use api\tests\_pages\AccountsRoute;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class EnableTwoFactorAuthCest { class EnableTwoFactorAuthCest {

View File

@ -1,8 +1,8 @@
<?php <?php
namespace tests\codeception\api\functional\accounts; namespace api\tests\functional\accounts;
use tests\codeception\api\_pages\AccountsRoute; use api\tests\_pages\AccountsRoute;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class GetCest { class GetCest {

View File

@ -1,10 +1,10 @@
<?php <?php
namespace tests\codeception\api\functional\accounts; namespace api\tests\functional\accounts;
use common\rbac\Permissions as P; use common\rbac\Permissions as P;
use tests\codeception\api\_pages\AccountsRoute; use api\tests\_pages\AccountsRoute;
use tests\codeception\api\functional\_steps\OauthSteps; use api\tests\functional\_steps\OauthSteps;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class PardonCest { class PardonCest {

View File

@ -1,8 +1,8 @@
<?php <?php
namespace tests\codeception\api\functional\accounts; namespace api\tests\functional\accounts;
use tests\codeception\api\_pages\AccountsRoute; use api\tests\_pages\AccountsRoute;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class TwoFactorAuthCredentialsCest { class TwoFactorAuthCredentialsCest {

View File

@ -1,9 +1,9 @@
<?php <?php
namespace tests\codeception\api\functional\authserver; namespace api\tests\functional\authserver;
use Ramsey\Uuid\Uuid; use Ramsey\Uuid\Uuid;
use tests\codeception\api\_pages\AuthserverRoute; use api\tests\_pages\AuthserverRoute;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class AuthorizationCest { class AuthorizationCest {

View File

@ -1,9 +1,9 @@
<?php <?php
namespace tests\codeception\api\functional\authserver; namespace api\tests\functional\authserver;
use Ramsey\Uuid\Uuid; use Ramsey\Uuid\Uuid;
use tests\codeception\api\_pages\AuthserverRoute; use api\tests\_pages\AuthserverRoute;
use tests\codeception\api\functional\_steps\AuthserverSteps; use api\tests\functional\_steps\AuthserverSteps;
class InvalidateCest { class InvalidateCest {

View File

@ -1,9 +1,9 @@
<?php <?php
namespace tests\codeception\api\functional\authserver; namespace api\tests\functional\authserver;
use Ramsey\Uuid\Uuid; use Ramsey\Uuid\Uuid;
use tests\codeception\api\_pages\AuthserverRoute; use api\tests\_pages\AuthserverRoute;
use tests\codeception\api\functional\_steps\AuthserverSteps; use api\tests\functional\_steps\AuthserverSteps;
class RefreshCest { class RefreshCest {

View File

@ -1,8 +1,8 @@
<?php <?php
namespace tests\codeception\api\functional\authserver; namespace api\tests\functional\authserver;
use tests\codeception\api\_pages\AuthserverRoute; use api\tests\_pages\AuthserverRoute;
use tests\codeception\api\functional\_steps\AuthserverSteps; use api\tests\functional\_steps\AuthserverSteps;
class SignoutCest { class SignoutCest {

View File

@ -1,9 +1,9 @@
<?php <?php
namespace tests\codeception\api\functional\authserver; namespace api\tests\functional\authserver;
use Ramsey\Uuid\Uuid; use Ramsey\Uuid\Uuid;
use tests\codeception\api\_pages\AuthserverRoute; use api\tests\_pages\AuthserverRoute;
use tests\codeception\api\functional\_steps\AuthserverSteps; use api\tests\functional\_steps\AuthserverSteps;
class ValidateCest { class ValidateCest {

View File

@ -1,9 +1,9 @@
<?php <?php
namespace tests\codeception\api\functional\internal; namespace api\tests\functional\internal;
use tests\codeception\api\_pages\InternalRoute; use api\tests\_pages\InternalRoute;
use tests\codeception\api\functional\_steps\OauthSteps; use api\tests\functional\_steps\OauthSteps;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class InfoCest { class InfoCest {

View File

@ -1,8 +1,8 @@
<?php <?php
namespace tests\codeception\api\functional\authserver; namespace api\tests\functional\authserver;
use tests\codeception\api\_pages\MojangApiRoute; use api\tests\_pages\MojangApiRoute;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class UsernameToUuidCest { class UsernameToUuidCest {

View File

@ -1,8 +1,8 @@
<?php <?php
namespace tests\codeception\api\functional\authserver; namespace api\tests\functional\authserver;
use tests\codeception\api\_pages\MojangApiRoute; use api\tests\_pages\MojangApiRoute;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class UsernamesToUuidsCest { class UsernamesToUuidsCest {

View File

@ -1,9 +1,9 @@
<?php <?php
namespace tests\codeception\api\functional\authserver; namespace api\tests\functional\authserver;
use Faker\Provider\Uuid; use Faker\Provider\Uuid;
use tests\codeception\api\_pages\MojangApiRoute; use api\tests\_pages\MojangApiRoute;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class UuidToUsernamesHistoryCest { class UuidToUsernamesHistoryCest {

View File

@ -1,9 +1,9 @@
<?php <?php
namespace tests\codeception\api\oauth; namespace api\tests\functional\oauth;
use tests\codeception\api\_pages\OauthRoute; use api\tests\_pages\OauthRoute;
use tests\codeception\api\functional\_steps\OauthSteps; use api\tests\functional\_steps\OauthSteps;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class AccessTokenCest { class AccessTokenCest {
@ -67,6 +67,7 @@ class AccessTokenCest {
'token_type' => 'Bearer', 'token_type' => 'Bearer',
]); ]);
$I->canSeeResponseJsonMatchesJsonPath('$.access_token'); $I->canSeeResponseJsonMatchesJsonPath('$.access_token');
$I->cantSeeResponseJsonMatchesJsonPath('$.refresh_token');
$I->canSeeResponseJsonMatchesJsonPath('$.expires_in'); $I->canSeeResponseJsonMatchesJsonPath('$.expires_in');
} }

View File

@ -1,9 +1,9 @@
<?php <?php
namespace tests\codeception\api\oauth; namespace api\tests\functional\oauth;
use common\rbac\Permissions as P; use common\rbac\Permissions as P;
use tests\codeception\api\_pages\OauthRoute; use api\tests\_pages\OauthRoute;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class AuthCodeCest { class AuthCodeCest {

View File

@ -1,9 +1,9 @@
<?php <?php
namespace tests\codeception\api\oauth; namespace api\tests\functional\oauth;
use tests\codeception\api\_pages\OauthRoute; use api\tests\_pages\OauthRoute;
use tests\codeception\api\functional\_steps\OauthSteps; use api\tests\functional\_steps\OauthSteps;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class ClientCredentialsCest { class ClientCredentialsCest {

View File

@ -1,8 +1,8 @@
<?php <?php
namespace tests\codeception\api\oauth; namespace api\tests\functional\oauth;
use tests\codeception\api\_pages\OauthRoute; use api\tests\_pages\OauthRoute;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class CreateClientCest { class CreateClientCest {

View File

@ -1,8 +1,8 @@
<?php <?php
namespace tests\codeception\api\oauth; namespace api\tests\functional\oauth;
use tests\codeception\api\_pages\OauthRoute; use api\tests\_pages\OauthRoute;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class DeleteClientCest { class DeleteClientCest {

View File

@ -1,8 +1,8 @@
<?php <?php
namespace tests\codeception\api\oauth; namespace api\tests\functional\oauth;
use tests\codeception\api\_pages\OauthRoute; use api\tests\_pages\OauthRoute;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class GetClientsCest { class GetClientsCest {

View File

@ -1,9 +1,9 @@
<?php <?php
namespace codeception\api\functional; namespace api\tests\functional\oauth;
use tests\codeception\api\_pages\IdentityInfoRoute; use api\tests\_pages\IdentityInfoRoute;
use tests\codeception\api\functional\_steps\OauthSteps; use api\tests\functional\_steps\OauthSteps;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class IdentityInfoCest { class IdentityInfoCest {
@ -16,7 +16,20 @@ class IdentityInfoCest {
$this->route = new IdentityInfoRoute($I); $this->route = new IdentityInfoRoute($I);
} }
public function testGetErrorIfNoAccessToken(OauthSteps $I) {
$I->wantToTest('behavior when this endpoint called without Authorization header');
$this->route->info();
$I->canSeeResponseCodeIs(401);
$I->canSeeResponseIsJson();
$I->canSeeResponseContainsJson([
'name' => 'Unauthorized',
'status' => 401,
'message' => 'Your request was made with invalid credentials.',
]);
}
public function testGetErrorIfNotEnoughPerms(OauthSteps $I) { public function testGetErrorIfNotEnoughPerms(OauthSteps $I) {
$I->wantToTest('behavior when this endpoint called with token, that have not enough scopes');
$accessToken = $I->getAccessToken(); $accessToken = $I->getAccessToken();
$I->amBearerAuthenticated($accessToken); $I->amBearerAuthenticated($accessToken);
$this->route->info(); $this->route->info();
@ -25,6 +38,7 @@ class IdentityInfoCest {
$I->canSeeResponseContainsJson([ $I->canSeeResponseContainsJson([
'name' => 'Forbidden', 'name' => 'Forbidden',
'status' => 403, 'status' => 403,
'message' => 'You are not allowed to perform this action.',
]); ]);
} }

View File

@ -1,11 +1,11 @@
<?php <?php
namespace tests\codeception\api\oauth; namespace api\tests\functional\oauth;
use api\components\OAuth2\Storage\ScopeStorage as S; use api\components\OAuth2\Storage\ScopeStorage as S;
use common\rbac\Permissions as P; use common\rbac\Permissions as P;
use tests\codeception\api\_pages\OauthRoute; use api\tests\_pages\OauthRoute;
use tests\codeception\api\functional\_steps\OauthSteps; use api\tests\functional\_steps\OauthSteps;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class RefreshTokenCest { class RefreshTokenCest {

View File

@ -1,8 +1,8 @@
<?php <?php
namespace tests\codeception\api\oauth; namespace api\tests\functional\oauth;
use tests\codeception\api\_pages\OauthRoute; use api\tests\_pages\OauthRoute;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class ResetClientCest { class ResetClientCest {

View File

@ -1,8 +1,8 @@
<?php <?php
namespace tests\codeception\api\oauth; namespace api\tests\functional\oauth;
use tests\codeception\api\_pages\OauthRoute; use api\tests\_pages\OauthRoute;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class UpdateClientCest { class UpdateClientCest {

View File

@ -1,10 +1,10 @@
<?php <?php
namespace tests\codeception\api\functional\sessionserver; namespace api\tests\functional\sessionserver;
use Faker\Provider\Uuid; use Faker\Provider\Uuid;
use tests\codeception\api\_pages\SessionServerRoute; use api\tests\_pages\SessionServerRoute;
use tests\codeception\api\functional\_steps\SessionServerSteps; use api\tests\functional\_steps\SessionServerSteps;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class HasJoinedCest { class HasJoinedCest {

View File

@ -1,10 +1,10 @@
<?php <?php
namespace tests\codeception\api\functional\sessionserver; namespace api\tests\functional\sessionserver;
use Faker\Provider\Uuid; use Faker\Provider\Uuid;
use tests\codeception\api\_pages\SessionServerRoute; use api\tests\_pages\SessionServerRoute;
use tests\codeception\api\functional\_steps\SessionServerSteps; use api\tests\functional\_steps\SessionServerSteps;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class HasJoinedLegacyCest { class HasJoinedLegacyCest {

View File

@ -1,12 +1,12 @@
<?php <?php
namespace tests\codeception\api\functional\sessionserver; namespace api\tests\functional\sessionserver;
use common\rbac\Permissions as P; use common\rbac\Permissions as P;
use Faker\Provider\Uuid; use Faker\Provider\Uuid;
use tests\codeception\api\_pages\SessionServerRoute; use api\tests\_pages\SessionServerRoute;
use tests\codeception\api\functional\_steps\AuthserverSteps; use api\tests\functional\_steps\AuthserverSteps;
use tests\codeception\api\functional\_steps\OauthSteps; use api\tests\functional\_steps\OauthSteps;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class JoinCest { class JoinCest {

View File

@ -1,12 +1,12 @@
<?php <?php
namespace tests\codeception\api\functional\sessionserver; namespace api\tests\functional\sessionserver;
use common\rbac\Permissions as P; use common\rbac\Permissions as P;
use Faker\Provider\Uuid; use Faker\Provider\Uuid;
use tests\codeception\api\_pages\SessionServerRoute; use api\tests\_pages\SessionServerRoute;
use tests\codeception\api\functional\_steps\AuthserverSteps; use api\tests\functional\_steps\AuthserverSteps;
use tests\codeception\api\functional\_steps\OauthSteps; use api\tests\functional\_steps\OauthSteps;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class JoinLegacyCest { class JoinLegacyCest {

View File

@ -1,10 +1,10 @@
<?php <?php
namespace tests\codeception\api\functional\sessionserver; namespace api\tests\functional\sessionserver;
use Faker\Provider\Uuid; use Faker\Provider\Uuid;
use tests\codeception\api\_pages\SessionServerRoute; use api\tests\_pages\SessionServerRoute;
use tests\codeception\api\functional\_steps\SessionServerSteps; use api\tests\functional\_steps\SessionServerSteps;
use tests\codeception\api\FunctionalTester; use api\tests\FunctionalTester;
class ProfileCest { class ProfileCest {

View File

@ -0,0 +1,10 @@
suite_namespace: api\tests\unit
actor: UnitTester
modules:
enabled:
- Asserts
- Yii2:
part: [orm, email, fixtures]
configFile: tests/config/unit.php
- common\tests\_support\queue\CodeceptionQueueHelper
- common\tests\_support\Mockery

View File

@ -1,12 +1,12 @@
<?php <?php
namespace tests\codeception\api\unit; namespace api\tests\unit;
use Mockery; use Mockery;
class TestCase extends \Codeception\Test\Unit { class TestCase extends \Codeception\Test\Unit {
/** /**
* @var \tests\codeception\api\UnitTester * @var \api\tests\UnitTester
*/ */
protected $tester; protected $tester;

View File

@ -7,7 +7,7 @@ use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Psr7\Response; use GuzzleHttp\Psr7\Response;
use phpmock\mockery\PHPMockery; use phpmock\mockery\PHPMockery;
use ReflectionClass; use ReflectionClass;
use tests\codeception\api\unit\TestCase; use api\tests\unit\TestCase;
class ValidatorTest extends TestCase { class ValidatorTest extends TestCase {

View File

@ -9,11 +9,11 @@ use common\models\AccountSession;
use Emarref\Jwt\Claim; use Emarref\Jwt\Claim;
use Emarref\Jwt\Jwt; use Emarref\Jwt\Jwt;
use Emarref\Jwt\Token; use Emarref\Jwt\Token;
use tests\codeception\api\unit\TestCase; use api\tests\unit\TestCase;
use tests\codeception\common\_support\ProtectedCaller; use common\tests\_support\ProtectedCaller;
use tests\codeception\common\fixtures\AccountFixture; use common\tests\fixtures\AccountFixture;
use tests\codeception\common\fixtures\AccountSessionFixture; use common\tests\fixtures\AccountSessionFixture;
use tests\codeception\common\fixtures\MinecraftAccessKeyFixture; use common\tests\fixtures\MinecraftAccessKeyFixture;
use Yii; use Yii;
use yii\web\Request; use yii\web\Request;

View File

@ -1,5 +1,5 @@
<?php <?php
namespace tests\codeception\api\unit\components\User; namespace api\tests\unit\components\User;
use api\components\User\AuthenticationResult; use api\components\User\AuthenticationResult;
use common\models\Account; use common\models\Account;
@ -9,7 +9,7 @@ use Emarref\Jwt\Claim\Expiration;
use Emarref\Jwt\Encryption\Factory as EncryptionFactory; use Emarref\Jwt\Encryption\Factory as EncryptionFactory;
use Emarref\Jwt\Jwt; use Emarref\Jwt\Jwt;
use Emarref\Jwt\Token; use Emarref\Jwt\Token;
use tests\codeception\api\unit\TestCase; use api\tests\unit\TestCase;
class JwtAuthenticationResultTest extends TestCase { class JwtAuthenticationResultTest extends TestCase {

View File

@ -1,8 +1,8 @@
<?php <?php
namespace tests\codeception\api\unit\filters; namespace api\tests\unit\filters;
use api\filters\NginxCache; use api\filters\NginxCache;
use tests\codeception\api\unit\TestCase; use api\tests\unit\TestCase;
use Yii; use Yii;
use yii\base\Action; use yii\base\Action;
use yii\web\Controller; use yii\web\Controller;

View File

@ -3,7 +3,7 @@ namespace codeception\api\unit\models;
use api\models\FeedbackForm; use api\models\FeedbackForm;
use common\models\Account; use common\models\Account;
use tests\codeception\api\unit\TestCase; use api\tests\unit\TestCase;
use yii\swiftmailer\Message; use yii\swiftmailer\Message;
class FeedbackFormTest extends TestCase { class FeedbackFormTest extends TestCase {

View File

@ -8,9 +8,9 @@ use Codeception\Specify;
use Emarref\Jwt\Claim; use Emarref\Jwt\Claim;
use Emarref\Jwt\Encryption\Factory as EncryptionFactory; use Emarref\Jwt\Encryption\Factory as EncryptionFactory;
use Emarref\Jwt\Token; use Emarref\Jwt\Token;
use tests\codeception\api\unit\TestCase; use api\tests\unit\TestCase;
use tests\codeception\common\_support\ProtectedCaller; use common\tests\_support\ProtectedCaller;
use tests\codeception\common\fixtures\AccountFixture; use common\tests\fixtures\AccountFixture;
use Yii; use Yii;
class JwtIdentityTest extends TestCase { class JwtIdentityTest extends TestCase {

View File

@ -1,13 +1,13 @@
<?php <?php
namespace tests\codeception\api\models\authentication; namespace api\tests\_support\models\authentication;
use api\components\User\AuthenticationResult; use api\components\User\AuthenticationResult;
use api\models\authentication\ConfirmEmailForm; use api\models\authentication\ConfirmEmailForm;
use common\models\Account; use common\models\Account;
use common\models\AccountSession; use common\models\AccountSession;
use common\models\EmailActivation; use common\models\EmailActivation;
use tests\codeception\api\unit\TestCase; use api\tests\unit\TestCase;
use tests\codeception\common\fixtures\EmailActivationFixture; use common\tests\fixtures\EmailActivationFixture;
class ConfirmEmailFormTest extends TestCase { class ConfirmEmailFormTest extends TestCase {

View File

@ -8,9 +8,9 @@ use common\models\Account;
use common\models\EmailActivation; use common\models\EmailActivation;
use common\tasks\SendPasswordRecoveryEmail; use common\tasks\SendPasswordRecoveryEmail;
use GuzzleHttp\ClientInterface; use GuzzleHttp\ClientInterface;
use tests\codeception\api\unit\TestCase; use api\tests\unit\TestCase;
use tests\codeception\common\fixtures\AccountFixture; use common\tests\fixtures\AccountFixture;
use tests\codeception\common\fixtures\EmailActivationFixture; use common\tests\fixtures\EmailActivationFixture;
use Yii; use Yii;
class ForgotPasswordFormTest extends TestCase { class ForgotPasswordFormTest extends TestCase {

View File

@ -1,13 +1,13 @@
<?php <?php
namespace tests\codeception\api\models\authentication; namespace api\tests\_support\models\authentication;
use api\components\User\AuthenticationResult; use api\components\User\AuthenticationResult;
use api\models\authentication\LoginForm; use api\models\authentication\LoginForm;
use Codeception\Specify; use Codeception\Specify;
use common\models\Account; use common\models\Account;
use OTPHP\TOTP; use OTPHP\TOTP;
use tests\codeception\api\unit\TestCase; use api\tests\unit\TestCase;
use tests\codeception\common\fixtures\AccountFixture; use common\tests\fixtures\AccountFixture;
class LoginFormTest extends TestCase { class LoginFormTest extends TestCase {
use Specify; use Specify;

View File

@ -1,12 +1,12 @@
<?php <?php
namespace tests\codeception\api\models\authentication; namespace api\tests\_support\models\authentication;
use api\components\User\Component; use api\components\User\Component;
use api\components\User\Identity; use api\components\User\Identity;
use api\models\authentication\LogoutForm; use api\models\authentication\LogoutForm;
use Codeception\Specify; use Codeception\Specify;
use common\models\AccountSession; use common\models\AccountSession;
use tests\codeception\api\unit\TestCase; use api\tests\unit\TestCase;
use Yii; use Yii;
class LogoutFormTest extends TestCase { class LogoutFormTest extends TestCase {

View File

@ -1,13 +1,13 @@
<?php <?php
namespace tests\codeception\api\models\authentication; namespace api\tests\_support\models\authentication;
use api\components\User\AuthenticationResult; use api\components\User\AuthenticationResult;
use api\models\authentication\RecoverPasswordForm; use api\models\authentication\RecoverPasswordForm;
use Codeception\Specify; use Codeception\Specify;
use common\models\Account; use common\models\Account;
use common\models\EmailActivation; use common\models\EmailActivation;
use tests\codeception\api\unit\TestCase; use api\tests\unit\TestCase;
use tests\codeception\common\fixtures\EmailActivationFixture; use common\tests\fixtures\EmailActivationFixture;
class RecoverPasswordFormTest extends TestCase { class RecoverPasswordFormTest extends TestCase {
use Specify; use Specify;

View File

@ -5,8 +5,8 @@ use api\components\User\AuthenticationResult;
use api\models\authentication\RefreshTokenForm; use api\models\authentication\RefreshTokenForm;
use Codeception\Specify; use Codeception\Specify;
use common\models\AccountSession; use common\models\AccountSession;
use tests\codeception\api\unit\TestCase; use api\tests\unit\TestCase;
use tests\codeception\common\fixtures\AccountSessionFixture; use common\tests\fixtures\AccountSessionFixture;
class RefreshTokenFormTest extends TestCase { class RefreshTokenFormTest extends TestCase {
use Specify; use Specify;

View File

@ -1,26 +1,24 @@
<?php <?php
namespace tests\codeception\api\models\authentication; namespace api\tests\_support\models\authentication;
use api\components\ReCaptcha\Validator as ReCaptchaValidator; use api\components\ReCaptcha\Validator as ReCaptchaValidator;
use api\models\authentication\RegistrationForm; use api\models\authentication\RegistrationForm;
use Codeception\Specify;
use common\models\Account; use common\models\Account;
use common\models\EmailActivation; use common\models\EmailActivation;
use common\models\UsernameHistory; use common\models\UsernameHistory;
use common\tasks\SendRegistrationEmail; use common\tasks\SendRegistrationEmail;
use GuzzleHttp\ClientInterface; use GuzzleHttp\ClientInterface;
use tests\codeception\api\unit\TestCase; use api\tests\unit\TestCase;
use tests\codeception\common\fixtures\AccountFixture; use common\tests\fixtures\AccountFixture;
use tests\codeception\common\fixtures\EmailActivationFixture; use common\tests\fixtures\EmailActivationFixture;
use tests\codeception\common\fixtures\UsernameHistoryFixture; use common\tests\fixtures\UsernameHistoryFixture;
use tests\codeception\common\helpers\Mock; use common\tests\helpers\Mock;
use Yii; use Yii;
use yii\validators\EmailValidator; use yii\validators\EmailValidator;
use yii\web\Request; use yii\web\Request;
use const common\LATEST_RULES_VERSION; use const common\LATEST_RULES_VERSION;
class RegistrationFormTest extends TestCase { class RegistrationFormTest extends TestCase {
use Specify;
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
@ -132,9 +130,8 @@ class RegistrationFormTest extends TestCase {
->getMock(); ->getMock();
$request $request
->expects($this->any())
->method('getUserIP') ->method('getUserIP')
->will($this->returnValue($ip)); ->willReturn($ip);
Yii::$app->set('request', $request); Yii::$app->set('request', $request);

View File

@ -1,5 +1,5 @@
<?php <?php
namespace tests\codeception\api\models\authentication; namespace api\tests\_support\models\authentication;
use api\components\ReCaptcha\Validator as ReCaptchaValidator; use api\components\ReCaptcha\Validator as ReCaptchaValidator;
use api\models\authentication\RepeatAccountActivationForm; use api\models\authentication\RepeatAccountActivationForm;
@ -7,9 +7,9 @@ use Codeception\Specify;
use common\models\EmailActivation; use common\models\EmailActivation;
use common\tasks\SendRegistrationEmail; use common\tasks\SendRegistrationEmail;
use GuzzleHttp\ClientInterface; use GuzzleHttp\ClientInterface;
use tests\codeception\api\unit\TestCase; use api\tests\unit\TestCase;
use tests\codeception\common\fixtures\AccountFixture; use common\tests\fixtures\AccountFixture;
use tests\codeception\common\fixtures\EmailActivationFixture; use common\tests\fixtures\EmailActivationFixture;
use Yii; use Yii;
class RepeatAccountActivationFormTest extends TestCase { class RepeatAccountActivationFormTest extends TestCase {

View File

@ -1,8 +1,8 @@
<?php <?php
namespace tests\codeception\api\models\base; namespace api\tests\_support\models\base;
use api\models\base\ApiForm; use api\models\base\ApiForm;
use tests\codeception\api\unit\TestCase; use api\tests\unit\TestCase;
class ApiFormTest extends TestCase { class ApiFormTest extends TestCase {

View File

@ -1,9 +1,9 @@
<?php <?php
namespace tests\codeception\api\unit\modules\accounts\models; namespace api\tests\unit\modules\accounts\models;
use api\modules\accounts\models\AcceptRulesForm; use api\modules\accounts\models\AcceptRulesForm;
use common\models\Account; use common\models\Account;
use tests\codeception\api\unit\TestCase; use api\tests\unit\TestCase;
use const common\LATEST_RULES_VERSION; use const common\LATEST_RULES_VERSION;
class AcceptRulesFormTest extends TestCase { class AcceptRulesFormTest extends TestCase {

View File

@ -1,12 +1,12 @@
<?php <?php
namespace tests\codeception\api\unit\modules\accounts\models; namespace api\tests\unit\modules\accounts\models;
use api\modules\accounts\models\ChangeEmailForm; use api\modules\accounts\models\ChangeEmailForm;
use common\models\Account; use common\models\Account;
use common\models\EmailActivation; use common\models\EmailActivation;
use tests\codeception\api\unit\TestCase; use api\tests\unit\TestCase;
use tests\codeception\common\fixtures\AccountFixture; use common\tests\fixtures\AccountFixture;
use tests\codeception\common\fixtures\EmailActivationFixture; use common\tests\fixtures\EmailActivationFixture;
class ChangeEmailFormTest extends TestCase { class ChangeEmailFormTest extends TestCase {

Some files were not shown because too many files have changed in this diff Show More