Skip to content

Commit 00da092

Browse files
committed
Fix tests
1 parent 2f08456 commit 00da092

File tree

11 files changed

+21
-389
lines changed

11 files changed

+21
-389
lines changed

app/Console/Commands/Server/BulkPowerActionCommand.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,7 @@ public function handle(DaemonPowerRepository $powerRepository, ValidatorFactory
8989
*/
9090
protected function getQueryBuilder(array $servers, array $nodes)
9191
{
92-
$instance = Server::query()
93-
->where('suspended', false)
94-
->where('installed', Server::STATUS_INSTALLED);
92+
$instance = Server::query()->whereNull('status');
9593

9694
if (!empty($nodes) && !empty($servers)) {
9795
$instance->whereIn('id', $servers)->orWhereIn('node_id', $nodes);

app/Contracts/Repository/ServerRepositoryInterface.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@ public function getByUuid(string $uuid): Server;
6666
*/
6767
public function isUniqueUuidCombo(string $uuid, string $short): bool;
6868

69-
/**
70-
* Get the amount of servers that are suspended.
71-
*/
72-
public function getSuspendedServersCount(): int;
73-
7469
/**
7570
* Returns all of the servers that exist for a given node in a paginated response.
7671
*/

app/Http/Controllers/Admin/StatisticsController.php

Lines changed: 0 additions & 99 deletions
This file was deleted.

app/Http/Controllers/Api/Client/Servers/BackupController.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Pterodactyl\Models\AuditLog;
99
use Illuminate\Http\JsonResponse;
1010
use Pterodactyl\Models\Permission;
11-
use Illuminate\Validation\UnauthorizedException;
11+
use Illuminate\Auth\Access\AuthorizationException;
1212
use Pterodactyl\Services\Backups\DeleteBackupService;
1313
use Pterodactyl\Services\Backups\DownloadLinkService;
1414
use Pterodactyl\Services\Backups\InitiateBackupService;
@@ -63,11 +63,12 @@ public function __construct(
6363
*
6464
* @throws \Spatie\Fractalistic\Exceptions\InvalidTransformation
6565
* @throws \Spatie\Fractalistic\Exceptions\NoTransformerSpecified
66+
* @throws \Illuminate\Auth\Access\AuthorizationException
6667
*/
6768
public function index(Request $request, Server $server): array
6869
{
6970
if (!$request->user()->can(Permission::ACTION_BACKUP_READ, $server)) {
70-
throw new UnauthorizedException();
71+
throw new AuthorizationException();
7172
}
7273

7374
$limit = min($request->query('per_page') ?? 20, 50);
@@ -109,11 +110,12 @@ public function store(StoreBackupRequest $request, Server $server): array
109110
*
110111
* @throws \Spatie\Fractalistic\Exceptions\InvalidTransformation
111112
* @throws \Spatie\Fractalistic\Exceptions\NoTransformerSpecified
113+
* @throws \Illuminate\Auth\Access\AuthorizationException
112114
*/
113115
public function view(Request $request, Server $server, Backup $backup): array
114116
{
115117
if (!$request->user()->can(Permission::ACTION_BACKUP_READ, $server)) {
116-
throw new UnauthorizedException();
118+
throw new AuthorizationException();
117119
}
118120

119121
return $this->fractal->item($backup)
@@ -130,7 +132,7 @@ public function view(Request $request, Server $server, Backup $backup): array
130132
public function delete(Request $request, Server $server, Backup $backup): JsonResponse
131133
{
132134
if (!$request->user()->can(Permission::ACTION_BACKUP_DELETE, $server)) {
133-
throw new UnauthorizedException();
135+
throw new AuthorizationException();
134136
}
135137

136138
$server->audit(AuditLog::SERVER__BACKUP_DELETED, function (AuditLog $audit) use ($backup) {
@@ -146,11 +148,13 @@ public function delete(Request $request, Server $server, Backup $backup): JsonRe
146148
* Download the backup for a given server instance. For daemon local files, the file
147149
* will be streamed back through the Panel. For AWS S3 files, a signed URL will be generated
148150
* which the user is redirected to.
151+
*
152+
* @throws \Illuminate\Auth\Access\AuthorizationException
149153
*/
150154
public function download(Request $request, Server $server, Backup $backup): JsonResponse
151155
{
152156
if (!$request->user()->can(Permission::ACTION_BACKUP_DOWNLOAD, $server)) {
153-
throw new UnauthorizedException();
157+
throw new AuthorizationException();
154158
}
155159

156160
switch ($backup->disk) {
@@ -179,7 +183,7 @@ public function download(Request $request, Server $server, Backup $backup): Json
179183
public function restore(Request $request, Server $server, Backup $backup): JsonResponse
180184
{
181185
if (!$request->user()->can(Permission::ACTION_BACKUP_RESTORE, $server)) {
182-
throw new UnauthorizedException();
186+
throw new AuthorizationException();
183187
}
184188

185189
// Cannot restore a backup unless a server is fully installed and not currently

app/Repositories/Eloquent/ServerRepository.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,6 @@ public function isUniqueUuidCombo(string $uuid, string $short): bool
168168
return !$this->getBuilder()->where('uuid', '=', $uuid)->orWhere('uuidShort', '=', $short)->exists();
169169
}
170170

171-
/**
172-
* Get the amount of servers that are suspended.
173-
*/
174-
public function getSuspendedServersCount(): int
175-
{
176-
return $this->getBuilder()->where('suspended', true)->count();
177-
}
178-
179171
/**
180172
* Returns all of the servers that exist for a given node in a paginated response.
181173
*/

database/Factories/ServerFactory.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,14 @@ public function definition()
3030
'name' => $this->faker->firstName,
3131
'description' => implode(' ', $this->faker->sentences()),
3232
'skip_scripts' => 0,
33-
'suspended' => 0,
33+
'status' => null,
3434
'memory' => 512,
3535
'swap' => 0,
3636
'disk' => 512,
3737
'io' => 500,
3838
'cpu' => 0,
3939
'threads' => null,
4040
'oom_disabled' => 0,
41-
'installed' => 1,
4241
'allocation_limit' => null,
4342
'database_limit' => null,
4443
'created_at' => Carbon::now(),

public/themes/pterodactyl/js/admin/statistics.js

Lines changed: 0 additions & 118 deletions
This file was deleted.

resources/scripts/api/server/getServer.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ export interface Server {
3939
allocations: number;
4040
backups: number;
4141
};
42-
// Only isSuspended got marked as deprecated since the isInstalling is a nice helper
43-
// since you'd have to check multiple potential values for that. isSuspended should
44-
// be replaced with status !== 'suspended'.
45-
/** @deprecated */
46-
isSuspended: boolean;
4742
isInstalling: boolean;
4843
isTransferring: boolean;
4944
variables: ServerEggVariable[];
@@ -67,7 +62,6 @@ export const rawDataToServerObject = ({ attributes: data }: FractalResponseData)
6762
limits: { ...data.limits },
6863
eggFeatures: data.egg_features || [],
6964
featureLimits: { ...data.feature_limits },
70-
isSuspended: data.status === 'suspended',
7165
isInstalling: data.status === 'installing' || data.status === 'install_failed',
7266
isTransferring: data.is_transferring,
7367
variables: ((data.relationships?.variables as FractalResponseList | undefined)?.data || []).map(rawDataToServerEggVariable),

0 commit comments

Comments
 (0)