Fix some failing test cases
This commit is contained in:
parent
625fd92130
commit
f99ac0ecde
3 changed files with 12 additions and 4 deletions
|
@ -163,7 +163,7 @@ class SubuserController extends ClientApiController
|
||||||
$this->repository->delete($subuser->id);
|
$this->repository->delete($subuser->id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->serverRepository->revokeJTIs([md5($subuser->user_id . $server->uuid)]);
|
$this->serverRepository->setServer($server)->revokeJTIs([md5($subuser->user_id . $server->uuid)]);
|
||||||
} catch (DaemonConnectionException $exception) {
|
} catch (DaemonConnectionException $exception) {
|
||||||
// Don't block this request if we can't connect to the Wings instance.
|
// Don't block this request if we can't connect to the Wings instance.
|
||||||
Log::warning($exception, ['user_id' => $subuser->user_id, 'server_id' => $server->id]);
|
Log::warning($exception, ['user_id' => $subuser->user_id, 'server_id' => $server->id]);
|
||||||
|
|
|
@ -2,10 +2,12 @@
|
||||||
|
|
||||||
namespace Pterodactyl\Tests\Integration\Api\Client\Server\Subuser;
|
namespace Pterodactyl\Tests\Integration\Api\Client\Server\Subuser;
|
||||||
|
|
||||||
|
use Mockery;
|
||||||
use Ramsey\Uuid\Uuid;
|
use Ramsey\Uuid\Uuid;
|
||||||
use Pterodactyl\Models\User;
|
use Pterodactyl\Models\User;
|
||||||
use Pterodactyl\Models\Subuser;
|
use Pterodactyl\Models\Subuser;
|
||||||
use Pterodactyl\Models\Permission;
|
use Pterodactyl\Models\Permission;
|
||||||
|
use Pterodactyl\Repositories\Wings\DaemonServerRepository;
|
||||||
use Pterodactyl\Tests\Integration\Api\Client\ClientApiIntegrationTestCase;
|
use Pterodactyl\Tests\Integration\Api\Client\ClientApiIntegrationTestCase;
|
||||||
|
|
||||||
class DeleteSubuserTest extends ClientApiIntegrationTestCase
|
class DeleteSubuserTest extends ClientApiIntegrationTestCase
|
||||||
|
@ -23,6 +25,8 @@ class DeleteSubuserTest extends ClientApiIntegrationTestCase
|
||||||
*/
|
*/
|
||||||
public function testCorrectSubuserIsDeletedFromServer()
|
public function testCorrectSubuserIsDeletedFromServer()
|
||||||
{
|
{
|
||||||
|
$this->swap(DaemonServerRepository::class, $mock = Mockery::mock(DaemonServerRepository::class));
|
||||||
|
|
||||||
[$user, $server] = $this->generateTestAccount();
|
[$user, $server] = $this->generateTestAccount();
|
||||||
|
|
||||||
/** @var \Pterodactyl\Models\User $differentUser */
|
/** @var \Pterodactyl\Models\User $differentUser */
|
||||||
|
@ -37,9 +41,11 @@ class DeleteSubuserTest extends ClientApiIntegrationTestCase
|
||||||
Subuser::query()->forceCreate([
|
Subuser::query()->forceCreate([
|
||||||
'user_id' => $subuser->id,
|
'user_id' => $subuser->id,
|
||||||
'server_id' => $server->id,
|
'server_id' => $server->id,
|
||||||
'permissions' => [ Permission::ACTION_WEBSOCKET_CONNECT ],
|
'permissions' => [Permission::ACTION_WEBSOCKET_CONNECT],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$mock->expects('setServer->revokeJTIs')->with([md5($subuser->id . $server->uuid)])->andReturnUndefined();
|
||||||
|
|
||||||
$this->actingAs($user)->deleteJson($this->link($server) . "/users/{$subuser->uuid}")->assertNoContent();
|
$this->actingAs($user)->deleteJson($this->link($server) . "/users/{$subuser->uuid}")->assertNoContent();
|
||||||
|
|
||||||
// Try the same test, but this time with a UUID that if cast to an int (shouldn't) line up with
|
// Try the same test, but this time with a UUID that if cast to an int (shouldn't) line up with
|
||||||
|
@ -51,9 +57,11 @@ class DeleteSubuserTest extends ClientApiIntegrationTestCase
|
||||||
Subuser::query()->forceCreate([
|
Subuser::query()->forceCreate([
|
||||||
'user_id' => $subuser->id,
|
'user_id' => $subuser->id,
|
||||||
'server_id' => $server->id,
|
'server_id' => $server->id,
|
||||||
'permissions' => [ Permission::ACTION_WEBSOCKET_CONNECT ],
|
'permissions' => [Permission::ACTION_WEBSOCKET_CONNECT],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$mock->expects('setServer->revokeJTIs')->with([md5($subuser->id . $server->uuid)])->andReturnUndefined();
|
||||||
|
|
||||||
$this->actingAs($user)->deleteJson($this->link($server) . "/users/{$subuser->uuid}")->assertNoContent();
|
$this->actingAs($user)->deleteJson($this->link($server) . "/users/{$subuser->uuid}")->assertNoContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ class WebsocketControllerTest extends ClientApiIntegrationTestCase
|
||||||
$this->assertSame($server->node->getConnectionAddress(), $token->getClaim('aud'));
|
$this->assertSame($server->node->getConnectionAddress(), $token->getClaim('aud'));
|
||||||
$this->assertSame(CarbonImmutable::now()->getTimestamp(), $token->getClaim('iat'));
|
$this->assertSame(CarbonImmutable::now()->getTimestamp(), $token->getClaim('iat'));
|
||||||
$this->assertSame(CarbonImmutable::now()->subMinutes(5)->getTimestamp(), $token->getClaim('nbf'));
|
$this->assertSame(CarbonImmutable::now()->subMinutes(5)->getTimestamp(), $token->getClaim('nbf'));
|
||||||
$this->assertSame(CarbonImmutable::now()->addMinutes(15)->getTimestamp(), $token->getClaim('exp'));
|
$this->assertSame(CarbonImmutable::now()->addMinutes(10)->getTimestamp(), $token->getClaim('exp'));
|
||||||
$this->assertSame($user->id, $token->getClaim('user_id'));
|
$this->assertSame($user->id, $token->getClaim('user_id'));
|
||||||
$this->assertSame($server->uuid, $token->getClaim('server_uuid'));
|
$this->assertSame($server->uuid, $token->getClaim('server_uuid'));
|
||||||
$this->assertSame(['*'], $token->getClaim('permissions'));
|
$this->assertSame(['*'], $token->getClaim('permissions'));
|
||||||
|
|
Loading…
Reference in a new issue