Revert "Add concat_space rule"

This reverts commit 96acd268bee7005fe1691b572a4674575604d437.
This commit is contained in:
Lance Pioch 2024-10-19 21:14:41 -04:00
parent 466f9f7edc
commit deb6603840
105 changed files with 272 additions and 271 deletions

View File

@ -16,7 +16,7 @@ class AppSettingsCommand extends Command
$path = base_path('.env');
if (!file_exists($path)) {
$this->comment('Copying example .env file');
copy($path.'.example', $path);
copy($path . '.example', $path);
}
if (!config('app.key')) {

View File

@ -44,7 +44,7 @@ class EmailSettingsCommand extends Command
env('MAIL_MAILER', env('MAIL_DRIVER', 'smtp')),
);
$method = 'setup'.studly_case($this->variables['MAIL_MAILER']).'DriverVariables';
$method = 'setup' . studly_case($this->variables['MAIL_MAILER']) . 'DriverVariables';
if (method_exists($this, $method)) {
$this->{$method}();
}

View File

@ -19,7 +19,7 @@ class QueueWorkerServiceCommand extends Command
public function handle(): void
{
$serviceName = $this->option('service-name') ?? $this->ask('Queue worker service name', 'pelican-queue');
$path = '/etc/systemd/system/'.$serviceName.'.service';
$path = '/etc/systemd/system/' . $serviceName . '.service';
$fileExists = file_exists($path);
if ($fileExists && !$this->option('overwrite') && !$this->confirm('The service file already exists. Do you want to overwrite it?')) {
@ -65,7 +65,7 @@ WantedBy=multi-user.target
if ($fileExists) {
$result = Process::run("systemctl restart $serviceName.service");
if ($result->failed()) {
$this->error('Error restarting service: '.$result->errorOutput());
$this->error('Error restarting service: ' . $result->errorOutput());
return;
}
@ -74,7 +74,7 @@ WantedBy=multi-user.target
} else {
$result = Process::run("systemctl enable --now $serviceName.service");
if ($result->failed()) {
$this->error('Error enabling service: '.$result->errorOutput());
$this->error('Error enabling service: ' . $result->errorOutput());
return;
}

View File

@ -50,7 +50,7 @@ class PruneImagesCommand extends Command
$count = count($response['ImagesDeleted']);
$useBinaryPrefix = config('panel.use_binary_prefix');
$space = round($useBinaryPrefix ? $response['SpaceReclaimed'] / 1024 / 1024 : $response['SpaceReclaimed'] / 1000 / 1000, 2).($useBinaryPrefix ? ' MiB' : ' MB');
$space = round($useBinaryPrefix ? $response['SpaceReclaimed'] / 1024 / 1024 : $response['SpaceReclaimed'] / 1000 / 1000, 2) . ($useBinaryPrefix ? ' MiB' : ' MB');
$this->info("Node {$node->id}: Cleaned up {$count} dangling docker images. ({$space})");
} catch (Exception $exception) {

View File

@ -67,7 +67,7 @@ class ProcessRunnableCommand extends Command
} catch (\Throwable|\Exception $exception) {
logger()->error($exception, ['schedule_id' => $schedule->id]);
$this->error(__('commands.schedule.process.no_tasks')." #$schedule->id: ".$exception->getMessage());
$this->error(__('commands.schedule.process.no_tasks') . " #$schedule->id: " . $exception->getMessage());
}
}
}

View File

@ -40,7 +40,7 @@ class UpgradeCommand extends Command
}
if (version_compare(PHP_VERSION, '7.4.0') < 0) {
$this->error(__('commands.upgrade.php_version').' ['.PHP_VERSION.'].');
$this->error(__('commands.upgrade.php_version') . ' [' . PHP_VERSION . '].');
}
$user = 'www-data';
@ -125,7 +125,7 @@ class UpgradeCommand extends Command
$command[] = '--no-dev';
}
$this->line('$upgrader> '.implode(' ', $command));
$this->line('$upgrader> ' . implode(' ', $command));
$process = new Process($command);
$process->setTimeout(10 * 60);
$process->run(function ($type, $buffer) {
@ -134,7 +134,7 @@ class UpgradeCommand extends Command
});
/** @var \Illuminate\Foundation\Application $app */
$app = require __DIR__.'/../../../bootstrap/app.php';
$app = require __DIR__ . '/../../../bootstrap/app.php';
/** @var \App\Console\Kernel $kernel */
$kernel = $app->make(Kernel::class);
$kernel->bootstrap();
@ -192,6 +192,6 @@ class UpgradeCommand extends Command
return $this->option('url');
}
return sprintf(self::DEFAULT_URL, $this->option('release') ? 'download/v'.$this->option('release') : 'latest/download');
return sprintf(self::DEFAULT_URL, $this->option('release') ? 'download/v' . $this->option('release') : 'latest/download');
}
}

View File

