22
33namespace Pterodactyl \Tests \Integration \Api \Client \Server \Subuser ;
44
5+ use Mockery ;
56use Ramsey \Uuid \Uuid ;
67use Pterodactyl \Models \User ;
78use Pterodactyl \Models \Subuser ;
89use Pterodactyl \Models \Permission ;
10+ use Pterodactyl \Repositories \Wings \DaemonServerRepository ;
911use Pterodactyl \Tests \Integration \Api \Client \ClientApiIntegrationTestCase ;
1012
1113class 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}
0 commit comments