mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Add additional tests cases, implemented custom error formatter
This commit is contained in:
@@ -3,15 +3,15 @@ declare(strict_types=1);
|
||||
|
||||
namespace api\tests\functional\mojang;
|
||||
|
||||
use api\tests\functional\_steps\OauthSteps;
|
||||
use api\tests\FunctionalTester;
|
||||
|
||||
class ProfileCest {
|
||||
final class ProfileCest {
|
||||
|
||||
public function getProfile(FunctionalTester $I): void {
|
||||
$I->amAuthenticated();
|
||||
$I->sendGet('/api/mojang/services/minecraft/profile');
|
||||
$I->canSeeResponseCodeIs(200);
|
||||
$I->canSeeResponseIsJson();
|
||||
$I->canSeeResponseContainsJson([
|
||||
'id' => 'df936908b2e1544d96f82977ec213022',
|
||||
'name' => 'Admin',
|
||||
@@ -28,7 +28,31 @@ class ProfileCest {
|
||||
]);
|
||||
}
|
||||
|
||||
// TODO: add cases for unauthenticated user
|
||||
// TODO: add cases for authenticated as a service account user
|
||||
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',
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user