@ -20,7 +20,7 @@ class Kernel extends ConsoleKernel
*/
protected function commands(): void
{
$this->load(__DIR__.'/Commands');
$this->load(__DIR__ . '/Commands');
}
/**

View File

@ -108,7 +108,7 @@ class Handler extends ExceptionHandler
$exception->getLine()
);
return $message."\nStack trace:\n".trim($cleanedStack);
return $message . "\nStack trace:\n" . trim($cleanedStack);
}
/**
@ -160,7 +160,7 @@ class Handler extends ExceptionHandler
'source_field' => $field,
'rule' => str_replace(self::PANEL_RULE_STRING, 'p_', Arr::get(
$codes,
str_replace('.', '_', $field).'.'.$key
str_replace('.', '_', $field) . '.' . $key
)),
];

View File

@ -74,7 +74,7 @@ class BackupManager
return $this->callCustomCreator($config);
}
$adapterMethod = 'create'.Str::studly($adapter).'Adapter';
$adapterMethod = 'create' . Str::studly($adapter) . 'Adapter';
if (method_exists($this, $adapterMethod)) {
$instance = $this->{$adapterMethod}($config);

View File

@ -21,7 +21,7 @@ class DynamicDatabaseConnection
$host = DatabaseHost::query()->findOrFail($host);
}
config()->set('database.connections.'.$connection, [
config()->set('database.connections.' . $connection, [
'driver' => self::DB_DRIVER,
'host' => $host->host,
'port' => $host->port,

View File

@ -6,16 +6,16 @@ class Theme
{
public function js($path): string
{
return sprintf('<script src="%s"></script>'.PHP_EOL, $this->getUrl($path));
return sprintf('<script src="%s"></script>' . PHP_EOL, $this->getUrl($path));
}
public function css($path): string
{
return sprintf('<link media="all" type="text/css" rel="stylesheet" href="%s"/>'.PHP_EOL, $this->getUrl($path));
return sprintf('<link media="all" type="text/css" rel="stylesheet" href="%s"/>' . PHP_EOL, $this->getUrl($path));
}
protected function getUrl($path): string
{
return '/themes/panel/'.ltrim($path, '/');
return '/themes/panel/' . ltrim($path, '/');
}
}

View File

@ -21,12 +21,12 @@ class CompletedStep
->label(new HtmlString('Run the following command to setup your crontab. Note that <code>www-data</code> is your webserver user. On some systems this username might be different!'))
->disabled()
->hintAction(CopyAction::make())
->default('(crontab -l -u www-data 2>/dev/null; echo "* * * * * php '.base_path().'/artisan schedule:run >> /dev/null 2>&1") | crontab -u www-data -'),
->default('(crontab -l -u www-data 2>/dev/null; echo "* * * * * php ' . base_path() . '/artisan schedule:run >> /dev/null 2>&1") | crontab -u www-data -'),
TextInput::make('queueService')
->label(new HtmlString('To setup the queue worker service you simply have to run the following command.'))
->disabled()
->hintAction(CopyAction::make())
->default('sudo php '.base_path().'/artisan p:environment:queue-service'),
->default('sudo php ' . base_path() . '/artisan p:environment:queue-service'),
Placeholder::make('')
->content('After you finished these two last tasks you can click on "Finish" and use your new panel! Have fun!'),
]);

View File

@ -18,12 +18,12 @@ class RequirementsStep
$fields = [
Section::make('PHP Version')
->description(self::MIN_PHP_VERSION.' or newer')
->description(self::MIN_PHP_VERSION . ' or newer')
->icon($correctPhpVersion ? 'tabler-check' : 'tabler-x')
->iconColor($correctPhpVersion ? 'success' : 'danger')
->schema([
Placeholder::make('')
->content('Your PHP Version is '.PHP_VERSION.'.'),
->content('Your PHP Version is ' . PHP_VERSION . '.'),
]),
];
@ -49,7 +49,7 @@ class RequirementsStep
->content('All needed PHP Extensions are installed.')
->visible($allExtensionsInstalled),
Placeholder::make('')
->content('The following PHP Extensions are missing: '.implode(', ', array_keys($phpExtensions, false)))
->content('The following PHP Extensions are missing: ' . implode(', ', array_keys($phpExtensions, false)))
->visible(!$allExtensionsInstalled),
]);
@ -68,7 +68,7 @@ class RequirementsStep
->content('All Folders have the correct permissions.')
->visible($correctFolderPermissions),
Placeholder::make('')
->content('The following Folders have wrong permissions: '.implode(', ', array_keys($folderPermissions, false)))
->content('The following Folders have wrong permissions: ' . implode(', ', array_keys($folderPermissions, false)))
->visible(!$correctFolderPermissions),
]);

View File

@ -24,7 +24,7 @@ class ListApiKeys extends ListRecords
TextColumn::make('key')
->copyable()
->icon('tabler-clipboard-text')
->state(fn (ApiKey $key) => $key->identifier.$key->token),
->state(fn (ApiKey $key) => $key->identifier . $key->token),
TextColumn::make('memo')
->label('Description')

View File

@ -37,7 +37,7 @@ class DatabasesRelationManager extends RelationManager
TextInput::make('JDBC')
->label('JDBC Connection String')
->columnSpanFull()
->formatStateUsing(fn (Get $get, Database $database) => 'jdbc:mysql://'.$get('username').':'.urlencode($database->password).'@'.$database->host->host.':'.$database->host->port.'/'.$get('database')),
->formatStateUsing(fn (Get $get, Database $database) => 'jdbc:mysql://' . $get('username') . ':' . urlencode($database->password) . '@' . $database->host->host . ':' . $database->host->port . '/' . $get('database')),
]);
}
@ -64,7 +64,7 @@ class DatabasesRelationManager extends RelationManager
protected function rotatePassword(DatabasePasswordService $service, Database $database, $set, $get): void
{
$newPassword = $service->handle($database);
$jdbcString = 'jdbc:mysql://'.$get('username').':'.urlencode($newPassword).'@'.$database->host->host.':'.$database->host->port.'/'.$get('database');
$jdbcString = 'jdbc:mysql://' . $get('username') . ':' . urlencode($newPassword) . '@' . $database->host->host . ':' . $database->host->port . '/' . $get('database');
$set('password', $newPassword);
$set('JDBC', $jdbcString);

View File

@ -249,7 +249,7 @@ class EditEgg extends EditRecord
->color('primary')
->action(fn (EggExporterService $service, Egg $egg) => response()->streamDownload(function () use ($service, $egg) {
echo $service->handle($egg->id);
}, 'egg-'.$egg->getKebabName().'.json'))
}, 'egg-' . $egg->getKebabName() . '.json'))
->authorize(fn () => auth()->user()->can('export egg')),
Actions\Action::make('importEgg')
->label('Import')

View File

@ -55,7 +55,7 @@ class ListEggs extends ListRecords
->color('primary')
->action(fn (EggExporterService $service, Egg $egg) => response()->streamDownload(function () use ($service, $egg) {
echo $service->handle($egg->id);
}, 'egg-'.$egg->getKebabName().'.json'))
}, 'egg-' . $egg->getKebabName() . '.json'))
->authorize(fn () => auth()->user()->can('export egg')),
Action::make('update')
->icon('tabler-cloud-download')

View File

@ -76,8 +76,8 @@ class NodeCpuChart extends ChartWidget
$threads = $node->systemInformation()['cpu_count'] ?? 0;
$cpu = Number::format(collect(cache()->get("nodes.$node->id.cpu_percent"))->last() * $threads, maxPrecision: 2, locale: auth()->user()->language);
$max = Number::format($threads * 100, locale: auth()->user()->language).'%';
$max = Number::format($threads * 100, locale: auth()->user()->language) . '%';
return 'CPU - '.$cpu.'% Of '.$max;
return 'CPU - ' . $cpu . '% Of ' . $max;
}
}

View File

@ -75,13 +75,13 @@ class NodeMemoryChart extends ChartWidget
$totalMemory = collect(cache()->get("nodes.$node->id.memory_total"))->last();
$used = config('panel.use_binary_prefix')
? Number::format($latestMemoryUsed / 1024 / 1024 / 1024, maxPrecision: 2, locale: auth()->user()->language).' GiB'
: Number::format($latestMemoryUsed / 1000 / 1000 / 1000, maxPrecision: 2, locale: auth()->user()->language).' GB';
? Number::format($latestMemoryUsed / 1024 / 1024 / 1024, maxPrecision: 2, locale: auth()->user()->language) .' GiB'
: Number::format($latestMemoryUsed / 1000 / 1000 / 1000, maxPrecision: 2, locale: auth()->user()->language) . ' GB';
$total = config('panel.use_binary_prefix')
? Number::format($totalMemory / 1024 / 1024 / 1024, maxPrecision: 2, locale: auth()->user()->language).' GiB'
: Number::format($totalMemory / 1000 / 1000 / 1000, maxPrecision: 2, locale: auth()->user()->language).' GB';
? Number::format($totalMemory / 1024 / 1024 / 1024, maxPrecision: 2, locale: auth()->user()->language) .' GiB'
: Number::format($totalMemory / 1000 / 1000 / 1000, maxPrecision: 2, locale: auth()->user()->language) . ' GB';
return 'Memory - '.$used.' Of '.$total;
return 'Memory - ' . $used . ' Of ' . $total;
}
}

View File

@ -40,12 +40,12 @@ class RoleResource extends Resource
$options = [];
foreach (RolePermissionPrefixes::cases() as $prefix) {
$options[$prefix->value.' '.strtolower($model->value)] = Str::headline($prefix->value);
$options[$prefix->value . ' ' . strtolower($model->value)] = Str::headline($prefix->value);
}
if (array_key_exists($model->value, Role::MODEL_SPECIFIC_PERMISSIONS)) {
foreach (Role::MODEL_SPECIFIC_PERMISSIONS[$model->value] as $permission) {
$options[$permission.' '.strtolower($model->value)] = Str::headline($permission);
$options[$permission . ' ' . strtolower($model->value)] = Str::headline($permission);
}
}
@ -56,7 +56,7 @@ class RoleResource extends Resource
$options = [];
foreach ($prefixes as $prefix) {
$options[$prefix.' '.strtolower($model)] = Str::headline($prefix);
$options[$prefix . ' ' . strtolower($model)] = Str::headline($prefix);
}
$permissions[] = self::makeSection($model, $options);
@ -88,10 +88,10 @@ class RoleResource extends Resource
{
$icon = null;
if (class_exists('\App\Filament\Resources\\'.$model.'Resource')) {
$icon = ('\App\Filament\Resources\\'.$model.'Resource')::getNavigationIcon();
} elseif (class_exists('\App\Filament\Pages\\'.$model)) {
$icon = ('\App\Filament\Pages\\'.$model)::getNavigationIcon();
if (class_exists('\App\Filament\Resources\\' . $model . 'Resource')) {
$icon = ('\App\Filament\Resources\\' . $model . 'Resource')::getNavigationIcon();
} elseif (class_exists('\App\Filament\Pages\\' . $model)) {
$icon = ('\App\Filament\Pages\\' . $model)::getNavigationIcon();
}
return Section::make(Str::headline(Str::plural($model)))
@ -101,11 +101,11 @@ class RoleResource extends Resource
->icon($icon)
->headerActions([
Action::make('count')
->label(fn (Get $get) => count($get(strtolower($model).'_list')))
->label(fn (Get $get) => count($get(strtolower($model) . '_list')))
->badge(),
])
->schema([
CheckboxList::make(strtolower($model).'_list')
CheckboxList::make(strtolower($model) . '_list')
->label('')
->options($options)
->columns()

View File

@ -70,14 +70,14 @@ class CreateServer extends CreateRecord
->prefixIcon('tabler-server')
->label('Name')
->suffixAction(Forms\Components\Actions\Action::make('random')
->icon('tabler-dice-'.random_int(1, 6))
->icon('tabler-dice-' . random_int(1, 6))
->action(function (Set $set, Get $get) {
$egg = Egg::find($get('egg_id'));
$prefix = $egg ? str($egg->name)->lower()->kebab().'-' : '';
$prefix = $egg ? str($egg->name)->lower()->kebab() . '-' : '';
$word = (new RandomWordService())->word();
$set('name', $prefix.$word);
$set('name', $prefix . $word);
}))
->columnSpan([
'default' => 2,
@ -101,7 +101,7 @@ class CreateServer extends CreateRecord
])
->relationship('user', 'username')
->searchable(['username', 'email'])
->getOptionLabelFromRecordUsing(fn (User $user) => "$user->email | $user->username ".($user->isRootAdmin() ? '(admin)' : ''))
->getOptionLabelFromRecordUsing(fn (User $user) => "$user->email | $user->username " . ($user->isRootAdmin() ? '(admin)' : ''))
->createOptionForm([
TextInput::make('username')
->alphaNum()
@ -163,7 +163,7 @@ class CreateServer extends CreateRecord
$set('allocation_additional.needstobeastringhere.extra_allocations', null);
})
->getOptionLabelFromRecordUsing(
fn (Allocation $allocation) => "$allocation->ip:$allocation->port".
fn (Allocation $allocation) => "$allocation->ip:$allocation->port" .
($allocation->ip_alias ? " ($allocation->ip_alias)" : '')
)
->placeholder(function (Get $get) {
@ -293,7 +293,7 @@ class CreateServer extends CreateRecord
->disabled(fn (Get $get) => $get('../../node_id') === null)
->searchable(['ip', 'port', 'ip_alias'])
->getOptionLabelFromRecordUsing(
fn (Allocation $allocation) => "$allocation->ip:$allocation->port".
fn (Allocation $allocation) => "$allocation->ip:$allocation->port" .
($allocation->ip_alias ? " ($allocation->ip_alias)" : '')
)
->placeholder('Select additional Allocations')
@ -498,7 +498,7 @@ class CreateServer extends CreateRecord
->hintIcon('tabler-code')
->label(fn (Get $get) => $get('name'))
->hintIconTooltip(fn (Get $get) => implode('|', $get('rules')))
->prefix(fn (Get $get) => '{{'.$get('env_variable').'}}')
->prefix(fn (Get $get) => '{{' . $get('env_variable') . '}}')
->helperText(fn (Get $get) => empty($get('description')) ? '—' : $get('description'))
->afterStateUpdated(function (Set $set, Get $get, $state) {
$environment = $get($envPath = '../../environment');
@ -846,7 +846,7 @@ class CreateServer extends CreateRecord
return !$containsRuleIn;
}
throw new Exception('Component type not supported: '.$component::class);
throw new Exception('Component type not supported: ' . $component::class);
}
private function getSelectOptionsFromRules(Get $get): array

View File

@ -66,14 +66,14 @@ class EditServer extends EditRecord
->prefixIcon('tabler-server')
->label('Display Name')
->suffixAction(Action::make('random')
->icon('tabler-dice-'.random_int(1, 6))
->icon('tabler-dice-' . random_int(1, 6))
->action(function (Set $set, Get $get) {
$egg = Egg::find($get('egg_id'));
$prefix = $egg ? str($egg->name)->lower()->kebab().'-' : '';
$prefix = $egg ? str($egg->name)->lower()->kebab() . '-' : '';
$word = (new RandomWordService())->word();
$set('name', $prefix.$word);
$set('name', $prefix . $word);
}))
->columnSpan([
'default' => 2,
@ -541,7 +541,7 @@ class EditServer extends EditRecord
->hintIcon('tabler-code')
->label(fn (ServerVariable $serverVariable) => $serverVariable->variable->name)
->hintIconTooltip(fn (ServerVariable $serverVariable) => implode('|', $serverVariable->variable->rules))
->prefix(fn (ServerVariable $serverVariable) => '{{'.$serverVariable->variable->env_variable.'}}')
->prefix(fn (ServerVariable $serverVariable) => '{{' . $serverVariable->variable->env_variable . '}}')
->helperText(fn (ServerVariable $serverVariable) => empty($serverVariable->variable->description) ? '—' : $serverVariable->variable->description);
}
@ -606,7 +606,7 @@ class EditServer extends EditRecord
->disabled()
->label('JDBC Connection String')
->columnSpan(2)
->formatStateUsing(fn (Get $get, $record) => 'jdbc:mysql://'.$get('username').':'.urlencode($record->password).'@'.$record->host->host.':'.$record->host->port.'/'.$get('database')),
->formatStateUsing(fn (Get $get, $record) => 'jdbc:mysql://' . $get('username') . ':' . urlencode($record->password) . '@' . $record->host->host . ':' . $record->host->port . '/' . $get('database')),
])
->relationship('databases')
->deletable(false)
@ -800,7 +800,7 @@ class EditServer extends EditRecord
return $containsRuleIn;
}
throw new Exception('Component type not supported: '.$component::class);
throw new Exception('Component type not supported: ' . $component::class);
}
private function getSelectOptionsFromRules(ServerVariable $serverVariable): array
@ -818,7 +818,7 @@ class EditServer extends EditRecord
protected function rotatePassword(DatabasePasswordService $service, $record, $set, $get): void
{
$newPassword = $service->handle($record);
$jdbcString = 'jdbc:mysql://'.$get('username').':'.urlencode($newPassword).'@'.$record->host->host.':'.$record->host->port.'/'.$get('database');
$jdbcString = 'jdbc:mysql://' . $get('username') . ':' . urlencode($newPassword) . '@' . $record->host->host . ':' . $record->host->port . '/' . $get('database');
$set('password', $newPassword);
$set('JDBC', $jdbcString);

View File

@ -178,7 +178,7 @@ class EditProfile extends \Filament\Pages\Auth\EditProfile
->content(fn () => new HtmlString("
<div style='width: 300px; background-color: rgb(24, 24, 27);'>$image</div>
"))
->helperText('Setup Key: '.$secret),
->helperText('Setup Key: '. $secret),
TextInput::make('2facode')
->label('Code')
->requiredWith('2fapassword')

View File

@ -33,7 +33,7 @@ class ListUsers extends ListRecords
->visibleFrom('lg')
->label('')
->extraImgAttributes(['class' => 'rounded-full'])
->defaultImageUrl(fn (User $user) => 'https://gravatar.com/avatar/'.md5(strtolower($user->email))),
->defaultImageUrl(fn (User $user) => 'https://gravatar.com/avatar/' . md5(strtolower($user->email))),
TextColumn::make('external_id')
->searchable()
->hidden(),
@ -55,7 +55,7 @@ class ListUsers extends ListRecords
->counts('roles')
->icon('tabler-users-group')
->label('Roles')
->formatStateUsing(fn (User $user, $state) => $state.($user->isRootAdmin() ? ' (Root Admin)' : '')),
->formatStateUsing(fn (User $user, $state) => $state . ($user->isRootAdmin() ? ' (Root Admin)' : '')),
TextColumn::make('servers_count')
->counts('servers')
->icon('tabler-server')

View File

@ -30,7 +30,7 @@ class EggShareController extends Controller
return response($this->exporterService->handle($egg->id), 200, [
'Content-Transfer-Encoding' => 'binary',
'Content-Description' => 'File Transfer',
'Content-Disposition' => 'attachment; filename=egg-'.$filename.'.json',
'Content-Disposition' => 'attachment; filename=egg-' . $filename . '.json',
'Content-Type' => 'application/json',
]);
}

View File

@ -56,7 +56,7 @@ class NodeAutoDeployController extends Controller
return new JsonResponse([
'node' => $node->id,
'token' => $key->identifier.$key->token,
'token' => $key->identifier . $key->token,
]);
}
}

View File

@ -67,6 +67,6 @@ class CreateServerController extends Controller
$this->alert->success(trans('admin/server.alerts.server_created'))->flash();
return new RedirectResponse('/admin/servers/view/'.$server->id);
return new RedirectResponse('/admin/servers/view/' . $server->id);
}
}

View File

@ -115,7 +115,7 @@ class ServersController extends Controller
{
$this->suspensionService->toggle($server, $request->input('action'));
$this->alert->success(trans('admin/server.alerts.suspension_toggled', [
'status' => $request->input('action').'ed',
'status' => $request->input('action') . 'ed',
]))->flash();
return redirect()->route('admin.servers.view.manage', $server->id);

View File

@ -83,7 +83,7 @@ class FileController extends ClientApiController
'file_path' => rawurldecode($request->get('file')),
'server_uuid' => $server->uuid,
])
->handle($server->node, $request->user()->id.$server->uuid);
->handle($server->node, $request->user()->id . $server->uuid);
Activity::event('server:file.download')->property('file', $request->get('file'))->log();

View File

@ -43,7 +43,7 @@ class FileUploadController extends ClientApiController
->setExpiresAt(CarbonImmutable::now()->addMinutes(15))
->setUser($user)
->setClaims(['server_uuid' => $server->uuid])
->handle($server->node, $user->id.$server->uuid);
->handle($server->node, $user->id . $server->uuid);
return sprintf(
'%s/upload/file?token=%s',

View File

@ -59,14 +59,14 @@ class WebsocketController extends ClientApiController
'server_uuid' => $server->uuid,
'permissions' => $permissions,
])
->handle($node, $user->id.$server->uuid);
->handle($node, $user->id . $server->uuid);
$socket = str_replace(['https://', 'http://'], ['wss://', 'ws://'], $node->getConnectionAddress());
return new JsonResponse([
'data' => [
'token' => $token->toString(),
'socket' => $socket.sprintf('/api/servers/%s/ws', $server->uuid),
'socket' => $socket . sprintf('/api/servers/%s/ws', $server->uuid),
],
]);
}

View File

@ -64,7 +64,7 @@ class BackupStatusController extends Controller
// deleted easily. Also does not make sense to have a locked backup on the system
// that is failed.
'is_locked' => $successful ? $model->is_locked : false,
'checksum' => $successful ? ($request->input('checksum_type').':'.$request->input('checksum')) : null,
'checksum' => $successful ? ($request->input('checksum_type') . ':' . $request->input('checksum')) : null,
'bytes' => $successful ? $request->input('size') : 0,
'completed_at' => CarbonImmutable::now(),
])->save();

View File

@ -160,6 +160,6 @@ class SftpAuthenticationController extends Controller
{
$username = explode('.', strrev($request->input('username', '')));
return strtolower(strrev($username[0] ?? '').'|'.$request->ip());
return strtolower(strrev($username[0] ?? '') . '|' . $request->ip());
}
}

View File

@ -48,7 +48,7 @@ class OAuthController extends Controller
}
try {
$user = User::query()->whereJsonContains('oauth->'.$driver, $oauthUser->getId())->firstOrFail();
$user = User::query()->whereJsonContains('oauth->'. $driver, $oauthUser->getId())->firstOrFail();
$this->auth->guard()->login($user, true);
} catch (Exception $e) {

View File

@ -43,6 +43,6 @@ class AuthenticateIPAccess
->property('identifier', $token->identifier)
->log();
throw new AccessDeniedHttpException('This IP address ('.$request->ip().') does not have permission to access the API using these credentials.');
throw new AccessDeniedHttpException('This IP address (' . $request->ip() . ') does not have permission to access the API using these credentials.');
}
}

View File

@ -80,7 +80,7 @@ class ResourceBelongsToServer
default:
// Don't return a 404 here since we want to make sure no one relies
// on this middleware in a context in which it will not work. Fail safe.
throw new \InvalidArgumentException('There is no handler configured for a resource of this type: '.get_class($model));
throw new \InvalidArgumentException('There is no handler configured for a resource of this type: ' . get_class($model));
}
}

View File

@ -18,7 +18,7 @@ class IsValidJson
try {
json_decode($request->getContent(), true, 512, JSON_THROW_ON_ERROR);
} catch (\JsonException $exception) {
throw new BadRequestHttpException('The JSON data passed in the request appears to be malformed: '.$exception->getMessage());
throw new BadRequestHttpException('The JSON data passed in the request appears to be malformed: ' . $exception->getMessage());
}
}

View File

@ -38,7 +38,7 @@ class RequireTwoFactorAuthentication
public function handle(Request $request, \Closure $next): mixed
{
$user = $request->user();
$uri = rtrim($request->getRequestUri(), '/').'/';
$uri = rtrim($request->getRequestUri(), '/') . '/';
$current = $request->route()->getName();
if (!$user || Str::startsWith($uri, ['/auth/']) || Str::startsWith($current, ['auth.', 'account.'])) {

View File

@ -17,7 +17,7 @@ class StoreApplicationApiKeyRequest extends AdminFormRequest
$modelRules = ApiKey::getRules();
return collect(AdminAcl::getResourceList())->mapWithKeys(function ($resource) use ($modelRules) {
return [AdminAcl::COLUMN_IDENTIFIER.$resource => $modelRules['r_'.$resource]];
return [AdminAcl::COLUMN_IDENTIFIER . $resource => $modelRules['r_' . $resource]];
})->merge(['memo' => $modelRules['memo']])->toArray();
}

View File

@ -15,7 +15,7 @@ class EggVariableFormRequest extends AdminFormRequest
return [
'name' => 'required|string|min:1|max:255',
'description' => 'sometimes|nullable|string',
'env_variable' => 'required|regex:/^[\w]{1,255}$/|notIn:'.EggVariable::RESERVED_ENV_NAMES,
'env_variable' => 'required|regex:/^[\w]{1,255}$/|notIn:' . EggVariable::RESERVED_ENV_NAMES,
'options' => 'sometimes|required|array',
'rules' => 'bail|required|string',
'default_value' => 'present',

View File

@ -39,7 +39,7 @@ class StoreApiKeyRequest extends ClientApiRequest
throw $exception;
}
} finally {
$validator->errors()->addIf(!$valid, "allowed_ips.{$index}", '"'.$ip.'" is not a valid IP address or CIDR range.');
$validator->errors()->addIf(!$valid, "allowed_ips.{$index}", '"' . $ip . '" is not a valid IP address or CIDR range.');
}
}
});

View File

@ -73,7 +73,7 @@ class RunTaskJob extends Job implements ShouldQueue
$deleteFilesService->handle($server, explode(PHP_EOL, $this->task->payload));
break;
default:
throw new \InvalidArgumentException('Invalid task action provided: '.$this->task->action);
throw new \InvalidArgumentException('Invalid task action provided: ' . $this->task->action);
}
} catch (\Exception $exception) {
// If this isn't a DaemonConnectionException on a task that allows for failures

View File

@ -110,14 +110,14 @@ class ApiKey extends Model
'memo',
'last_used_at',
'expires_at',
'r_'.AdminAcl::RESOURCE_USERS,
'r_'.AdminAcl::RESOURCE_ALLOCATIONS,
'r_'.AdminAcl::RESOURCE_DATABASE_HOSTS,
'r_'.AdminAcl::RESOURCE_SERVER_DATABASES,
'r_'.AdminAcl::RESOURCE_EGGS,
'r_'.AdminAcl::RESOURCE_NODES,
'r_'.AdminAcl::RESOURCE_SERVERS,
'r_'.AdminAcl::RESOURCE_MOUNTS,
'r_' . AdminAcl::RESOURCE_USERS,
'r_' . AdminAcl::RESOURCE_ALLOCATIONS,
'r_' . AdminAcl::RESOURCE_DATABASE_HOSTS,
'r_' . AdminAcl::RESOURCE_SERVER_DATABASES,
'r_' . AdminAcl::RESOURCE_EGGS,
'r_' . AdminAcl::RESOURCE_NODES,
'r_' . AdminAcl::RESOURCE_SERVERS,
'r_' . AdminAcl::RESOURCE_MOUNTS,
];
/**
@ -146,14 +146,14 @@ class ApiKey extends Model
'allowed_ips.*' => 'string',
'last_used_at' => 'nullable|date',
'expires_at' => 'nullable|date',
'r_'.AdminAcl::RESOURCE_USERS => 'integer|min:0|max:3',
'r_'.AdminAcl::RESOURCE_ALLOCATIONS => 'integer|min:0|max:3',
'r_'.AdminAcl::RESOURCE_DATABASE_HOSTS => 'integer|min:0|max:3',
'r_'.AdminAcl::RESOURCE_SERVER_DATABASES => 'integer|min:0|max:3',
'r_'.AdminAcl::RESOURCE_EGGS => 'integer|min:0|max:3',
'r_'.AdminAcl::RESOURCE_NODES => 'integer|min:0|max:3',
'r_'.AdminAcl::RESOURCE_SERVERS => 'integer|min:0|max:3',
'r_'.AdminAcl::RESOURCE_MOUNTS => 'integer|min:0|max:3',
'r_' . AdminAcl::RESOURCE_USERS => 'integer|min:0|max:3',
'r_' . AdminAcl::RESOURCE_ALLOCATIONS => 'integer|min:0|max:3',
'r_' . AdminAcl::RESOURCE_DATABASE_HOSTS => 'integer|min:0|max:3',
'r_' . AdminAcl::RESOURCE_SERVER_DATABASES => 'integer|min:0|max:3',
'r_' . AdminAcl::RESOURCE_EGGS => 'integer|min:0|max:3',
'r_' . AdminAcl::RESOURCE_NODES => 'integer|min:0|max:3',
'r_' . AdminAcl::RESOURCE_SERVERS => 'integer|min:0|max:3',
'r_' . AdminAcl::RESOURCE_MOUNTS => 'integer|min:0|max:3',
];
protected function casts(): array
@ -166,14 +166,14 @@ class ApiKey extends Model
'token' => 'encrypted',
self::CREATED_AT => 'datetime',
self::UPDATED_AT => 'datetime',
'r_'.AdminAcl::RESOURCE_USERS => 'int',
'r_'.AdminAcl::RESOURCE_ALLOCATIONS => 'int',
'r_'.AdminAcl::RESOURCE_DATABASE_HOSTS => 'int',
'r_'.AdminAcl::RESOURCE_SERVER_DATABASES => 'int',
'r_'.AdminAcl::RESOURCE_EGGS => 'int',
'r_'.AdminAcl::RESOURCE_NODES => 'int',
'r_'.AdminAcl::RESOURCE_SERVERS => 'int',
'r_'.AdminAcl::RESOURCE_MOUNTS => 'int',
'r_' . AdminAcl::RESOURCE_USERS => 'int',
'r_' . AdminAcl::RESOURCE_ALLOCATIONS => 'int',
'r_' . AdminAcl::RESOURCE_DATABASE_HOSTS => 'int',
'r_' . AdminAcl::RESOURCE_SERVER_DATABASES => 'int',
'r_' . AdminAcl::RESOURCE_EGGS => 'int',
'r_' . AdminAcl::RESOURCE_NODES => 'int',
'r_' . AdminAcl::RESOURCE_SERVERS => 'int',
'r_' . AdminAcl::RESOURCE_MOUNTS => 'int',
];
}
@ -227,6 +227,6 @@ class ApiKey extends Model
{
$prefix = self::getPrefixForType($type);
return $prefix.Str::random(self::IDENTIFIER_LENGTH - strlen($prefix));
return $prefix . Str::random(self::IDENTIFIER_LENGTH - strlen($prefix));
}
}

View File

@ -54,7 +54,7 @@ class EggVariable extends Model
'sort' => 'nullable',
'name' => 'required|string|between:1,255',
'description' => 'string',
'env_variable' => 'required|alphaDash|between:1,255|notIn:'.self::RESERVED_ENV_NAMES,
'env_variable' => 'required|alphaDash|between:1,255|notIn:' . self::RESERVED_ENV_NAMES,
'default_value' => 'string',
'user_viewable' => 'boolean',
'user_editable' => 'boolean',

View File

@ -48,7 +48,7 @@ class MultiFieldServerFilter implements Filter
},
// Otherwise, just try to search for that specific port in the allocations.
function (Builder $builder) use ($value) {
$builder->orWhere('allocations.port', 'LIKE', substr($value, 1).'%');
$builder->orWhere('allocations.port', 'LIKE', substr($value, 1) . '%');
}
);
})

View File

@ -184,8 +184,8 @@ class Node extends Model
'port' => $this->daemon_listen,
'ssl' => [
'enabled' => (!$this->behind_proxy && $this->scheme === 'https'),
'cert' => '/etc/letsencrypt/live/'.Str::lower($this->fqdn).'/fullchain.pem',
'key' => '/etc/letsencrypt/live/'.Str::lower($this->fqdn).'/privkey.pem',
'cert' => '/etc/letsencrypt/live/' . Str::lower($this->fqdn) . '/fullchain.pem',
'key' => '/etc/letsencrypt/live/' . Str::lower($this->fqdn) . '/privkey.pem',
],
'upload_limit' => $this->upload_size,
],

View File

@ -259,7 +259,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
*/
public function getNameAttribute(): string
{
return trim($this->name_first.' '.$this->name_last);
return trim($this->name_first . ' ' . $this->name_last);
}
/**
@ -379,7 +379,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
public function getFilamentAvatarUrl(): ?string
{
return 'https://gravatar.com/avatar/'.md5(strtolower($this->email));
return 'https://gravatar.com/avatar/' . md5(strtolower($this->email));
}
public function canTarget(IlluminateModel $user): bool

View File

@ -33,13 +33,13 @@ class AccountCreated extends Notification implements ShouldQueue
public function toMail(): MailMessage
{
$message = (new MailMessage())
->greeting('Hello '.$this->user->name.'!')
->line('You are receiving this email because an account has been created for you on '.config('app.name').'.')
->line('Username: '.$this->user->username)
->line('Email: '.$this->user->email);
->greeting('Hello ' . $this->user->name . '!')
->line('You are receiving this email because an account has been created for you on ' . config('app.name') . '.')
->line('Username: ' . $this->user->username)
->line('Email: ' . $this->user->email);
if (!is_null($this->token)) {
return $message->action('Setup Your Account', url('/auth/password/reset/'.$this->token.'?email='.urlencode($this->user->email)));
return $message->action('Setup Your Account', url('/auth/password/reset/' . $this->token . '?email=' . urlencode($this->user->email)));
}
return $message;

View File

@ -35,9 +35,9 @@ class AddedToServer extends Notification implements ShouldQueue
public function toMail(): MailMessage
{
return (new MailMessage())
->greeting('Hello '.$this->server->user.'!')
->greeting('Hello ' . $this->server->user . '!')
->line('You have been added as a subuser for the following server, allowing you certain control over the server.')
->line('Server Name: '.$this->server->name)
->action('Visit Server', url('/server/'.$this->server->uuid_short));
->line('Server Name: ' . $this->server->name)
->action('Visit Server', url('/server/' . $this->server->uuid_short));
}
}

View File

@ -21,7 +21,7 @@ class MailTested extends Notification
{
return (new MailMessage())
->subject('Panel Test Message')
->greeting('Hello '.$this->user->name.'!')
->greeting('Hello ' . $this->user->name . '!')
->line('This is a test of the Panel mail system. You\'re good to go!');
}
}

View File

@ -36,9 +36,9 @@ class RemovedFromServer extends Notification implements ShouldQueue
{
return (new MailMessage())
->error()
->greeting('Hello '.$this->server->user.'.')
->greeting('Hello ' . $this->server->user . '.')
->line('You have been removed as a subuser for the following server.')
->line('Server Name: '.$this->server->name)
->line('Server Name: ' . $this->server->name)
->action('Visit Panel', route('index'));
}
}

View File

@ -34,7 +34,7 @@ class SendPasswordReset extends Notification implements ShouldQueue
return (new MailMessage())
->subject('Reset Password')
->line('You are receiving this email because we received a password reset request for your account.')
->action('Reset Password', url('/auth/password/reset/'.$this->token.'?email='.urlencode($notifiable->email)))
->action('Reset Password', url('/auth/password/reset/' . $this->token . '?email=' . urlencode($notifiable->email)))
->line('If you did not request a password reset, no further action is required.');
}
}

View File

@ -51,9 +51,9 @@ class ServerInstalled extends Notification implements ShouldQueue
public function toMail(): MailMessage
{
return (new MailMessage())
->greeting('Hello '.$this->user->username.'.')
->greeting('Hello ' . $this->user->username . '.')
->line('Your server has finished installing and is now ready for you to use.')
->line('Server Name: '.$this->server->name)
->line('Server Name: ' . $this->server->name)
->action('Login and Begin Using', route('index'));
}
}

View File

@ -12,7 +12,7 @@ trait DefaultPolicies
*/
public function viewAny(User $user): bool
{
return $user->can('viewList '.$this->modelName);
return $user->can('viewList ' . $this->modelName);
}
/**
@ -20,7 +20,7 @@ trait DefaultPolicies
*/
public function view(User $user, Model $model): bool
{
return $user->can('view '.$this->modelName, $model);
return $user->can('view ' . $this->modelName, $model);
}
/**
@ -28,7 +28,7 @@ trait DefaultPolicies
*/
public function create(User $user): bool
{
return $user->can('create '.$this->modelName);
return $user->can('create ' . $this->modelName);
}
/**
@ -36,7 +36,7 @@ trait DefaultPolicies
*/
public function update(User $user, Model $model): bool
{
return $user->can('update '.$this->modelName, $model);
return $user->can('update ' . $this->modelName, $model);
}
/**
@ -44,6 +44,6 @@ trait DefaultPolicies
*/
public function delete(User $user, Model $model): bool
{
return $user->can('delete '.$this->modelName, $model);
return $user->can('delete ' . $this->modelName, $model);
}
}

