From cb40b280a4fd030dbc35e340f9b97af29b0bf883 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sun, 17 Jan 2021 15:55:46 -0800 Subject: [PATCH] Fix single failing test --- .../Api/Remote/Servers/ServerInstallController.php | 12 ++++++++---- app/Models/Server.php | 1 - .../Middleware/Server/AccessingValidServerTest.php | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Api/Remote/Servers/ServerInstallController.php b/app/Http/Controllers/Api/Remote/Servers/ServerInstallController.php index 530832d4e..976493835 100644 --- a/app/Http/Controllers/Api/Remote/Servers/ServerInstallController.php +++ b/app/Http/Controllers/Api/Remote/Servers/ServerInstallController.php @@ -4,6 +4,7 @@ namespace Pterodactyl\Http\Controllers\Api\Remote\Servers; use Illuminate\Http\Request; use Illuminate\Http\Response; +use Pterodactyl\Models\Server; use Illuminate\Http\JsonResponse; use Pterodactyl\Http\Controllers\Controller; use Pterodactyl\Repositories\Eloquent\ServerRepository; @@ -61,10 +62,13 @@ class ServerInstallController extends Controller { $server = $this->repository->getByUuid($uuid); - $this->repository->update($server->id, [ - 'installed' => (string) $request->input('successful') === '1' ? 1 : 2, - ], true, true); + $status = $request->input('successful') === '1' ? null : Server::STATUS_INSTALL_FAILED; + if ($server->status === Server::STATUS_SUSPENDED) { + $status = Server::STATUS_SUSPENDED + } - return JsonResponse::create([], Response::HTTP_NO_CONTENT); + $this->repository->update($server->id, ['status' => $status], true, true); + + return new JsonResponse([], Response::HTTP_NO_CONTENT); } } diff --git a/app/Models/Server.php b/app/Models/Server.php index 775fbf3c3..0f8597224 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -129,7 +129,6 @@ class Server extends Model 'startup' => 'required|string', 'skip_scripts' => 'sometimes|boolean', 'image' => 'required|string|max:191', - 'installed' => 'in:0,1,2', 'database_limit' => 'present|nullable|integer|min:0', 'allocation_limit' => 'sometimes|nullable|integer|min:0', 'backup_limit' => 'present|nullable|integer|min:0', diff --git a/tests/Unit/Http/Middleware/Server/AccessingValidServerTest.php b/tests/Unit/Http/Middleware/Server/AccessingValidServerTest.php index 1ecef153b..c092813cd 100644 --- a/tests/Unit/Http/Middleware/Server/AccessingValidServerTest.php +++ b/tests/Unit/Http/Middleware/Server/AccessingValidServerTest.php @@ -67,7 +67,7 @@ class AccessingValidServerTest extends MiddlewareTestCase $this->expectException(ConflictHttpException::class); $this->expectExceptionMessage('Server is still completing the installation process.'); - $model = factory(Server::class)->make(['installed' => 0]); + $model = factory(Server::class)->make(['status' => Server::STATUS_INSTALLING]); $this->request->shouldReceive('route->parameter')->with('server')->once()->andReturn('123456'); $this->request->shouldReceive('expectsJson')->withNoArgs()->once()->andReturn(true);