mirror of
https://github.com/elyby/accounts.git
synced 2024-12-25 14:49:46 +05:30
57d492da8a
* start updating to PHP 8.3
* taking off!
Co-authored-by: ErickSkrauch <erickskrauch@yandex.ru>
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
* dropped this
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
* migrate to symfonymailer
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
* this is so stupid 😭
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
* ah, free, at last.
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
* oh, Gabriel.
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
* now dawns thy reckoning.
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
* and thy gore shall GLISTEN before the temples of man.
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
* creature of steel.
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
* my gratitude upon thee for my freedom.
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
* but the crimes thy kind has committed against humanity
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
* Upgrade PHP-CS-Fixer and do fix the codebase
* First review round (maybe I have broken something)
* are NOT forgotten.
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
* Enable parallel PHP-CS-Fixer runner
* PHPStan level 1
* PHPStan level 2
* PHPStan level 3
* PHPStan level 4
* PHPStan level 5
* Levels 6 and 7 takes too much effort. Generate a baseline and fix them eventually
* Resolve TODO's related to the php-mock
* Drastically reduce baseline size with the Rector
* More code modernization with help of the Rector
* Update GitLab CI
---------
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
Co-authored-by: ErickSkrauch <erickskrauch@yandex.ru>
123 lines
4.7 KiB
PHP
123 lines
4.7 KiB
PHP
<?php
|
|
namespace api\tests\functional\sessionserver;
|
|
|
|
use api\rbac\Permissions as P;
|
|
use api\tests\_pages\SessionServerRoute;
|
|
use api\tests\functional\_steps\AuthserverSteps;
|
|
use api\tests\functional\_steps\OauthSteps;
|
|
use api\tests\FunctionalTester;
|
|
use function Ramsey\Uuid\v4 as uuid;
|
|
|
|
class JoinLegacyCest {
|
|
|
|
private SessionServerRoute $route;
|
|
|
|
public function _before(AuthserverSteps $I): void {
|
|
$this->route = new SessionServerRoute($I);
|
|
}
|
|
|
|
public function joinByLegacyAuthserver(AuthserverSteps $I): void {
|
|
$I->wantTo('join to server by legacy protocol, using legacy authserver access token');
|
|
[$accessToken] = $I->amAuthenticated();
|
|
$this->route->joinLegacy([
|
|
'sessionId' => $accessToken,
|
|
'user' => 'Admin',
|
|
'serverId' => uuid(),
|
|
]);
|
|
$this->expectSuccessResponse($I);
|
|
}
|
|
|
|
public function joinByOauth2TokenAndDifferentLetterCase(AuthserverSteps $I): void {
|
|
$I->wantTo('join to server by legacy protocol, using legacy authserver access token and different letter case');
|
|
[$accessToken] = $I->amAuthenticated();
|
|
$this->route->joinLegacy([
|
|
'sessionId' => $accessToken,
|
|
'user' => 'admin',
|
|
'serverId' => uuid(),
|
|
]);
|
|
$this->expectSuccessResponse($I);
|
|
}
|
|
|
|
public function joinByNewSessionFormat(AuthserverSteps $I): void {
|
|
$I->wantTo('join to server by legacy protocol with new launcher session format, using legacy authserver');
|
|
[$accessToken] = $I->amAuthenticated();
|
|
$this->route->joinLegacy([
|
|
'sessionId' => 'token:' . $accessToken . ':df936908-b2e1-544d-96f8-2977ec213022',
|
|
'user' => 'Admin',
|
|
'serverId' => uuid(),
|
|
]);
|
|
$this->expectSuccessResponse($I);
|
|
}
|
|
|
|
public function joinByOauth2Token(OauthSteps $I): void {
|
|
$I->wantTo('join to server using modern oAuth2 generated token with new launcher session format');
|
|
$accessToken = $I->getAccessToken([P::MINECRAFT_SERVER_SESSION]);
|
|
$this->route->joinLegacy([
|
|
'sessionId' => 'token:' . $accessToken . ':df936908-b2e1-544d-96f8-2977ec213022',
|
|
'user' => 'Admin',
|
|
'serverId' => uuid(),
|
|
]);
|
|
$this->expectSuccessResponse($I);
|
|
}
|
|
|
|
public function wrongArguments(FunctionalTester $I): void {
|
|
$I->wantTo('get error on wrong amount of arguments');
|
|
$this->route->joinLegacy([
|
|
'wrong' => 'argument',
|
|
]);
|
|
$I->canSeeResponseCodeIs(400);
|
|
$I->canSeeResponseContains('credentials can not be null.');
|
|
}
|
|
|
|
public function joinWithWrongAccessToken(FunctionalTester $I): void {
|
|
$I->wantTo('join to some server with wrong accessToken');
|
|
$this->route->joinLegacy([
|
|
'sessionId' => 'token:' . uuid() . ':' . uuid(),
|
|
'user' => 'random-username',
|
|
'serverId' => uuid(),
|
|
]);
|
|
$I->seeResponseCodeIs(401);
|
|
$I->canSeeResponseContains('Ely.by authorization required');
|
|
}
|
|
|
|
public function joinWithAccessTokenWithoutMinecraftPermission(OauthSteps $I): void {
|
|
$I->wantTo('join to some server with wrong accessToken');
|
|
$accessToken = $I->getAccessToken(['account_info']);
|
|
$this->route->joinLegacy([
|
|
'sessionId' => 'token:' . $accessToken . ':df936908-b2e1-544d-96f8-2977ec213022',
|
|
'user' => 'Admin',
|
|
'serverId' => uuid(),
|
|
]);
|
|
$I->seeResponseCodeIs(401);
|
|
$I->canSeeResponseContains('Ely.by authorization required');
|
|
}
|
|
|
|
public function joinWithNilUuids(FunctionalTester $I): void {
|
|
$I->wantTo('join to some server by legacy protocol with nil accessToken and selectedProfile');
|
|
$this->route->joinLegacy([
|
|
'sessionId' => 'token:00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000',
|
|
'user' => 'SomeUser',
|
|
'serverId' => uuid(),
|
|
]);
|
|
$I->canSeeResponseCodeIs(400);
|
|
$I->canSeeResponseContains('credentials can not be null.');
|
|
}
|
|
|
|
public function joinByAccountMarkedForDeletion(FunctionalTester $I): void {
|
|
$I->wantTo('join to some server by legacy protocol with nil accessToken and selectedProfile');
|
|
$this->route->joinLegacy([
|
|
'sessionId' => 'token:239ba889-7020-4383-8d99-cd8c8aab4a2f:6383de63-8f85-4ed5-92b7-5401a1fa68cd',
|
|
'user' => 'DeletedAccount',
|
|
'serverId' => uuid(),
|
|
]);
|
|
$I->canSeeResponseCodeIs(401);
|
|
$I->canSeeResponseContains('Ely.by authorization required');
|
|
}
|
|
|
|
private function expectSuccessResponse(FunctionalTester $I): void {
|
|
$I->seeResponseCodeIs(200);
|
|
$I->canSeeResponseEquals('OK');
|
|
}
|
|
|
|
}
|