mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Merge pull request #21 from elyby/iss_20_minecraftservices_profile
MinecraftServices Profile info API endpoint
This commit is contained in:
58
api/tests/functional/mojang/ProfileCest.php
Normal file
58
api/tests/functional/mojang/ProfileCest.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace api\tests\functional\mojang;
|
||||
|
||||
use api\tests\functional\_steps\OauthSteps;
|
||||
use api\tests\FunctionalTester;
|
||||
|
||||
final class ProfileCest {
|
||||
|
||||
public function getProfile(FunctionalTester $I): void {
|
||||
$I->amAuthenticated();
|
||||
$I->sendGet('/api/mojang/services/minecraft/profile');
|
||||
$I->canSeeResponseCodeIs(200);
|
||||
$I->canSeeResponseContainsJson([
|
||||
'id' => 'df936908b2e1544d96f82977ec213022',
|
||||
'name' => 'Admin',
|
||||
'skins' => [
|
||||
[
|
||||
'id' => '1794a784-2d87-32f0-b233-0b2fd5682444',
|
||||
'state' => 'ACTIVE',
|
||||
'url' => 'http://localhost/skin.png',
|
||||
'variant' => 'CLASSIC',
|
||||
'alias' => '',
|
||||
],
|
||||
],
|
||||
'capes' => [],
|
||||
]);
|
||||
}
|
||||
|
||||
public function getProfileAsServiceAccount(OauthSteps $I): void {
|
||||
$accessToken = $I->getAccessTokenByClientCredentialsGrant(['internal_account_info']);
|
||||
$I->amBearerAuthenticated($accessToken);
|
||||
|
||||
$I->sendGet('/api/mojang/services/minecraft/profile');
|
||||
$I->canSeeResponseCodeIs(404);
|
||||
$I->canSeeResponseContainsJson([
|
||||
'path' => '/mojang/services/minecraft/profile',
|
||||
'errorType' => 'NOT_FOUND',
|
||||
'error' => 'NOT_FOUND',
|
||||
'errorMessage' => 'The server has not found anything matching the request URI',
|
||||
'developerMessage' => 'The server has not found anything matching the request URI',
|
||||
]);
|
||||
}
|
||||
|
||||
public function getProfileWithoutAuthentication(FunctionalTester $I): void {
|
||||
$I->sendGet('/api/mojang/services/minecraft/profile');
|
||||
$I->canSeeResponseCodeIs(401);
|
||||
$I->canSeeResponseContainsJson([
|
||||
'path' => '/mojang/services/minecraft/profile',
|
||||
'errorType' => 'UnauthorizedOperationException',
|
||||
'error' => 'UnauthorizedOperationException',
|
||||
'errorMessage' => 'Unauthorized',
|
||||
'developerMessage' => 'Unauthorized',
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
@@ -93,7 +93,7 @@ class TokensFactoryTest extends TestCase {
|
||||
$token = $factory->createForMinecraftAccount($account, $clientToken);
|
||||
$this->assertEqualsWithDelta(time(), $token->getClaim('iat'), 5);
|
||||
$this->assertEqualsWithDelta(time() + 60 * 60 * 24 * 2, $token->getClaim('exp'), 5);
|
||||
$this->assertSame('minecraft_server_session', $token->getClaim('scope'));
|
||||
$this->assertSame('obtain_own_account_info minecraft_server_session', $token->getClaim('scope'));
|
||||
$this->assertNotSame('e44fae79-f80e-4975-952e-47e8a9ed9472', $token->getClaim('ely-client-token'));
|
||||
$this->assertSame('ely|1', $token->getClaim('sub'));
|
||||
}
|
||||
|
Reference in New Issue
Block a user