mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-19 06:43:45 +02:00
Get client API tests back into passing order
This commit is contained in:
@@ -36,11 +36,11 @@ class SubstituteClientApiBindings
|
|||||||
});
|
});
|
||||||
|
|
||||||
$this->router->bind('allocation', function ($value, $route) {
|
$this->router->bind('allocation', function ($value, $route) {
|
||||||
return $this->server($route)->allocations()->where('id', $value)->firstOrFail();
|
return $this->server($route)->allocations()->findOrFail($value);
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->router->bind('schedule', function ($value, $route) {
|
$this->router->bind('schedule', function ($value, $route) {
|
||||||
return $this->server($route)->schedule()->where('id', $value)->firstOrFail();
|
return $this->server($route)->schedule()->findOrFail($value);
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->router->bind('task', function ($value, $route) {
|
$this->router->bind('task', function ($value, $route) {
|
||||||
@@ -51,14 +51,13 @@ class SubstituteClientApiBindings
|
|||||||
->where('schedules.server_id', $route->parameter('server')->id);
|
->where('schedules.server_id', $route->parameter('server')->id);
|
||||||
})
|
})
|
||||||
->where('schedules.id', $route->parameter('schedule')->id)
|
->where('schedules.id', $route->parameter('schedule')->id)
|
||||||
->where('tasks.id', $value)
|
->findOrFail($value);
|
||||||
->firstOrFail();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->router->bind('database', function ($value, $route) {
|
$this->router->bind('database', function ($value, $route) {
|
||||||
$id = Container::getInstance()->make(HashidsInterface::class)->decodeFirst($value);
|
$id = Container::getInstance()->make(HashidsInterface::class)->decodeFirst($value);
|
||||||
|
|
||||||
return $this->server($route)->where('id', $id)->firstOrFail();
|
return $this->server($route)->databases()->findOrFail($id);
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->router->bind('backup', function ($value, $route) {
|
$this->router->bind('backup', function ($value, $route) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace Pterodactyl\Http\Requests\Api;
|
namespace Pterodactyl\Http\Requests\Api;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Auth\Access\AuthorizationException;
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace Pterodactyl\Http\Requests\Api\Client;
|
namespace Pterodactyl\Http\Requests\Api\Client;
|
||||||
|
|
||||||
use Pterodactyl\Models\Permission;
|
use Pterodactyl\Models\Permission;
|
||||||
|
use Illuminate\Auth\Access\AuthorizationException;
|
||||||
|
|
||||||
class WebsocketTokenRequest extends ClientApiRequest
|
class WebsocketTokenRequest extends ClientApiRequest
|
||||||
{
|
{
|
||||||
@@ -10,4 +11,9 @@ class WebsocketTokenRequest extends ClientApiRequest
|
|||||||
{
|
{
|
||||||
return Permission::ACTION_WEBSOCKET_CONNECT;
|
return Permission::ACTION_WEBSOCKET_CONNECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function failedAuthorization()
|
||||||
|
{
|
||||||
|
throw new AuthorizationException('You do not have permission to connect to this server\'s websocket.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class WebsocketControllerTest extends ClientApiIntegrationTestCase
|
|||||||
|
|
||||||
$this->actingAs($user)->getJson("/api/client/servers/{$server->uuid}/websocket")
|
$this->actingAs($user)->getJson("/api/client/servers/{$server->uuid}/websocket")
|
||||||
->assertStatus(Response::HTTP_FORBIDDEN)
|
->assertStatus(Response::HTTP_FORBIDDEN)
|
||||||
->assertJsonPath('errors.0.code', 'HttpForbiddenException')
|
->assertJsonPath('errors.0.code', 'AccessDeniedHttpException')
|
||||||
->assertJsonPath('errors.0.detail', 'You do not have permission to connect to this server\'s websocket.');
|
->assertJsonPath('errors.0.detail', 'You do not have permission to connect to this server\'s websocket.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user