mirror of
https://github.com/pterodactyl/panel.git
synced 2026-11-30 11:25:52 -05:00
port fix from 1.0 for display exceptions not returning correctly on api
This commit is contained in:
@@ -57,7 +57,7 @@ class DisplayException extends PterodactylException implements HttpExceptionInte
|
||||
*/
|
||||
public function render(Request $request): JsonResponse|RedirectResponse
|
||||
{
|
||||
if ($request->expectsJson()) {
|
||||
if ($request->expectsJson() || $request->is('api/*')) {
|
||||
return response()->json(ApiErrorResponse::toArray($this), $this->getStatusCode(), $this->getHeaders());
|
||||
}
|
||||
|
||||
|
||||
@@ -87,6 +87,16 @@ test('a server that skips its install script cannot be reinstalled', function ()
|
||||
expect($server->refresh()->status)->toBeNull()
|
||||
->and($fake->callsFor('reinstall'))->toBeEmpty();
|
||||
});
|
||||
test('a blocked reinstall returns an error to clients not requesting json', function (): void {
|
||||
$fake = new FakeDaemonServer;
|
||||
$server = $this->createServerModel(['skip_scripts' => true]);
|
||||
|
||||
$this->post("/api/application/servers/{$server->id}/reinstall", [], ['Accept' => '*/*'])
|
||||
->assertStatus(Response::HTTP_BAD_REQUEST)
|
||||
->assertJsonPath('errors.0.detail', trans('admin/server.exceptions.skipping_install_script'));
|
||||
|
||||
expect($fake->callsFor('reinstall'))->toBeEmpty();
|
||||
});
|
||||
test('a server that skips its install script can be reinstalled from an unfinished install', function (string $status): void {
|
||||
$fake = new FakeDaemonServer;
|
||||
$server = $this->createServerModel(['skip_scripts' => true, 'status' => $status]);
|
||||
|
||||
Reference in New Issue
Block a user