diff --git a/.gitignore b/.gitignore index f18c018..e17f58f 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,7 @@ npm-debug* # PHP-CS-Fixer .php_cs .php_cs.cache + +# Codeception +codeception.yml +*/codeception.yml diff --git a/api/codeception.dist.yml b/api/codeception.dist.yml new file mode 100644 index 0000000..527e806 --- /dev/null +++ b/api/codeception.dist.yml @@ -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' diff --git a/tests/codeception/config/api/config.php b/api/config/config-test.php similarity index 59% rename from tests/codeception/config/api/config.php rename to api/config/config-test.php index c6ea4c5..7e5ff0c 100644 --- a/tests/codeception/config/api/config.php +++ b/api/config/config-test.php @@ -1,7 +1,4 @@ [ 'user' => [ @@ -12,18 +9,13 @@ return [ 'secret' => 'private-key', ], ], - 'modules' => [ - 'authserver' => [ - 'host' => 'localhost', - ], - ], 'params' => [ - 'authserverHost' => 'authserver.ely.by', + 'authserverHost' => 'localhost', ], 'container' => [ 'definitions' => [ - Validator::class => function() { - return new class(new Client()) extends Validator { + api\components\ReCaptcha\Validator::class => function() { + return new class(new GuzzleHttp\Client()) extends api\components\ReCaptcha\Validator { protected function validateValue($value) { return null; } diff --git a/api/config/config.php b/api/config/config.php index ffe0ee2..46a30f9 100644 --- a/api/config/config.php +++ b/api/config/config.php @@ -1,15 +1,12 @@ 'accounts-site-api', 'basePath' => dirname(__DIR__), - 'bootstrap' => ['log', 'authserver', 'internal'], + 'bootstrap' => ['log', 'authserver', 'internal', 'mojang'], 'controllerNamespace' => 'api\controllers', - 'params' => $params, + 'params' => [ + 'authserverHost' => getenv('AUTHSERVER_HOST'), + ], 'components' => [ 'user' => [ 'class' => api\components\User\Component::class, @@ -79,10 +76,7 @@ return [ ], ], 'modules' => [ - 'authserver' => [ - 'class' => api\modules\authserver\Module::class, - 'host' => $params['authserverHost'], - ], + 'authserver' => api\modules\authserver\Module::class, 'session' => api\modules\session\Module::class, 'mojang' => api\modules\mojang\Module::class, 'internal' => api\modules\internal\Module::class, diff --git a/api/config/params.php b/api/config/params.php deleted file mode 100644 index 5412ed8..0000000 --- a/api/config/params.php +++ /dev/null @@ -1,4 +0,0 @@ - getenv('AUTHSERVER_HOST'), -]; diff --git a/api/config/routes.php b/api/config/routes.php index 9a385ef..f61cab1 100644 --- a/api/config/routes.php +++ b/api/config/routes.php @@ -1,7 +1,4 @@ ' => 'oauth/authorization/', @@ -46,8 +43,4 @@ return [ '/mojang/profiles/' => 'mojang/api/uuid-by-username', '/mojang/profiles//names' => 'mojang/api/usernames-by-uuid', 'POST /mojang/profiles' => 'mojang/api/uuids-by-usernames', - - "//{$params['authserverHost']}/mojang/api/users/profiles/minecraft/" => 'mojang/api/uuid-by-username', - "//{$params['authserverHost']}/mojang/api/user/profiles//names" => 'mojang/api/usernames-by-uuid', - "POST //{$params['authserverHost']}/mojang/api/profiles/minecraft" => 'mojang/api/uuids-by-usernames', ]; diff --git a/api/modules/authserver/Module.php b/api/modules/authserver/Module.php index 793c658..b2c1b22 100644 --- a/api/modules/authserver/Module.php +++ b/api/modules/authserver/Module.php @@ -1,9 +1,10 @@ host === null) { - throw new InvalidConfigException('base domain must be specified'); - } - } - public function beforeAction($action) { if (!parent::beforeAction($action)) { 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) { + $legacyHost = $app->params['authserverHost']; $app->getUrlManager()->addRules([ - "//$this->host/$this->id/auth/" => "$this->id/authentication/", + "//{$legacyHost}/authserver/auth/" => "{$this->id}/authentication/", ], false); } @@ -59,7 +49,7 @@ class Module extends \yii\base\Module implements BootstrapInterface { * @throws NotFoundHttpException */ 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(); } } diff --git a/api/modules/mojang/Module.php b/api/modules/mojang/Module.php index 9306443..5c41899 100644 --- a/api/modules/mojang/Module.php +++ b/api/modules/mojang/Module.php @@ -1,10 +1,26 @@ params['authserverHost']; + $app->getUrlManager()->addRules([ + "//{$legacyHost}/mojang/api/users/profiles/minecraft/" => "{$this->id}/api/uuid-by-username", + "//{$legacyHost}/mojang/api/user/profiles//names" => "{$this->id}/api/usernames-by-uuid", + "POST //{$legacyHost}/mojang/api/profiles/minecraft" => "{$this->id}/api/uuids-by-usernames", + ]); + } + } diff --git a/api/modules/oauth/controllers/AuthorizationController.php b/api/modules/oauth/controllers/AuthorizationController.php index d0ad35c..03d073f 100644 --- a/api/modules/oauth/controllers/AuthorizationController.php +++ b/api/modules/oauth/controllers/AuthorizationController.php @@ -55,7 +55,10 @@ class AuthorizationController extends Controller { } 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); } } diff --git a/api/tests/.gitignore b/api/tests/.gitignore new file mode 100644 index 0000000..3adb08b --- /dev/null +++ b/api/tests/.gitignore @@ -0,0 +1,3 @@ +functional.suite.yml +unit.suite.yml +_support/_generated diff --git a/api/tests/_bootstrap.php b/api/tests/_bootstrap.php new file mode 100644 index 0000000..156889d --- /dev/null +++ b/api/tests/_bootstrap.php @@ -0,0 +1,10 @@ +getActor()->sendGET("/v1/accounts/{$accountId}"); + $this->getActor()->sendGET("/api/v1/accounts/{$accountId}"); } 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, 'newPassword' => $newPassword, 'newRePassword' => $newRePassword, @@ -16,65 +16,65 @@ class AccountsRoute extends BasePage { } 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, 'username' => $newUsername, ]); } 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, ]); } 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, 'email' => $email, ]); } public function changeEmail(int $accountId, $key = null) { - $this->getActor()->sendPOST("/v1/accounts/{$accountId}/email", [ + $this->getActor()->sendPOST("/api/v1/accounts/{$accountId}/email", [ 'key' => $key, ]); } public function changeLanguage(int $accountId, $lang = null) { - $this->getActor()->sendPOST("/v1/accounts/{$accountId}/language", [ + $this->getActor()->sendPOST("/api/v1/accounts/{$accountId}/language", [ 'lang' => $lang, ]); } 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) { - $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) { - $this->getActor()->sendPOST("/v1/accounts/{$accountId}/two-factor-auth", [ + $this->getActor()->sendPOST("/api/v1/accounts/{$accountId}/two-factor-auth", [ 'totp' => $totp, 'password' => $password, ]); } 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, 'password' => $password, ]); } 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) { - $this->getActor()->sendDELETE("/v1/accounts/{$accountId}/ban"); + $this->getActor()->sendDELETE("/api/v1/accounts/{$accountId}/ban"); } } diff --git a/tests/codeception/api/_pages/AuthenticationRoute.php b/api/tests/_pages/AuthenticationRoute.php similarity index 75% rename from tests/codeception/api/_pages/AuthenticationRoute.php rename to api/tests/_pages/AuthenticationRoute.php index 6ce52f1..d926d0b 100644 --- a/tests/codeception/api/_pages/AuthenticationRoute.php +++ b/api/tests/_pages/AuthenticationRoute.php @@ -1,5 +1,5 @@ getActor()->sendPOST('/authentication/login', $params); + $this->getActor()->sendPOST('/api/authentication/login', $params); } public function logout() { - $this->getActor()->sendPOST('/authentication/logout'); + $this->getActor()->sendPOST('/api/authentication/logout'); } public function forgotPassword($login = null, $token = null) { - $this->getActor()->sendPOST('/authentication/forgot-password', [ + $this->getActor()->sendPOST('/api/authentication/forgot-password', [ 'login' => $login, 'totp' => $token, ]); } public function recoverPassword($key = null, $newPassword = null, $newRePassword = null) { - $this->getActor()->sendPOST('/authentication/recover-password', [ + $this->getActor()->sendPOST('/api/authentication/recover-password', [ 'key' => $key, 'newPassword' => $newPassword, 'newRePassword' => $newRePassword, @@ -44,7 +44,7 @@ class AuthenticationRoute extends BasePage { } public function refreshToken($refreshToken = null) { - $this->getActor()->sendPOST('/authentication/refresh-token', [ + $this->getActor()->sendPOST('/api/authentication/refresh-token', [ 'refresh_token' => $refreshToken, ]); } diff --git a/api/tests/_pages/AuthserverRoute.php b/api/tests/_pages/AuthserverRoute.php new file mode 100644 index 0000000..90649c1 --- /dev/null +++ b/api/tests/_pages/AuthserverRoute.php @@ -0,0 +1,26 @@ +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); + } + +} diff --git a/tests/codeception/api/_pages/BasePage.php b/api/tests/_pages/BasePage.php similarity index 76% rename from tests/codeception/api/_pages/BasePage.php rename to api/tests/_pages/BasePage.php index 8bf9dad..17e2130 100644 --- a/tests/codeception/api/_pages/BasePage.php +++ b/api/tests/_pages/BasePage.php @@ -1,7 +1,7 @@ getActor()->sendGET('/api/account/v1/info'); + } + +} diff --git a/api/tests/_pages/InternalRoute.php b/api/tests/_pages/InternalRoute.php new file mode 100644 index 0000000..c383a96 --- /dev/null +++ b/api/tests/_pages/InternalRoute.php @@ -0,0 +1,10 @@ +getActor()->sendGET('/api/internal/accounts/info', [$param => $value]); + } + +} diff --git a/tests/codeception/api/_pages/MojangApiRoute.php b/api/tests/_pages/MojangApiRoute.php similarity index 52% rename from tests/codeception/api/_pages/MojangApiRoute.php rename to api/tests/_pages/MojangApiRoute.php index 7a2a25c..3fdebb1 100644 --- a/tests/codeception/api/_pages/MojangApiRoute.php +++ b/api/tests/_pages/MojangApiRoute.php @@ -1,19 +1,19 @@ $at]; - $this->getActor()->sendGET("/mojang/profiles/{$username}", $params); + $this->getActor()->sendGET("/api/mojang/profiles/{$username}", $params); } public function usernamesByUuid($uuid) { - $this->getActor()->sendGET("/mojang/profiles/{$uuid}/names"); + $this->getActor()->sendGET("/api/mojang/profiles/{$uuid}/names"); } public function uuidsByUsernames($uuids) { - $this->getActor()->sendPOST('/mojang/profiles', $uuids); + $this->getActor()->sendPOST('/api/mojang/profiles', $uuids); } } diff --git a/api/tests/_pages/OauthRoute.php b/api/tests/_pages/OauthRoute.php new file mode 100644 index 0000000..a4473ce --- /dev/null +++ b/api/tests/_pages/OauthRoute.php @@ -0,0 +1,42 @@ +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"); + } + +} diff --git a/api/tests/_pages/OptionsRoute.php b/api/tests/_pages/OptionsRoute.php new file mode 100644 index 0000000..2f4a2d3 --- /dev/null +++ b/api/tests/_pages/OptionsRoute.php @@ -0,0 +1,10 @@ +getActor()->sendGET('/api/options'); + } + +} diff --git a/api/tests/_pages/SessionServerRoute.php b/api/tests/_pages/SessionServerRoute.php new file mode 100644 index 0000000..677f4d5 --- /dev/null +++ b/api/tests/_pages/SessionServerRoute.php @@ -0,0 +1,26 @@ +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}"); + } + +} diff --git a/tests/codeception/api/_pages/SignupRoute.php b/api/tests/_pages/SignupRoute.php similarity index 50% rename from tests/codeception/api/_pages/SignupRoute.php rename to api/tests/_pages/SignupRoute.php index 4aba204..6ab219c 100644 --- a/tests/codeception/api/_pages/SignupRoute.php +++ b/api/tests/_pages/SignupRoute.php @@ -1,18 +1,18 @@ getActor()->sendPOST('/signup', $registrationData); + $this->getActor()->sendPOST('/api/signup', $registrationData); } 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 = '') { - $this->getActor()->sendPOST('/signup/confirm', [ + $this->getActor()->sendPOST('/api/signup/confirm', [ 'key' => $key, ]); } diff --git a/tests/codeception/api/_support/FunctionalTester.php b/api/tests/_support/FunctionalTester.php similarity index 65% rename from tests/codeception/api/_support/FunctionalTester.php rename to api/tests/_support/FunctionalTester.php index 3d2b489..45399cd 100644 --- a/tests/codeception/api/_support/FunctionalTester.php +++ b/api/tests/_support/FunctionalTester.php @@ -1,28 +1,16 @@ id; } - public function notLoggedIn() { + public function notLoggedIn(): void { $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('$.expires_in'); if ($expectRefresh) { diff --git a/api/tests/_support/UnitTester.php b/api/tests/_support/UnitTester.php new file mode 100644 index 0000000..e7b2540 --- /dev/null +++ b/api/tests/_support/UnitTester.php @@ -0,0 +1,12 @@ +sendPOST('/feedback', [ + $I->sendPOST('/api/feedback', [ 'subject' => 'Test', 'email' => 'email@ely.by', 'type' => 0, @@ -21,7 +21,7 @@ class FeedbackCest { public function testFeedbackWithAuth(FunctionalTester $I) { $I->amAuthenticated(); - $I->sendPOST('/feedback', [ + $I->sendPOST('/api/feedback', [ 'subject' => 'Test', 'email' => 'email@ely.by', 'type' => 0, diff --git a/tests/codeception/api/functional/ForgotPasswordCest.php b/api/tests/functional/ForgotPasswordCest.php similarity index 94% rename from tests/codeception/api/functional/ForgotPasswordCest.php rename to api/tests/functional/ForgotPasswordCest.php index 72a7ef8..c9a88ff 100644 --- a/tests/codeception/api/functional/ForgotPasswordCest.php +++ b/api/tests/functional/ForgotPasswordCest.php @@ -1,8 +1,8 @@ toString(); $route->authenticate([ diff --git a/tests/codeception/api/functional/_steps/OauthSteps.php b/api/tests/functional/_steps/OauthSteps.php similarity index 94% rename from tests/codeception/api/functional/_steps/OauthSteps.php rename to api/tests/functional/_steps/OauthSteps.php index ff573b2..da3b9a6 100644 --- a/tests/codeception/api/functional/_steps/OauthSteps.php +++ b/api/tests/functional/_steps/OauthSteps.php @@ -1,9 +1,9 @@ 'Bearer', ]); $I->canSeeResponseJsonMatchesJsonPath('$.access_token'); + $I->cantSeeResponseJsonMatchesJsonPath('$.refresh_token'); $I->canSeeResponseJsonMatchesJsonPath('$.expires_in'); } diff --git a/tests/codeception/api/functional/oauth/AuthCodeCest.php b/api/tests/functional/oauth/AuthCodeCest.php similarity index 98% rename from tests/codeception/api/functional/oauth/AuthCodeCest.php rename to api/tests/functional/oauth/AuthCodeCest.php index daccabb..e0093c2 100644 --- a/tests/codeception/api/functional/oauth/AuthCodeCest.php +++ b/api/tests/functional/oauth/AuthCodeCest.php @@ -1,9 +1,9 @@ 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) { + $I->wantToTest('behavior when this endpoint called with token, that have not enough scopes'); $accessToken = $I->getAccessToken(); $I->amBearerAuthenticated($accessToken); $this->route->info(); @@ -25,6 +38,7 @@ class IdentityInfoCest { $I->canSeeResponseContainsJson([ 'name' => 'Forbidden', 'status' => 403, + 'message' => 'You are not allowed to perform this action.', ]); } diff --git a/tests/codeception/api/functional/oauth/RefreshTokenCest.php b/api/tests/functional/oauth/RefreshTokenCest.php similarity index 95% rename from tests/codeception/api/functional/oauth/RefreshTokenCest.php rename to api/tests/functional/oauth/RefreshTokenCest.php index e5185c2..16bd6c2 100644 --- a/tests/codeception/api/functional/oauth/RefreshTokenCest.php +++ b/api/tests/functional/oauth/RefreshTokenCest.php @@ -1,11 +1,11 @@ getMock(); $request - ->expects($this->any()) ->method('getUserIP') - ->will($this->returnValue($ip)); + ->willReturn($ip); Yii::$app->set('request', $request); diff --git a/tests/codeception/api/unit/models/authentication/RepeatAccountActivationFormTest.php b/api/tests/unit/models/authentication/RepeatAccountActivationFormTest.php similarity index 95% rename from tests/codeception/api/unit/models/authentication/RepeatAccountActivationFormTest.php rename to api/tests/unit/models/authentication/RepeatAccountActivationFormTest.php index 6dbebb1..5c1a254 100644 --- a/tests/codeception/api/unit/models/authentication/RepeatAccountActivationFormTest.php +++ b/api/tests/unit/models/authentication/RepeatAccountActivationFormTest.php @@ -1,5 +1,5 @@ getMockBuilder(Connection::class) ->setMethods(['executeCommand']) ->getMock(); @@ -22,23 +24,22 @@ class RateLimiterTest extends TestCase { Yii::$app->set('redis', $redis); - /** @var RateLimiter|\PHPUnit_Framework_MockObject_MockObject $filter */ + /** @var RateLimiter|\PHPUnit\Framework\MockObject\MockObject $filter */ $filter = $this->getMockBuilder(RateLimiter::class) ->setConstructorArgs([[ - 'authserverDomain' => Yii::$app->params['authserverHost'], + 'authserverDomain' => 'authserver.ely.by', ]]) ->setMethods(['getServer']) ->getMock(); - $filter->expects($this->any()) - ->method('getServer') - ->will($this->returnValue(new OauthClient())); + $filter->method('getServer') + ->willReturn(new OauthClient()); $filter->checkRateLimit(null, new Request(), null, null); } public function testCheckRateLimiterWithValidServerId() { - /** @var Connection|\PHPUnit_Framework_MockObject_MockObject $redis */ + /** @var Connection|\PHPUnit\Framework\MockObject\MockObject $redis */ $redis = $this->getMockBuilder(Connection::class) ->setMethods(['executeCommand']) ->getMock(); @@ -48,17 +49,16 @@ class RateLimiterTest extends TestCase { Yii::$app->set('redis', $redis); - /** @var Request|\PHPUnit_Framework_MockObject_MockObject $request */ + /** @var Request|\PHPUnit\Framework\MockObject\MockObject $request */ $request = $this->getMockBuilder(Request::class) ->setMethods(['getHostInfo']) ->getMock(); - $request->expects($this->any()) - ->method('getHostInfo') - ->will($this->returnValue('http://authserver.ely.by')); + $request->method('getHostInfo') + ->willReturn('http://authserver.ely.by'); $filter = new RateLimiter([ - 'authserverDomain' => Yii::$app->params['authserverHost'], + 'authserverDomain' => 'authserver.ely.by', ]); $filter->checkRateLimit(null, $request, null, null); } @@ -67,7 +67,7 @@ class RateLimiterTest extends TestCase { * @expectedException \yii\web\TooManyRequestsHttpException */ public function testCheckRateLimiter() { - /** @var Connection|\PHPUnit_Framework_MockObject_MockObject $redis */ + /** @var Connection|\PHPUnit\Framework\MockObject\MockObject $redis */ $redis = $this->getMockBuilder(Connection::class) ->setMethods(['executeCommand']) ->getMock(); @@ -78,27 +78,25 @@ class RateLimiterTest extends TestCase { Yii::$app->set('redis', $redis); - /** @var Request|\PHPUnit_Framework_MockObject_MockObject $request */ + /** @var Request|\PHPUnit\Framework\MockObject\MockObject $request */ $request = $this->getMockBuilder(Request::class) ->setMethods(['getUserIP']) ->getMock(); - $request->expects($this->any()) - ->method('getUserIp') - ->will($this->returnValue(Internet::localIpv4())); + $request->method('getUserIp') + ->willReturn(Internet::localIpv4()); - /** @var RateLimiter|\PHPUnit_Framework_MockObject_MockObject $filter */ + /** @var RateLimiter|\PHPUnit\Framework\MockObject\MockObject $filter */ $filter = $this->getMockBuilder(RateLimiter::class) ->setConstructorArgs([[ 'limit' => 3, - 'authserverDomain' => Yii::$app->params['authserverHost'], + 'authserverDomain' => 'authserver.ely.by', ]]) ->setMethods(['getServer']) ->getMock(); - $filter->expects($this->any()) - ->method('getServer') - ->will($this->returnValue(null)); + $filter->method('getServer') + ->willReturn(null); for ($i = 0; $i < 5; $i++) { $filter->checkRateLimit(null, $request, null, null); diff --git a/tests/codeception/api/unit/request/RequestParserTest.php b/api/tests/unit/request/RequestParserTest.php similarity index 87% rename from tests/codeception/api/unit/request/RequestParserTest.php rename to api/tests/unit/request/RequestParserTest.php index 8dbb3e0..97962b7 100644 --- a/tests/codeception/api/unit/request/RequestParserTest.php +++ b/api/tests/unit/request/RequestParserTest.php @@ -1,8 +1,8 @@ init([ ]); require __DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'; -spl_autoload_unregister(['Yii', 'autoload']); require __DIR__ . '/../../common/config/bootstrap.php'; require __DIR__ . '/../config/bootstrap.php'; diff --git a/codeception.dist.yml b/codeception.dist.yml new file mode 100644 index 0000000..bac3dc2 --- /dev/null +++ b/codeception.dist.yml @@ -0,0 +1,10 @@ +include: + - common + - api + - console + +paths: + log: console/runtime/logs + +settings: + colors: true diff --git a/common/codeception.dist.yml b/common/codeception.dist.yml new file mode 100644 index 0000000..8874605 --- /dev/null +++ b/common/codeception.dist.yml @@ -0,0 +1,21 @@ +namespace: common\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 + whitelist: + include: + - ./* + exclude: + - config/* + - mail/* + - codeception.dist.yml + - codeception.yml diff --git a/common/config/ConfigLoader.php b/common/config/ConfigLoader.php index c4bf229..58f4495 100644 --- a/common/config/ConfigLoader.php +++ b/common/config/ConfigLoader.php @@ -1,4 +1,6 @@ 'common-tests', + 'basePath' => dirname(__DIR__), + 'params' => [ + 'fromEmail' => 'ely@ely.by', + ], + 'components' => [ + 'security' => [ + // It's allows us to increase tests speed by decreasing password hashing algorithm complexity + 'passwordHashCost' => 4, + ], + 'queue' => [ + 'class' => common\tests\_support\queue\Queue::class, + ], + 'sentry' => [ + 'enabled' => false, + ], + 'mailer' => [ + 'useFileTransport' => true, + ], + ], +]; diff --git a/common/config/config.php b/common/config/config.php index cd71980..8e468c6 100644 --- a/common/config/config.php +++ b/common/config/config.php @@ -2,6 +2,24 @@ return [ 'version' => '{{PLACE_VERSION_HERE}}', // This will be replaced by build tool 'vendorPath' => dirname(__DIR__, 2) . '/vendor', + 'aliases' => [ + '@bower' => '@vendor/bower-asset', + '@npm' => '@vendor/npm-asset', + + '@root' => dirname(__DIR__, 2), + '@api' => '@root/api', + '@common' => '@root/common', + '@console' => '@root/console', + ], + 'params' => [ + 'fromEmail' => 'ely@ely.by', + 'supportEmail' => 'support@ely.by', + ], + 'container' => [ + 'definitions' => [ + GuzzleHttp\ClientInterface::class => GuzzleHttp\Client::class, + ], + ], 'components' => [ 'cache' => [ 'class' => yii\redis\Cache::class, @@ -91,13 +109,4 @@ return [ 'class' => yii\queue\redis\Queue::class, ], ], - 'container' => [ - 'definitions' => [ - GuzzleHttp\ClientInterface::class => GuzzleHttp\Client::class, - ], - ], - 'aliases' => [ - '@bower' => '@vendor/bower-asset', - '@npm' => '@vendor/npm-asset', - ], ]; diff --git a/common/config/params.php b/common/config/params.php deleted file mode 100644 index bc54b66..0000000 --- a/common/config/params.php +++ /dev/null @@ -1,5 +0,0 @@ - 'ely@ely.by', - 'supportEmail' => 'support@ely.by', -]; diff --git a/common/tests/.gitignore b/common/tests/.gitignore new file mode 100644 index 0000000..089cfd4 --- /dev/null +++ b/common/tests/.gitignore @@ -0,0 +1,2 @@ +unit.suite.yml +_support/_generated diff --git a/common/tests/_bootstrap.php b/common/tests/_bootstrap.php new file mode 100644 index 0000000..41318a6 --- /dev/null +++ b/common/tests/_bootstrap.php @@ -0,0 +1,8 @@ + 'Redis', + ]; + + public function _initialize(): void { + if (!$this->hasModule($this->config['module'])) { + throw new ModuleConfigException($this, 'This module should be used together with Redis module'); + } + + /** @var \Codeception\Module\Redis $module */ + $module = $this->getModule($this->config['module']); + $config = $module->_getConfig(); + $config['host'] = Yii::$app->redis->hostname; + $config['port'] = Yii::$app->redis->port; + $config['database'] = Yii::$app->redis->database; + $module->_setConfig($config); + if ($module->driver !== null) { + $module->_initialize(); + } + } + +} diff --git a/tests/codeception/common/_support/FixtureHelper.php b/common/tests/_support/FixtureHelper.php similarity index 77% rename from tests/codeception/common/_support/FixtureHelper.php rename to common/tests/_support/FixtureHelper.php index 6e5dfd0..17914cd 100644 --- a/tests/codeception/common/_support/FixtureHelper.php +++ b/common/tests/_support/FixtureHelper.php @@ -1,15 +1,15 @@ assertEquals('**@ely.by', StringHelper::getEmailMask('e@ely.by')); diff --git a/tests/codeception/common/unit/models/AccountSessionTest.php b/common/tests/unit/models/AccountSessionTest.php similarity index 90% rename from tests/codeception/common/unit/models/AccountSessionTest.php rename to common/tests/unit/models/AccountSessionTest.php index 0e98803..ca429f1 100644 --- a/tests/codeception/common/unit/models/AccountSessionTest.php +++ b/common/tests/unit/models/AccountSessionTest.php @@ -1,8 +1,8 @@ =5.4.0", - "psr/http-message": "~1.0" + "psr/http-message": "~1.0", + "ralouphie/getallheaders": "^2.0.5" }, "provide": { "psr/http-message-implementation": "1.0" }, "require-dev": { - "phpunit/phpunit": "~4.0" + "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "1.5-dev" } }, "autoload": { @@ -1080,13 +1081,14 @@ "keywords": [ "http", "message", + "psr-7", "request", "response", "stream", "uri", "url" ], - "time": "2017-03-20T17:10:46+00:00" + "time": "2018-12-04T20:46:45+00:00" }, { "name": "jakubledl/dissect", @@ -1522,6 +1524,46 @@ ], "time": "2016-08-06T14:39:51+00:00" }, + { + "name": "ralouphie/getallheaders", + "version": "2.0.5", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "5601c8a83fbba7ef674a7369456d12f1e0d0eafa" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/5601c8a83fbba7ef674a7369456d12f1e0d0eafa", + "reference": "5601c8a83fbba7ef674a7369456d12f1e0d0eafa", + "shasum": "" + }, + "require": { + "php": ">=5.3" + }, + "require-dev": { + "phpunit/phpunit": "~3.7.0", + "satooshi/php-coveralls": ">=1.0" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "time": "2016-02-11T07:05:27+00:00" + }, { "name": "ramsey/uuid", "version": "3.7.3", @@ -1837,17 +1879,75 @@ "time": "2018-06-21T11:10:19+00:00" }, { - "name": "symfony/polyfill-mbstring", - "version": "v1.7.0", + "name": "symfony/polyfill-ctype", + "version": "v1.10.0", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "78be803ce01e55d3491c1397cf1c64beb9c1b63b" + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "e3d826245268269cd66f8326bd8bc066687b4a19" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/78be803ce01e55d3491c1397cf1c64beb9c1b63b", - "reference": "78be803ce01e55d3491c1397cf1c64beb9c1b63b", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e3d826245268269cd66f8326bd8bc066687b4a19", + "reference": "e3d826245268269cd66f8326bd8bc066687b4a19", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + }, + { + "name": "Gert de Pagter", + "email": "backendtea@gmail.com" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "time": "2018-08-06T14:22:27+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.10.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "c79c051f5b3a46be09205c73b80b346e4153e494" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/c79c051f5b3a46be09205c73b80b346e4153e494", + "reference": "c79c051f5b3a46be09205c73b80b346e4153e494", "shasum": "" }, "require": { @@ -1859,7 +1959,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.7-dev" + "dev-master": "1.9-dev" } }, "autoload": { @@ -1893,7 +1993,7 @@ "portable", "shim" ], - "time": "2018-01-30T19:27:44+00:00" + "time": "2018-09-21T13:07:52+00:00" }, { "name": "symfony/polyfill-php70", @@ -1956,16 +2056,16 @@ }, { "name": "symfony/process", - "version": "v4.0.4", + "version": "v4.2.3", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "e1712002d81de6f39f854bc5bbd9e9f4bb6345b4" + "reference": "6c05edb11fbeff9e2b324b4270ecb17911a8b7ad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/e1712002d81de6f39f854bc5bbd9e9f4bb6345b4", - "reference": "e1712002d81de6f39f854bc5bbd9e9f4bb6345b4", + "url": "https://api.github.com/repos/symfony/process/zipball/6c05edb11fbeff9e2b324b4270ecb17911a8b7ad", + "reference": "6c05edb11fbeff9e2b324b4270ecb17911a8b7ad", "shasum": "" }, "require": { @@ -1974,7 +2074,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-master": "4.2-dev" } }, "autoload": { @@ -2001,24 +2101,25 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2018-01-29T09:06:29+00:00" + "time": "2019-01-24T22:05:03+00:00" }, { "name": "webmozart/assert", - "version": "1.3.0", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "0df1908962e7a3071564e857d86874dad1ef204a" + "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a", - "reference": "0df1908962e7a3071564e857d86874dad1ef204a", + "url": "https://api.github.com/repos/webmozart/assert/zipball/83e253c8e0be5b0257b881e1827274667c5c17a9", + "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": "^5.3.3 || ^7.0", + "symfony/polyfill-ctype": "^1.8" }, "require-dev": { "phpunit/phpunit": "^4.6", @@ -2051,7 +2152,7 @@ "check", "validate" ], - "time": "2018-01-29T19:49:41+00:00" + "time": "2018-12-25T11:19:39+00:00" }, { "name": "yiisoft/yii2", @@ -2392,16 +2493,16 @@ "packages-dev": [ { "name": "behat/gherkin", - "version": "v4.4.5", + "version": "v4.6.0", "source": { "type": "git", "url": "https://github.com/Behat/Gherkin.git", - "reference": "5c14cff4f955b17d20d088dec1bde61c0539ec74" + "reference": "ab0a02ea14893860bca00f225f5621d351a3ad07" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Behat/Gherkin/zipball/5c14cff4f955b17d20d088dec1bde61c0539ec74", - "reference": "5c14cff4f955b17d20d088dec1bde61c0539ec74", + "url": "https://api.github.com/repos/Behat/Gherkin/zipball/ab0a02ea14893860bca00f225f5621d351a3ad07", + "reference": "ab0a02ea14893860bca00f225f5621d351a3ad07", "shasum": "" }, "require": { @@ -2409,8 +2510,8 @@ }, "require-dev": { "phpunit/phpunit": "~4.5|~5", - "symfony/phpunit-bridge": "~2.7|~3", - "symfony/yaml": "~2.3|~3" + "symfony/phpunit-bridge": "~2.7|~3|~4", + "symfony/yaml": "~2.3|~3|~4" }, "suggest": { "symfony/yaml": "If you want to parse features, represented in YAML files" @@ -2447,7 +2548,7 @@ "gherkin", "parser" ], - "time": "2016-10-30T11:50:56+00:00" + "time": "2019-01-16T14:22:17+00:00" }, { "name": "bower-asset/bootstrap", @@ -2473,31 +2574,29 @@ }, { "name": "codeception/codeception", - "version": "2.3.8", + "version": "2.5.3", "source": { "type": "git", "url": "https://github.com/Codeception/Codeception.git", - "reference": "43eade17a8cd68e9cde401e8585b09d11d41b12d" + "reference": "19f0fe845c0af5af2a6c094dc0df3a178a3fd5b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeception/Codeception/zipball/43eade17a8cd68e9cde401e8585b09d11d41b12d", - "reference": "43eade17a8cd68e9cde401e8585b09d11d41b12d", + "url": "https://api.github.com/repos/Codeception/Codeception/zipball/19f0fe845c0af5af2a6c094dc0df3a178a3fd5b0", + "reference": "19f0fe845c0af5af2a6c094dc0df3a178a3fd5b0", "shasum": "" }, "require": { - "behat/gherkin": "~4.4.0", - "codeception/stub": "^1.0", + "behat/gherkin": "^4.4.0", + "codeception/phpunit-wrapper": "^6.0.9|^7.0.6", + "codeception/stub": "^2.0", + "ext-curl": "*", "ext-json": "*", "ext-mbstring": "*", "facebook/webdriver": ">=1.1.3 <2.0", "guzzlehttp/guzzle": ">=4.1.4 <7.0", "guzzlehttp/psr7": "~1.0", - "php": ">=5.4.0 <8.0", - "phpunit/php-code-coverage": ">=2.2.4 <6.0", - "phpunit/phpunit": ">=4.8.28 <5.0.0 || >=5.6.3 <7.0", - "sebastian/comparator": ">1.1 <3.0", - "sebastian/diff": ">=1.4 <3.0", + "php": ">=5.6.0 <8.0", "symfony/browser-kit": ">=2.7 <5.0", "symfony/console": ">=2.7 <5.0", "symfony/css-selector": ">=2.7 <5.0", @@ -2516,7 +2615,7 @@ "predis/predis": "^1.0", "squizlabs/php_codesniffer": "~2.0", "symfony/process": ">=2.7 <5.0", - "vlucas/phpdotenv": "^2.4.0" + "vlucas/phpdotenv": "^3.0" }, "suggest": { "aws/aws-sdk-php": "For using AWS Auth in REST module and Queue module", @@ -2539,7 +2638,7 @@ }, "autoload": { "psr-4": { - "Codeception\\": "src\\Codeception", + "Codeception\\": "src/Codeception", "Codeception\\Extension\\": "ext" } }, @@ -2563,7 +2662,53 @@ "functional testing", "unit testing" ], - "time": "2018-01-27T22:47:33+00:00" + "time": "2019-02-02T15:39:58+00:00" + }, + { + "name": "codeception/phpunit-wrapper", + "version": "6.5.1", + "source": { + "type": "git", + "url": "https://github.com/Codeception/phpunit-wrapper.git", + "reference": "d78f9eb9c4300a5924cc27dee03e8c1a96fcf5f3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Codeception/phpunit-wrapper/zipball/d78f9eb9c4300a5924cc27dee03e8c1a96fcf5f3", + "reference": "d78f9eb9c4300a5924cc27dee03e8c1a96fcf5f3", + "shasum": "" + }, + "require": { + "phpunit/php-code-coverage": ">=4.0.4 <6.0", + "phpunit/phpunit": ">=6.5.13 <7.0", + "sebastian/comparator": ">=1.2.4 <3.0", + "sebastian/diff": ">=1.4 <4.0" + }, + "replace": { + "codeception/phpunit-wrapper": "*" + }, + "require-dev": { + "codeception/specify": "*", + "vlucas/phpdotenv": "^2.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Codeception\\PHPUnit\\": "src\\" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Davert", + "email": "davert.php@resend.cc" + } + ], + "description": "PHPUnit classes used by Codeception", + "time": "2019-01-13T10:34:55+00:00" }, { "name": "codeception/specify", @@ -2605,22 +2750,19 @@ }, { "name": "codeception/stub", - "version": "1.0.2", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/Codeception/Stub.git", - "reference": "95fb7a36b81890dd2e5163e7ab31310df6f1bb99" + "reference": "f50bc271f392a2836ff80690ce0c058efe1ae03e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeception/Stub/zipball/95fb7a36b81890dd2e5163e7ab31310df6f1bb99", - "reference": "95fb7a36b81890dd2e5163e7ab31310df6f1bb99", + "url": "https://api.github.com/repos/Codeception/Stub/zipball/f50bc271f392a2836ff80690ce0c058efe1ae03e", + "reference": "f50bc271f392a2836ff80690ce0c058efe1ae03e", "shasum": "" }, "require": { - "phpunit/phpunit-mock-objects": ">2.3 <7.0" - }, - "require-dev": { "phpunit/phpunit": ">=4.8 <8.0" }, "type": "library", @@ -2634,7 +2776,7 @@ "MIT" ], "description": "Flexible Stub wrapper for PHPUnit's Mock Builder", - "time": "2018-02-18T13:56:56+00:00" + "time": "2018-07-26T11:55:37+00:00" }, { "name": "codeception/verify", @@ -2887,34 +3029,39 @@ }, { "name": "facebook/webdriver", - "version": "1.5.0", + "version": "1.6.0", "source": { "type": "git", "url": "https://github.com/facebook/php-webdriver.git", - "reference": "86b5ca2f67173c9d34340845dd690149c886a605" + "reference": "bd8c740097eb9f2fc3735250fc1912bc811a954e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/facebook/php-webdriver/zipball/86b5ca2f67173c9d34340845dd690149c886a605", - "reference": "86b5ca2f67173c9d34340845dd690149c886a605", + "url": "https://api.github.com/repos/facebook/php-webdriver/zipball/bd8c740097eb9f2fc3735250fc1912bc811a954e", + "reference": "bd8c740097eb9f2fc3735250fc1912bc811a954e", "shasum": "" }, "require": { "ext-curl": "*", + "ext-json": "*", + "ext-mbstring": "*", "ext-zip": "*", "php": "^5.6 || ~7.0", "symfony/process": "^2.8 || ^3.1 || ^4.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^2.0", - "guzzle/guzzle": "^3.4.1", - "php-coveralls/php-coveralls": "^1.0.2", + "jakub-onderka/php-parallel-lint": "^0.9.2", + "php-coveralls/php-coveralls": "^2.0", "php-mock/php-mock-phpunit": "^1.1", "phpunit/phpunit": "^5.7", "sebastian/environment": "^1.3.4 || ^2.0 || ^3.0", "squizlabs/php_codesniffer": "^2.6", "symfony/var-dumper": "^3.3 || ^4.0" }, + "suggest": { + "ext-SimpleXML": "For Firefox profile creation" + }, "type": "library", "extra": { "branch-alias": { @@ -2938,7 +3085,7 @@ "selenium", "webdriver" ], - "time": "2017-11-15T11:08:09+00:00" + "time": "2018-05-16T17:37:13+00:00" }, { "name": "flow/jsonpath", @@ -3237,25 +3384,28 @@ }, { "name": "myclabs/deep-copy", - "version": "1.7.0", + "version": "1.8.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e" + "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", - "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", + "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0" + "php": "^7.1" + }, + "replace": { + "myclabs/deep-copy": "self.version" }, "require-dev": { "doctrine/collections": "^1.0", "doctrine/common": "^2.6", - "phpunit/phpunit": "^4.1" + "phpunit/phpunit": "^7.1" }, "type": "library", "autoload": { @@ -3278,7 +3428,7 @@ "object", "object graph" ], - "time": "2017-10-19T19:58:43+00:00" + "time": "2018-06-11T23:09:50+00:00" }, { "name": "phar-io/manifest", @@ -3756,33 +3906,33 @@ }, { "name": "phpspec/prophecy", - "version": "1.7.5", + "version": "1.8.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401" + "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/dfd6be44111a7c41c2e884a336cc4f461b3b2401", - "reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4ba436b55987b4bf311cb7c6ba82aa528aac0a06", + "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", - "sebastian/comparator": "^1.1|^2.0", + "sebastian/comparator": "^1.1|^2.0|^3.0", "sebastian/recursion-context": "^1.0|^2.0|^3.0" }, "require-dev": { "phpspec/phpspec": "^2.5|^3.2", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5" + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.7.x-dev" + "dev-master": "1.8.x-dev" } }, "autoload": { @@ -3815,20 +3965,20 @@ "spy", "stub" ], - "time": "2018-02-19T10:16:54+00:00" + "time": "2018-08-05T17:53:17+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "5.3.0", + "version": "5.3.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "661f34d0bd3f1a7225ef491a70a020ad23a057a1" + "reference": "c89677919c5dd6d3b3852f230a663118762218ac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/661f34d0bd3f1a7225ef491a70a020ad23a057a1", - "reference": "661f34d0bd3f1a7225ef491a70a020ad23a057a1", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/c89677919c5dd6d3b3852f230a663118762218ac", + "reference": "c89677919c5dd6d3b3852f230a663118762218ac", "shasum": "" }, "require": { @@ -3878,7 +4028,7 @@ "testing", "xunit" ], - "time": "2017-12-06T09:29:45+00:00" + "time": "2018-04-06T15:36:58+00:00" }, { "name": "phpunit/php-file-iterator", @@ -4068,16 +4218,16 @@ }, { "name": "phpunit/phpunit", - "version": "6.5.6", + "version": "6.5.14", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "3330ef26ade05359d006041316ed0fa9e8e3cefe" + "reference": "bac23fe7ff13dbdb461481f706f0e9fe746334b7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3330ef26ade05359d006041316ed0fa9e8e3cefe", - "reference": "3330ef26ade05359d006041316ed0fa9e8e3cefe", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/bac23fe7ff13dbdb461481f706f0e9fe746334b7", + "reference": "bac23fe7ff13dbdb461481f706f0e9fe746334b7", "shasum": "" }, "require": { @@ -4095,7 +4245,7 @@ "phpunit/php-file-iterator": "^1.4.3", "phpunit/php-text-template": "^1.2.1", "phpunit/php-timer": "^1.0.9", - "phpunit/phpunit-mock-objects": "^5.0.5", + "phpunit/phpunit-mock-objects": "^5.0.9", "sebastian/comparator": "^2.1", "sebastian/diff": "^2.0", "sebastian/environment": "^3.1", @@ -4148,20 +4298,20 @@ "testing", "xunit" ], - "time": "2018-02-01T05:57:37+00:00" + "time": "2019-02-01T05:22:47+00:00" }, { "name": "phpunit/phpunit-mock-objects", - "version": "5.0.6", + "version": "5.0.10", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "33fd41a76e746b8fa96d00b49a23dadfa8334cdf" + "reference": "cd1cf05c553ecfec36b170070573e540b67d3f1f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/33fd41a76e746b8fa96d00b49a23dadfa8334cdf", - "reference": "33fd41a76e746b8fa96d00b49a23dadfa8334cdf", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/cd1cf05c553ecfec36b170070573e540b67d3f1f", + "reference": "cd1cf05c553ecfec36b170070573e540b67d3f1f", "shasum": "" }, "require": { @@ -4174,7 +4324,7 @@ "phpunit/phpunit": "<6.0" }, "require-dev": { - "phpunit/phpunit": "^6.5" + "phpunit/phpunit": "^6.5.11" }, "suggest": { "ext-soap": "*" @@ -4207,7 +4357,7 @@ "mock", "xunit" ], - "time": "2018-01-06T05:45:45+00:00" + "time": "2018-08-09T05:50:03+00:00" }, { "name": "predis/predis", @@ -5034,16 +5184,16 @@ }, { "name": "symfony/browser-kit", - "version": "v4.0.4", + "version": "v4.2.3", "source": { "type": "git", "url": "https://github.com/symfony/browser-kit.git", - "reference": "fee0fcd501304b1c3190f6293f650cceb738a353" + "reference": "ee4462581eb54bf34b746e4a5d522a4f21620160" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/browser-kit/zipball/fee0fcd501304b1c3190f6293f650cceb738a353", - "reference": "fee0fcd501304b1c3190f6293f650cceb738a353", + "url": "https://api.github.com/repos/symfony/browser-kit/zipball/ee4462581eb54bf34b746e4a5d522a4f21620160", + "reference": "ee4462581eb54bf34b746e4a5d522a4f21620160", "shasum": "" }, "require": { @@ -5060,7 +5210,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-master": "4.2-dev" } }, "autoload": { @@ -5087,30 +5237,34 @@ ], "description": "Symfony BrowserKit Component", "homepage": "https://symfony.com", - "time": "2018-01-03T07:38:00+00:00" + "time": "2019-01-16T21:31:25+00:00" }, { "name": "symfony/console", - "version": "v4.0.4", + "version": "v4.2.3", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "36d5b41e7d4e1ccf0370f6babe966c08ef0a1488" + "reference": "1f0ad51dfde4da8a6070f06adc58b4e37cbb37a4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/36d5b41e7d4e1ccf0370f6babe966c08ef0a1488", - "reference": "36d5b41e7d4e1ccf0370f6babe966c08ef0a1488", + "url": "https://api.github.com/repos/symfony/console/zipball/1f0ad51dfde4da8a6070f06adc58b4e37cbb37a4", + "reference": "1f0ad51dfde4da8a6070f06adc58b4e37cbb37a4", "shasum": "" }, "require": { "php": "^7.1.3", + "symfony/contracts": "^1.0", "symfony/polyfill-mbstring": "~1.0" }, "conflict": { "symfony/dependency-injection": "<3.4", "symfony/process": "<3.3" }, + "provide": { + "psr/log-implementation": "1.0" + }, "require-dev": { "psr/log": "~1.0", "symfony/config": "~3.4|~4.0", @@ -5128,7 +5282,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-master": "4.2-dev" } }, "autoload": { @@ -5155,20 +5309,88 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2018-01-29T09:06:29+00:00" + "time": "2019-01-25T14:35:16+00:00" }, { - "name": "symfony/css-selector", - "version": "v4.0.4", + "name": "symfony/contracts", + "version": "v1.0.2", "source": { "type": "git", - "url": "https://github.com/symfony/css-selector.git", - "reference": "f97600434e3141ef3cbb9ea42cf500fba88022b7" + "url": "https://github.com/symfony/contracts.git", + "reference": "1aa7ab2429c3d594dd70689604b5cf7421254cdf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/f97600434e3141ef3cbb9ea42cf500fba88022b7", - "reference": "f97600434e3141ef3cbb9ea42cf500fba88022b7", + "url": "https://api.github.com/repos/symfony/contracts/zipball/1aa7ab2429c3d594dd70689604b5cf7421254cdf", + "reference": "1aa7ab2429c3d594dd70689604b5cf7421254cdf", + "shasum": "" + }, + "require": { + "php": "^7.1.3" + }, + "require-dev": { + "psr/cache": "^1.0", + "psr/container": "^1.0" + }, + "suggest": { + "psr/cache": "When using the Cache contracts", + "psr/container": "When using the Service contracts", + "symfony/cache-contracts-implementation": "", + "symfony/service-contracts-implementation": "", + "symfony/translation-contracts-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\": "" + }, + "exclude-from-classmap": [ + "**/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A set of abstractions extracted out of the Symfony components", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "time": "2018-12-05T08:06:11+00:00" + }, + { + "name": "symfony/css-selector", + "version": "v4.2.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/css-selector.git", + "reference": "48eddf66950fa57996e1be4a55916d65c10c604a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/48eddf66950fa57996e1be4a55916d65c10c604a", + "reference": "48eddf66950fa57996e1be4a55916d65c10c604a", "shasum": "" }, "require": { @@ -5177,7 +5399,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-master": "4.2-dev" } }, "autoload": { @@ -5208,24 +5430,25 @@ ], "description": "Symfony CssSelector Component", "homepage": "https://symfony.com", - "time": "2018-01-03T07:38:00+00:00" + "time": "2019-01-16T20:31:39+00:00" }, { "name": "symfony/dom-crawler", - "version": "v4.0.4", + "version": "v4.2.3", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", - "reference": "39b785e1cf28e9f21bb601a5d62c4992a8e8a290" + "reference": "d8476760b04cdf7b499c8718aa437c20a9155103" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/39b785e1cf28e9f21bb601a5d62c4992a8e8a290", - "reference": "39b785e1cf28e9f21bb601a5d62c4992a8e8a290", + "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/d8476760b04cdf7b499c8718aa437c20a9155103", + "reference": "d8476760b04cdf7b499c8718aa437c20a9155103", "shasum": "" }, "require": { "php": "^7.1.3", + "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-mbstring": "~1.0" }, "require-dev": { @@ -5237,7 +5460,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-master": "4.2-dev" } }, "autoload": { @@ -5264,24 +5487,25 @@ ], "description": "Symfony DomCrawler Component", "homepage": "https://symfony.com", - "time": "2018-01-03T07:38:00+00:00" + "time": "2019-01-16T20:35:37+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v4.0.4", + "version": "v4.2.3", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "74d33aac36208c4d6757807d9f598f0133a3a4eb" + "reference": "bd09ad265cd50b2b9d09d65ce6aba2d29bc81fe1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/74d33aac36208c4d6757807d9f598f0133a3a4eb", - "reference": "74d33aac36208c4d6757807d9f598f0133a3a4eb", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/bd09ad265cd50b2b9d09d65ce6aba2d29bc81fe1", + "reference": "bd09ad265cd50b2b9d09d65ce6aba2d29bc81fe1", "shasum": "" }, "require": { - "php": "^7.1.3" + "php": "^7.1.3", + "symfony/contracts": "^1.0" }, "conflict": { "symfony/dependency-injection": "<3.4" @@ -5300,7 +5524,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-master": "4.2-dev" } }, "autoload": { @@ -5327,7 +5551,7 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2018-01-03T07:38:00+00:00" + "time": "2019-01-16T20:35:37+00:00" }, { "name": "symfony/filesystem", @@ -5380,16 +5604,16 @@ }, { "name": "symfony/finder", - "version": "v4.0.4", + "version": "v4.2.3", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "8b08180f2b7ccb41062366b9ad91fbc4f1af8601" + "reference": "ef71816cbb264988bb57fe6a73f610888b9aa70c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/8b08180f2b7ccb41062366b9ad91fbc4f1af8601", - "reference": "8b08180f2b7ccb41062366b9ad91fbc4f1af8601", + "url": "https://api.github.com/repos/symfony/finder/zipball/ef71816cbb264988bb57fe6a73f610888b9aa70c", + "reference": "ef71816cbb264988bb57fe6a73f610888b9aa70c", "shasum": "" }, "require": { @@ -5398,7 +5622,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-master": "4.2-dev" } }, "autoload": { @@ -5425,7 +5649,7 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2018-01-03T07:38:00+00:00" + "time": "2019-01-16T20:35:37+00:00" }, { "name": "symfony/options-resolver", @@ -5587,20 +5811,21 @@ }, { "name": "symfony/yaml", - "version": "v4.0.4", + "version": "v4.2.3", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "ffc60bda1d4a00ec0b32eeabf39dc017bf480028" + "reference": "d461670ee145092b7e2a56c1da7118f19cadadb0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/ffc60bda1d4a00ec0b32eeabf39dc017bf480028", - "reference": "ffc60bda1d4a00ec0b32eeabf39dc017bf480028", + "url": "https://api.github.com/repos/symfony/yaml/zipball/d461670ee145092b7e2a56c1da7118f19cadadb0", + "reference": "d461670ee145092b7e2a56c1da7118f19cadadb0", "shasum": "" }, "require": { - "php": "^7.1.3" + "php": "^7.1.3", + "symfony/polyfill-ctype": "~1.8" }, "conflict": { "symfony/console": "<3.4" @@ -5614,7 +5839,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-master": "4.2-dev" } }, "autoload": { @@ -5641,7 +5866,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2018-01-21T19:06:11+00:00" + "time": "2019-01-16T20:35:37+00:00" }, { "name": "theseer/tokenizer", @@ -5847,7 +6072,8 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "^7.1" + "php": "^7.2", + "ext-json": "*" }, "platform-dev": [] } diff --git a/console/codeception.dist.yml b/console/codeception.dist.yml new file mode 100644 index 0000000..673cb42 --- /dev/null +++ b/console/codeception.dist.yml @@ -0,0 +1,23 @@ +namespace: console\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 + whitelist: + include: + - ./* + exclude: + - config/* + - runtime/* + - migrations/* + - views/* + - codeception.dist.yml + - codeception.yml diff --git a/console/config/config.php b/console/config/config.php index be4d94e..06eba95 100644 --- a/console/config/config.php +++ b/console/config/config.php @@ -1,15 +1,9 @@ 'accounts-console', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log', 'queue'], 'controllerNamespace' => 'console\controllers', - 'params' => $params, 'components' => [ 'log' => [ 'targets' => [ diff --git a/console/config/params.php b/console/config/params.php deleted file mode 100644 index d0b9c34..0000000 --- a/console/config/params.php +++ /dev/null @@ -1,3 +0,0 @@ - fixtures\EmailActivationFixture::class, 'minecraftSessions' => fixtures\MinecraftAccessKeyFixture::class, diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 7854586..b58867a 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -1,82 +1,136 @@ version: '2' services: - app: - image: registry.ely.by/elyby/accounts:dev - build: - context: . - args: - build_env: dev - depends_on: - - db - - redis - volumes: - - ./:/var/www/html/ - env_file: .env + app: + image: registry.ely.by/elyby/accounts:dev + build: + context: . + args: + build_env: dev + depends_on: + - db + - redis + volumes: + - ./:/var/www/html/ + env_file: .env - worker: - image: registry.ely.by/elyby/accounts:dev - build: - context: . - args: - build_env: dev - command: ['php', 'yii', 'queue/listen', '-v'] - depends_on: - - db - - redis - volumes: - - ./:/var/www/html/ - env_file: .env + worker: + image: registry.ely.by/elyby/accounts:dev + build: + context: . + args: + build_env: dev + command: ['php', 'yii', 'queue/listen', '-v'] + depends_on: + - db + - redis + volumes: + - ./:/var/www/html/ + env_file: .env - cron: - image: registry.ely.by/elyby/accounts:dev - build: - context: . - args: - build_env: dev - command: ['crond', '-s', '/etc/cron.d', '-f', '-L', '/var/log/cron.log'] - depends_on: - - db - - redis - volumes: - - ./:/var/www/html/ - env_file: .env + cron: + image: registry.ely.by/elyby/accounts:dev + build: + context: . + args: + build_env: dev + command: ['crond', '-s', '/etc/cron.d', '-f', '-L', '/var/log/cron.log'] + stop_signal: SIGKILL + depends_on: + - db + - redis + volumes: + - ./:/var/www/html/ + env_file: .env - web: - image: registry.ely.by/elyby/accounts-nginx:latest - volumes_from: - - app - links: - - app:php - env_file: .env - networks: - - default - - nginx-proxy + web: + image: registry.ely.by/elyby/accounts-nginx:latest + volumes_from: + - app + links: + - app:php + env_file: .env + networks: + - default + - nginx-proxy - db: - build: ./docker/mariadb - env_file: .env - volumes: - - ./data/mysql:/var/lib/mysql + db: + build: ./docker/mariadb + env_file: .env + volumes: + - ./data/mysql:/var/lib/mysql - redis: - image: redis:3.0-alpine - volumes: - - ./data/redis:/data + redis: + image: redis:3.0-alpine + volumes: + - ./data/redis:/data - phpmyadmin: - build: ./docker/phpmyadmin - environment: - - PMA_ARBITRARY=1 - - PMA_USER=root - - PMA_PASSWORD= - - VIRTUAL_HOST=pma.account.ely.by.local - depends_on: - - db - networks: - - default - - nginx-proxy + # If you want to use separate databases for the tests follow the next steps: + # 1) Create a file common/config/config-local.php with the next containment: + # + # [ + # 'db' => [ + # 'dsn' => 'mysql:host=testdb;dbname=test', + # 'username' => 'test', + # 'password' => 'test', + # ], + # 'unbufferedDb' => [ + # 'dsn' => 'mysql:host=testdb;dbname=test', + # 'username' => 'test', + # 'password' => 'test', + # ], + # 'redis' => [ + # 'hostname' => 'testredis', + # 'password' => null, + # 'port' => 6379, + # 'database' => 0, + # ], + # ], + # ]; + # + # 2) Clone api/tests/functional.suite.dist.yml into api/test/functional.suite.yml + # and adjust Redis module host value to the "testredis". + # + # 3) Uncomment the next 2 services (testdb and testredis): + # + # testdb: + # build: ./docker/mariadb + # volumes: + # - ./data/mysql-test:/var/lib/mysql + # environment: + # - MYSQL_ALLOW_EMPTY_PASSWORD=yes + # - MYSQL_ROOT_PASSWORD= + # - MYSQL_DATABASE=test + # - MYSQL_USER=test + # - MYSQL_PASSWORD=test + # + # testredis: + # image: redis:3.0-alpine + # volumes: + # - ./data/redis-test:/data + # + # 4) To run migrations on tests database you must execute slightly adjusted + # migrate command: env YII_ENV=test yii migrate + + phpmyadmin: + build: ./docker/phpmyadmin + environment: + - PMA_ARBITRARY=1 + - PMA_USER=root + - PMA_PASSWORD= + - VIRTUAL_HOST=pma.account.ely.by.local # Feel free to adjust this domain + depends_on: + - db + networks: + - default + - nginx-proxy networks: - nginx-proxy: - external: - name: nginx-proxy + nginx-proxy: + external: + name: nginx-proxy diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 687baab..6b0f928 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -1,57 +1,58 @@ version: '2' services: - app: - image: registry.ely.by/elyby/accounts:latest - restart: always - depends_on: - - db - - redis - env_file: .env + app: + image: registry.ely.by/elyby/accounts:latest + restart: always + depends_on: + - db + - redis + env_file: .env - worker: - image: registry.ely.by/elyby/accounts:latest - restart: always - command: ['php', 'yii', 'queue/listen', '-v'] - depends_on: - - db - - redis - env_file: .env + worker: + image: registry.ely.by/elyby/accounts:latest + restart: always + command: ['php', 'yii', 'queue/listen', '-v'] + depends_on: + - db + - redis + env_file: .env - worker: - image: registry.ely.by/elyby/accounts:latest - restart: always - command: ['crond', '-s', '/etc/cron.d', '-f', '-L', '/var/log/cron.log'] - depends_on: - - db - - redis - env_file: .env + cron: + image: registry.ely.by/elyby/accounts:latest + restart: always + command: ['crond', '-s', '/etc/cron.d', '-f', '-L', '/var/log/cron.log'] + stop_signal: SIGKILL + depends_on: + - db + - redis + env_file: .env - web: - image: registry.ely.by/elyby/accounts-nginx:1.0.3 - restart: always - volumes_from: - - app - links: - - app:php - env_file: .env - networks: - - default - - nginx-proxy + web: + image: registry.ely.by/elyby/accounts-nginx:1.0.3 + restart: always + volumes_from: + - app + links: + - app:php + env_file: .env + networks: + - default + - nginx-proxy - db: - build: ./docker/mariadb - restart: always - env_file: .env - volumes: - - ./data/mysql:/var/lib/mysql + db: + build: ./docker/mariadb + restart: always + env_file: .env + volumes: + - ./data/mysql:/var/lib/mysql - redis: - image: redis:3.0-alpine - restart: always - volumes: - - ./data/redis:/data + redis: + image: redis:3.0-alpine + restart: always + volumes: + - ./data/redis:/data networks: - nginx-proxy: - external: - name: nginx-proxy + nginx-proxy: + external: + name: nginx-proxy diff --git a/tests/.gitignore b/tests/.gitignore deleted file mode 100644 index c40b483..0000000 --- a/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.bash_history diff --git a/tests/codeception.yml b/tests/codeception.yml deleted file mode 100644 index d6db419..0000000 --- a/tests/codeception.yml +++ /dev/null @@ -1,10 +0,0 @@ -include: - - codeception/common - - codeception/console - - codeception/api - -paths: - log: codeception/_output - -settings: - colors: true diff --git a/tests/codeception/api/.gitignore b/tests/codeception/api/.gitignore deleted file mode 100644 index 3217386..0000000 --- a/tests/codeception/api/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# these files are auto generated by codeception build -_support/_generated diff --git a/tests/codeception/api/_bootstrap.php b/tests/codeception/api/_bootstrap.php deleted file mode 100644 index 3bd1f3c..0000000 --- a/tests/codeception/api/_bootstrap.php +++ /dev/null @@ -1,23 +0,0 @@ -getActor()->sendPOST('/authserver/authentication/authenticate', $params); - } - - public function refresh($params) { - $this->getActor()->sendPOST('/authserver/authentication/refresh', $params); - } - - public function validate($params) { - $this->getActor()->sendPOST('/authserver/authentication/validate', $params); - } - - public function invalidate($params) { - $this->getActor()->sendPOST('/authserver/authentication/invalidate', $params); - } - - public function signout($params) { - $this->getActor()->sendPOST('/authserver/authentication/signout', $params); - } - -} diff --git a/tests/codeception/api/_pages/IdentityInfoRoute.php b/tests/codeception/api/_pages/IdentityInfoRoute.php deleted file mode 100644 index c3a8ed4..0000000 --- a/tests/codeception/api/_pages/IdentityInfoRoute.php +++ /dev/null @@ -1,10 +0,0 @@ -getActor()->sendGET('/account/v1/info'); - } - -} diff --git a/tests/codeception/api/_pages/InternalRoute.php b/tests/codeception/api/_pages/InternalRoute.php deleted file mode 100644 index ceacfb8..0000000 --- a/tests/codeception/api/_pages/InternalRoute.php +++ /dev/null @@ -1,10 +0,0 @@ -getActor()->sendGET('/internal/accounts/info', [$param => $value]); - } - -} diff --git a/tests/codeception/api/_pages/OauthRoute.php b/tests/codeception/api/_pages/OauthRoute.php deleted file mode 100644 index 11b5e18..0000000 --- a/tests/codeception/api/_pages/OauthRoute.php +++ /dev/null @@ -1,42 +0,0 @@ -getActor()->sendGET('/oauth2/v1/validate', $queryParams); - } - - public function complete(array $queryParams = [], array $postParams = []): void { - $this->getActor()->sendPOST('/oauth2/v1/complete?' . http_build_query($queryParams), $postParams); - } - - public function issueToken(array $postParams = []): void { - $this->getActor()->sendPOST('/oauth2/v1/token', $postParams); - } - - public function createClient(string $type, array $postParams): void { - $this->getActor()->sendPOST('/v1/oauth2/' . $type, $postParams); - } - - public function updateClient(string $clientId, array $params): void { - $this->getActor()->sendPUT('/v1/oauth2/' . $clientId, $params); - } - - public function deleteClient(string $clientId): void { - $this->getActor()->sendDELETE('/v1/oauth2/' . $clientId); - } - - public function resetClient(string $clientId, bool $regenerateSecret = false): void { - $this->getActor()->sendPOST("/v1/oauth2/$clientId/reset" . ($regenerateSecret ? '?regenerateSecret' : '')); - } - - public function getClient(string $clientId): void { - $this->getActor()->sendGET("/v1/oauth2/$clientId"); - } - - public function getPerAccount(int $accountId): void { - $this->getActor()->sendGET("/v1/accounts/$accountId/oauth2/clients"); - } - -} diff --git a/tests/codeception/api/_pages/OptionsRoute.php b/tests/codeception/api/_pages/OptionsRoute.php deleted file mode 100644 index 9413aeb..0000000 --- a/tests/codeception/api/_pages/OptionsRoute.php +++ /dev/null @@ -1,10 +0,0 @@ -getActor()->sendGET('/options'); - } - -} diff --git a/tests/codeception/api/_pages/SessionServerRoute.php b/tests/codeception/api/_pages/SessionServerRoute.php deleted file mode 100644 index 5d34346..0000000 --- a/tests/codeception/api/_pages/SessionServerRoute.php +++ /dev/null @@ -1,26 +0,0 @@ -getActor()->sendPOST('/minecraft/session/join', $params); - } - - public function joinLegacy(array $params) { - $this->getActor()->sendGET('/minecraft/session/legacy/join', $params); - } - - public function hasJoined(array $params) { - $this->getActor()->sendGET('/minecraft/session/hasJoined', $params); - } - - public function hasJoinedLegacy(array $params) { - $this->getActor()->sendGET('/minecraft/session/legacy/hasJoined', $params); - } - - public function profile($profileUuid) { - $this->getActor()->sendGET("/minecraft/session/profile/{$profileUuid}"); - } - -} diff --git a/tests/codeception/api/codeception.yml b/tests/codeception/api/codeception.yml deleted file mode 100644 index 406850d..0000000 --- a/tests/codeception/api/codeception.yml +++ /dev/null @@ -1,27 +0,0 @@ -namespace: tests\codeception\api -actor: Tester -params: [env] -paths: - tests: . - log: _output - data: _data - helpers: _support -settings: - bootstrap: _bootstrap.php - suite_class: \PHPUnit_Framework_TestSuite - colors: true - memory_limit: 1024M - log: true -config: - test_entry_url: http://localhost/api/web/index.php -coverage: - enabled: true - remote: true - whitelist: - include: - - ../../../api/* - exclude: - - ../../../api/config/* - - ../../../api/web/* - - ../../../api/runtime/* - c3url: 'http://localhost/api/web/index.php' diff --git a/tests/codeception/api/functional.suite.yml b/tests/codeception/api/functional.suite.yml deleted file mode 100644 index 570a025..0000000 --- a/tests/codeception/api/functional.suite.yml +++ /dev/null @@ -1,22 +0,0 @@ -class_name: FunctionalTester -modules: - enabled: - - Filesystem - - Yii2 - - tests\codeception\common\_support\FixtureHelper - - tests\codeception\common\_support\Mockery - - Redis - - Asserts - - REST: - depends: Yii2 - url: /api - config: - Yii2: - configFile: '../config/api/functional.php' - cleanup: true - transaction: false - Redis: - host: "%REDIS_HOST%" - port: 6379 - database: 0 - cleanupBefore: 'test' diff --git a/tests/codeception/api/unit.suite.yml b/tests/codeception/api/unit.suite.yml deleted file mode 100644 index beea248..0000000 --- a/tests/codeception/api/unit.suite.yml +++ /dev/null @@ -1,12 +0,0 @@ -class_name: UnitTester -modules: - enabled: - - Yii2: - part: [orm, email, fixtures] - - tests\codeception\common\_support\queue\CodeceptionQueueHelper - - tests\codeception\common\_support\Mockery - config: - Yii2: - configFile: '../config/api/unit.php' - cleanup: true - transaction: false diff --git a/tests/codeception/bin/_bootstrap.php b/tests/codeception/bin/_bootstrap.php deleted file mode 100644 index abbeded..0000000 --- a/tests/codeception/bin/_bootstrap.php +++ /dev/null @@ -1,9 +0,0 @@ -run(); -exit($exitCode); diff --git a/tests/codeception/common/.gitignore b/tests/codeception/common/.gitignore deleted file mode 100644 index 3217386..0000000 --- a/tests/codeception/common/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# these files are auto generated by codeception build -_support/_generated diff --git a/tests/codeception/common/_bootstrap.php b/tests/codeception/common/_bootstrap.php deleted file mode 100644 index a75fbc6..0000000 --- a/tests/codeception/common/_bootstrap.php +++ /dev/null @@ -1,13 +0,0 @@ - 'app-common', - 'basePath' => dirname(__DIR__), - ] -); diff --git a/tests/codeception/config/config.php b/tests/codeception/config/config.php deleted file mode 100644 index 72c5fa3..0000000 --- a/tests/codeception/config/config.php +++ /dev/null @@ -1,30 +0,0 @@ - 'en-US', - 'controllerMap' => [ - 'fixture' => [ - 'class' => yii\faker\FixtureController::class, - 'fixtureDataPath' => '@tests/codeception/common/fixtures/data', - 'templatePath' => '@tests/codeception/common/templates/fixtures', - 'namespace' => 'tests\codeception\common\fixtures', - ], - ], - 'params' => [ - 'fromEmail' => 'ely@ely.by', - ], - 'components' => [ - 'urlManager' => [ - 'showScriptName' => true, - ], - 'security' => [ - // Для тестов нам не сильно важна безопасность, а вот время прохождения тестов значительно сокращается - 'passwordHashCost' => 4, - ], - 'queue' => [ - 'class' => tests\codeception\common\_support\queue\Queue::class, - ], - 'sentry' => [ - 'enabled' => false, - ], - ], -]; diff --git a/tests/codeception/config/console/unit.php b/tests/codeception/config/console/unit.php deleted file mode 100644 index b0ad993..0000000 --- a/tests/codeception/config/console/unit.php +++ /dev/null @@ -1,6 +0,0 @@ - [ - 'request' => [ - // it's not recommended to run functional tests with CSRF validation enabled - 'enableCsrfValidation' => false, - 'enableCookieValidation' => false, - // but if you absolutely need it set cookie domain to localhost - ], - ], -]; diff --git a/tests/codeception/config/unit.php b/tests/codeception/config/unit.php deleted file mode 100644 index bee73cf..0000000 --- a/tests/codeception/config/unit.php +++ /dev/null @@ -1,4 +0,0 @@ -