2016-09-05 20:25:38 +05:30
|
|
|
<?php
|
2019-02-21 01:28:52 +05:30
|
|
|
namespace api\tests\functional\sessionserver;
|
2016-09-05 20:25:38 +05:30
|
|
|
|
2019-08-02 05:59:20 +05:30
|
|
|
use api\rbac\Permissions as P;
|
2019-02-21 01:28:52 +05:30
|
|
|
use api\tests\_pages\SessionServerRoute;
|
|
|
|
use api\tests\functional\_steps\AuthserverSteps;
|
|
|
|
use api\tests\functional\_steps\OauthSteps;
|
|
|
|
use api\tests\FunctionalTester;
|
2019-12-21 04:56:06 +05:30
|
|
|
use function Ramsey\Uuid\v4 as uuid;
|
2016-09-05 20:25:38 +05:30
|
|
|
|
|
|
|
class JoinLegacyCest {
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
private SessionServerRoute $route;
|
2016-09-05 20:25:38 +05:30
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function _before(AuthserverSteps $I): void {
|
2016-09-05 20:25:38 +05:30
|
|
|
$this->route = new SessionServerRoute($I);
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function joinByLegacyAuthserver(AuthserverSteps $I): void {
|
2016-09-05 20:25:38 +05:30
|
|
|
$I->wantTo('join to server by legacy protocol, using legacy authserver access token');
|
2017-01-24 04:30:08 +05:30
|
|
|
[$accessToken] = $I->amAuthenticated();
|
2016-09-05 20:25:38 +05:30
|
|
|
$this->route->joinLegacy([
|
|
|
|
'sessionId' => $accessToken,
|
|
|
|
'user' => 'Admin',
|
2019-12-21 04:56:06 +05:30
|
|
|
'serverId' => uuid(),
|
2016-09-05 20:25:38 +05:30
|
|
|
]);
|
|
|
|
$this->expectSuccessResponse($I);
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function joinByOauth2TokenAndDifferentLetterCase(AuthserverSteps $I): void {
|
2017-10-20 17:49:39 +05:30
|
|
|
$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',
|
2019-12-21 04:56:06 +05:30
|
|
|
'serverId' => uuid(),
|
2017-10-20 17:49:39 +05:30
|
|
|
]);
|
|
|
|
$this->expectSuccessResponse($I);
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function joinByNewSessionFormat(AuthserverSteps $I): void {
|
2016-09-05 20:25:38 +05:30
|
|
|
$I->wantTo('join to server by legacy protocol with new launcher session format, using legacy authserver');
|
2017-01-24 04:30:08 +05:30
|
|
|
[$accessToken] = $I->amAuthenticated();
|
2016-09-05 20:25:38 +05:30
|
|
|
$this->route->joinLegacy([
|
2024-12-02 15:40:55 +05:30
|
|
|
'sessionId' => 'token:' . $accessToken . ':df936908-b2e1-544d-96f8-2977ec213022',
|
2016-09-05 20:25:38 +05:30
|
|
|
'user' => 'Admin',
|
2019-12-21 04:56:06 +05:30
|
|
|
'serverId' => uuid(),
|
2016-09-05 20:25:38 +05:30
|
|
|
]);
|
|
|
|
$this->expectSuccessResponse($I);
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function joinByOauth2Token(OauthSteps $I): void {
|
2016-09-05 20:25:38 +05:30
|
|
|
$I->wantTo('join to server using modern oAuth2 generated token with new launcher session format');
|
2017-09-19 22:36:16 +05:30
|
|
|
$accessToken = $I->getAccessToken([P::MINECRAFT_SERVER_SESSION]);
|
2016-09-05 20:25:38 +05:30
|
|
|
$this->route->joinLegacy([
|
2024-12-02 15:40:55 +05:30
|
|
|
'sessionId' => 'token:' . $accessToken . ':df936908-b2e1-544d-96f8-2977ec213022',
|
2016-09-05 20:25:38 +05:30
|
|
|
'user' => 'Admin',
|
2019-12-21 04:56:06 +05:30
|
|
|
'serverId' => uuid(),
|
2016-09-05 20:25:38 +05:30
|
|
|
]);
|
|
|
|
$this->expectSuccessResponse($I);
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function wrongArguments(FunctionalTester $I): void {
|
2016-09-05 20:25:38 +05:30
|
|
|
$I->wantTo('get error on wrong amount of arguments');
|
|
|
|
$this->route->joinLegacy([
|
|
|
|
'wrong' => 'argument',
|
|
|
|
]);
|
|
|
|
$I->canSeeResponseCodeIs(400);
|
|
|
|
$I->canSeeResponseContains('credentials can not be null.');
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function joinWithWrongAccessToken(FunctionalTester $I): void {
|
2016-09-05 20:25:38 +05:30
|
|
|
$I->wantTo('join to some server with wrong accessToken');
|
|
|
|
$this->route->joinLegacy([
|
2019-12-21 04:56:06 +05:30
|
|
|
'sessionId' => 'token:' . uuid() . ':' . uuid(),
|
2016-09-05 20:25:38 +05:30
|
|
|
'user' => 'random-username',
|
2019-12-21 04:56:06 +05:30
|
|
|
'serverId' => uuid(),
|
2016-09-05 20:25:38 +05:30
|
|
|
]);
|
|
|
|
$I->seeResponseCodeIs(401);
|
|
|
|
$I->canSeeResponseContains('Ely.by authorization required');
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function joinWithAccessTokenWithoutMinecraftPermission(OauthSteps $I): void {
|
2016-09-05 20:25:38 +05:30
|
|
|
$I->wantTo('join to some server with wrong accessToken');
|
2017-09-19 22:36:16 +05:30
|
|
|
$accessToken = $I->getAccessToken(['account_info']);
|
2016-09-05 20:25:38 +05:30
|
|
|
$this->route->joinLegacy([
|
2024-12-02 15:40:55 +05:30
|
|
|
'sessionId' => 'token:' . $accessToken . ':df936908-b2e1-544d-96f8-2977ec213022',
|
2016-09-05 20:25:38 +05:30
|
|
|
'user' => 'Admin',
|
2019-12-21 04:56:06 +05:30
|
|
|
'serverId' => uuid(),
|
2016-09-05 20:25:38 +05:30
|
|
|
]);
|
|
|
|
$I->seeResponseCodeIs(401);
|
|
|
|
$I->canSeeResponseContains('Ely.by authorization required');
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function joinWithNilUuids(FunctionalTester $I): void {
|
2016-11-04 22:03:57 +05:30
|
|
|
$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',
|
2019-12-21 04:56:06 +05:30
|
|
|
'serverId' => uuid(),
|
2016-11-04 22:03:57 +05:30
|
|
|
]);
|
|
|
|
$I->canSeeResponseCodeIs(400);
|
|
|
|
$I->canSeeResponseContains('credentials can not be null.');
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function joinByAccountMarkedForDeletion(FunctionalTester $I): void {
|
2020-06-12 02:57:02 +05:30
|
|
|
$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');
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
private function expectSuccessResponse(FunctionalTester $I): void {
|
2016-09-05 20:25:38 +05:30
|
|
|
$I->seeResponseCodeIs(200);
|
|
|
|
$I->canSeeResponseEquals('OK');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|