2021-03-03 19:34:42 +05:30
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace api\tests\functional\authlibInjector;
|
|
|
|
|
|
|
|
use api\tests\functional\_steps\SessionServerSteps;
|
|
|
|
use api\tests\FunctionalTester;
|
|
|
|
use function Ramsey\Uuid\v4 as uuid;
|
|
|
|
|
|
|
|
class HasJoinedCest {
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function hasJoined(SessionServerSteps $I): void {
|
2021-03-03 19:34:42 +05:30
|
|
|
$I->wantTo('check hasJoined user to some server');
|
|
|
|
[$username, $serverId] = $I->amJoined();
|
|
|
|
|
|
|
|
$I->sendGET('/api/authlib-injector/sessionserver/session/minecraft/hasJoined', [
|
|
|
|
'username' => $username,
|
|
|
|
'serverId' => $serverId,
|
|
|
|
]);
|
|
|
|
|
|
|
|
$I->seeResponseCodeIs(200);
|
|
|
|
$I->canSeeValidTexturesResponse($username, 'df936908b2e1544d96f82977ec213022', true);
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function wrongArguments(FunctionalTester $I): void {
|
2021-03-03 19:34:42 +05:30
|
|
|
$I->wantTo('get error on wrong amount of arguments');
|
|
|
|
$I->sendGET('/api/authlib-injector/sessionserver/session/minecraft/hasJoined', [
|
|
|
|
'wrong' => 'argument',
|
|
|
|
]);
|
|
|
|
$I->canSeeResponseCodeIs(400);
|
|
|
|
$I->canSeeResponseIsJson();
|
|
|
|
$I->canSeeResponseContainsJson([
|
|
|
|
'error' => 'IllegalArgumentException',
|
|
|
|
'errorMessage' => 'credentials can not be null.',
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function hasJoinedWithNoJoinOperation(FunctionalTester $I): void {
|
2021-03-03 19:34:42 +05:30
|
|
|
$I->wantTo('hasJoined to some server without join call');
|
|
|
|
$I->sendGET('/api/authlib-injector/sessionserver/session/minecraft/hasJoined', [
|
|
|
|
'username' => 'some-username',
|
|
|
|
'serverId' => uuid(),
|
|
|
|
]);
|
|
|
|
$I->seeResponseCodeIs(401);
|
|
|
|
$I->seeResponseIsJson();
|
|
|
|
$I->canSeeResponseContainsJson([
|
|
|
|
'error' => 'ForbiddenOperationException',
|
|
|
|
'errorMessage' => 'Invalid token.',
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|