mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
api
common
console
data
docker
tests
codeception
_output
api
_output
_pages
_support
functional
_steps
AuthserverSteps.php
OauthSteps.php
SessionServerSteps.php
accounts
authserver
internal
mojang
oauth
sessionserver
EmailConfirmationCest.php
FeedbackCest.php
ForgotPasswordCest.php
IdentityInfoCest.php
LoginCest.php
LogoutCest.php
OptionsCest.php
RecoverPasswordCest.php
RefreshTokenCest.php
RegisterCest.php
RepeatAccountActivationCest.php
_bootstrap.php
unit
.gitignore
_bootstrap.php
codeception.yml
functional.suite.yml
unit.suite.yml
bin
common
config
console
codeception.yml
docker-compose.yml
php.sh
run-tests.sh
.dockerignore
.env-dist
.gitignore
.gitlab-ci.yml
.php_cs.dist
Dockerfile
Dockerfile-dev
README.md
autocompletion.php
composer.json
composer.lock
docker-compose.dev.yml
docker-compose.prod.yml
yii
68 lines
2.4 KiB
PHP
68 lines
2.4 KiB
PHP
<?php
|
|
namespace tests\codeception\api\functional\_steps;
|
|
|
|
use common\rbac\Permissions as P;
|
|
use Faker\Provider\Uuid;
|
|
use tests\codeception\api\_pages\SessionServerRoute;
|
|
use tests\codeception\api\FunctionalTester;
|
|
|
|
class SessionServerSteps extends FunctionalTester {
|
|
|
|
public function amJoined($byLegacy = false) {
|
|
$oauthSteps = new OauthSteps($this->scenario);
|
|
$accessToken = $oauthSteps->getAccessToken([P::MINECRAFT_SERVER_SESSION]);
|
|
$route = new SessionServerRoute($this);
|
|
$serverId = Uuid::uuid();
|
|
$username = 'Admin';
|
|
|
|
if ($byLegacy) {
|
|
$route->joinLegacy([
|
|
'sessionId' => 'token:' . $accessToken . ':' . 'df936908-b2e1-544d-96f8-2977ec213022',
|
|
'user' => $username,
|
|
'serverId' => $serverId,
|
|
]);
|
|
|
|
$this->canSeeResponseEquals('OK');
|
|
} else {
|
|
$route->join([
|
|
'accessToken' => $accessToken,
|
|
'selectedProfile' => 'df936908-b2e1-544d-96f8-2977ec213022',
|
|
'serverId' => $serverId,
|
|
]);
|
|
|
|
$this->canSeeResponseContainsJson(['id' => 'OK']);
|
|
}
|
|
|
|
return [$username, $serverId];
|
|
}
|
|
|
|
public function canSeeValidTexturesResponse($expectedUsername, $expectedUuid) {
|
|
$this->seeResponseIsJson();
|
|
$this->canSeeResponseContainsJson([
|
|
'name' => $expectedUsername,
|
|
'id' => $expectedUuid,
|
|
'ely' => true,
|
|
'properties' => [
|
|
[
|
|
'name' => 'textures',
|
|
'signature' => 'Cg==',
|
|
],
|
|
],
|
|
]);
|
|
$this->canSeeResponseJsonMatchesJsonPath('$.properties[0].value');
|
|
$value = json_decode($this->grabResponse(), true)['properties'][0]['value'];
|
|
$decoded = json_decode(base64_decode($value), true);
|
|
$this->assertArrayHasKey('timestamp', $decoded);
|
|
$this->assertArrayHasKey('textures', $decoded);
|
|
$this->assertEquals($expectedUuid, $decoded['profileId']);
|
|
$this->assertEquals($expectedUsername, $decoded['profileName']);
|
|
$this->assertTrue($decoded['ely']);
|
|
$textures = $decoded['textures'];
|
|
$this->assertArrayHasKey('SKIN', $textures);
|
|
$skinTextures = $textures['SKIN'];
|
|
$this->assertArrayHasKey('url', $skinTextures);
|
|
$this->assertArrayHasKey('hash', $skinTextures);
|
|
}
|
|
|
|
}
|