Skip to content

Commit 75e0a86

Browse files
committed
Add another sanity check for websocket permissions
1 parent 9bffa6a commit 75e0a86

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Pterodactyl\Tests\Integration\Api\Client\Server;
44

55
use Carbon\CarbonImmutable;
6+
use Pterodactyl\Models\User;
67
use Illuminate\Http\Response;
78
use Lcobucci\JWT\Configuration;
89
use Pterodactyl\Models\Permission;
@@ -27,6 +28,18 @@ public function testSubuserWithoutWebsocketPermissionReceivesError()
2728
->assertJsonPath('errors.0.detail', 'You do not have permission to connect to this server\'s websocket.');
2829
}
2930

31+
/**
32+
* Confirm users cannot access the websocket for another user's server.
33+
*/
34+
public function testUserWithoutPermissionForServerReceivesError()
35+
{
36+
[,$server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]);
37+
[$user,] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]);
38+
39+
$this->actingAs($user)->getJson("/api/client/servers/{$server->uuid}/websocket")
40+
->assertStatus(Response::HTTP_NOT_FOUND);
41+
}
42+
3043
/**
3144
* Test that the expected permissions are returned for the server owner and that the JWT is
3245
* configured correctly.

0 commit comments

Comments
 (0)