View File

@ -19,7 +19,7 @@ class DaemonConfigurationRepository extends DaemonRepository
$response = $this
->getHttpClient()
->connectTimeout($connectTimeout)
->get('/api/system'.(!is_null($version) ? '?v='.$version : ''));
->get('/api/system' . (!is_null($version) ? '?v=' . $version : ''));
} catch (TransferException $exception) {
throw new DaemonConnectionException($exception);
}

View File

@ -96,7 +96,7 @@ class DaemonServerRepository extends DaemonRepository
Assert::isInstanceOf($this->server, Server::class);
try {
$this->getHttpClient()->delete('/api/servers/'.$this->server->uuid);
$this->getHttpClient()->delete('/api/servers/' . $this->server->uuid);
} catch (TransferException $exception) {
throw new DaemonConnectionException($exception);
}
@ -192,7 +192,7 @@ class DaemonServerRepository extends DaemonRepository
{
Assert::isInstanceOf($this->server, Server::class);
$this->revokeJTIs([md5($id.$this->server->uuid)]);
$this->revokeJTIs([md5($id . $this->server->uuid)]);
}
/**

View File

@ -62,7 +62,7 @@ class AdminAcl
*/
public static function check(ApiKey $key, string $resource, int $action = self::READ): bool
{
return self::can(data_get($key, self::COLUMN_IDENTIFIER.$resource, self::NONE), $action);
return self::can(data_get($key, self::COLUMN_IDENTIFIER . $resource, self::NONE), $action);
}
/**

View File

@ -34,7 +34,7 @@ class DownloadLinkService
'backup_uuid' => $backup->uuid,
'server_uuid' => $backup->server->uuid,
])
->handle($backup->server->node, $user->id.$backup->server->uuid);
->handle($backup->server->node, $user->id . $backup->server->uuid);
return sprintf('%s/download/backup?token=%s', $backup->server->node->getConnectionAddress(), $token->toString());
}

View File

@ -30,7 +30,7 @@ class DeleteFilesService
$pattern = basename($line);
collect($this->daemonFileRepository->setServer($server)->getDirectory($path))->each(function ($item) use ($path, $pattern, $filesToDelete) {
if (Str::is($pattern, $item['name'])) {
$filesToDelete->push($path.'/'.$item['name']);
$filesToDelete->push($path . '/' . $item['name']);
}
});
}

View File

@ -70,7 +70,7 @@ class AssetHashService
$output .= " $key=\"$value\"";
}
return $output.'>';
return $output . '>';
}
/**
@ -92,7 +92,7 @@ class AssetHashService
$output .= " $key=\"$value\"";
}
return $output.'></script>';
return $output . '></script>';
}
/**

View File

@ -127,13 +127,13 @@ class SoftwareVersionService
$head = explode(' ', file_get_contents(base_path('.git/HEAD')));
if (array_key_exists(1, $head)) {
$path = base_path('.git/'.trim($head[1]));
$path = base_path('.git/' . trim($head[1]));
}
}
if (isset($path) && file_exists($path)) {
return [
'version' => 'canary ('.substr(file_get_contents($path), 0, 8).')',
'version' => 'canary (' . substr(file_get_contents($path), 0, 8) . ')',
'is_git' => true,
];
}

View File

@ -15,7 +15,7 @@ class StartupCommandService
$replace = [$server->memory, $server->allocation->ip, $server->allocation->port];
foreach ($server->variables as $variable) {
$find[] = '{{'.$variable->env_variable.'}}';
$find[] = '{{' . $variable->env_variable . '}}';
$replace[] = ($variable->user_viewable && !$hideAllValues) ? ($variable->server_value ?? $variable->default_value) : '[hidden]';
}

View File

@ -31,8 +31,8 @@ class TransferServerService
Http::daemon($server->node)->post('/api/transfer', [
'json' => [
'server_id' => $server->uuid,
'url' => $server->node->getConnectionAddress()."/api/servers/$server->uuid/archive",
'token' => 'Bearer '.$token->toString(),
'url' => $server->node->getConnectionAddress() . "/api/servers/$server->uuid/archive",
'token' => 'Bearer ' . $token->toString(),
'server' => [
'uuid' => $server->uuid,
'start_on_completion' => false,

View File

@ -40,8 +40,8 @@ class VariableValidatorService
$data = $rules = $customAttributes = [];
foreach ($variables as $variable) {
$data['environment'][$variable->env_variable] = array_get($fields, $variable->env_variable);
$rules['environment.'.$variable->env_variable] = $variable->rules;
$customAttributes['environment.'.$variable->env_variable] = trans('validation.internal.variable_value', ['env' => $variable->name]);
$rules['environment.' . $variable->env_variable] = $variable->rules;
$customAttributes['environment.' . $variable->env_variable] = trans('validation.internal.variable_value', ['env' => $variable->name]);
}
$validator = $this->validator->make($data, $rules, [], $customAttributes);

View File

@ -39,7 +39,7 @@ class SubuserCreationService
if (!$user) {
// Just cap the username generated at 64 characters at most and then append a random string
// to the end to make it "unique"...
$username = substr(preg_replace('/([^\w\.-]+)/', '', strtok($email, '@')), 0, 64).Str::random(3);
$username = substr(preg_replace('/([^\w\.-]+)/', '', strtok($email, '@')), 0, 64) . Str::random(3);
$user = $this->userCreationService->handle([
'email' => $email,

View File

@ -37,10 +37,10 @@ trait EnvironmentWriterTrait
$key = strtoupper($key);
$saveValue = sprintf('%s=%s', $key, $this->escapeEnvironmentValue($value ?? ''));
if (preg_match_all('/^'.$key.'=(.*)$/m', $saveContents) < 1) {
$saveContents = $saveContents.PHP_EOL.$saveValue;
if (preg_match_all('/^' . $key . '=(.*)$/m', $saveContents) < 1) {
$saveContents = $saveContents . PHP_EOL . $saveValue;
} else {
$saveContents = preg_replace('/^'.$key.'=(.*)$/m', $saveValue, $saveContents);
$saveContents = preg_replace('/^' . $key . '=(.*)$/m', $saveValue, $saveContents);
}
});

View File

@ -62,7 +62,7 @@ class ActivityLogTransformer extends BaseClientTransformer
if (!is_array($value)) {
// Perform some directory normalization at this point.
if ($key === 'directory') {
$value = str_replace('//', '/', '/'.trim($value, '/').'/');
$value = str_replace('//', '/', '/' . trim($value, '/') . '/');
}
return [$key => $value];
@ -94,7 +94,7 @@ class ActivityLogTransformer extends BaseClientTransformer
return false;
}
$str = trans('activity.'.str_replace(':', '.', $model->event));
$str = trans('activity.' . str_replace(':', '.', $model->event));
preg_match_all('/:(?<key>[\w.-]+\w)(?:[^\w:]?|$)/', $str, $matches);
$exclude = array_merge($matches['key'], ['ip', 'useragent', 'using_sftp']);

View File

@ -28,7 +28,7 @@ class UserTransformer extends BaseClientTransformer
'first_name' => $user->name_first,
'last_name' => $user->name_last,
'language' => $user->language,
'image' => 'https://gravatar.com/avatar/'.md5(Str::lower($user->email)), // deprecated
'image' => 'https://gravatar.com/avatar/' . md5(Str::lower($user->email)), // deprecated
'admin' => $user->isRootAdmin(), // deprecated, use "root_admin"
'root_admin' => $user->isRootAdmin(),
'2fa_enabled' => (bool) $user->use_totp,

View File

@ -5,9 +5,9 @@ use NunoMaduro\Collision\Provider;
use Illuminate\Contracts\Console\Kernel;
use Symfony\Component\Console\Output\ConsoleOutput;
require __DIR__.'/../vendor/autoload.php';
require __DIR__ . '/../vendor/autoload.php';
$app = require __DIR__.'/app.php';
$app = require __DIR__ . '/app.php';
/** @var \App\Console\Kernel $kernel */
$kernel = $app->make(Kernel::class);
@ -23,10 +23,10 @@ $kernel->bootstrap();
$output = new ConsoleOutput();
$prefix = 'database.connections.'.config('database.default');
$prefix = 'database.connections.' . config('database.default');
if (!Str::contains(config("$prefix.database"), 'test')) {
$output->writeln(PHP_EOL.'<error>Cannot run test process against non-testing database.</error>');
$output->writeln(PHP_EOL.'<error>Environment is currently pointed at: "'.config("$prefix.database").'".</error>');
$output->writeln(PHP_EOL . '<error>Cannot run test process against non-testing database.</error>');
$output->writeln(PHP_EOL . '<error>Environment is currently pointed at: "' . config("$prefix.database") . '".</error>');
exit(1);
}
@ -35,11 +35,11 @@ if (!Str::contains(config("$prefix.database"), 'test')) {
* running the tests.
*/
if (!env('SKIP_MIGRATIONS')) {
$output->writeln(PHP_EOL.'<info>Refreshing database for Integration tests...</info>');
$output->writeln(PHP_EOL . '<info>Refreshing database for Integration tests...</info>');
$kernel->call('migrate:fresh');
$output->writeln('<info>Seeding database for Integration tests...</info>'.PHP_EOL);
$output->writeln('<info>Seeding database for Integration tests...</info>' . PHP_EOL);
$kernel->call('db:seed');
} else {
$output->writeln(PHP_EOL.'<comment>Skipping database migrations...</comment>'.PHP_EOL);
$output->writeln(PHP_EOL . '<comment>Skipping database migrations...</comment>' . PHP_EOL);
}

View File

@ -24,7 +24,7 @@ class NodeFactory extends Factory
return [
'uuid' => Uuid::uuid4()->toString(),
'public' => true,
'name' => 'FactoryNode_'.Str::random(10),
'name' => 'FactoryNode_' . Str::random(10),
'fqdn' => $this->faker->unique()->ipv4(),
'scheme' => 'http',
'behind_proxy' => false,

View File

@ -27,8 +27,8 @@ class UserFactory extends Factory
return [
'external_id' => null,
'uuid' => Uuid::uuid4()->toString(),
'username' => $this->faker->userName().'_'.Str::random(10),
'email' => Str::random(32).'@example.com',
'username' => $this->faker->userName() . '_' . Str::random(10),
'email' => Str::random(32) . '@example.com',
'name_first' => $this->faker->firstName(),
'name_last' => $this->faker->lastName(),
'password' => $password ?: $password = bcrypt('password'),

View File

@ -47,9 +47,9 @@ class EggSeeder extends Seeder
*/
protected function parseEggFiles($name)
{
$files = new \DirectoryIterator(database_path('Seeders/eggs/'.kebab_case($name)));
$files = new \DirectoryIterator(database_path('Seeders/eggs/' . kebab_case($name)));
$this->command->alert('Updating Eggs for: '.$name);
$this->command->alert('Updating Eggs for: ' . $name);
/** @var \DirectoryIterator $file */
foreach ($files as $file) {
if (!$file->isFile() || !$file->isReadable()) {
@ -71,10 +71,10 @@ class EggSeeder extends Seeder
if ($egg instanceof Egg) {
$this->importerService->fromFile($file, $egg);
$this->command->info('Updated '.$decoded['name']);
$this->command->info('Updated ' . $decoded['name']);
} else {
$this->importerService->fromFile($file);
$this->command->comment('Created '.$decoded['name']);
$this->command->comment('Created ' . $decoded['name']);
}
}

View File

@ -17,7 +17,7 @@ return new class extends Migration
DB::transaction(function () {
foreach (DB::table('service_variables')->get() as $variable) {
$variable->rules = ($variable->required) ? 'required|regex:'.$variable->rules : 'regex:'.$variable->rules;
$variable->rules = ($variable->required) ? 'required|regex:' . $variable->rules : 'regex:' . $variable->rules;
$variable->save();
}
});

View File

@ -17,7 +17,7 @@ return new class extends Migration
continue;
}
$newPermission = $parts[0].'-'.str_replace('task', 'schedule', $parts[1]);
$newPermission = $parts[0] . '-' . str_replace('task', 'schedule', $parts[1]);
DB::table('permissions')->where('id', '=', $record->id)->update(['permission' => $newPermission]);
}
@ -35,7 +35,7 @@ return new class extends Migration
continue;
}
$newPermission = $parts[0].'-'.str_replace('schedule', 'task', $parts[1]);
$newPermission = $parts[0] . '-' . str_replace('schedule', 'task', $parts[1]);
DB::table('permissions')->where('id', '=', $record->id)->update(['permission' => $newPermission]);
}

View File

@ -21,7 +21,7 @@ return new class extends Migration
$inserts[] = [
'user_id' => $server->owner_id,
'server_id' => $server->id,
'secret' => DaemonKeyRepositoryInterface::INTERNAL_KEY_IDENTIFIER.str_random(40),
'secret' => DaemonKeyRepositoryInterface::INTERNAL_KEY_IDENTIFIER . str_random(40),
'expires_at' => Carbon::now()->addMinutes(config('panel.api.key_expire_time', 720))->toDateTimeString(),
'created_at' => Carbon::now()->toDateTimeString(),
'updated_at' => Carbon::now()->toDateTimeString(),

View File

@ -19,7 +19,7 @@ return new class extends Migration
$inserts[] = [
'user_id' => $subuser->user_id,
'server_id' => $subuser->server_id,
'secret' => DaemonKeyRepositoryInterface::INTERNAL_KEY_IDENTIFIER.str_random(40),
'secret' => DaemonKeyRepositoryInterface::INTERNAL_KEY_IDENTIFIER . str_random(40),
'expires_at' => Carbon::now()->addMinutes(config('panel.api.key_expire_time', 720))->toDateTimeString(),
'created_at' => Carbon::now()->toDateTimeString(),
'updated_at' => Carbon::now()->toDateTimeString(),

View File

@ -112,9 +112,9 @@ return new class extends Migration
}
if (!empty($values)) {
$string = 'VALUES '.implode(', ', array_fill(0, count($values) / 2, '(?, ?)'));
$string = 'VALUES ' . implode(', ', array_fill(0, count($values) / 2, '(?, ?)'));
DB::insert('INSERT INTO permissions(`subuser_id`, `permission`) '.$string, $values);
DB::insert('INSERT INTO permissions(`subuser_id`, `permission`) ' . $string, $values);
}
}

View File

@ -53,7 +53,7 @@ return new class extends Migration
DB::transaction(function () {
foreach (DB::select('SELECT id, daemon_token_id, daemon_token FROM nodes') as $datum) {
DB::update('UPDATE nodes SET daemon_token = ? WHERE id = ?', [
$datum->daemon_token_id.decrypt($datum->daemon_token),
$datum->daemon_token_id . decrypt($datum->daemon_token),
$datum->id,
]);
}

View File

@ -1,6 +1,7 @@
{
"preset": "laravel",
"rules": {
"concat_space": false,
"not_operator_with_successor_space": false,
"ordered_imports": false
}

View File

@ -35,7 +35,7 @@ trait AssertsActivityLogged
public function assertActivitySubjects(string $event, Model|array $subjects): void
{
if (is_array($subjects)) {
\Webmozart\Assert\Assert::lessThanEq(count(func_get_args()), 2, 'Invalid call to '.__METHOD__.': cannot provide additional arguments if providing an array.');
\Webmozart\Assert\Assert::lessThanEq(count(func_get_args()), 2, 'Invalid call to ' . __METHOD__ . ': cannot provide additional arguments if providing an array.');
} else {
$subjects = array_slice(func_get_args(), 1);
}

View File

@ -11,7 +11,7 @@ trait MiddlewareAttributeAssertionsTrait
*/
public function assertRequestHasAttribute(string $attribute): void
{
Assert::assertTrue($this->request->attributes->has($attribute), 'Assert that request mock has '.$attribute.' attribute.');
Assert::assertTrue($this->request->attributes->has($attribute), 'Assert that request mock has ' . $attribute . ' attribute.');
}
/**
@ -19,7 +19,7 @@ trait MiddlewareAttributeAssertionsTrait
*/
public function assertRequestMissingAttribute(string $attribute): void
{
Assert::assertFalse($this->request->attributes->has($attribute), 'Assert that request mock does not have '.$attribute.' attribute.');
Assert::assertFalse($this->request->attributes->has($attribute), 'Assert that request mock does not have ' . $attribute . ' attribute.');
}
/**

View File

@ -38,7 +38,7 @@ abstract class ApplicationApiIntegrationTestCase extends IntegrationTestCase
$this
->withHeader('Accept', 'application/vnd.panel.v1+json')
->withHeader('Authorization', 'Bearer '.$this->key->identifier.$this->key->token);
->withHeader('Authorization', 'Bearer ' . $this->key->identifier . $this->key->token);
}
public function getApiUser(): User
@ -58,7 +58,7 @@ abstract class ApplicationApiIntegrationTestCase extends IntegrationTestCase
{
$this->key = $this->createApiKey($user, $permissions);
$this->withHeader('Authorization', 'Bearer '.$this->key->identifier.$this->key->token);
$this->withHeader('Authorization', 'Bearer ' . $this->key->identifier . $this->key->token);
return $this->key;
}

View File

@ -48,7 +48,7 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase
$this->assertSame(
$expected,
$actual,
'Unable to find JSON fragment: '.PHP_EOL.PHP_EOL."[$expected]".PHP_EOL.PHP_EOL.'within'.PHP_EOL.PHP_EOL."[$actual]."
'Unable to find JSON fragment: ' . PHP_EOL . PHP_EOL . "[$expected]" . PHP_EOL . PHP_EOL . 'within' . PHP_EOL . PHP_EOL . "[$actual]."
);
}
}
@ -60,7 +60,7 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase
{
$egg = Egg::query()->findOrFail(1);
$response = $this->getJson('/api/application/eggs/'.$egg->id);
$response = $this->getJson('/api/application/eggs/' . $egg->id);
$response->assertStatus(Response::HTTP_OK);
$response->assertJsonStructure([
'object',
@ -82,7 +82,7 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase
{
$egg = Egg::query()->findOrFail(1);
$response = $this->getJson('/api/application/eggs/'.$egg->id.'?include=servers,variables');
$response = $this->getJson('/api/application/eggs/' . $egg->id . '?include=servers,variables');
$response->assertStatus(Response::HTTP_OK);
$response->assertJsonStructure([
'object',

View File

@ -16,7 +16,7 @@ class ExternalUserControllerTest extends ApplicationApiIntegrationTestCase
{
$user = User::factory()->create(['external_id' => Str::random()]);
$response = $this->getJson('/api/application/users/external/'.$user->external_id);
$response = $this->getJson('/api/application/users/external/' . $user->external_id);
$response->assertStatus(Response::HTTP_OK);
$response->assertJsonCount(2);
$response->assertJsonStructure([
@ -64,7 +64,7 @@ class ExternalUserControllerTest extends ApplicationApiIntegrationTestCase
$user = User::factory()->create(['external_id' => Str::random()]);
$this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => 0]);
$response = $this->getJson('/api/application/users/external/'.$user->external_id);
$response = $this->getJson('/api/application/users/external/' . $user->external_id);
$this->assertAccessDeniedJson($response);
}
}

View File

@ -89,7 +89,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
{
$user = User::factory()->create();
$response = $this->getJson('/api/application/users/'.$user->id);
$response = $this->getJson('/api/application/users/' . $user->id);
$response->assertStatus(Response::HTTP_OK);
$response->assertJsonCount(2);
$response->assertJsonStructure([
@ -124,7 +124,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
$user = User::factory()->create();
$server = $this->createServerModel(['user_id' => $user->id]);
$response = $this->getJson('/api/application/users/'.$user->id.'?include=servers');
$response = $this->getJson('/api/application/users/' . $user->id . '?include=servers');
$response->assertStatus(Response::HTTP_OK);
$response->assertJsonCount(2);
$response->assertJsonStructure([
@ -157,7 +157,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
$user = User::factory()->create();
$this->createServerModel(['user_id' => $user->id]);
$response = $this->getJson('/api/application/users/'.$user->id.'?include=servers');
$response = $this->getJson('/api/application/users/' . $user->id . '?include=servers');
$response->assertStatus(Response::HTTP_OK);
$response->assertJsonCount(2)->assertJsonCount(1, 'attributes.relationships');
$response->assertJsonStructure([
@ -199,7 +199,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
$user = User::factory()->create();
$this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => 0]);
$response = $this->getJson('/api/application/users/'.$user->id);
$response = $this->getJson('/api/application/users/' . $user->id);
$this->assertAccessDeniedJson($response);
}
@ -242,7 +242,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
{
$user = User::factory()->create();
$response = $this->patchJson('/api/application/users/'.$user->id, [
$response = $this->patchJson('/api/application/users/' . $user->id, [
'username' => 'new.test.name',
'email' => 'new@emailtest.com',
'first_name' => $user->name_first,
@ -272,7 +272,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
$user = User::factory()->create();
$this->assertDatabaseHas('users', ['id' => $user->id]);
$response = $this->delete('/api/application/users/'.$user->id);
$response = $this->delete('/api/application/users/' . $user->id);
$response->assertStatus(Response::HTTP_NO_CONTENT);
$this->assertDatabaseMissing('users', ['id' => $user->id]);

View File

@ -28,7 +28,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase
'first_name' => $user->name_first,
'last_name' => $user->name_last,
'language' => 'en',
'image' => 'https://gravatar.com/avatar/'.md5(Str::lower($user->email)),
'image' => 'https://gravatar.com/avatar/' . md5(Str::lower($user->email)),
'admin' => false,
'root_admin' => false,
'2fa_enabled' => false,
@ -47,7 +47,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase
$user = User::factory()->create();
$response = $this->actingAs($user)->putJson('/api/client/account/email', [
'email' => $email = Str::random().'@example.com',
'email' => $email = Str::random() . '@example.com',
'password' => 'password',
]);

View File

@ -83,7 +83,7 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase
{
$ips = [];
for ($i = 0; $i < 100; $i++) {
$ips[] = '127.0.0.'.$i;
$ips[] = '127.0.0.' . $i;
}
$this->actingAs(User::factory()->create())
@ -162,7 +162,7 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase
'key_type' => ApiKey::TYPE_ACCOUNT,
]);
$response = $this->actingAs($user)->delete('/api/client/account/api-keys/'.$key->identifier);
$response = $this->actingAs($user)->delete('/api/client/account/api-keys/' . $key->identifier);
$response->assertStatus(Response::HTTP_NO_CONTENT);
$this->assertDatabaseMissing('api_keys', ['id' => $key->id]);
@ -205,7 +205,7 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase
]);
$this->actingAs($user)
->deleteJson('/api/client/account/api-keys/'.$key->identifier)
->deleteJson('/api/client/account/api-keys/' . $key->identifier)
->assertNotFound();
$this->assertDatabaseHas('api_keys', ['id' => $key->id]);
@ -226,7 +226,7 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase
]);
$this->actingAs($user)
->deleteJson('/api/client/account/api-keys/'.$key->identifier)
->deleteJson('/api/client/account/api-keys/' . $key->identifier)
->assertNotFound();
$this->assertDatabaseHas('api_keys', ['id' => $key->id]);

View File

@ -69,7 +69,7 @@ abstract class ClientApiIntegrationTestCase extends IntegrationTestCase
throw new \InvalidArgumentException(sprintf('Cannot create link for Model of type %s', class_basename($model)));
}
return $link.($append ? '/'.ltrim($append, '/') : '');
return $link . ($append ? '/' . ltrim($append, '/') : '');
}
/**

View File

@ -298,7 +298,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase
$this->createServerModel(['user_id' => $users[1]->id]);
$this->createServerModel(['user_id' => $users[2]->id]);
$response = $this->actingAs($users[0])->getJson('/api/client?type='.$type);
$response = $this->actingAs($users[0])->getJson('/api/client?type=' . $type);
$response->assertOk();
$response->assertJsonCount(0, 'data');

View File

@ -30,20 +30,20 @@ class AllocationAuthorizationTest extends ClientApiIntegrationTestCase
// This is the only valid call for this test, accessing the allocation for the same
// server that the API user is the owner of.
$response = $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/'.$allocation1->id.$endpoint));
$response = $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/' . $allocation1->id . $endpoint));
$this->assertTrue($response->status() <= 204 || $response->status() === 400 || $response->status() === 422);
// This request fails because the allocation is valid for that server but the user
// making the request is not authorized to perform that action.
$this->actingAs($user)->json($method, $this->link($server2, '/network/allocations/'.$allocation2->id.$endpoint))->assertForbidden();
$this->actingAs($user)->json($method, $this->link($server2, '/network/allocations/' . $allocation2->id . $endpoint))->assertForbidden();
// Both of these should report a 404 error due to the allocations being linked to
// servers that are not the same as the server in the request, or are assigned
// to a server for which the user making the request has no access to.
$this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/'.$allocation2->id.$endpoint))->assertNotFound();
$this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/'.$allocation3->id.$endpoint))->assertNotFound();
$this->actingAs($user)->json($method, $this->link($server2, '/network/allocations/'.$allocation3->id.$endpoint))->assertNotFound();
$this->actingAs($user)->json($method, $this->link($server3, '/network/allocations/'.$allocation3->id.$endpoint))->assertNotFound();
$this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/' . $allocation2->id . $endpoint))->assertNotFound();
$this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/' . $allocation3->id . $endpoint))->assertNotFound();
$this->actingAs($user)->json($method, $this->link($server2, '/network/allocations/' . $allocation3->id . $endpoint))->assertNotFound();
$this->actingAs($user)->json($method, $this->link($server3, '/network/allocations/' . $allocation3->id . $endpoint))->assertNotFound();
}
public static function methodDataProvider(): array

View File

@ -38,20 +38,20 @@ class BackupAuthorizationTest extends ClientApiIntegrationTestCase
// This is the only valid call for this test, accessing the backup for the same
// server that the API user is the owner of.
$this->actingAs($user)->json($method, $this->link($server1, '/backups/'.$backup1->uuid.$endpoint))
$this->actingAs($user)->json($method, $this->link($server1, '/backups/' . $backup1->uuid . $endpoint))
->assertStatus($method === 'DELETE' ? 204 : 200);
// This request fails because the backup is valid for that server but the user
// making the request is not authorized to perform that action.
$this->actingAs($user)->json($method, $this->link($server2, '/backups/'.$backup2->uuid.$endpoint))->assertForbidden();
$this->actingAs($user)->json($method, $this->link($server2, '/backups/' . $backup2->uuid . $endpoint))->assertForbidden();
// Both of these should report a 404 error due to the backup being linked to
// servers that are not the same as the server in the request, or are assigned
// to a server for which the user making the request has no access to.
$this->actingAs($user)->json($method, $this->link($server1, '/backups/'.$backup2->uuid.$endpoint))->assertNotFound();
$this->actingAs($user)->json($method, $this->link($server1, '/backups/'.$backup3->uuid.$endpoint))->assertNotFound();
$this->actingAs($user)->json($method, $this->link($server2, '/backups/'.$backup3->uuid.$endpoint))->assertNotFound();
$this->actingAs($user)->json($method, $this->link($server3, '/backups/'.$backup3->uuid.$endpoint))->assertNotFound();
$this->actingAs($user)->json($method, $this->link($server1, '/backups/' . $backup2->uuid . $endpoint))->assertNotFound();
$this->actingAs($user)->json($method, $this->link($server1, '/backups/' . $backup3->uuid . $endpoint))->assertNotFound();
$this->actingAs($user)->json($method, $this->link($server2, '/backups/' . $backup3->uuid . $endpoint))->assertNotFound();
$this->actingAs($user)->json($method, $this->link($server3, '/backups/' . $backup3->uuid . $endpoint))->assertNotFound();
}
public static function methodDataProvider(): array

View File

@ -40,20 +40,20 @@ class DatabaseAuthorizationTest extends ClientApiIntegrationTestCase
// This is the only valid call for this test, accessing the database for the same
// server that the API user is the owner of.
$this->actingAs($user)->json($method, $this->link($server1, '/databases/'.$database1->id.$endpoint))
$this->actingAs($user)->json($method, $this->link($server1, '/databases/' . $database1->id . $endpoint))
->assertStatus($method === 'DELETE' ? 204 : 200);
// This request fails because the database is valid for that server but the user
// making the request is not authorized to perform that action.
$this->actingAs($user)->json($method, $this->link($server2, '/databases/'.$database2->id.$endpoint))->assertForbidden();
$this->actingAs($user)->json($method, $this->link($server2, '/databases/' . $database2->id . $endpoint))->assertForbidden();
// Both of these should report a 404 error due to the database being linked to
// servers that are not the same as the server in the request, or are assigned
// to a server for which the user making the request has no access to.
$this->actingAs($user)->json($method, $this->link($server1, '/databases/'.$database2->id.$endpoint))->assertNotFound();
$this->actingAs($user)->json($method, $this->link($server1, '/databases/'.$database3->id.$endpoint))->assertNotFound();
$this->actingAs($user)->json($method, $this->link($server2, '/databases/'.$database3->id.$endpoint))->assertNotFound();
$this->actingAs($user)->json($method, $this->link($server3, '/databases/'.$database3->id.$endpoint))->assertNotFound();
$this->actingAs($user)->json($method, $this->link($server1, '/databases/' . $database2->id . $endpoint))->assertNotFound();
$this->actingAs($user)->json($method, $this->link($server1, '/databases/' . $database3->id . $endpoint))->assertNotFound();
$this->actingAs($user)->json($method, $this->link($server2, '/databases/' . $database3->id . $endpoint))->assertNotFound();
$this->actingAs($user)->json($method, $this->link($server3, '/databases/' . $database3->id . $endpoint))->assertNotFound();
}
public static function methodDataProvider(): array

View File

@ -47,13 +47,13 @@ class GetServerSchedulesTest extends ClientApiIntegrationTestCase
$response->assertJsonCount(1, 'data');
}
$response->assertJsonCount(1, $prefix.'attributes.relationships.tasks.data');
$response->assertJsonCount(1, $prefix . 'attributes.relationships.tasks.data');
$response->assertJsonPath($prefix.'object', Schedule::RESOURCE_NAME);
$response->assertJsonPath($prefix.'attributes.relationships.tasks.data.0.object', Task::RESOURCE_NAME);
$response->assertJsonPath($prefix . 'object', Schedule::RESOURCE_NAME);
$response->assertJsonPath($prefix . 'attributes.relationships.tasks.data.0.object', Task::RESOURCE_NAME);
$this->assertJsonTransformedWith($response->json($prefix.'attributes'), $schedule);
$this->assertJsonTransformedWith($response->json($prefix.'attributes.relationships.tasks.data.0.attributes'), $task);
$this->assertJsonTransformedWith($response->json($prefix . 'attributes'), $schedule);
$this->assertJsonTransformedWith($response->json($prefix . 'attributes.relationships.tasks.data.0.attributes'), $task);
}
/**

View File

@ -38,20 +38,20 @@ class ScheduleAuthorizationTest extends ClientApiIntegrationTestCase
// This is the only valid call for this test, accessing the schedule for the same
// server that the API user is the owner of.
$response = $this->actingAs($user)->json($method, $this->link($server1, '/schedules/'.$schedule1->id.$endpoint));
$response = $this->actingAs($user)->json($method, $this->link($server1, '/schedules/' . $schedule1->id . $endpoint));
$this->assertTrue($response->status() <= 204 || $response->status() === 400 || $response->status() === 422);
// This request fails because the schedule is valid for that server but the user
// making the request is not authorized to perform that action.
$this->actingAs($user)->json($method, $this->link($server2, '/schedules/'.$schedule2->id.$endpoint))->assertForbidden();
$this->actingAs($user)->json($method, $this->link($server2, '/schedules/' . $schedule2->id . $endpoint))->assertForbidden();
// Both of these should report a 404 error due to the schedules being linked to
// servers that are not the same as the server in the request, or are assigned
// to a server for which the user making the request has no access to.
$this->actingAs($user)->json($method, $this->link($server1, '/schedules/'.$schedule2->id.$endpoint))->assertNotFound();
$this->actingAs($user)->json($method, $this->link($server1, '/schedules/'.$schedule3->id.$endpoint))->assertNotFound();
$this->actingAs($user)->json($method, $this->link($server2, '/schedules/'.$schedule3->id.$endpoint))->assertNotFound();
$this->actingAs($user)->json($method, $this->link($server3, '/schedules/'.$schedule3->id.$endpoint))->assertNotFound();
$this->actingAs($user)->json($method, $this->link($server1, '/schedules/' . $schedule2->id . $endpoint))->assertNotFound();
$this->actingAs($user)->json($method, $this->link($server1, '/schedules/' . $schedule3->id . $endpoint))->assertNotFound();
$this->actingAs($user)->json($method, $this->link($server2, '/schedules/' . $schedule3->id . $endpoint))->assertNotFound();
$this->actingAs($user)->json($method, $this->link($server3, '/schedules/' . $schedule3->id . $endpoint))->assertNotFound();
}
public static function methodDataProvider(): array

View File

@ -33,7 +33,7 @@ class GetStartupAndVariablesTest extends ClientApiIntegrationTestCase
])->save();
$server = $server->refresh();
$response = $this->actingAs($user)->getJson($this->link($server).'/startup');
$response = $this->actingAs($user)->getJson($this->link($server) . '/startup');
$response->assertOk();
$response->assertJsonPath('meta.startup_command', 'java bungeecord.jar --version [hidden]');
@ -52,10 +52,10 @@ class GetStartupAndVariablesTest extends ClientApiIntegrationTestCase
public function testStartupDataIsNotReturnedWithoutPermission(): void
{
[$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]);
$this->actingAs($user)->getJson($this->link($server).'/startup')->assertForbidden();
$this->actingAs($user)->getJson($this->link($server) . '/startup')->assertForbidden();
$user2 = User::factory()->create();
$this->actingAs($user2)->getJson($this->link($server).'/startup')->assertNotFound();
$this->actingAs($user2)->getJson($this->link($server) . '/startup')->assertNotFound();
}
public static function permissionsDataProvider(): array

View File

@ -23,7 +23,7 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase
'startup' => 'java {{SERVER_JARFILE}} --version {{BUNGEE_VERSION}}',
])->save();
$response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', [
$response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [
'key' => 'BUNGEE_VERSION',
'value' => '1.2.3',
]);
@ -32,7 +32,7 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase
$response->assertJsonPath('errors.0.code', 'ValidationException');
$response->assertJsonPath('errors.0.detail', 'The value may only contain letters and numbers.');
$response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', [
$response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [
'key' => 'BUNGEE_VERSION',
'value' => '123',
]);
@ -62,7 +62,7 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase
$server->fill(['egg_id' => $egg->id])->save();
$server->refresh();
$response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', [
$response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [
'key' => 'BUNGEE_VERSION',
'value' => '123',
]);
@ -71,7 +71,7 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase
$response->assertJsonPath('errors.0.code', 'BadRequestHttpException');
$response->assertJsonPath('errors.0.detail', 'The environment variable you are trying to edit does not exist.');
$response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', [
$response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [
'key' => 'SERVER_JARFILE',
'value' => 'server2.jar',
]);
@ -100,7 +100,7 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase
$server->refresh();
$response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', [
$response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [
'key' => 'SERVER_JARFILE',
'value' => 'server2.jar',
]);
@ -125,7 +125,7 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase
$server->fill(['egg_id' => $egg->id])->save();
$server->refresh();
$response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', [
$response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [
'key' => 'BUNGEE_VERSION',
'value' => '',
]);
@ -141,10 +141,10 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase
public function testStartupVariableCannotBeUpdatedIfNotUserViewable(): void
{
[$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]);
$this->actingAs($user)->putJson($this->link($server).'/startup/variable')->assertForbidden();
$this->actingAs($user)->putJson($this->link($server) . '/startup/variable')->assertForbidden();
$user2 = User::factory()->create();
$this->actingAs($user2)->putJson($this->link($server).'/startup/variable')->assertNotFound();
$this->actingAs($user2)->putJson($this->link($server) . '/startup/variable')->assertNotFound();
}
public static function permissionsDataProvider(): array

View File

@ -23,7 +23,7 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase
{
[$user, $server] = $this->generateTestAccount($permissions);
$response = $this->actingAs($user)->postJson($this->link($server).'/users', [
$response = $this->actingAs($user)->postJson($this->link($server) . '/users', [
'email' => $email = $this->faker->email(),
'permissions' => [
Permission::ACTION_USER_CREATE,
@ -60,7 +60,7 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase
Permission::ACTION_CONTROL_CONSOLE,
]);
$response = $this->actingAs($user)->postJson($this->link($server).'/users', [
$response = $this->actingAs($user)->postJson($this->link($server) . '/users', [
'email' => $this->faker->email(),
'permissions' => [
Permission::ACTION_USER_CREATE,
@ -80,9 +80,9 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase
{
[$user, $server] = $this->generateTestAccount();
$email = str_repeat(Str::random(35), 7).'@gmail.com'; // 255 is the hard limit for the column in MySQL.
$email = str_repeat(Str::random(35), 7) . '@gmail.com'; // 255 is the hard limit for the column in MySQL.
$response = $this->actingAs($user)->postJson($this->link($server).'/users', [
$response = $this->actingAs($user)->postJson($this->link($server) . '/users', [
'email' => $email,
'permissions' => [
Permission::ACTION_USER_CREATE,
@ -91,8 +91,8 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase
$response->assertOk();
$response = $this->actingAs($user)->postJson($this->link($server).'/users', [
'email' => $email.'.au',
$response = $this->actingAs($user)->postJson($this->link($server) . '/users', [
'email' => $email . '.au',
'permissions' => [
Permission::ACTION_USER_CREATE,
],
@ -114,7 +114,7 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase
/** @var \App\Models\User $existing */
$existing = User::factory()->create(['email' => $this->faker->email()]);
$response = $this->actingAs($user)->postJson($this->link($server).'/users', [
$response = $this->actingAs($user)->postJson($this->link($server) . '/users', [
'email' => $existing->email,
'permissions' => [
Permission::ACTION_USER_CREATE,
@ -134,7 +134,7 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase
{
[$user, $server] = $this->generateTestAccount();
$response = $this->actingAs($user)->postJson($this->link($server).'/users', [
$response = $this->actingAs($user)->postJson($this->link($server) . '/users', [
'email' => $email = $this->faker->email(),
'permissions' => [
Permission::ACTION_USER_CREATE,
@ -143,7 +143,7 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase
$response->assertOk();
$response = $this->actingAs($user)->postJson($this->link($server).'/users', [
$response = $this->actingAs($user)->postJson($this->link($server) . '/users', [
'email' => $email,
'permissions' => [
Permission::ACTION_USER_CREATE,

View File

@ -31,7 +31,7 @@ class DeleteSubuserTest extends ClientApiIntegrationTestCase
$real = Uuid::uuid4()->toString();
// Generate a UUID that lines up with a user in the database if it were to be cast to an int.
$uuid = $differentUser->id.substr($real, strlen((string) $differentUser->id));
$uuid = $differentUser->id . substr($real, strlen((string) $differentUser->id));
/** @var \App\Models\User $subuser */
$subuser = User::factory()->create(['uuid' => $uuid]);
@ -44,11 +44,11 @@ class DeleteSubuserTest extends ClientApiIntegrationTestCase
$mock->expects('setServer->revokeUserJTI')->with($subuser->id)->andReturnUndefined();
$this->actingAs($user)->deleteJson($this->link($server)."/users/$subuser->uuid")->assertNoContent();
$this->actingAs($user)->deleteJson($this->link($server) . "/users/$subuser->uuid")->assertNoContent();
// Try the same test, but this time with a UUID that if cast to an int (shouldn't) line up with
// anything in the database.
$uuid = '18180000'.substr(Uuid::uuid4()->toString(), 8);
$uuid = '18180000' . substr(Uuid::uuid4()->toString(), 8);
/** @var \App\Models\User $subuser */
$subuser = User::factory()->create(['uuid' => $uuid]);
@ -60,6 +60,6 @@ class DeleteSubuserTest extends ClientApiIntegrationTestCase
$mock->expects('setServer->revokeUserJTI')->with($subuser->id)->andReturnUndefined();
$this->actingAs($user)->deleteJson($this->link($server)."/users/$subuser->uuid")->assertNoContent();
$this->actingAs($user)->deleteJson($this->link($server) . "/users/$subuser->uuid")->assertNoContent();
}
}

View File

@ -41,12 +41,12 @@ class SubuserAuthorizationTest extends ClientApiIntegrationTestCase
}
// This route is acceptable since they're accessing a subuser on their own server.
$this->actingAs($user)->json($method, $this->link($server1, '/users/'.$internal->uuid))->assertStatus($method === 'POST' ? 422 : ($method === 'DELETE' ? 204 : 200));
$this->actingAs($user)->json($method, $this->link($server1, '/users/' . $internal->uuid))->assertStatus($method === 'POST' ? 422 : ($method === 'DELETE' ? 204 : 200));
// This route can be revealed since the subuser belongs to the correct server, but
// errors out with a 403 since $user does not have the right permissions for this.
$this->actingAs($user)->json($method, $this->link($server2, '/users/'.$internal->uuid))->assertForbidden();
$this->actingAs($user)->json($method, $this->link($server3, '/users/'.$internal->uuid))->assertNotFound();
$this->actingAs($user)->json($method, $this->link($server2, '/users/' . $internal->uuid))->assertForbidden();
$this->actingAs($user)->json($method, $this->link($server3, '/users/' . $internal->uuid))->assertNotFound();
}
public static function methodDataProvider(): array

View File

@ -69,7 +69,7 @@ class DaemonAuthenticateTest extends MiddlewareTestCase
$this->expectException(AccessDeniedHttpException::class);
$this->request->expects('route->getName')->withNoArgs()->andReturn('random.route');
$this->request->expects('bearerToken')->withNoArgs()->andReturn($node->daemon_token_id.'.random_string_123');
$this->request->expects('bearerToken')->withNoArgs()->andReturn($node->daemon_token_id . '.random_string_123');
$this->getMiddleware()->handle($this->request, $this->getClosureAssertions());
}
@ -98,7 +98,7 @@ class DaemonAuthenticateTest extends MiddlewareTestCase
$node->save();
$this->request->expects('route->getName')->withNoArgs()->andReturn('random.route');
$this->request->expects('bearerToken')->withNoArgs()->andReturn($node->daemon_token_id.'.the_same');
$this->request->expects('bearerToken')->withNoArgs()->andReturn($node->daemon_token_id . '.the_same');
$this->getMiddleware()->handle($this->request, $this->getClosureAssertions());
$this->assertRequestHasAttribute('node');

Some files were not shown because too many files have changed in this diff Show More