Merge branch '1.0-develop' into develop

This commit is contained in:
Matthew Penner 2023-02-23 12:36:22 -07:00
commit 18f6611a2d
No known key found for this signature in database
60 changed files with 181 additions and 152 deletions

View file

@ -18,7 +18,7 @@ class Kernel extends ConsoleKernel
/** /**
* Register the commands for the application. * Register the commands for the application.
*/ */
protected function commands() protected function commands(): void
{ {
$this->load(__DIR__ . '/Commands'); $this->load(__DIR__ . '/Commands');
} }
@ -26,8 +26,11 @@ class Kernel extends ConsoleKernel
/** /**
* Define the application's command schedule. * Define the application's command schedule.
*/ */
protected function schedule(Schedule $schedule) protected function schedule(Schedule $schedule): void
{ {
// https://laravel.com/docs/10.x/upgrade#redis-cache-tags
$schedule->command('cache:prune-stale-tags')->hourly();
// Execute scheduled commands for servers every minute, as if there was a normal cron running. // Execute scheduled commands for servers every minute, as if there was a normal cron running.
$schedule->command(ProcessRunnableCommand::class)->everyMinute()->withoutOverlapping(); $schedule->command(ProcessRunnableCommand::class)->everyMinute()->withoutOverlapping();
$schedule->command(CleanServiceBackupFilesCommand::class)->daily(); $schedule->command(CleanServiceBackupFilesCommand::class)->daily();

View file

@ -73,7 +73,7 @@ final class Handler extends ExceptionHandler
* *
* @noinspection PhpUnusedLocalVariableInspection * @noinspection PhpUnusedLocalVariableInspection
*/ */
public function register() public function register(): void
{ {
if (config('app.exceptions.report_all', false)) { if (config('app.exceptions.report_all', false)) {
$this->dontReport = []; $this->dontReport = [];

View file

@ -18,6 +18,7 @@ use Pterodactyl\Transformers\Api\Client\BackupTransformer;
use Pterodactyl\Http\Controllers\Api\Client\ClientApiController; use Pterodactyl\Http\Controllers\Api\Client\ClientApiController;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Pterodactyl\Http\Requests\Api\Client\Servers\Backups\StoreBackupRequest; use Pterodactyl\Http\Requests\Api\Client\Servers\Backups\StoreBackupRequest;
use Pterodactyl\Http\Requests\Api\Client\Servers\Backups\RestoreBackupRequest;
class BackupController extends ClientApiController class BackupController extends ClientApiController
{ {
@ -188,12 +189,8 @@ class BackupController extends ClientApiController
* *
* @throws \Throwable * @throws \Throwable
*/ */
public function restore(Request $request, Server $server, Backup $backup): JsonResponse public function restore(RestoreBackupRequest $request, Server $server, Backup $backup): JsonResponse
{ {
if (!$request->user()->can(Permission::ACTION_BACKUP_RESTORE, $server)) {
throw new AuthorizationException();
}
// Cannot restore a backup unless a server is fully installed and not currently // Cannot restore a backup unless a server is fully installed and not currently
// processing a different backup restoration request. // processing a different backup restoration request.
if (!is_null($server->status)) { if (!is_null($server->status)) {

View file

@ -86,7 +86,7 @@ class Kernel extends HttpKernel
/** /**
* The application's route middleware. * The application's route middleware.
*/ */
protected $routeMiddleware = [ protected $middlewareAliases = [
'auth' => Authenticate::class, 'auth' => Authenticate::class,
'auth.basic' => AuthenticateWithBasicAuth::class, 'auth.basic' => AuthenticateWithBasicAuth::class,
'auth.session' => AuthenticateSession::class, 'auth.session' => AuthenticateSession::class,

View file

@ -0,0 +1,19 @@
<?php
namespace Pterodactyl\Http\Requests\Api\Client\Servers\Backups;
use Pterodactyl\Models\Permission;
use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest;
class RestoreBackupRequest extends ClientApiRequest
{
public function permission(): string
{
return Permission::ACTION_BACKUP_RESTORE;
}
public function rules(): array
{
return ['truncate' => 'required|boolean'];
}
}

View file

@ -18,6 +18,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
* @property array|null $allowed_ips * @property array|null $allowed_ips
* @property string|null $memo * @property string|null $memo
* @property \Illuminate\Support\Carbon|null $last_used_at * @property \Illuminate\Support\Carbon|null $last_used_at
* @property \Illuminate\Support\Carbon|null $expires_at
* @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at * @property \Illuminate\Support\Carbon|null $updated_at
* @property int $r_servers * @property int $r_servers
@ -97,6 +98,10 @@ class ApiKey extends Model
protected $casts = [ protected $casts = [
'allowed_ips' => 'array', 'allowed_ips' => 'array',
'user_id' => 'int', 'user_id' => 'int',
'last_used_at' => 'datetime',
'expires_at' => 'datetime',
self::CREATED_AT => 'datetime',
self::UPDATED_AT => 'datetime',
'r_' . AdminAcl::RESOURCE_USERS => 'int', 'r_' . AdminAcl::RESOURCE_USERS => 'int',
'r_' . AdminAcl::RESOURCE_ALLOCATIONS => 'int', 'r_' . AdminAcl::RESOURCE_ALLOCATIONS => 'int',
'r_' . AdminAcl::RESOURCE_DATABASE_HOSTS => 'int', 'r_' . AdminAcl::RESOURCE_DATABASE_HOSTS => 'int',
@ -117,6 +122,7 @@ class ApiKey extends Model
'allowed_ips', 'allowed_ips',
'memo', 'memo',
'last_used_at', 'last_used_at',
'expires_at',
]; ];
/** /**
@ -137,6 +143,7 @@ class ApiKey extends Model
'allowed_ips' => 'nullable|array', 'allowed_ips' => 'nullable|array',
'allowed_ips.*' => 'string', 'allowed_ips.*' => 'string',
'last_used_at' => 'nullable|date', 'last_used_at' => 'nullable|date',
'expires_at' => 'nullable|date',
'r_' . AdminAcl::RESOURCE_USERS => '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_ALLOCATIONS => 'integer|min:0|max:3',
'r_' . AdminAcl::RESOURCE_DATABASE_HOSTS => 'integer|min:0|max:3', 'r_' . AdminAcl::RESOURCE_DATABASE_HOSTS => 'integer|min:0|max:3',
@ -148,12 +155,6 @@ class ApiKey extends Model
'r_' . AdminAcl::RESOURCE_SERVERS => 'integer|min:0|max:3', 'r_' . AdminAcl::RESOURCE_SERVERS => 'integer|min:0|max:3',
]; ];
protected $dates = [
self::CREATED_AT,
self::UPDATED_AT,
'last_used_at',
];
/** /**
* Returns the user this token is assigned to. * Returns the user this token is assigned to.
*/ */

View file

@ -42,10 +42,7 @@ class Backup extends Model
'is_locked' => 'bool', 'is_locked' => 'bool',
'ignored_files' => 'array', 'ignored_files' => 'array',
'bytes' => 'int', 'bytes' => 'int',
]; 'completed_at' => 'datetime',
protected $dates = [
'completed_at',
]; ];
protected $attributes = [ protected $attributes = [

View file

@ -71,14 +71,8 @@ class Schedule extends Model
'is_active' => 'boolean', 'is_active' => 'boolean',
'is_processing' => 'boolean', 'is_processing' => 'boolean',
'only_when_online' => 'boolean', 'only_when_online' => 'boolean',
]; 'last_run_at' => 'datetime',
'next_run_at' => 'datetime',
/**
* Columns to mutate to a date.
*/
protected $dates = [
'last_run_at',
'next_run_at',
]; ];
protected $attributes = [ protected $attributes = [

View file

@ -140,11 +140,6 @@ class Server extends Model
*/ */
protected $with = ['allocation']; protected $with = ['allocation'];
/**
* The attributes that should be mutated to dates.
*/
protected $dates = [self::CREATED_AT, self::UPDATED_AT, 'deleted_at', 'installed_at'];
/** /**
* Fields that are not mass assignable. * Fields that are not mass assignable.
*/ */
@ -194,6 +189,10 @@ class Server extends Model
'database_limit' => 'integer', 'database_limit' => 'integer',
'allocation_limit' => 'integer', 'allocation_limit' => 'integer',
'backup_limit' => 'integer', 'backup_limit' => 'integer',
self::CREATED_AT => 'datetime',
self::UPDATED_AT => 'datetime',
'deleted_at' => 'datetime',
'installed_at' => 'datetime',
]; ];
/** /**

View file

@ -23,10 +23,8 @@ class TaskLog extends Model
'id' => 'integer', 'id' => 'integer',
'task_id' => 'integer', 'task_id' => 'integer',
'run_status' => 'integer', 'run_status' => 'integer',
'run_time' => 'datetime',
'created_at' => 'datetime',
'updated_at' => 'datetime',
]; ];
/**
* The attributes that should be mutated to dates.
*/
protected $dates = ['run_time', 'created_at', 'updated_at'];
} }

View file

@ -138,10 +138,9 @@ class User extends Model implements
'root_admin' => 'boolean', 'root_admin' => 'boolean',
'use_totp' => 'boolean', 'use_totp' => 'boolean',
'gravatar' => 'boolean', 'gravatar' => 'boolean',
'totp_authenticated_at' => 'datetime',
]; ];
protected $dates = ['totp_authenticated_at'];
/** /**
* The attributes excluded from the model's JSON form. * The attributes excluded from the model's JSON form.
*/ */

View file

@ -15,7 +15,7 @@ class AppServiceProvider extends ServiceProvider
/** /**
* Bootstrap any application services. * Bootstrap any application services.
*/ */
public function boot() public function boot(): void
{ {
Schema::defaultStringLength(191); Schema::defaultStringLength(191);
@ -48,7 +48,7 @@ class AppServiceProvider extends ServiceProvider
/** /**
* Register application service providers. * Register application service providers.
*/ */
public function register() public function register(): void
{ {
// Only load the settings service provider if the environment // Only load the settings service provider if the environment
// is configured to allow it. // is configured to allow it.

View file

@ -17,14 +17,12 @@ class AuthServiceProvider extends ServiceProvider
Server::class => ServerPolicy::class, Server::class => ServerPolicy::class,
]; ];
public function boot() public function boot(): void
{ {
Sanctum::usePersonalAccessTokenModel(ApiKey::class); Sanctum::usePersonalAccessTokenModel(ApiKey::class);
$this->registerPolicies();
} }
public function register() public function register(): void
{ {
Sanctum::ignoreMigrations(); Sanctum::ignoreMigrations();
} }

View file

@ -11,7 +11,7 @@ class BackupsServiceProvider extends ServiceProvider implements DeferrableProvid
/** /**
* Register the S3 backup disk. * Register the S3 backup disk.
*/ */
public function register() public function register(): void
{ {
$this->app->singleton(BackupManager::class, function ($app) { $this->app->singleton(BackupManager::class, function ($app) {
return new BackupManager($app); return new BackupManager($app);

View file

@ -9,7 +9,7 @@ class BladeServiceProvider extends ServiceProvider
/** /**
* Perform post-registration booting of services. * Perform post-registration booting of services.
*/ */
public function boot() public function boot(): void
{ {
$this->app->make('blade.compiler') $this->app->make('blade.compiler')
->directive('datetimeHuman', function ($expression) { ->directive('datetimeHuman', function ($expression) {

View file

@ -10,7 +10,7 @@ class BroadcastServiceProvider extends ServiceProvider
/** /**
* Bootstrap any application services. * Bootstrap any application services.
*/ */
public function boot() public function boot(): void
{ {
Broadcast::routes(); Broadcast::routes();

View file

@ -11,7 +11,7 @@ class HashidsServiceProvider extends ServiceProvider
/** /**
* Register the ability to use Hashids. * Register the ability to use Hashids.
*/ */
public function register() public function register(): void
{ {
$this->app->singleton(HashidsInterface::class, function () { $this->app->singleton(HashidsInterface::class, function () {
return new Hashids( return new Hashids(

View file

@ -43,7 +43,7 @@ class RepositoryServiceProvider extends ServiceProvider
/** /**
* Register all the repository bindings. * Register all the repository bindings.
*/ */
public function register() public function register(): void
{ {
// Eloquent Repositories // Eloquent Repositories
$this->app->bind(AllocationRepositoryInterface::class, AllocationRepository::class); $this->app->bind(AllocationRepositoryInterface::class, AllocationRepository::class);

View file

@ -19,7 +19,7 @@ class RouteServiceProvider extends ServiceProvider
/** /**
* Define your route model bindings, pattern filters, etc. * Define your route model bindings, pattern filters, etc.
*/ */
public function boot() public function boot(): void
{ {
$this->configureRateLimiting(); $this->configureRateLimiting();
@ -68,7 +68,7 @@ class RouteServiceProvider extends ServiceProvider
/** /**
* Configure the rate limiters for the application. * Configure the rate limiters for the application.
*/ */
protected function configureRateLimiting() protected function configureRateLimiting(): void
{ {
// Authentication rate limiting. For login and checkpoint endpoints we'll apply // Authentication rate limiting. For login and checkpoint endpoints we'll apply
// a limit of 10 requests per minute, for the forgot password endpoint apply a // a limit of 10 requests per minute, for the forgot password endpoint apply a

View file

@ -57,7 +57,7 @@ class SettingsServiceProvider extends ServiceProvider
/** /**
* Boot the service provider. * Boot the service provider.
*/ */
public function boot(ConfigRepository $config, Encrypter $encrypter, Log $log, SettingsRepositoryInterface $settings) public function boot(ConfigRepository $config, Encrypter $encrypter, Log $log, SettingsRepositoryInterface $settings): void
{ {
// Only set the email driver settings from the database if we // Only set the email driver settings from the database if we
// are configured using SMTP as the driver. // are configured using SMTP as the driver.

View file

@ -10,7 +10,7 @@ class ViewComposerServiceProvider extends ServiceProvider
/** /**
* Register bindings in the container. * Register bindings in the container.
*/ */
public function boot() public function boot(): void
{ {
$this->app->make('view')->composer('*', AssetComposer::class); $this->app->make('view')->composer('*', AssetComposer::class);
} }

View file

@ -17,54 +17,54 @@
} }
], ],
"require": { "require": {
"php": "^8.0.2 || ^8.1 || ^8.2", "php": "^8.1 || ^8.2",
"ext-json": "*", "ext-json": "*",
"ext-mbstring": "*", "ext-mbstring": "*",
"ext-pdo": "*", "ext-pdo": "*",
"ext-pdo_mysql": "*", "ext-pdo_mysql": "*",
"ext-posix": "*", "ext-posix": "*",
"ext-zip": "*", "ext-zip": "*",
"aws/aws-sdk-php": "~3.253", "aws/aws-sdk-php": "~3.260.1",
"doctrine/dbal": "~3.5", "doctrine/dbal": "~3.6.0",
"guzzlehttp/guzzle": "~7.5", "guzzlehttp/guzzle": "~7.5.0",
"hashids/hashids": "~4.1", "hashids/hashids": "~5.0.0",
"laracasts/utilities": "~3.2", "laracasts/utilities": "~3.2.2",
"laravel/framework": "~9.43", "laravel/framework": "~10.1.3",
"laravel/helpers": "~1.5", "laravel/helpers": "~1.6.0",
"laravel/sanctum": "~3.0", "laravel/sanctum": "~3.2.1",
"laravel/tinker": "~2.7", "laravel/tinker": "~2.8.1",
"laravel/ui": "~4.1", "laravel/ui": "~4.2.1",
"lcobucci/jwt": "~4.2", "lcobucci/jwt": "~4.3.0",
"league/flysystem-aws-s3-v3": "~3.10", "league/flysystem-aws-s3-v3": "~3.12.2",
"league/flysystem-memory": "~3.10", "league/flysystem-memory": "~3.10.3",
"matriphe/iso-639": "~1.2", "matriphe/iso-639": "~1.2",
"phpseclib/phpseclib": "~3.0", "phpseclib/phpseclib": "~3.0.18",
"pragmarx/google2fa": "~8.0", "pragmarx/google2fa": "~8.0.0",
"predis/predis": "~2.0", "predis/predis": "~2.1.1",
"psr/cache": "~3.0", "prologue/alerts": "~1.1.0",
"s1lentium/iptools": "~1.1", "psr/cache": "~3.0.0",
"spatie/laravel-fractal": "~6.0", "s1lentium/iptools": "~1.2.0",
"spatie/laravel-query-builder": "~5.1", "spatie/laravel-fractal": "~6.0.3",
"staudenmeir/belongs-to-through": "~2.12", "spatie/laravel-query-builder": "~5.1.2",
"symfony/http-client": "~6.0", "staudenmeir/belongs-to-through": "~2.13",
"symfony/mailgun-mailer": "~6.0", "symfony/http-client": "~6.2.6",
"symfony/postmark-mailer": "~6.0", "symfony/mailgun-mailer": "~6.2.5",
"symfony/yaml": "~6.0", "symfony/postmark-mailer": "~6.2.5",
"webmozart/assert": "~1.11" "symfony/yaml": "~6.2.5",
"webmozart/assert": "~1.11.0"
}, },
"require-dev": { "require-dev": {
"barryvdh/laravel-ide-helper": "~2.12.3", "barryvdh/laravel-ide-helper": "~2.13.0",
"fakerphp/faker": "~1.20", "fakerphp/faker": "~1.21.0",
"friendsofphp/php-cs-fixer": "~3.11", "friendsofphp/php-cs-fixer": "~3.14.4",
"itsgoingd/clockwork": "~5.1", "itsgoingd/clockwork": "~5.1.12",
"laravel/sail": "~1.16", "laravel/sail": "~1.21.0",
"mockery/mockery": "~1.5", "mockery/mockery": "~1.5.1",
"nunomaduro/collision": "~6.3", "nunomaduro/collision": "~7.0.5",
"nunomaduro/larastan": "^2.0", "nunomaduro/larastan": "~2.4.1",
"phpstan/phpstan": "~1.9", "phpstan/phpstan": "~1.10.1",
"php-mock/php-mock-phpunit": "~2.6", "phpunit/phpunit": "~10.0.11",
"phpunit/phpunit": "~9.5", "spatie/laravel-ignition": "~2.0.0"
"spatie/laravel-ignition": "~1.5"
}, },
"autoload": { "autoload": {
"files": [ "files": [
@ -84,24 +84,25 @@
"scripts": { "scripts": {
"cs:fix": "php-cs-fixer fix", "cs:fix": "php-cs-fixer fix",
"cs:check": "php-cs-fixer fix --dry-run --diff --verbose", "cs:check": "php-cs-fixer fix --dry-run --diff --verbose",
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi || true"
],
"post-root-package-install": [ "post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
], ],
"post-create-project-cmd": [ "post-create-project-cmd": [
"@php artisan key:generate" "@php artisan key:generate --ansi"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover || true"
] ]
}, },
"prefer-stable": true,
"config": { "config": {
"optimize-autoloader": true, "optimize-autoloader": true,
"preferred-install": "dist", "preferred-install": "dist",
"sort-packages": true, "sort-packages": true,
"platform": { "platform": {
"php": "8.0.2" "php": "8.1.0"
}
} }
},
"minimum-stability": "stable",
"prefer-stable": true
} }

View file

@ -27,7 +27,7 @@ return [
| sending an e-mail. You will specify which one you are using for your | sending an e-mail. You will specify which one you are using for your
| mailers below. You are free to add additional mailers as required. | mailers below. You are free to add additional mailers as required.
| |
| Supported: "smtp", "sendmail", "mailgun", "ses", | Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2",
| "postmark", "log", "array", "failover" | "postmark", "log", "array", "failover"
| |
*/ */

View file

@ -34,7 +34,7 @@ class EggVariableFactory extends Factory
/** /**
* Indicate that the egg variable is viewable. * Indicate that the egg variable is viewable.
*/ */
public function viewable(): Factory public function viewable(): static
{ {
return $this->state(function (array $attributes) { return $this->state(function (array $attributes) {
return [ return [
@ -46,7 +46,7 @@ class EggVariableFactory extends Factory
/** /**
* Indicate that the egg variable is editable. * Indicate that the egg variable is editable.
*/ */
public function editable(): Factory public function editable(): static
{ {
return $this->state(function (array $attributes) { return $this->state(function (array $attributes) {
return [ return [

View file

@ -41,7 +41,7 @@ class UserFactory extends Factory
/** /**
* Indicate that the user is an admin. * Indicate that the user is an admin.
*/ */
public function admin(): Factory public function admin(): static
{ {
return $this->state(['root_admin' => true]); return $this->state(['root_admin' => true]);
} }

View file

@ -0,0 +1,27 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('api_keys', function (Blueprint $table) {
$table->timestamp('expires_at')->nullable()->after('last_used_at');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('api_keys', function (Blueprint $table) {
$table->dropColumn('expires_at');
});
}
};

View file

@ -4,9 +4,8 @@
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd" xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="bootstrap/tests.php" bootstrap="bootstrap/tests.php"
colors="true" colors="true"
printerClass="NunoMaduro\Collision\Adapters\Phpunit\Printer"
> >
<coverage processUncoveredFiles="true"> <coverage>
<include> <include>
<directory suffix=".php">./app</directory> <directory suffix=".php">./app</directory>
</include> </include>

View file

@ -47,7 +47,7 @@ export const rawDataToFileObject = (data: FractalResponseData): FileObject => ({
isEditable: function () { isEditable: function () {
if (this.isArchiveType() || !this.isFile) return false; if (this.isArchiveType() || !this.isFile) return false;
const matches = ['application/jar', 'application/octet-stream', 'inode/directory', /^image\//]; const matches = ['application/jar', 'application/octet-stream', 'inode/directory', /^image\/(?!svg\+xml)/];
return matches.every(m => !this.mimetype.match(m)); return matches.every(m => !this.mimetype.match(m));
}, },

View file

@ -255,7 +255,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
* Endpoints that should return a 403 error when the key does not have write * Endpoints that should return a 403 error when the key does not have write
* permissions for user management. * permissions for user management.
*/ */
public function userWriteEndpointsDataProvider(): array public static function userWriteEndpointsDataProvider(): array
{ {
return [ return [
['postJson', '/api/application/users'], ['postJson', '/api/application/users'],

View file

@ -241,7 +241,7 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase
* Provides some different IP address combinations that can be used when * Provides some different IP address combinations that can be used when
* testing that we accept the expected IP values. * testing that we accept the expected IP values.
*/ */
public function validIPAddressDataProvider(): array public static function validIPAddressDataProvider(): array
{ {
return [ return [
[[]], [[]],

View file

@ -331,7 +331,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase
$response->assertJsonPath('data.0.attributes.relationships.allocations.data.0.attributes.notes', null); $response->assertJsonPath('data.0.attributes.relationships.allocations.data.0.attributes.notes', null);
} }
public function filterTypeDataProvider(): array public static function filterTypeDataProvider(): array
{ {
return [['admin'], ['admin-all']]; return [['admin'], ['admin-all']];
} }

View file

@ -46,7 +46,7 @@ class AllocationAuthorizationTest extends ClientApiIntegrationTestCase
$this->actingAs($user)->json($method, $this->link($server3, '/network/allocations/' . $allocation3->id . $endpoint))->assertNotFound(); $this->actingAs($user)->json($method, $this->link($server3, '/network/allocations/' . $allocation3->id . $endpoint))->assertNotFound();
} }
public function methodDataProvider(): array public static function methodDataProvider(): array
{ {
return [ return [
['POST', ''], ['POST', ''],

View file

@ -86,7 +86,7 @@ class CreateNewAllocationTest extends ClientApiIntegrationTestCase
->assertJsonPath('errors.0.detail', 'Cannot assign additional allocations to this server: limit has been reached.'); ->assertJsonPath('errors.0.detail', 'Cannot assign additional allocations to this server: limit has been reached.');
} }
public function permissionDataProvider(): array public static function permissionDataProvider(): array
{ {
return [[[Permission::ACTION_ALLOCATION_CREATE]], [[]]]; return [[[Permission::ACTION_ALLOCATION_CREATE]], [[]]];
} }

View file

@ -98,10 +98,7 @@ class DeleteAllocationTest extends ClientApiIntegrationTestCase
$this->actingAs($user)->deleteJson($this->link($server, "/network/allocations/{$server2->allocation_id}"))->assertNotFound(); $this->actingAs($user)->deleteJson($this->link($server, "/network/allocations/{$server2->allocation_id}"))->assertNotFound();
} }
/** public static function permissionDataProvider(): array
* @return array
*/
public function permissionDataProvider()
{ {
return [[[Permission::ACTION_ALLOCATION_DELETE]], [[]]]; return [[[Permission::ACTION_ALLOCATION_DELETE]], [[]]];
} }

View file

@ -54,7 +54,7 @@ class BackupAuthorizationTest extends ClientApiIntegrationTestCase
$this->actingAs($user)->json($method, $this->link($server3, '/backups/' . $backup3->uuid . $endpoint))->assertNotFound(); $this->actingAs($user)->json($method, $this->link($server3, '/backups/' . $backup3->uuid . $endpoint))->assertNotFound();
} }
public function methodDataProvider(): array public static function methodDataProvider(): array
{ {
return [ return [
['GET', ''], ['GET', ''],

View file

@ -58,7 +58,7 @@ class DatabaseAuthorizationTest extends ClientApiIntegrationTestCase
$this->actingAs($user)->json($method, $this->link($server3, '/databases/' . $hashids->encode($database3->id) . $endpoint))->assertNotFound(); $this->actingAs($user)->json($method, $this->link($server3, '/databases/' . $hashids->encode($database3->id) . $endpoint))->assertNotFound();
} }
public function methodDataProvider(): array public static function methodDataProvider(): array
{ {
return [ return [
['POST', '/rotate-password'], ['POST', '/rotate-password'],

View file

@ -133,7 +133,7 @@ class NetworkAllocationControllerTest extends ClientApiIntegrationTestCase
->assertForbidden(); ->assertForbidden();
} }
public function updatePermissionsDataProvider(): array public static function updatePermissionsDataProvider(): array
{ {
return [[[]], [[Permission::ACTION_ALLOCATION_UPDATE]]]; return [[[]], [[Permission::ACTION_ALLOCATION_UPDATE]]];
} }

View file

@ -72,7 +72,7 @@ class PowerControllerTest extends ClientApiIntegrationTestCase
/** /**
* Returns invalid permission combinations for a given power action. * Returns invalid permission combinations for a given power action.
*/ */
public function invalidPermissionDataProvider(): array public static function invalidPermissionDataProvider(): array
{ {
return [ return [
['start', [Permission::ACTION_CONTROL_STOP, Permission::ACTION_CONTROL_RESTART]], ['start', [Permission::ACTION_CONTROL_STOP, Permission::ACTION_CONTROL_RESTART]],
@ -83,7 +83,7 @@ class PowerControllerTest extends ClientApiIntegrationTestCase
]; ];
} }
public function validPowerActionDataProvider(): array public static function validPowerActionDataProvider(): array
{ {
return [ return [
['start', Permission::ACTION_CONTROL_START], ['start', Permission::ACTION_CONTROL_START],

View file

@ -89,7 +89,7 @@ class CreateServerScheduleTest extends ClientApiIntegrationTestCase
->assertForbidden(); ->assertForbidden();
} }
public function permissionsDataProvider(): array public static function permissionsDataProvider(): array
{ {
return [[[]], [[Permission::ACTION_SCHEDULE_CREATE]]]; return [[[]], [[Permission::ACTION_SCHEDULE_CREATE]]];
} }

View file

@ -77,7 +77,7 @@ class DeleteServerScheduleTest extends ClientApiIntegrationTestCase
$this->assertDatabaseHas('schedules', ['id' => $schedule->id]); $this->assertDatabaseHas('schedules', ['id' => $schedule->id]);
} }
public function permissionsDataProvider(): array public static function permissionsDataProvider(): array
{ {
return [[[]], [[Permission::ACTION_SCHEDULE_DELETE]]]; return [[[]], [[Permission::ACTION_SCHEDULE_DELETE]]];
} }

View file

@ -64,7 +64,7 @@ class ExecuteScheduleTest extends ClientApiIntegrationTestCase
$this->actingAs($user)->postJson($this->link($schedule, '/execute'))->assertForbidden(); $this->actingAs($user)->postJson($this->link($schedule, '/execute'))->assertForbidden();
} }
public function permissionsDataProvider(): array public static function permissionsDataProvider(): array
{ {
return [[[]], [[Permission::ACTION_SCHEDULE_UPDATE]]]; return [[[]], [[Permission::ACTION_SCHEDULE_UPDATE]]];
} }

View file

@ -89,7 +89,7 @@ class GetServerSchedulesTest extends ClientApiIntegrationTestCase
->assertForbidden(); ->assertForbidden();
} }
public function permissionsDataProvider(): array public static function permissionsDataProvider(): array
{ {
return [ return [
[[], false], [[], false],

View file

@ -54,7 +54,7 @@ class ScheduleAuthorizationTest extends ClientApiIntegrationTestCase
$this->actingAs($user)->json($method, $this->link($server3, '/schedules/' . $schedule3->id . $endpoint))->assertNotFound(); $this->actingAs($user)->json($method, $this->link($server3, '/schedules/' . $schedule3->id . $endpoint))->assertNotFound();
} }
public function methodDataProvider(): array public static function methodDataProvider(): array
{ {
return [ return [
['GET', ''], ['GET', ''],

View file

@ -109,7 +109,7 @@ class UpdateServerScheduleTest extends ClientApiIntegrationTestCase
$this->assertFalse($schedule->is_processing); $this->assertFalse($schedule->is_processing);
} }
public function permissionsDataProvider(): array public static function permissionsDataProvider(): array
{ {
return [[[]], [[Permission::ACTION_SCHEDULE_UPDATE]]]; return [[[]], [[Permission::ACTION_SCHEDULE_UPDATE]]];
} }

View file

@ -170,7 +170,7 @@ class CreateServerScheduleTaskTest extends ClientApiIntegrationTestCase
->assertForbidden(); ->assertForbidden();
} }
public function permissionsDataProvider(): array public static function permissionsDataProvider(): array
{ {
return [[[]], [[Permission::ACTION_SCHEDULE_UPDATE]]]; return [[[]], [[Permission::ACTION_SCHEDULE_UPDATE]]];
} }

View file

@ -112,12 +112,12 @@ class SettingsControllerTest extends ClientApiIntegrationTestCase
$this->assertTrue($server->isInstalled()); $this->assertTrue($server->isInstalled());
} }
public function renamePermissionsDataProvider(): array public static function renamePermissionsDataProvider(): array
{ {
return [[[]], [[Permission::ACTION_SETTINGS_RENAME]]]; return [[[]], [[Permission::ACTION_SETTINGS_RENAME]]];
} }
public function reinstallPermissionsDataProvider(): array public static function reinstallPermissionsDataProvider(): array
{ {
return [[[]], [[Permission::ACTION_SETTINGS_REINSTALL]]]; return [[[]], [[Permission::ACTION_SETTINGS_REINSTALL]]];
} }

View file

@ -58,7 +58,7 @@ class GetStartupAndVariablesTest extends ClientApiIntegrationTestCase
$this->actingAs($user2)->getJson($this->link($server) . '/startup')->assertNotFound(); $this->actingAs($user2)->getJson($this->link($server) . '/startup')->assertNotFound();
} }
public function permissionsDataProvider(): array public static function permissionsDataProvider(): array
{ {
return [[[]], [[Permission::ACTION_STARTUP_READ]]]; return [[[]], [[Permission::ACTION_STARTUP_READ]]];
} }

View file

@ -149,7 +149,7 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase
$this->actingAs($user2)->putJson($this->link($server) . '/startup/variable')->assertNotFound(); $this->actingAs($user2)->putJson($this->link($server) . '/startup/variable')->assertNotFound();
} }
public function permissionsDataProvider(): array public static function permissionsDataProvider(): array
{ {
return [[[]], [[Permission::ACTION_STARTUP_UPDATE]]]; return [[[]], [[Permission::ACTION_STARTUP_UPDATE]]];
} }

View file

@ -155,7 +155,7 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase
$response->assertJsonPath('errors.0.detail', 'A user with that email address is already assigned as a subuser for this server.'); $response->assertJsonPath('errors.0.detail', 'A user with that email address is already assigned as a subuser for this server.');
} }
public function permissionsDataProvider(): array public static function permissionsDataProvider(): array
{ {
return [[[]], [[Permission::ACTION_USER_CREATE]]]; return [[[]], [[Permission::ACTION_USER_CREATE]]];
} }

View file

@ -49,7 +49,7 @@ class SubuserAuthorizationTest extends ClientApiIntegrationTestCase
$this->actingAs($user)->json($method, $this->link($server3, '/users/' . $internal->uuid))->assertNotFound(); $this->actingAs($user)->json($method, $this->link($server3, '/users/' . $internal->uuid))->assertNotFound();
} }
public function methodDataProvider(): array public static function methodDataProvider(): array
{ {
return [['GET'], ['POST'], ['DELETE']]; return [['GET'], ['POST'], ['DELETE']];
} }

View file

@ -213,7 +213,7 @@ class SftpAuthenticationControllerTest extends IntegrationTestCase
$this->post('/api/remote/sftp/auth', $data)->assertForbidden(); $this->post('/api/remote/sftp/auth', $data)->assertForbidden();
} }
public function authorizationTypeDataProvider(): array public static function authorizationTypeDataProvider(): array
{ {
return [ return [
'password auth' => ['password'], 'password auth' => ['password'],
@ -221,7 +221,7 @@ class SftpAuthenticationControllerTest extends IntegrationTestCase
]; ];
} }
public function serverStateDataProvider(): array public static function serverStateDataProvider(): array
{ {
return [ return [
'installing' => [Server::STATUS_INSTALLING], 'installing' => [Server::STATUS_INSTALLING],

View file

@ -37,7 +37,7 @@ class RunTaskJobTest extends IntegrationTestCase
$job = new RunTaskJob($task); $job = new RunTaskJob($task);
Bus::dispatchNow($job); Bus::dispatchSync($job);
$task->refresh(); $task->refresh();
$schedule->refresh(); $schedule->refresh();
@ -61,7 +61,7 @@ class RunTaskJobTest extends IntegrationTestCase
$this->expectException(\InvalidArgumentException::class); $this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid task action provided: foobar'); $this->expectExceptionMessage('Invalid task action provided: foobar');
Bus::dispatchNow($job); Bus::dispatchSync($job);
} }
/** /**
@ -95,7 +95,7 @@ class RunTaskJobTest extends IntegrationTestCase
}))->andReturnSelf(); }))->andReturnSelf();
$mock->expects('send')->with('start')->andReturn(new Response()); $mock->expects('send')->with('start')->andReturn(new Response());
Bus::dispatchNow(new RunTaskJob($task, $isManualRun)); Bus::dispatchSync(new RunTaskJob($task, $isManualRun));
$task->refresh(); $task->refresh();
$schedule->refresh(); $schedule->refresh();
@ -133,7 +133,7 @@ class RunTaskJobTest extends IntegrationTestCase
$this->expectException(DaemonConnectionException::class); $this->expectException(DaemonConnectionException::class);
} }
Bus::dispatchNow(new RunTaskJob($task)); Bus::dispatchSync(new RunTaskJob($task));
if ($continueOnFailure) { if ($continueOnFailure) {
$task->refresh(); $task->refresh();
@ -165,7 +165,7 @@ class RunTaskJobTest extends IntegrationTestCase
'payload' => 'start', 'payload' => 'start',
]); ]);
Bus::dispatchNow(new RunTaskJob($task)); Bus::dispatchSync(new RunTaskJob($task));
$task->refresh(); $task->refresh();
$schedule->refresh(); $schedule->refresh();
@ -175,7 +175,7 @@ class RunTaskJobTest extends IntegrationTestCase
$this->assertTrue(Carbon::now()->isSameAs(\DateTimeInterface::ATOM, $schedule->last_run_at)); $this->assertTrue(Carbon::now()->isSameAs(\DateTimeInterface::ATOM, $schedule->last_run_at));
} }
public function isManualRunDataProvider(): array public static function isManualRunDataProvider(): array
{ {
return [[true], [false]]; return [[true], [false]];
} }

View file

@ -194,7 +194,7 @@ class DatabaseManagementServiceTest extends IntegrationTestCase
$this->assertDatabaseMissing('databases', ['server_id' => $server->id]); $this->assertDatabaseMissing('databases', ['server_id' => $server->id]);
} }
public function invalidDataDataProvider(): array public static function invalidDataDataProvider(): array
{ {
return [ return [
[[]], [[]],

View file

@ -141,7 +141,7 @@ class DeployServerDatabaseServiceTest extends IntegrationTestCase
$this->assertInstanceOf(Database::class, $response); $this->assertInstanceOf(Database::class, $response);
} }
public function invalidDataProvider(): array public static function invalidDataProvider(): array
{ {
return [ return [
[['remote' => '%']], [['remote' => '%']],

View file

@ -148,7 +148,7 @@ class ProcessScheduleServiceTest extends IntegrationTestCase
$this->assertDatabaseHas('tasks', ['id' => $task->id, 'is_queued' => false]); $this->assertDatabaseHas('tasks', ['id' => $task->id, 'is_queued' => false]);
} }
public function dispatchNowDataProvider(): array public static function dispatchNowDataProvider(): array
{ {
return [[true], [false]]; return [[true], [false]];
} }

View file

@ -17,7 +17,7 @@ class EnvironmentWriterTraitTest extends TestCase
$this->assertSame($expected, $output); $this->assertSame($expected, $output);
} }
public function variableDataProvider(): array public static function variableDataProvider(): array
{ {
return [ return [
['foo', 'foo'], ['foo', 'foo'],

View file

@ -19,7 +19,7 @@ class IsDigitTest extends TestCase
/** /**
* Provide data to test against the helper function. * Provide data to test against the helper function.
*/ */
public function helperDataProvider(): array public static function helperDataProvider(): array
{ {
return [ return [
[true, false], [true, false],

View file

@ -138,7 +138,7 @@ class DaemonAuthenticateTest extends MiddlewareTestCase
* *
* @return array|\string[][] * @return array|\string[][]
*/ */
public function badTokenDataProvider(): array public static function badTokenDataProvider(): array
{ {
return [ return [
['foo'], ['foo'],

View file

@ -38,7 +38,7 @@ class UsernameTest extends TestCase
/** /**
* Provide valid usernames. * Provide valid usernames.
*/ */
public function validUsernameDataProvider(): array public static function validUsernameDataProvider(): array
{ {
return [ return [
['username'], ['username'],
@ -54,7 +54,7 @@ class UsernameTest extends TestCase
/** /**
* Provide invalid usernames. * Provide invalid usernames.
*/ */
public function invalidUsernameDataProvider(): array public static function invalidUsernameDataProvider(): array
{ {
return [ return [
['_username'], ['_username'],

View file

@ -31,7 +31,7 @@ class AdminAclTest extends TestCase
/** /**
* Provide valid and invalid permissions combos for testing. * Provide valid and invalid permissions combos for testing.
*/ */
public function permissionsDataProvider(): array public static function permissionsDataProvider(): array
{ {
return [ return [
[AdminAcl::READ, AdminAcl::READ, true], [AdminAcl::READ, AdminAcl::READ, true],