diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index f79e6c905..56343297c 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -18,7 +18,7 @@ class Kernel extends ConsoleKernel /** * Register the commands for the application. */ - protected function commands() + protected function commands(): void { $this->load(__DIR__ . '/Commands'); } @@ -26,8 +26,11 @@ class Kernel extends ConsoleKernel /** * 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. $schedule->command(ProcessRunnableCommand::class)->everyMinute()->withoutOverlapping(); $schedule->command(CleanServiceBackupFilesCommand::class)->daily(); diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 6fd1b5d8e..5786d7dd5 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -73,7 +73,7 @@ final class Handler extends ExceptionHandler * * @noinspection PhpUnusedLocalVariableInspection */ - public function register() + public function register(): void { if (config('app.exceptions.report_all', false)) { $this->dontReport = []; diff --git a/app/Http/Controllers/Api/Client/Servers/BackupController.php b/app/Http/Controllers/Api/Client/Servers/BackupController.php index 13c9ac7ea..8ee5f7b0e 100644 --- a/app/Http/Controllers/Api/Client/Servers/BackupController.php +++ b/app/Http/Controllers/Api/Client/Servers/BackupController.php @@ -18,6 +18,7 @@ use Pterodactyl\Transformers\Api\Client\BackupTransformer; use Pterodactyl\Http\Controllers\Api\Client\ClientApiController; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Pterodactyl\Http\Requests\Api\Client\Servers\Backups\StoreBackupRequest; +use Pterodactyl\Http\Requests\Api\Client\Servers\Backups\RestoreBackupRequest; class BackupController extends ClientApiController { @@ -188,12 +189,8 @@ class BackupController extends ClientApiController * * @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 // processing a different backup restoration request. if (!is_null($server->status)) { diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 7df1ed2b1..b7085d9ed 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -86,7 +86,7 @@ class Kernel extends HttpKernel /** * The application's route middleware. */ - protected $routeMiddleware = [ + protected $middlewareAliases = [ 'auth' => Authenticate::class, 'auth.basic' => AuthenticateWithBasicAuth::class, 'auth.session' => AuthenticateSession::class, diff --git a/app/Http/Requests/Api/Client/Servers/Backups/RestoreBackupRequest.php b/app/Http/Requests/Api/Client/Servers/Backups/RestoreBackupRequest.php new file mode 100644 index 000000000..d2d427f99 --- /dev/null +++ b/app/Http/Requests/Api/Client/Servers/Backups/RestoreBackupRequest.php @@ -0,0 +1,19 @@ + 'required|boolean']; + } +} diff --git a/app/Models/ApiKey.php b/app/Models/ApiKey.php index 5bfb89549..e141e89a2 100644 --- a/app/Models/ApiKey.php +++ b/app/Models/ApiKey.php @@ -18,6 +18,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo; * @property array|null $allowed_ips * @property string|null $memo * @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 $updated_at * @property int $r_servers @@ -97,6 +98,10 @@ class ApiKey extends Model protected $casts = [ 'allowed_ips' => 'array', '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_ALLOCATIONS => 'int', 'r_' . AdminAcl::RESOURCE_DATABASE_HOSTS => 'int', @@ -117,6 +122,7 @@ class ApiKey extends Model 'allowed_ips', 'memo', 'last_used_at', + 'expires_at', ]; /** @@ -137,6 +143,7 @@ class ApiKey extends Model 'allowed_ips' => 'nullable|array', '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', @@ -148,12 +155,6 @@ class ApiKey extends Model '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. */ diff --git a/app/Models/Backup.php b/app/Models/Backup.php index 500205b13..44fccf73f 100644 --- a/app/Models/Backup.php +++ b/app/Models/Backup.php @@ -42,10 +42,7 @@ class Backup extends Model 'is_locked' => 'bool', 'ignored_files' => 'array', 'bytes' => 'int', - ]; - - protected $dates = [ - 'completed_at', + 'completed_at' => 'datetime', ]; protected $attributes = [ diff --git a/app/Models/Schedule.php b/app/Models/Schedule.php index 183ebb82b..a61bd3cd8 100644 --- a/app/Models/Schedule.php +++ b/app/Models/Schedule.php @@ -71,14 +71,8 @@ class Schedule extends Model 'is_active' => 'boolean', 'is_processing' => 'boolean', 'only_when_online' => 'boolean', - ]; - - /** - * Columns to mutate to a date. - */ - protected $dates = [ - 'last_run_at', - 'next_run_at', + 'last_run_at' => 'datetime', + 'next_run_at' => 'datetime', ]; protected $attributes = [ diff --git a/app/Models/Server.php b/app/Models/Server.php index 6502a3410..a0ca620e4 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -140,11 +140,6 @@ class Server extends Model */ 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. */ @@ -194,6 +189,10 @@ class Server extends Model 'database_limit' => 'integer', 'allocation_limit' => 'integer', 'backup_limit' => 'integer', + self::CREATED_AT => 'datetime', + self::UPDATED_AT => 'datetime', + 'deleted_at' => 'datetime', + 'installed_at' => 'datetime', ]; /** diff --git a/app/Models/TaskLog.php b/app/Models/TaskLog.php index 0efd77ff4..81b7fdb78 100644 --- a/app/Models/TaskLog.php +++ b/app/Models/TaskLog.php @@ -23,10 +23,8 @@ class TaskLog extends Model 'id' => 'integer', 'task_id' => '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']; } diff --git a/app/Models/User.php b/app/Models/User.php index 6ffe07091..3446bf807 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -138,10 +138,9 @@ class User extends Model implements 'root_admin' => 'boolean', 'use_totp' => 'boolean', 'gravatar' => 'boolean', + 'totp_authenticated_at' => 'datetime', ]; - protected $dates = ['totp_authenticated_at']; - /** * The attributes excluded from the model's JSON form. */ diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 1bb94d258..f5e39acf3 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -15,7 +15,7 @@ class AppServiceProvider extends ServiceProvider /** * Bootstrap any application services. */ - public function boot() + public function boot(): void { Schema::defaultStringLength(191); @@ -48,7 +48,7 @@ class AppServiceProvider extends ServiceProvider /** * Register application service providers. */ - public function register() + public function register(): void { // Only load the settings service provider if the environment // is configured to allow it. diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index fed77e15a..9f9556b9a 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -17,14 +17,12 @@ class AuthServiceProvider extends ServiceProvider Server::class => ServerPolicy::class, ]; - public function boot() + public function boot(): void { Sanctum::usePersonalAccessTokenModel(ApiKey::class); - - $this->registerPolicies(); } - public function register() + public function register(): void { Sanctum::ignoreMigrations(); } diff --git a/app/Providers/BackupsServiceProvider.php b/app/Providers/BackupsServiceProvider.php index 3b22a2069..25ce9bd7a 100644 --- a/app/Providers/BackupsServiceProvider.php +++ b/app/Providers/BackupsServiceProvider.php @@ -11,7 +11,7 @@ class BackupsServiceProvider extends ServiceProvider implements DeferrableProvid /** * Register the S3 backup disk. */ - public function register() + public function register(): void { $this->app->singleton(BackupManager::class, function ($app) { return new BackupManager($app); diff --git a/app/Providers/BladeServiceProvider.php b/app/Providers/BladeServiceProvider.php index 16a17a373..3512acfd9 100644 --- a/app/Providers/BladeServiceProvider.php +++ b/app/Providers/BladeServiceProvider.php @@ -9,7 +9,7 @@ class BladeServiceProvider extends ServiceProvider /** * Perform post-registration booting of services. */ - public function boot() + public function boot(): void { $this->app->make('blade.compiler') ->directive('datetimeHuman', function ($expression) { diff --git a/app/Providers/BroadcastServiceProvider.php b/app/Providers/BroadcastServiceProvider.php index 3f7c84be4..0630a6377 100644 --- a/app/Providers/BroadcastServiceProvider.php +++ b/app/Providers/BroadcastServiceProvider.php @@ -10,7 +10,7 @@ class BroadcastServiceProvider extends ServiceProvider /** * Bootstrap any application services. */ - public function boot() + public function boot(): void { Broadcast::routes(); diff --git a/app/Providers/HashidsServiceProvider.php b/app/Providers/HashidsServiceProvider.php index 4e48208ef..6722f8dec 100644 --- a/app/Providers/HashidsServiceProvider.php +++ b/app/Providers/HashidsServiceProvider.php @@ -11,7 +11,7 @@ class HashidsServiceProvider extends ServiceProvider /** * Register the ability to use Hashids. */ - public function register() + public function register(): void { $this->app->singleton(HashidsInterface::class, function () { return new Hashids( diff --git a/app/Providers/RepositoryServiceProvider.php b/app/Providers/RepositoryServiceProvider.php index e5a16dd50..b06ca7a13 100644 --- a/app/Providers/RepositoryServiceProvider.php +++ b/app/Providers/RepositoryServiceProvider.php @@ -43,7 +43,7 @@ class RepositoryServiceProvider extends ServiceProvider /** * Register all the repository bindings. */ - public function register() + public function register(): void { // Eloquent Repositories $this->app->bind(AllocationRepositoryInterface::class, AllocationRepository::class); diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 25f18c524..ac7d52902 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -19,7 +19,7 @@ class RouteServiceProvider extends ServiceProvider /** * Define your route model bindings, pattern filters, etc. */ - public function boot() + public function boot(): void { $this->configureRateLimiting(); @@ -68,7 +68,7 @@ class RouteServiceProvider extends ServiceProvider /** * 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 // a limit of 10 requests per minute, for the forgot password endpoint apply a diff --git a/app/Providers/SettingsServiceProvider.php b/app/Providers/SettingsServiceProvider.php index dc310495d..e463961cf 100644 --- a/app/Providers/SettingsServiceProvider.php +++ b/app/Providers/SettingsServiceProvider.php @@ -57,7 +57,7 @@ class SettingsServiceProvider extends ServiceProvider /** * 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 // are configured using SMTP as the driver. diff --git a/app/Providers/ViewComposerServiceProvider.php b/app/Providers/ViewComposerServiceProvider.php index 9f484e006..8ab7208c7 100644 --- a/app/Providers/ViewComposerServiceProvider.php +++ b/app/Providers/ViewComposerServiceProvider.php @@ -10,7 +10,7 @@ class ViewComposerServiceProvider extends ServiceProvider /** * Register bindings in the container. */ - public function boot() + public function boot(): void { $this->app->make('view')->composer('*', AssetComposer::class); } diff --git a/composer.json b/composer.json index cf82119e7..40441a7d1 100644 --- a/composer.json +++ b/composer.json @@ -17,54 +17,54 @@ } ], "require": { - "php": "^8.0.2 || ^8.1 || ^8.2", + "php": "^8.1 || ^8.2", "ext-json": "*", "ext-mbstring": "*", "ext-pdo": "*", "ext-pdo_mysql": "*", "ext-posix": "*", "ext-zip": "*", - "aws/aws-sdk-php": "~3.253", - "doctrine/dbal": "~3.5", - "guzzlehttp/guzzle": "~7.5", - "hashids/hashids": "~4.1", - "laracasts/utilities": "~3.2", - "laravel/framework": "~9.43", - "laravel/helpers": "~1.5", - "laravel/sanctum": "~3.0", - "laravel/tinker": "~2.7", - "laravel/ui": "~4.1", - "lcobucci/jwt": "~4.2", - "league/flysystem-aws-s3-v3": "~3.10", - "league/flysystem-memory": "~3.10", + "aws/aws-sdk-php": "~3.260.1", + "doctrine/dbal": "~3.6.0", + "guzzlehttp/guzzle": "~7.5.0", + "hashids/hashids": "~5.0.0", + "laracasts/utilities": "~3.2.2", + "laravel/framework": "~10.1.3", + "laravel/helpers": "~1.6.0", + "laravel/sanctum": "~3.2.1", + "laravel/tinker": "~2.8.1", + "laravel/ui": "~4.2.1", + "lcobucci/jwt": "~4.3.0", + "league/flysystem-aws-s3-v3": "~3.12.2", + "league/flysystem-memory": "~3.10.3", "matriphe/iso-639": "~1.2", - "phpseclib/phpseclib": "~3.0", - "pragmarx/google2fa": "~8.0", - "predis/predis": "~2.0", - "psr/cache": "~3.0", - "s1lentium/iptools": "~1.1", - "spatie/laravel-fractal": "~6.0", - "spatie/laravel-query-builder": "~5.1", - "staudenmeir/belongs-to-through": "~2.12", - "symfony/http-client": "~6.0", - "symfony/mailgun-mailer": "~6.0", - "symfony/postmark-mailer": "~6.0", - "symfony/yaml": "~6.0", - "webmozart/assert": "~1.11" + "phpseclib/phpseclib": "~3.0.18", + "pragmarx/google2fa": "~8.0.0", + "predis/predis": "~2.1.1", + "prologue/alerts": "~1.1.0", + "psr/cache": "~3.0.0", + "s1lentium/iptools": "~1.2.0", + "spatie/laravel-fractal": "~6.0.3", + "spatie/laravel-query-builder": "~5.1.2", + "staudenmeir/belongs-to-through": "~2.13", + "symfony/http-client": "~6.2.6", + "symfony/mailgun-mailer": "~6.2.5", + "symfony/postmark-mailer": "~6.2.5", + "symfony/yaml": "~6.2.5", + "webmozart/assert": "~1.11.0" }, "require-dev": { - "barryvdh/laravel-ide-helper": "~2.12.3", - "fakerphp/faker": "~1.20", - "friendsofphp/php-cs-fixer": "~3.11", - "itsgoingd/clockwork": "~5.1", - "laravel/sail": "~1.16", - "mockery/mockery": "~1.5", - "nunomaduro/collision": "~6.3", - "nunomaduro/larastan": "^2.0", - "phpstan/phpstan": "~1.9", - "php-mock/php-mock-phpunit": "~2.6", - "phpunit/phpunit": "~9.5", - "spatie/laravel-ignition": "~1.5" + "barryvdh/laravel-ide-helper": "~2.13.0", + "fakerphp/faker": "~1.21.0", + "friendsofphp/php-cs-fixer": "~3.14.4", + "itsgoingd/clockwork": "~5.1.12", + "laravel/sail": "~1.21.0", + "mockery/mockery": "~1.5.1", + "nunomaduro/collision": "~7.0.5", + "nunomaduro/larastan": "~2.4.1", + "phpstan/phpstan": "~1.10.1", + "phpunit/phpunit": "~10.0.11", + "spatie/laravel-ignition": "~2.0.0" }, "autoload": { "files": [ @@ -84,24 +84,25 @@ "scripts": { "cs:fix": "php-cs-fixer fix", "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": [ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" ], "post-create-project-cmd": [ - "@php artisan key:generate" - ], - "post-autoload-dump": [ - "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", - "@php artisan package:discover || true" + "@php artisan key:generate --ansi" ] }, - "prefer-stable": true, "config": { "optimize-autoloader": true, "preferred-install": "dist", "sort-packages": true, "platform": { - "php": "8.0.2" + "php": "8.1.0" } - } + }, + "minimum-stability": "stable", + "prefer-stable": true } diff --git a/config/mail.php b/config/mail.php index ee612fdcc..71c693cff 100644 --- a/config/mail.php +++ b/config/mail.php @@ -27,7 +27,7 @@ return [ | 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. | - | Supported: "smtp", "sendmail", "mailgun", "ses", + | Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2", | "postmark", "log", "array", "failover" | */ diff --git a/database/Factories/EggVariableFactory.php b/database/Factories/EggVariableFactory.php index 53b94c4c2..c2bce816b 100644 --- a/database/Factories/EggVariableFactory.php +++ b/database/Factories/EggVariableFactory.php @@ -34,7 +34,7 @@ class EggVariableFactory extends Factory /** * Indicate that the egg variable is viewable. */ - public function viewable(): Factory + public function viewable(): static { return $this->state(function (array $attributes) { return [ @@ -46,7 +46,7 @@ class EggVariableFactory extends Factory /** * Indicate that the egg variable is editable. */ - public function editable(): Factory + public function editable(): static { return $this->state(function (array $attributes) { return [ diff --git a/database/Factories/UserFactory.php b/database/Factories/UserFactory.php index 7cb3f0eda..4ebe192c7 100644 --- a/database/Factories/UserFactory.php +++ b/database/Factories/UserFactory.php @@ -41,7 +41,7 @@ class UserFactory extends Factory /** * Indicate that the user is an admin. */ - public function admin(): Factory + public function admin(): static { return $this->state(['root_admin' => true]); } diff --git a/database/migrations/2023_02_23_191004_add_expires_at_column_to_api_keys_table.php b/database/migrations/2023_02_23_191004_add_expires_at_column_to_api_keys_table.php new file mode 100644 index 000000000..49e19bfed --- /dev/null +++ b/database/migrations/2023_02_23_191004_add_expires_at_column_to_api_keys_table.php @@ -0,0 +1,27 @@ +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'); + }); + } +}; diff --git a/phpunit.xml b/phpunit.xml index 5319118fd..531bab69a 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -4,9 +4,8 @@ xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd" bootstrap="bootstrap/tests.php" colors="true" - printerClass="NunoMaduro\Collision\Adapters\Phpunit\Printer" > - + ./app diff --git a/resources/scripts/api/transformers.ts b/resources/scripts/api/transformers.ts index 34a2611d0..6d1e75c5a 100644 --- a/resources/scripts/api/transformers.ts +++ b/resources/scripts/api/transformers.ts @@ -47,7 +47,7 @@ export const rawDataToFileObject = (data: FractalResponseData): FileObject => ({ isEditable: function () { 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)); }, diff --git a/tests/Integration/Api/Application/Users/UserControllerTest.php b/tests/Integration/Api/Application/Users/UserControllerTest.php index 7ddf8b975..fd6c7618f 100644 --- a/tests/Integration/Api/Application/Users/UserControllerTest.php +++ b/tests/Integration/Api/Application/Users/UserControllerTest.php @@ -255,7 +255,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase * Endpoints that should return a 403 error when the key does not have write * permissions for user management. */ - public function userWriteEndpointsDataProvider(): array + public static function userWriteEndpointsDataProvider(): array { return [ ['postJson', '/api/application/users'], diff --git a/tests/Integration/Api/Client/ApiKeyControllerTest.php b/tests/Integration/Api/Client/ApiKeyControllerTest.php index 9aa515f9b..39b2055eb 100644 --- a/tests/Integration/Api/Client/ApiKeyControllerTest.php +++ b/tests/Integration/Api/Client/ApiKeyControllerTest.php @@ -241,7 +241,7 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase * Provides some different IP address combinations that can be used when * testing that we accept the expected IP values. */ - public function validIPAddressDataProvider(): array + public static function validIPAddressDataProvider(): array { return [ [[]], diff --git a/tests/Integration/Api/Client/ClientControllerTest.php b/tests/Integration/Api/Client/ClientControllerTest.php index ed0cada00..cb9cdfc01 100644 --- a/tests/Integration/Api/Client/ClientControllerTest.php +++ b/tests/Integration/Api/Client/ClientControllerTest.php @@ -331,7 +331,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase $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']]; } diff --git a/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php b/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php index 11ad2fa83..9c5eebd10 100644 --- a/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php @@ -46,7 +46,7 @@ class AllocationAuthorizationTest extends ClientApiIntegrationTestCase $this->actingAs($user)->json($method, $this->link($server3, '/network/allocations/' . $allocation3->id . $endpoint))->assertNotFound(); } - public function methodDataProvider(): array + public static function methodDataProvider(): array { return [ ['POST', ''], diff --git a/tests/Integration/Api/Client/Server/Allocation/CreateNewAllocationTest.php b/tests/Integration/Api/Client/Server/Allocation/CreateNewAllocationTest.php index 1abb106cd..8022fb1e4 100644 --- a/tests/Integration/Api/Client/Server/Allocation/CreateNewAllocationTest.php +++ b/tests/Integration/Api/Client/Server/Allocation/CreateNewAllocationTest.php @@ -86,7 +86,7 @@ class CreateNewAllocationTest extends ClientApiIntegrationTestCase ->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]], [[]]]; } diff --git a/tests/Integration/Api/Client/Server/Allocation/DeleteAllocationTest.php b/tests/Integration/Api/Client/Server/Allocation/DeleteAllocationTest.php index 42db6eef7..7d4737b75 100644 --- a/tests/Integration/Api/Client/Server/Allocation/DeleteAllocationTest.php +++ b/tests/Integration/Api/Client/Server/Allocation/DeleteAllocationTest.php @@ -98,10 +98,7 @@ class DeleteAllocationTest extends ClientApiIntegrationTestCase $this->actingAs($user)->deleteJson($this->link($server, "/network/allocations/{$server2->allocation_id}"))->assertNotFound(); } - /** - * @return array - */ - public function permissionDataProvider() + public static function permissionDataProvider(): array { return [[[Permission::ACTION_ALLOCATION_DELETE]], [[]]]; } diff --git a/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php b/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php index 9344c6ab5..20d9e13a7 100644 --- a/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php @@ -54,7 +54,7 @@ class BackupAuthorizationTest extends ClientApiIntegrationTestCase $this->actingAs($user)->json($method, $this->link($server3, '/backups/' . $backup3->uuid . $endpoint))->assertNotFound(); } - public function methodDataProvider(): array + public static function methodDataProvider(): array { return [ ['GET', ''], diff --git a/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php b/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php index b6f3924e0..30abd5454 100644 --- a/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php @@ -58,7 +58,7 @@ class DatabaseAuthorizationTest extends ClientApiIntegrationTestCase $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 [ ['POST', '/rotate-password'], diff --git a/tests/Integration/Api/Client/Server/NetworkAllocationControllerTest.php b/tests/Integration/Api/Client/Server/NetworkAllocationControllerTest.php index c9523733d..b19be99cc 100644 --- a/tests/Integration/Api/Client/Server/NetworkAllocationControllerTest.php +++ b/tests/Integration/Api/Client/Server/NetworkAllocationControllerTest.php @@ -133,7 +133,7 @@ class NetworkAllocationControllerTest extends ClientApiIntegrationTestCase ->assertForbidden(); } - public function updatePermissionsDataProvider(): array + public static function updatePermissionsDataProvider(): array { return [[[]], [[Permission::ACTION_ALLOCATION_UPDATE]]]; } diff --git a/tests/Integration/Api/Client/Server/PowerControllerTest.php b/tests/Integration/Api/Client/Server/PowerControllerTest.php index ea261ce0b..f31244948 100644 --- a/tests/Integration/Api/Client/Server/PowerControllerTest.php +++ b/tests/Integration/Api/Client/Server/PowerControllerTest.php @@ -72,7 +72,7 @@ class PowerControllerTest extends ClientApiIntegrationTestCase /** * Returns invalid permission combinations for a given power action. */ - public function invalidPermissionDataProvider(): array + public static function invalidPermissionDataProvider(): array { return [ ['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 [ ['start', Permission::ACTION_CONTROL_START], diff --git a/tests/Integration/Api/Client/Server/Schedule/CreateServerScheduleTest.php b/tests/Integration/Api/Client/Server/Schedule/CreateServerScheduleTest.php index f87aef292..f72ef09f5 100644 --- a/tests/Integration/Api/Client/Server/Schedule/CreateServerScheduleTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/CreateServerScheduleTest.php @@ -89,7 +89,7 @@ class CreateServerScheduleTest extends ClientApiIntegrationTestCase ->assertForbidden(); } - public function permissionsDataProvider(): array + public static function permissionsDataProvider(): array { return [[[]], [[Permission::ACTION_SCHEDULE_CREATE]]]; } diff --git a/tests/Integration/Api/Client/Server/Schedule/DeleteServerScheduleTest.php b/tests/Integration/Api/Client/Server/Schedule/DeleteServerScheduleTest.php index 4a79584a8..d44447025 100644 --- a/tests/Integration/Api/Client/Server/Schedule/DeleteServerScheduleTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/DeleteServerScheduleTest.php @@ -77,7 +77,7 @@ class DeleteServerScheduleTest extends ClientApiIntegrationTestCase $this->assertDatabaseHas('schedules', ['id' => $schedule->id]); } - public function permissionsDataProvider(): array + public static function permissionsDataProvider(): array { return [[[]], [[Permission::ACTION_SCHEDULE_DELETE]]]; } diff --git a/tests/Integration/Api/Client/Server/Schedule/ExecuteScheduleTest.php b/tests/Integration/Api/Client/Server/Schedule/ExecuteScheduleTest.php index 9964691aa..7ca355299 100644 --- a/tests/Integration/Api/Client/Server/Schedule/ExecuteScheduleTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/ExecuteScheduleTest.php @@ -64,7 +64,7 @@ class ExecuteScheduleTest extends ClientApiIntegrationTestCase $this->actingAs($user)->postJson($this->link($schedule, '/execute'))->assertForbidden(); } - public function permissionsDataProvider(): array + public static function permissionsDataProvider(): array { return [[[]], [[Permission::ACTION_SCHEDULE_UPDATE]]]; } diff --git a/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php b/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php index d9d2ae3f6..483c7ae42 100644 --- a/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php @@ -89,7 +89,7 @@ class GetServerSchedulesTest extends ClientApiIntegrationTestCase ->assertForbidden(); } - public function permissionsDataProvider(): array + public static function permissionsDataProvider(): array { return [ [[], false], diff --git a/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php b/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php index a8a881194..bf5b8d729 100644 --- a/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php @@ -54,7 +54,7 @@ class ScheduleAuthorizationTest extends ClientApiIntegrationTestCase $this->actingAs($user)->json($method, $this->link($server3, '/schedules/' . $schedule3->id . $endpoint))->assertNotFound(); } - public function methodDataProvider(): array + public static function methodDataProvider(): array { return [ ['GET', ''], diff --git a/tests/Integration/Api/Client/Server/Schedule/UpdateServerScheduleTest.php b/tests/Integration/Api/Client/Server/Schedule/UpdateServerScheduleTest.php index 7442a2b5f..23a054b34 100644 --- a/tests/Integration/Api/Client/Server/Schedule/UpdateServerScheduleTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/UpdateServerScheduleTest.php @@ -109,7 +109,7 @@ class UpdateServerScheduleTest extends ClientApiIntegrationTestCase $this->assertFalse($schedule->is_processing); } - public function permissionsDataProvider(): array + public static function permissionsDataProvider(): array { return [[[]], [[Permission::ACTION_SCHEDULE_UPDATE]]]; } diff --git a/tests/Integration/Api/Client/Server/ScheduleTask/CreateServerScheduleTaskTest.php b/tests/Integration/Api/Client/Server/ScheduleTask/CreateServerScheduleTaskTest.php index a71e0233c..736344a68 100644 --- a/tests/Integration/Api/Client/Server/ScheduleTask/CreateServerScheduleTaskTest.php +++ b/tests/Integration/Api/Client/Server/ScheduleTask/CreateServerScheduleTaskTest.php @@ -170,7 +170,7 @@ class CreateServerScheduleTaskTest extends ClientApiIntegrationTestCase ->assertForbidden(); } - public function permissionsDataProvider(): array + public static function permissionsDataProvider(): array { return [[[]], [[Permission::ACTION_SCHEDULE_UPDATE]]]; } diff --git a/tests/Integration/Api/Client/Server/SettingsControllerTest.php b/tests/Integration/Api/Client/Server/SettingsControllerTest.php index 17dc5e7e3..fcc7a5ce7 100644 --- a/tests/Integration/Api/Client/Server/SettingsControllerTest.php +++ b/tests/Integration/Api/Client/Server/SettingsControllerTest.php @@ -112,12 +112,12 @@ class SettingsControllerTest extends ClientApiIntegrationTestCase $this->assertTrue($server->isInstalled()); } - public function renamePermissionsDataProvider(): array + public static function renamePermissionsDataProvider(): array { return [[[]], [[Permission::ACTION_SETTINGS_RENAME]]]; } - public function reinstallPermissionsDataProvider(): array + public static function reinstallPermissionsDataProvider(): array { return [[[]], [[Permission::ACTION_SETTINGS_REINSTALL]]]; } diff --git a/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php b/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php index 3024ecf86..bc219a22f 100644 --- a/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php +++ b/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php @@ -58,7 +58,7 @@ class GetStartupAndVariablesTest extends ClientApiIntegrationTestCase $this->actingAs($user2)->getJson($this->link($server) . '/startup')->assertNotFound(); } - public function permissionsDataProvider(): array + public static function permissionsDataProvider(): array { return [[[]], [[Permission::ACTION_STARTUP_READ]]]; } diff --git a/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php b/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php index d7ade1eef..fed4d1377 100644 --- a/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php +++ b/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php @@ -149,7 +149,7 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase $this->actingAs($user2)->putJson($this->link($server) . '/startup/variable')->assertNotFound(); } - public function permissionsDataProvider(): array + public static function permissionsDataProvider(): array { return [[[]], [[Permission::ACTION_STARTUP_UPDATE]]]; } diff --git a/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php b/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php index f55ca18a8..c12ede61a 100644 --- a/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php +++ b/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php @@ -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.'); } - public function permissionsDataProvider(): array + public static function permissionsDataProvider(): array { return [[[]], [[Permission::ACTION_USER_CREATE]]]; } diff --git a/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php b/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php index 3f63131d5..c7935aa34 100644 --- a/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php @@ -49,7 +49,7 @@ class SubuserAuthorizationTest extends ClientApiIntegrationTestCase $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']]; } diff --git a/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php b/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php index 9e7136a80..38d4ccc65 100644 --- a/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php +++ b/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php @@ -213,7 +213,7 @@ class SftpAuthenticationControllerTest extends IntegrationTestCase $this->post('/api/remote/sftp/auth', $data)->assertForbidden(); } - public function authorizationTypeDataProvider(): array + public static function authorizationTypeDataProvider(): array { return [ 'password auth' => ['password'], @@ -221,7 +221,7 @@ class SftpAuthenticationControllerTest extends IntegrationTestCase ]; } - public function serverStateDataProvider(): array + public static function serverStateDataProvider(): array { return [ 'installing' => [Server::STATUS_INSTALLING], diff --git a/tests/Integration/Jobs/Schedule/RunTaskJobTest.php b/tests/Integration/Jobs/Schedule/RunTaskJobTest.php index ec1963b40..c1c324425 100644 --- a/tests/Integration/Jobs/Schedule/RunTaskJobTest.php +++ b/tests/Integration/Jobs/Schedule/RunTaskJobTest.php @@ -37,7 +37,7 @@ class RunTaskJobTest extends IntegrationTestCase $job = new RunTaskJob($task); - Bus::dispatchNow($job); + Bus::dispatchSync($job); $task->refresh(); $schedule->refresh(); @@ -61,7 +61,7 @@ class RunTaskJobTest extends IntegrationTestCase $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid task action provided: foobar'); - Bus::dispatchNow($job); + Bus::dispatchSync($job); } /** @@ -95,7 +95,7 @@ class RunTaskJobTest extends IntegrationTestCase }))->andReturnSelf(); $mock->expects('send')->with('start')->andReturn(new Response()); - Bus::dispatchNow(new RunTaskJob($task, $isManualRun)); + Bus::dispatchSync(new RunTaskJob($task, $isManualRun)); $task->refresh(); $schedule->refresh(); @@ -133,7 +133,7 @@ class RunTaskJobTest extends IntegrationTestCase $this->expectException(DaemonConnectionException::class); } - Bus::dispatchNow(new RunTaskJob($task)); + Bus::dispatchSync(new RunTaskJob($task)); if ($continueOnFailure) { $task->refresh(); @@ -165,7 +165,7 @@ class RunTaskJobTest extends IntegrationTestCase 'payload' => 'start', ]); - Bus::dispatchNow(new RunTaskJob($task)); + Bus::dispatchSync(new RunTaskJob($task)); $task->refresh(); $schedule->refresh(); @@ -175,7 +175,7 @@ class RunTaskJobTest extends IntegrationTestCase $this->assertTrue(Carbon::now()->isSameAs(\DateTimeInterface::ATOM, $schedule->last_run_at)); } - public function isManualRunDataProvider(): array + public static function isManualRunDataProvider(): array { return [[true], [false]]; } diff --git a/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php b/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php index 2848adb0f..5a0bda4cf 100644 --- a/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php +++ b/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php @@ -194,7 +194,7 @@ class DatabaseManagementServiceTest extends IntegrationTestCase $this->assertDatabaseMissing('databases', ['server_id' => $server->id]); } - public function invalidDataDataProvider(): array + public static function invalidDataDataProvider(): array { return [ [[]], diff --git a/tests/Integration/Services/Databases/DeployServerDatabaseServiceTest.php b/tests/Integration/Services/Databases/DeployServerDatabaseServiceTest.php index f1511852b..cc16bf2c2 100644 --- a/tests/Integration/Services/Databases/DeployServerDatabaseServiceTest.php +++ b/tests/Integration/Services/Databases/DeployServerDatabaseServiceTest.php @@ -141,7 +141,7 @@ class DeployServerDatabaseServiceTest extends IntegrationTestCase $this->assertInstanceOf(Database::class, $response); } - public function invalidDataProvider(): array + public static function invalidDataProvider(): array { return [ [['remote' => '%']], diff --git a/tests/Integration/Services/Schedules/ProcessScheduleServiceTest.php b/tests/Integration/Services/Schedules/ProcessScheduleServiceTest.php index c094e40cf..eaed38a16 100644 --- a/tests/Integration/Services/Schedules/ProcessScheduleServiceTest.php +++ b/tests/Integration/Services/Schedules/ProcessScheduleServiceTest.php @@ -148,7 +148,7 @@ class ProcessScheduleServiceTest extends IntegrationTestCase $this->assertDatabaseHas('tasks', ['id' => $task->id, 'is_queued' => false]); } - public function dispatchNowDataProvider(): array + public static function dispatchNowDataProvider(): array { return [[true], [false]]; } diff --git a/tests/Unit/Helpers/EnvironmentWriterTraitTest.php b/tests/Unit/Helpers/EnvironmentWriterTraitTest.php index f2022f798..0680da0db 100644 --- a/tests/Unit/Helpers/EnvironmentWriterTraitTest.php +++ b/tests/Unit/Helpers/EnvironmentWriterTraitTest.php @@ -17,7 +17,7 @@ class EnvironmentWriterTraitTest extends TestCase $this->assertSame($expected, $output); } - public function variableDataProvider(): array + public static function variableDataProvider(): array { return [ ['foo', 'foo'], diff --git a/tests/Unit/Helpers/IsDigitTest.php b/tests/Unit/Helpers/IsDigitTest.php index 4ba08042f..af19c732e 100644 --- a/tests/Unit/Helpers/IsDigitTest.php +++ b/tests/Unit/Helpers/IsDigitTest.php @@ -19,7 +19,7 @@ class IsDigitTest extends TestCase /** * Provide data to test against the helper function. */ - public function helperDataProvider(): array + public static function helperDataProvider(): array { return [ [true, false], diff --git a/tests/Unit/Http/Middleware/Api/Daemon/DaemonAuthenticateTest.php b/tests/Unit/Http/Middleware/Api/Daemon/DaemonAuthenticateTest.php index 8c8c76920..84562f6c9 100644 --- a/tests/Unit/Http/Middleware/Api/Daemon/DaemonAuthenticateTest.php +++ b/tests/Unit/Http/Middleware/Api/Daemon/DaemonAuthenticateTest.php @@ -138,7 +138,7 @@ class DaemonAuthenticateTest extends MiddlewareTestCase * * @return array|\string[][] */ - public function badTokenDataProvider(): array + public static function badTokenDataProvider(): array { return [ ['foo'], diff --git a/tests/Unit/Rules/UsernameTest.php b/tests/Unit/Rules/UsernameTest.php index 829cab2c3..003e3e8dd 100644 --- a/tests/Unit/Rules/UsernameTest.php +++ b/tests/Unit/Rules/UsernameTest.php @@ -38,7 +38,7 @@ class UsernameTest extends TestCase /** * Provide valid usernames. */ - public function validUsernameDataProvider(): array + public static function validUsernameDataProvider(): array { return [ ['username'], @@ -54,7 +54,7 @@ class UsernameTest extends TestCase /** * Provide invalid usernames. */ - public function invalidUsernameDataProvider(): array + public static function invalidUsernameDataProvider(): array { return [ ['_username'], diff --git a/tests/Unit/Services/Acl/Api/AdminAclTest.php b/tests/Unit/Services/Acl/Api/AdminAclTest.php index daaea838f..3f89659a2 100644 --- a/tests/Unit/Services/Acl/Api/AdminAclTest.php +++ b/tests/Unit/Services/Acl/Api/AdminAclTest.php @@ -31,7 +31,7 @@ class AdminAclTest extends TestCase /** * Provide valid and invalid permissions combos for testing. */ - public function permissionsDataProvider(): array + public static function permissionsDataProvider(): array { return [ [AdminAcl::READ, AdminAcl::READ, true],