Skip to content

Commit f99ac0e

Browse files
committed
Fix some failing test cases
1 parent 625fd92 commit f99ac0e

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

app/Http/Controllers/Api/Client/Servers/SubuserController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public function delete(DeleteSubuserRequest $request, Server $server)
163163
$this->repository->delete($subuser->id);
164164

165165
try {
166-
$this->serverRepository->revokeJTIs([md5($subuser->user_id . $server->uuid)]);
166+
$this->serverRepository->setServer($server)->revokeJTIs([md5($subuser->user_id . $server->uuid)]);
167167
} catch (DaemonConnectionException $exception) {
168168
// Don't block this request if we can't connect to the Wings instance.
169169
Log::warning($exception, ['user_id' => $subuser->user_id, 'server_id' => $server->id]);

tests/Integration/Api/Client/Server/Subuser/DeleteSubuserTest.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
namespace Pterodactyl\Tests\Integration\Api\Client\Server\Subuser;
44

5+
use Mockery;
56
use Ramsey\Uuid\Uuid;
67
use Pterodactyl\Models\User;
78
use Pterodactyl\Models\Subuser;
89
use Pterodactyl\Models\Permission;
10+
use Pterodactyl\Repositories\Wings\DaemonServerRepository;
911
use Pterodactyl\Tests\Integration\Api\Client\ClientApiIntegrationTestCase;
1012

1113
class DeleteSubuserTest extends ClientApiIntegrationTestCase
@@ -23,6 +25,8 @@ class DeleteSubuserTest extends ClientApiIntegrationTestCase
2325
*/
2426
public function testCorrectSubuserIsDeletedFromServer()
2527
{
28+
$this->swap(DaemonServerRepository::class, $mock = Mockery::mock(DaemonServerRepository::class));
29+
2630
[$user, $server] = $this->generateTestAccount();
2731

2832
/** @var \Pterodactyl\Models\User $differentUser */
@@ -37,9 +41,11 @@ public function testCorrectSubuserIsDeletedFromServer()
3741
Subuser::query()->forceCreate([
3842
'user_id' => $subuser->id,
3943
'server_id' => $server->id,
40-
'permissions' => [ Permission::ACTION_WEBSOCKET_CONNECT ],
44+
'permissions' => [Permission::ACTION_WEBSOCKET_CONNECT],
4145
]);
4246

47+
$mock->expects('setServer->revokeJTIs')->with([md5($subuser->id . $server->uuid)])->andReturnUndefined();
48+
4349
$this->actingAs($user)->deleteJson($this->link($server) . "/users/{$subuser->uuid}")->assertNoContent();
4450

4551
// 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 @@ public function testCorrectSubuserIsDeletedFromServer()
5157
Subuser::query()->forceCreate([
5258
'user_id' => $subuser->id,
5359
'server_id' => $server->id,
54-
'permissions' => [ Permission::ACTION_WEBSOCKET_CONNECT ],
60+
'permissions' => [Permission::ACTION_WEBSOCKET_CONNECT],
5561
]);
5662

63+
$mock->expects('setServer->revokeJTIs')->with([md5($subuser->id . $server->uuid)])->andReturnUndefined();
64+
5765
$this->actingAs($user)->deleteJson($this->link($server) . "/users/{$subuser->uuid}")->assertNoContent();
5866
}
5967
}

tests/Integration/Api/Client/Server/WebsocketControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function testJwtAndWebsocketUrlAreReturnedForServerOwner()
6363
$this->assertSame($server->node->getConnectionAddress(), $token->getClaim('aud'));
6464
$this->assertSame(CarbonImmutable::now()->getTimestamp(), $token->getClaim('iat'));
6565
$this->assertSame(CarbonImmutable::now()->subMinutes(5)->getTimestamp(), $token->getClaim('nbf'));
66-
$this->assertSame(CarbonImmutable::now()->addMinutes(15)->getTimestamp(), $token->getClaim('exp'));
66+
$this->assertSame(CarbonImmutable::now()->addMinutes(10)->getTimestamp(), $token->getClaim('exp'));
6767
$this->assertSame($user->id, $token->getClaim('user_id'));
6868
$this->assertSame($server->uuid, $token->getClaim('server_uuid'));
6969
$this->assertSame(['*'], $token->getClaim('permissions'));

0 commit comments

Comments
 (0)