Update to Laravel 5.5 (#814)

This commit is contained in:
Dane Everitt 2017-12-17 13:07:38 -06:00 committed by GitHub
parent f9df463d32
commit b9d67459b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 1021 additions and 818 deletions

View file

@ -4,10 +4,6 @@ php:
- 7.0 - 7.0
- 7.1 - 7.1
- 7.2 - 7.2
matrix:
fast_finish: true
allow_failures:
- php: 7.2
sudo: false sudo: false
cache: cache:
directories: directories:

View file

@ -15,6 +15,8 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
### Changed ### Changed
* Revoking the administrative status for an admin will revoke all authentication tokens currently assigned to their account. * Revoking the administrative status for an admin will revoke all authentication tokens currently assigned to their account.
* Updated core framework to Laravel 5.5. This includes many dependency updates.
* Certain AWS specific environment keys were changed, this should have minimal impact on users unless you specifically enabled AWS specific features. The renames are: `AWS_KEY -> AWS_ACCESS_KEY_ID`, `AWS_SECRET -> AWS_SECRET_ACCESS_KEY`, `AWS_REGION -> AWS_DEFAULT_REGION`
### Added ### Added
* Added star indicators to user listing in Admin CP to indicate users who are set as a root admin. * Added star indicators to user listing in Admin CP to indicate users who are set as a root admin.

View file

@ -1,14 +1,8 @@
<?php <?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Console\Commands\Maintenance; namespace Pterodactyl\Console\Commands\Maintenance;
use SplFileInfo;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Contracts\Filesystem\Factory as FilesystemFactory; use Illuminate\Contracts\Filesystem\Factory as FilesystemFactory;
@ -17,11 +11,6 @@ class CleanServiceBackupFilesCommand extends Command
{ {
const BACKUP_THRESHOLD_MINUTES = 5; const BACKUP_THRESHOLD_MINUTES = 5;
/**
* @var \Carbon\Carbon
*/
protected $carbon;
/** /**
* @var string * @var string
*/ */
@ -40,14 +29,12 @@ class CleanServiceBackupFilesCommand extends Command
/** /**
* CleanServiceBackupFilesCommand constructor. * CleanServiceBackupFilesCommand constructor.
* *
* @param \Carbon\Carbon $carbon
* @param \Illuminate\Contracts\Filesystem\Factory $filesystem * @param \Illuminate\Contracts\Filesystem\Factory $filesystem
*/ */
public function __construct(Carbon $carbon, FilesystemFactory $filesystem) public function __construct(FilesystemFactory $filesystem)
{ {
parent::__construct(); parent::__construct();
$this->carbon = $carbon;
$this->disk = $filesystem->disk(); $this->disk = $filesystem->disk();
} }
@ -58,11 +45,11 @@ class CleanServiceBackupFilesCommand extends Command
{ {
$files = $this->disk->files('services/.bak'); $files = $this->disk->files('services/.bak');
collect($files)->each(function ($file) { collect($files)->each(function (SplFileInfo $file) {
$lastModified = $this->carbon->timestamp($this->disk->lastModified($file)); $lastModified = Carbon::createFromTimestamp($this->disk->lastModified($file->getPath()));
if ($lastModified->diffInMinutes($this->carbon->now()) > self::BACKUP_THRESHOLD_MINUTES) { if ($lastModified->diffInMinutes(Carbon::now()) > self::BACKUP_THRESHOLD_MINUTES) {
$this->disk->delete($file); $this->disk->delete($file->getPath());
$this->info(trans('command/messages.maintenance.deleting_service_backup', ['file' => $file])); $this->info(trans('command/messages.maintenance.deleting_service_backup', ['file' => $file->getFilename()]));
} }
}); });
} }

View file

@ -3,41 +3,17 @@
namespace Pterodactyl\Console; namespace Pterodactyl\Console;
use Illuminate\Console\Scheduling\Schedule; use Illuminate\Console\Scheduling\Schedule;
use Pterodactyl\Console\Commands\InfoCommand;
use Pterodactyl\Console\Commands\User\MakeUserCommand;
use Pterodactyl\Console\Commands\User\DeleteUserCommand;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel; use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Pterodactyl\Console\Commands\Server\RebuildServerCommand;
use Pterodactyl\Console\Commands\Location\MakeLocationCommand;
use Pterodactyl\Console\Commands\User\DisableTwoFactorCommand;
use Pterodactyl\Console\Commands\Environment\AppSettingsCommand;
use Pterodactyl\Console\Commands\Location\DeleteLocationCommand;
use Pterodactyl\Console\Commands\Schedule\ProcessRunnableCommand;
use Pterodactyl\Console\Commands\Environment\EmailSettingsCommand;
use Pterodactyl\Console\Commands\Environment\DatabaseSettingsCommand;
use Pterodactyl\Console\Commands\Maintenance\CleanServiceBackupFilesCommand;
class Kernel extends ConsoleKernel class Kernel extends ConsoleKernel
{ {
/** /**
* The Artisan commands provided by your application. * Register the commands for the application.
*
* @var array
*/ */
protected $commands = [ protected function commands()
AppSettingsCommand::class, {
CleanServiceBackupFilesCommand::class, $this->load(__DIR__ . '/Commands');
DatabaseSettingsCommand::class, }
DeleteLocationCommand::class,
DeleteUserCommand::class,
DisableTwoFactorCommand::class,
EmailSettingsCommand::class,
InfoCommand::class,
MakeLocationCommand::class,
MakeUserCommand::class,
ProcessRunnableCommand::class,
RebuildServerCommand::class,
];
/** /**
* Define the application's command schedule. * Define the application's command schedule.

View file

@ -163,7 +163,7 @@ class PackController extends Controller
*/ */
public function store(PackFormRequest $request) public function store(PackFormRequest $request)
{ {
if ($request->has('from_template')) { if ($request->filled('from_template')) {
$pack = $this->templateUploadService->handle($request->input('egg_id'), $request->file('file_upload')); $pack = $this->templateUploadService->handle($request->input('egg_id'), $request->file('file_upload'));
} else { } else {
$pack = $this->creationService->handle($request->normalize(), $request->file('file_upload')); $pack = $this->creationService->handle($request->normalize(), $request->file('file_upload'));

View file

@ -524,7 +524,7 @@ class ServersController extends Controller
*/ */
public function delete(Request $request, Server $server) public function delete(Request $request, Server $server)
{ {
$this->deletionService->withForce($request->has('force_delete'))->handle($server); $this->deletionService->withForce($request->filled('force_delete'))->handle($server);
$this->alert->success(trans('admin/server.alerts.server_deleted'))->flash(); $this->alert->success(trans('admin/server.alerts.server_deleted'))->flash();
return redirect()->route('admin.servers'); return redirect()->route('admin.servers');

View file

@ -107,6 +107,8 @@ class LoginController extends Controller
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\Response * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\Response
*
* @throws \Illuminate\Validation\ValidationException
*/ */
public function login(Request $request) public function login(Request $request)
{ {
@ -115,8 +117,7 @@ class LoginController extends Controller
if ($this->hasTooManyLoginAttempts($request)) { if ($this->hasTooManyLoginAttempts($request)) {
$this->fireLockoutEvent($request); $this->fireLockoutEvent($request);
$this->sendLockoutResponse($request);
return $this->sendLockoutResponse($request);
} }
try { try {

View file

@ -1,27 +1,4 @@
<?php <?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>
* Some Modifications (c) 2015 Dylan Seidt <dylan.seidt@gmail.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Http\Controllers\Base; namespace Pterodactyl\Http\Controllers\Base;

View file

@ -2,10 +2,10 @@
namespace Pterodactyl\Http; namespace Pterodactyl\Http;
use Fideloper\Proxy\TrustProxies;
use Illuminate\Auth\Middleware\Authorize; use Illuminate\Auth\Middleware\Authorize;
use Illuminate\Auth\Middleware\Authenticate; use Illuminate\Auth\Middleware\Authenticate;
use Pterodactyl\Http\Middleware\TrimStrings; use Pterodactyl\Http\Middleware\TrimStrings;
use Pterodactyl\Http\Middleware\TrustProxies;
use Illuminate\Session\Middleware\StartSession; use Illuminate\Session\Middleware\StartSession;
use Pterodactyl\Http\Middleware\EncryptCookies; use Pterodactyl\Http\Middleware\EncryptCookies;
use Pterodactyl\Http\Middleware\VerifyCsrfToken; use Pterodactyl\Http\Middleware\VerifyCsrfToken;
@ -23,6 +23,7 @@ use Pterodactyl\Http\Middleware\RedirectIfAuthenticated;
use Illuminate\Auth\Middleware\AuthenticateWithBasicAuth; use Illuminate\Auth\Middleware\AuthenticateWithBasicAuth;
use Pterodactyl\Http\Middleware\API\AuthenticateIPAccess; use Pterodactyl\Http\Middleware\API\AuthenticateIPAccess;
use Pterodactyl\Http\Middleware\Daemon\DaemonAuthenticate; use Pterodactyl\Http\Middleware\Daemon\DaemonAuthenticate;
use Illuminate\Foundation\Http\Middleware\ValidatePostSize;
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse; use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
use Pterodactyl\Http\Middleware\API\HasPermissionToResource; use Pterodactyl\Http\Middleware\API\HasPermissionToResource;
use Pterodactyl\Http\Middleware\Server\AuthenticateAsSubuser; use Pterodactyl\Http\Middleware\Server\AuthenticateAsSubuser;
@ -31,6 +32,7 @@ use Pterodactyl\Http\Middleware\RequireTwoFactorAuthentication;
use Pterodactyl\Http\Middleware\Server\DatabaseBelongsToServer; use Pterodactyl\Http\Middleware\Server\DatabaseBelongsToServer;
use Pterodactyl\Http\Middleware\Server\ScheduleBelongsToServer; use Pterodactyl\Http\Middleware\Server\ScheduleBelongsToServer;
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode; use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode;
use Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull;
use Pterodactyl\Http\Middleware\DaemonAuthenticate as OldDaemonAuthenticate; use Pterodactyl\Http\Middleware\DaemonAuthenticate as OldDaemonAuthenticate;
class Kernel extends HttpKernel class Kernel extends HttpKernel
@ -42,9 +44,9 @@ class Kernel extends HttpKernel
*/ */
protected $middleware = [ protected $middleware = [
CheckForMaintenanceMode::class, CheckForMaintenanceMode::class,
EncryptCookies::class, ValidatePostSize::class,
AddQueuedCookiesToResponse::class,
TrimStrings::class, TrimStrings::class,
ConvertEmptyStringsToNull::class,
TrustProxies::class, TrustProxies::class,
]; ];

View file

@ -0,0 +1,29 @@
<?php
namespace Pterodactyl\Http\Middleware;
use Illuminate\Http\Request;
use Fideloper\Proxy\TrustProxies as Middleware;
class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array
*/
protected $proxies;
/**
* The current proxy header mappings.
*
* @var array
*/
protected $headers = [
Request::HEADER_FORWARDED => 'FORWARDED',
Request::HEADER_X_FORWARDED_FOR => 'X_FORWARDED_FOR',
Request::HEADER_X_FORWARDED_HOST => 'X_FORWARDED_HOST',
Request::HEADER_X_FORWARDED_PORT => 'X_FORWARDED_PORT',
Request::HEADER_X_FORWARDED_PROTO => 'X_FORWARDED_PROTO',
];
}

View file

@ -39,7 +39,7 @@ class VerifyReCaptcha
return $next($request); return $next($request);
} }
if ($request->has('g-recaptcha-response')) { if ($request->filled('g-recaptcha-response')) {
$client = new Client(); $client = new Client();
$res = $client->post($this->config->get('recaptcha.domain'), [ $res = $client->post($this->config->get('recaptcha.domain'), [
'form_params' => [ 'form_params' => [

View file

@ -44,9 +44,6 @@ abstract class AdminFormRequest extends FormRequest
*/ */
public function normalize($only = []) public function normalize($only = [])
{ {
return array_merge( return $this->all(empty($only) ? array_keys($this->rules()) : $only);
$this->only($only),
$this->intersect(array_keys($this->rules()))
);
} }
} }

View file

@ -18,7 +18,7 @@ class DatabaseHostFormRequest extends AdminFormRequest
*/ */
public function rules() public function rules()
{ {
if (! $this->has('node_id')) { if (! $this->filled('node_id')) {
$this->merge(['node_id' => null]); $this->merge(['node_id' => null]);
} }

View file

@ -1,11 +1,4 @@
<?php <?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Http\Requests\Admin; namespace Pterodactyl\Http\Requests\Admin;
@ -33,7 +26,7 @@ class UserFormRequest extends AdminFormRequest
{ {
if ($this->method === 'PATCH') { if ($this->method === 'PATCH') {
return array_merge( return array_merge(
$this->intersect('password'), $this->all(['password']),
$this->only(['email', 'username', 'name_first', 'name_last', 'root_admin', 'ignore_connection_error']) $this->only(['email', 'username', 'name_first', 'name_last', 'root_admin', 'ignore_connection_error'])
); );
} }

View file

@ -9,8 +9,6 @@
namespace Pterodactyl\Models; namespace Pterodactyl\Models;
use File;
use Storage;
use Sofa\Eloquence\Eloquence; use Sofa\Eloquence\Eloquence;
use Sofa\Eloquence\Validable; use Sofa\Eloquence\Validable;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
@ -88,30 +86,6 @@ class Pack extends Model implements CleansAttributes, ValidableContract
'version' => 2, 'version' => 2,
]; ];
/**
* Returns all of the archived files for a given pack.
*
* @param bool $collection
* @return \Illuminate\Support\Collection|object
* @deprecated
*/
public function files($collection = false)
{
$files = collect(Storage::files('packs/' . $this->uuid));
$files = $files->map(function ($item) {
$path = storage_path('app/' . $item);
return (object) [
'name' => basename($item),
'hash' => sha1_file($path),
'size' => File::humanReadableSize($path),
];
});
return ($collection) ? $files : (object) $files->all();
}
/** /**
* Gets egg associated with a service pack. * Gets egg associated with a service pack.
* *

View file

@ -51,4 +51,17 @@ class ServerPolicy
return $this->checkPermission($user, $server, $ability); return $this->checkPermission($user, $server, $ability);
} }
/**
* This is a horrendous hack to avoid Laravel's "smart" behavior that does
* not call the before() function if there isn't a function matching the
* policy permission.
*
* @param string $name
* @param mixed $arguments
*/
public function __call($name, $arguments)
{
// do nothing
}
} }

View file

@ -12,8 +12,6 @@ use Illuminate\Support\ServiceProvider;
use Pterodactyl\Observers\UserObserver; use Pterodactyl\Observers\UserObserver;
use Pterodactyl\Observers\ServerObserver; use Pterodactyl\Observers\ServerObserver;
use Pterodactyl\Observers\SubuserObserver; use Pterodactyl\Observers\SubuserObserver;
use Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider;
use Barryvdh\Debugbar\ServiceProvider as DebugbarServiceProvider;
class AppServiceProvider extends ServiceProvider class AppServiceProvider extends ServiceProvider
{ {
@ -32,17 +30,6 @@ class AppServiceProvider extends ServiceProvider
View::share('appIsGit', $this->versionData()['is_git'] ?? false); View::share('appIsGit', $this->versionData()['is_git'] ?? false);
} }
/**
* Register any application services.
*/
public function register()
{
if ($this->app->environment() !== 'production') {
$this->app->register(DebugbarServiceProvider::class);
$this->app->register(IdeHelperServiceProvider::class);
}
}
/** /**
* Return version information for the footer. * Return version information for the footer.
* *

View file

@ -12,12 +12,4 @@ class EventServiceProvider extends ServiceProvider
* @var array * @var array
*/ */
protected $listen = []; protected $listen = [];
/**
* Register any other events for your application.
*/
public function boot()
{
parent::boot();
}
} }

View file

@ -87,6 +87,24 @@ class SettingsServiceProvider extends ServiceProvider
} }
} }
switch (strtolower($value)) {
case 'true':
case '(true)':
$value = true;
break;
case 'false':
case '(false)':
$value = false;
break;
case 'empty':
case '(empty)':
$value = '';
break;
case 'null':
case '(null)':
$value = null;
}
$config->set(str_replace(':', '.', $key), $value); $config->set(str_replace(':', '.', $key), $value);
} }
} }

View file

@ -15,43 +15,40 @@
"ext-mbstring": "*", "ext-mbstring": "*",
"ext-pdo_mysql": "*", "ext-pdo_mysql": "*",
"ext-zip": "*", "ext-zip": "*",
"appstract/laravel-blade-directives": "^0.6.0", "appstract/laravel-blade-directives": "^0.7",
"aws/aws-sdk-php": "^3.29", "aws/aws-sdk-php": "^3.48",
"daneeveritt/login-notifications": "^1.0",
"doctrine/dbal": "^2.5", "doctrine/dbal": "^2.5",
"edvinaskrucas/settings": "^2.0",
"fideloper/proxy": "^3.3", "fideloper/proxy": "^3.3",
"guzzlehttp/guzzle": "~6.3.0", "guzzlehttp/guzzle": "^6.3",
"hashids/hashids": "^2.0", "hashids/hashids": "^2.0",
"igaster/laravel-theme": "^1.16", "igaster/laravel-theme": "^1.16",
"laracasts/utilities": "^3.0", "laracasts/utilities": "^3.0",
"laravel/framework": "5.4.27", "laravel/framework": "5.5.*",
"laravel/tinker": "1.0.1", "laravel/tinker": "^1.0",
"lord/laroute": "~2.4.5", "lord/laroute": "^2.4",
"matriphe/iso-639": "^1.2", "matriphe/iso-639": "^1.2",
"mtdowling/cron-expression": "^1.2", "mtdowling/cron-expression": "^1.2",
"nesbot/carbon": "^1.22", "nesbot/carbon": "^1.22",
"nicolaslopezj/searchable": "^1.9",
"pragmarx/google2fa": "^2.0", "pragmarx/google2fa": "^2.0",
"predis/predis": "^1.1", "predis/predis": "^1.1",
"prologue/alerts": "^0.4", "prologue/alerts": "^0.4",
"ramsey/uuid": "^3.7", "ramsey/uuid": "^3.7",
"s1lentium/iptools": "^1.1", "s1lentium/iptools": "^1.1",
"sofa/eloquence": "~5.4.1", "sofa/eloquence-base": "v5.5",
"spatie/laravel-fractal": "^4.0", "sofa/eloquence-validable": "v5.5",
"watson/validating": "^3.0", "spatie/laravel-fractal": "^5.3",
"webmozart/assert": "^1.2", "webmozart/assert": "^1.2",
"webpatser/laravel-uuid": "^2.0",
"znck/belongs-to-through": "^2.3" "znck/belongs-to-through": "^2.3"
}, },
"require-dev": { "require-dev": {
"barryvdh/laravel-debugbar": "^2.4", "barryvdh/laravel-debugbar": "^3.1",
"barryvdh/laravel-ide-helper": "^2.4", "barryvdh/laravel-ide-helper": "^2.4",
"filp/whoops": "^2.1",
"friendsofphp/php-cs-fixer": "^2.8.0", "friendsofphp/php-cs-fixer": "^2.8.0",
"fzaninotto/faker": "^1.6", "fzaninotto/faker": "^1.6",
"mockery/mockery": "^0.9", "mockery/mockery": "^1.0",
"php-mock/php-mock-phpunit": "^1.1", "php-mock/php-mock-phpunit": "^2.0",
"phpunit/phpunit": "^5.7" "phpunit/phpunit": "~6.4.0"
}, },
"autoload": { "autoload": {
"classmap": [ "classmap": [
@ -70,13 +67,15 @@
} }
}, },
"scripts": { "scripts": {
"post-install-cmd": [ "post-root-package-install": [
"Illuminate\\Foundation\\ComposerScripts::postInstall", "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
"php artisan optimize"
], ],
"post-update-cmd": [ "post-create-project-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate", "@php artisan key:generate"
"php artisan optimize" ],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover"
] ]
}, },
"prefer-stable": true, "prefer-stable": true,

1331
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,10 +1,15 @@
<?php <?php
return [ return [
'env' => env('APP_ENV', 'production'), /*
|--------------------------------------------------------------------------
| Application Version
|--------------------------------------------------------------------------
| This value is set when creating a Pterodactyl release. You should not
| change this value if you are not maintaining your own internal versions.
*/
'version' => env('APP_VERSION', 'canary'), 'version' => 'canary',
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@ -15,8 +20,22 @@ return [
| framework needs to place the application's name in a notification or | framework needs to place the application's name in a notification or
| any other location as required by the application or its packages. | any other location as required by the application or its packages.
*/ */
'name' => env('APP_NAME', 'Pterodactyl'), 'name' => env('APP_NAME', 'Pterodactyl'),
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services your application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Application Debug Mode | Application Debug Mode
@ -93,7 +112,7 @@ return [
| |
*/ */
'key' => env('APP_KEY', 'SomeRandomString3232RandomString'), 'key' => env('APP_KEY'),
'cipher' => 'AES-256-CBC', 'cipher' => 'AES-256-CBC',
@ -112,7 +131,7 @@ return [
'log' => env('APP_LOG', 'daily'), 'log' => env('APP_LOG', 'daily'),
'log_level' => env('APP_LOG_LEVEL', 'debug'), 'log_level' => env('APP_LOG_LEVEL', 'info'),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@ -141,6 +160,7 @@ return [
Illuminate\Foundation\Providers\FoundationServiceProvider::class, Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class, Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class, Illuminate\Mail\MailServiceProvider::class,
Illuminate\Notifications\NotificationServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class, Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class, Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class, Illuminate\Queue\QueueServiceProvider::class,
@ -149,12 +169,6 @@ return [
Illuminate\Session\SessionServiceProvider::class, Illuminate\Session\SessionServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class, Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class, Illuminate\View\ViewServiceProvider::class,
Illuminate\Notifications\NotificationServiceProvider::class,
/*
* Package Service Providers...
*/
Laravel\Tinker\TinkerServiceProvider::class,
/* /*
* Application Service Providers... * Application Service Providers...
@ -175,12 +189,7 @@ return [
*/ */
igaster\laravelTheme\themeServiceProvider::class, igaster\laravelTheme\themeServiceProvider::class,
Prologue\Alerts\AlertsServiceProvider::class, Prologue\Alerts\AlertsServiceProvider::class,
Fideloper\Proxy\TrustedProxyServiceProvider::class,
Laracasts\Utilities\JavaScript\JavaScriptServiceProvider::class,
Lord\Laroute\LarouteServiceProvider::class, Lord\Laroute\LarouteServiceProvider::class,
Spatie\Fractal\FractalServiceProvider::class,
Sofa\Eloquence\ServiceProvider::class,
Appstract\BladeDirectives\BladeDirectivesServiceProvider::class,
], ],
/* /*
@ -205,17 +214,14 @@ return [
'Carbon' => Carbon\Carbon::class, 'Carbon' => Carbon\Carbon::class,
'Config' => Illuminate\Support\Facades\Config::class, 'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class, 'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Cron' => Cron\CronExpression::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class, 'Crypt' => Illuminate\Support\Facades\Crypt::class,
'DB' => Illuminate\Support\Facades\DB::class, 'DB' => Illuminate\Support\Facades\DB::class,
'Eloquent' => Illuminate\Database\Eloquent\Model::class, 'Eloquent' => Illuminate\Database\Eloquent\Model::class,
'Event' => Illuminate\Support\Facades\Event::class, 'Event' => Illuminate\Support\Facades\Event::class,
'File' => Illuminate\Support\Facades\File::class, 'File' => Illuminate\Support\Facades\File::class,
'Fractal' => Spatie\Fractal\FractalFacade::class,
'Gate' => Illuminate\Support\Facades\Gate::class, 'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class, 'Hash' => Illuminate\Support\Facades\Hash::class,
'Input' => Illuminate\Support\Facades\Input::class, 'Input' => Illuminate\Support\Facades\Input::class,
'Inspiring' => Illuminate\Foundation\Inspiring::class,
'Javascript' => Laracasts\Utilities\JavaScript\JavaScriptFacade::class, 'Javascript' => Laracasts\Utilities\JavaScript\JavaScriptFacade::class,
'Lang' => Illuminate\Support\Facades\Lang::class, 'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class, 'Log' => Illuminate\Support\Facades\Log::class,
@ -233,7 +239,6 @@ return [
'Storage' => Illuminate\Support\Facades\Storage::class, 'Storage' => Illuminate\Support\Facades\Storage::class,
'Theme' => igaster\laravelTheme\Facades\Theme::class, 'Theme' => igaster\laravelTheme\Facades\Theme::class,
'URL' => Illuminate\Support\Facades\URL::class, 'URL' => Illuminate\Support\Facades\URL::class,
'Uuid' => Webpatser\Uuid\Uuid::class,
'Validator' => Illuminate\Support\Facades\Validator::class, 'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class, 'View' => Illuminate\Support\Facades\View::class,
], ],

View file

@ -10,6 +10,8 @@ return [
| using this caching library. This connection is used when another is | using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function. | not explicitly specified when executing a given caching function.
| |
| Supported: "apc", "array", "database", "file", "memcached", "redis"
|
*/ */
'default' => env('CACHE_DRIVER', 'file'), 'default' => env('CACHE_DRIVER', 'file'),
@ -39,6 +41,7 @@ return [
'table' => 'cache', 'table' => 'cache',
'connection' => null, 'connection' => null,
], ],
'file' => [ 'file' => [
'driver' => 'file', 'driver' => 'file',
'path' => storage_path('framework/cache/data'), 'path' => storage_path('framework/cache/data'),
@ -80,5 +83,5 @@ return [
| |
*/ */
'prefix' => 'pterodactyl', 'prefix' => env('CACHE_PREFIX', str_slug(env('APP_NAME', 'pterodactyl'), '_') . '_cache'),
]; ];

View file

@ -75,7 +75,7 @@ return [
'host' => env('REDIS_HOST', 'localhost'), 'host' => env('REDIS_HOST', 'localhost'),
'password' => env('REDIS_PASSWORD', null), 'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379), 'port' => env('REDIS_PORT', 6379),
'database' => 0, 'database' => env('REDIS_DATBASE', 0),
], ],
], ],
]; ];

View file

@ -10,11 +10,9 @@ return [
| by the framework. A "local" driver, as well as a variety of cloud | by the framework. A "local" driver, as well as a variety of cloud
| based drivers are available for your choosing. Just store away! | based drivers are available for your choosing. Just store away!
| |
| Supported: "local", "ftp", "s3", "rackspace"
|
*/ */
'default' => 'local', 'default' => env('FILESYSTEM_DRIVER', 'local'),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@ -27,7 +25,7 @@ return [
| |
*/ */
'cloud' => 's3', 'cloud' => env('FILESYSTEM_CLOUD', 's3'),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@ -56,9 +54,9 @@ return [
's3' => [ 's3' => [
'driver' => 's3', 'driver' => 's3',
'key' => env('AWS_KEY'), 'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET'), 'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_REGION'), 'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'), 'bucket' => env('AWS_BUCKET'),
], ],
], ],

View file

@ -28,7 +28,7 @@ return [
| |
*/ */
'lifetime' => 10080, 'lifetime' => env('SESSION_LIFETIME', 10080),
'expire_on_close' => false, 'expire_on_close' => false,
@ -121,7 +121,7 @@ return [
| |
*/ */
'cookie' => 'pterodactyl_session', 'cookie' => env('SESSION_COOKIE', str_slug(env('APP_NAME', 'pterodactyl'), '_') . '_session'),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@ -174,4 +174,19 @@ return [
*/ */
'http_only' => true, 'http_only' => true,
/*
|--------------------------------------------------------------------------
| Same-Site Cookies
|--------------------------------------------------------------------------
|
| This option determines how your cookies behave when cross-site requests
| take place, and can be used to mitigate CSRF attacks. By default, we
| do not enable this as other CSRF protection services are in place.
|
| Supported: "lax", "strict"
|
*/
'same_site' => null,
]; ];

View file

@ -1,5 +1,7 @@
<?php <?php
use Faker\Generator as Faker;
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Model Factories | Model Factories
@ -11,9 +13,7 @@
| |
*/ */
\Sofa\Eloquence\Model::unsetEventDispatcher(); $factory->define(Pterodactyl\Models\Server::class, function (Faker $faker) {
$factory->define(Pterodactyl\Models\Server::class, function (Faker\Generator $faker) {
return [ return [
'id' => $faker->unique()->randomNumber(), 'id' => $faker->unique()->randomNumber(),
'node_id' => $faker->randomNumber(), 'node_id' => $faker->randomNumber(),
@ -39,7 +39,7 @@ $factory->define(Pterodactyl\Models\Server::class, function (Faker\Generator $fa
]; ];
}); });
$factory->define(Pterodactyl\Models\User::class, function (Faker\Generator $faker) { $factory->define(Pterodactyl\Models\User::class, function (Faker $faker) {
static $password; static $password;
return [ return [
@ -63,7 +63,7 @@ $factory->state(Pterodactyl\Models\User::class, 'admin', function () {
]; ];
}); });
$factory->define(Pterodactyl\Models\Location::class, function (Faker\Generator $faker) { $factory->define(Pterodactyl\Models\Location::class, function (Faker $faker) {
return [ return [
'id' => $faker->unique()->randomNumber(), 'id' => $faker->unique()->randomNumber(),
'short' => $faker->domainWord, 'short' => $faker->domainWord,
@ -71,7 +71,7 @@ $factory->define(Pterodactyl\Models\Location::class, function (Faker\Generator $
]; ];
}); });
$factory->define(Pterodactyl\Models\Node::class, function (Faker\Generator $faker) { $factory->define(Pterodactyl\Models\Node::class, function (Faker $faker) {
return [ return [
'id' => $faker->unique()->randomNumber(), 'id' => $faker->unique()->randomNumber(),
'uuid' => $faker->unique()->uuid, 'uuid' => $faker->unique()->uuid,
@ -92,7 +92,7 @@ $factory->define(Pterodactyl\Models\Node::class, function (Faker\Generator $fake
]; ];
}); });
$factory->define(Pterodactyl\Models\Nest::class, function (Faker\Generator $faker) { $factory->define(Pterodactyl\Models\Nest::class, function (Faker $faker) {
return [ return [
'id' => $faker->unique()->randomNumber(), 'id' => $faker->unique()->randomNumber(),
'uuid' => $faker->unique()->uuid, 'uuid' => $faker->unique()->uuid,
@ -102,7 +102,7 @@ $factory->define(Pterodactyl\Models\Nest::class, function (Faker\Generator $fake
]; ];
}); });
$factory->define(Pterodactyl\Models\Egg::class, function (Faker\Generator $faker) { $factory->define(Pterodactyl\Models\Egg::class, function (Faker $faker) {
return [ return [
'id' => $faker->unique()->randomNumber(), 'id' => $faker->unique()->randomNumber(),
'uuid' => $faker->unique()->uuid, 'uuid' => $faker->unique()->uuid,
@ -113,7 +113,7 @@ $factory->define(Pterodactyl\Models\Egg::class, function (Faker\Generator $faker
]; ];
}); });
$factory->define(Pterodactyl\Models\EggVariable::class, function (Faker\Generator $faker) { $factory->define(Pterodactyl\Models\EggVariable::class, function (Faker $faker) {
return [ return [
'id' => $faker->unique()->randomNumber(), 'id' => $faker->unique()->randomNumber(),
'name' => $faker->firstName, 'name' => $faker->firstName,
@ -134,7 +134,7 @@ $factory->state(Pterodactyl\Models\EggVariable::class, 'editable', function () {
return ['user_editable' => 1]; return ['user_editable' => 1];
}); });
$factory->define(Pterodactyl\Models\Pack::class, function (Faker\Generator $faker) { $factory->define(Pterodactyl\Models\Pack::class, function (Faker $faker) {
return [ return [
'id' => $faker->unique()->randomNumber(), 'id' => $faker->unique()->randomNumber(),
'egg_id' => $faker->randomNumber(), 'egg_id' => $faker->randomNumber(),
@ -148,7 +148,7 @@ $factory->define(Pterodactyl\Models\Pack::class, function (Faker\Generator $fake
]; ];
}); });
$factory->define(Pterodactyl\Models\Subuser::class, function (Faker\Generator $faker) { $factory->define(Pterodactyl\Models\Subuser::class, function (Faker $faker) {
return [ return [
'id' => $faker->unique()->randomNumber(), 'id' => $faker->unique()->randomNumber(),
'user_id' => $faker->randomNumber(), 'user_id' => $faker->randomNumber(),
@ -156,7 +156,7 @@ $factory->define(Pterodactyl\Models\Subuser::class, function (Faker\Generator $f
]; ];
}); });
$factory->define(Pterodactyl\Models\Allocation::class, function (Faker\Generator $faker) { $factory->define(Pterodactyl\Models\Allocation::class, function (Faker $faker) {
return [ return [
'id' => $faker->unique()->randomNumber(), 'id' => $faker->unique()->randomNumber(),
'node_id' => $faker->randomNumber(), 'node_id' => $faker->randomNumber(),
@ -165,7 +165,7 @@ $factory->define(Pterodactyl\Models\Allocation::class, function (Faker\Generator
]; ];
}); });
$factory->define(Pterodactyl\Models\DatabaseHost::class, function (Faker\Generator $faker) { $factory->define(Pterodactyl\Models\DatabaseHost::class, function (Faker $faker) {
return [ return [
'id' => $faker->unique()->randomNumber(), 'id' => $faker->unique()->randomNumber(),
'name' => $faker->colorName, 'name' => $faker->colorName,
@ -177,7 +177,7 @@ $factory->define(Pterodactyl\Models\DatabaseHost::class, function (Faker\Generat
]; ];
}); });
$factory->define(Pterodactyl\Models\Database::class, function (Faker\Generator $faker) { $factory->define(Pterodactyl\Models\Database::class, function (Faker $faker) {
static $password; static $password;
return [ return [
@ -192,7 +192,7 @@ $factory->define(Pterodactyl\Models\Database::class, function (Faker\Generator $
]; ];
}); });
$factory->define(Pterodactyl\Models\Schedule::class, function (Faker\Generator $faker) { $factory->define(Pterodactyl\Models\Schedule::class, function (Faker $faker) {
return [ return [
'id' => $faker->unique()->randomNumber(), 'id' => $faker->unique()->randomNumber(),
'server_id' => $faker->randomNumber(), 'server_id' => $faker->randomNumber(),
@ -200,7 +200,7 @@ $factory->define(Pterodactyl\Models\Schedule::class, function (Faker\Generator $
]; ];
}); });
$factory->define(Pterodactyl\Models\Task::class, function (Faker\Generator $faker) { $factory->define(Pterodactyl\Models\Task::class, function (Faker $faker) {
return [ return [
'id' => $faker->unique()->randomNumber(), 'id' => $faker->unique()->randomNumber(),
'schedule_id' => $faker->randomNumber(), 'schedule_id' => $faker->randomNumber(),
@ -212,7 +212,7 @@ $factory->define(Pterodactyl\Models\Task::class, function (Faker\Generator $fake
]; ];
}); });
$factory->define(Pterodactyl\Models\DaemonKey::class, function (Faker\Generator $faker) { $factory->define(Pterodactyl\Models\DaemonKey::class, function (Faker $faker) {
return [ return [
'id' => $faker->unique()->randomNumber(), 'id' => $faker->unique()->randomNumber(),
'server_id' => $faker->randomNumber(), 'server_id' => $faker->randomNumber(),
@ -222,7 +222,7 @@ $factory->define(Pterodactyl\Models\DaemonKey::class, function (Faker\Generator
]; ];
}); });
$factory->define(Pterodactyl\Models\APIKey::class, function (Faker\Generator $faker) { $factory->define(Pterodactyl\Models\APIKey::class, function (Faker $faker) {
return [ return [
'id' => $faker->unique()->randomNumber(), 'id' => $faker->unique()->randomNumber(),
'user_id' => $faker->randomNumber(), 'user_id' => $faker->randomNumber(),
@ -233,7 +233,7 @@ $factory->define(Pterodactyl\Models\APIKey::class, function (Faker\Generator $fa
]; ];
}); });
$factory->define(Pterodactyl\Models\APIPermission::class, function (Faker\Generator $faker) { $factory->define(Pterodactyl\Models\APIPermission::class, function (Faker $faker) {
return [ return [
'id' => $faker->unique()->randomNumber(), 'id' => $faker->unique()->randomNumber(),
'key_id' => $faker->randomNumber(), 'key_id' => $faker->randomNumber(),

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false" <phpunit backupGlobals="false"
backupStaticAttributes="false" backupStaticAttributes="false"
bootstrap="bootstrap/autoload.php" bootstrap="vendor/autoload.php"
colors="true" colors="true"
convertErrorsToExceptions="true" convertErrorsToExceptions="true"
convertNoticesToExceptions="true" convertNoticesToExceptions="true"

View file

@ -1,17 +1,18 @@
<IfModule mod_rewrite.c> <IfModule mod_rewrite.c>
<IfModule mod_negotiation.c> <IfModule mod_negotiation.c>
Options -MultiViews Options -MultiViews -Indexes
</IfModule> </IfModule>
RewriteEngine On RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder... # Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301] RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Prevent stripping authorization headers
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
# Handle Front Controller... # Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-d

View file

@ -3,8 +3,9 @@
/** /**
* Laravel - A PHP Framework For Web Artisans. * Laravel - A PHP Framework For Web Artisans.
* *
* @author Taylor Otwell <taylorotwell@gmail.com> * @author Taylor Otwell <taylor@laravel.com>
*/ */
define('LARAVEL_START', microtime(true));
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@ -14,11 +15,11 @@
| Composer provides a convenient, automatically generated class loader for | Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it | our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual | into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels nice to relax. | loading any of our classes later on. It feels great to relax.
| |
*/ */
require __DIR__ . '/../bootstrap/autoload.php'; require __DIR__ . '/../vendor/autoload.php';
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------

View file

@ -113,13 +113,6 @@
<th>SHA1 Hash</th> <th>SHA1 Hash</th>
<th>File Size</th> <th>File Size</th>
</tr> </tr>
@foreach($pack->files() as $file)
<tr>
<td>{{ $file->name }}</td>
<td><code>{{ $file->hash }}</code></td>
<td>{{ $file->size }}</td>
</tr>
@endforeach
</table> </table>
</div> </div>
<div class="box-footer"> <div class="box-footer">

View file

@ -1,14 +1,8 @@
<?php <?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Tests\Unit\Commands\Maintenance; namespace Tests\Unit\Commands\Maintenance;
use SplFileInfo;
use Mockery as m; use Mockery as m;
use Carbon\Carbon; use Carbon\Carbon;
use Tests\Unit\Commands\CommandTestCase; use Tests\Unit\Commands\CommandTestCase;
@ -18,11 +12,6 @@ use Pterodactyl\Console\Commands\Maintenance\CleanServiceBackupFilesCommand;
class CleanServiceBackupFilesCommandTest extends CommandTestCase class CleanServiceBackupFilesCommandTest extends CommandTestCase
{ {
/**
* @var \Carbon\Carbon|\Mockery\Mock
*/
protected $carbon;
/** /**
* @var \Pterodactyl\Console\Commands\Maintenance\CleanServiceBackupFilesCommand * @var \Pterodactyl\Console\Commands\Maintenance\CleanServiceBackupFilesCommand
*/ */
@ -45,13 +34,10 @@ class CleanServiceBackupFilesCommandTest extends CommandTestCase
{ {
parent::setUp(); parent::setUp();
$this->carbon = m::mock(Carbon::class); Carbon::setTestNow();
$this->disk = m::mock(Filesystem::class); $this->disk = m::mock(Filesystem::class);
$this->filesystem = m::mock(Factory::class); $this->filesystem = m::mock(Factory::class);
$this->filesystem->shouldReceive('disk')->withNoArgs()->once()->andReturn($this->disk); $this->filesystem->shouldReceive('disk')->withNoArgs()->once()->andReturn($this->disk);
$this->command = new CleanServiceBackupFilesCommand($this->carbon, $this->filesystem);
$this->command->setLaravel($this->app);
} }
/** /**
@ -59,14 +45,13 @@ class CleanServiceBackupFilesCommandTest extends CommandTestCase
*/ */
public function testCommandCleansFilesMoreThan5MinutesOld() public function testCommandCleansFilesMoreThan5MinutesOld()
{ {
$this->disk->shouldReceive('files')->with('services/.bak')->once()->andReturn(['testfile.txt']); $file = new SplFileInfo('testfile.txt');
$this->disk->shouldReceive('lastModified')->with('testfile.txt')->once()->andReturn('disk:last:modified');
$this->carbon->shouldReceive('timestamp')->with('disk:last:modified')->once()->andReturnSelf();
$this->carbon->shouldReceive('now')->withNoArgs()->once()->andReturnNull();
$this->carbon->shouldReceive('diffInMinutes')->with(null)->once()->andReturn(10);
$this->disk->shouldReceive('delete')->with('testfile.txt')->once()->andReturnNull();
$display = $this->runCommand($this->command); $this->disk->shouldReceive('files')->with('services/.bak')->once()->andReturn([$file]);
$this->disk->shouldReceive('lastModified')->with($file->getPath())->once()->andReturn(Carbon::now()->subDays(100)->getTimestamp());
$this->disk->shouldReceive('delete')->with($file->getPath())->once()->andReturnNull();
$display = $this->runCommand($this->getCommand());
$this->assertNotEmpty($display); $this->assertNotEmpty($display);
$this->assertContains(trans('command/messages.maintenance.deleting_service_backup', ['file' => 'testfile.txt']), $display); $this->assertContains(trans('command/messages.maintenance.deleting_service_backup', ['file' => 'testfile.txt']), $display);
@ -77,14 +62,26 @@ class CleanServiceBackupFilesCommandTest extends CommandTestCase
*/ */
public function testCommandDoesNotCleanFileLessThan5MinutesOld() public function testCommandDoesNotCleanFileLessThan5MinutesOld()
{ {
$this->disk->shouldReceive('files')->with('services/.bak')->once()->andReturn(['testfile.txt']); $file = new SplFileInfo('testfile.txt');
$this->disk->shouldReceive('lastModified')->with('testfile.txt')->once()->andReturn('disk:last:modified');
$this->carbon->shouldReceive('timestamp')->with('disk:last:modified')->once()->andReturnSelf();
$this->carbon->shouldReceive('now')->withNoArgs()->once()->andReturnNull();
$this->carbon->shouldReceive('diffInMinutes')->with(null)->once()->andReturn(2);
$display = $this->runCommand($this->command); $this->disk->shouldReceive('files')->with('services/.bak')->once()->andReturn([$file]);
$this->disk->shouldReceive('lastModified')->with($file->getPath())->once()->andReturn(Carbon::now()->getTimestamp());
$display = $this->runCommand($this->getCommand());
$this->assertEmpty($display); $this->assertEmpty($display);
} }
/**
* Return an instance of the command for testing.
*
* @return \Pterodactyl\Console\Commands\Maintenance\CleanServiceBackupFilesCommand
*/
private function getCommand(): CleanServiceBackupFilesCommand
{
$command = new CleanServiceBackupFilesCommand($this->filesystem);
$command->setLaravel($this->app);
return $command;
}
} }

View file

@ -50,13 +50,13 @@ class AccountControllerTest extends ControllerTestCase
public function testUpdateControllerForPassword() public function testUpdateControllerForPassword()
{ {
$this->setRequestMockClass(AccountDataFormRequest::class); $this->setRequestMockClass(AccountDataFormRequest::class);
$user = $this->setRequestUser(); $user = $this->generateRequestUserModel();
$this->request->shouldReceive('input')->with('do_action')->andReturn('password'); $this->request->shouldReceive('input')->with('do_action')->andReturn('password');
$this->request->shouldReceive('input')->with('new_password')->once()->andReturn('test-password'); $this->request->shouldReceive('input')->with('new_password')->once()->andReturn('test-password');
$this->updateService->shouldReceive('setUserLevel')->with(User::USER_LEVEL_USER)->once()->andReturnNull(); $this->updateService->shouldReceive('setUserLevel')->with(User::USER_LEVEL_USER)->once()->andReturnNull();
$this->updateService->shouldReceive('handle')->with($user, ['password' => 'test-password'])->once()->andReturnNull(); $this->updateService->shouldReceive('handle')->with($user, ['password' => 'test-password'])->once()->andReturn(collect());
$this->alert->shouldReceive('success->flash')->once()->andReturnNull(); $this->alert->shouldReceive('success->flash')->once()->andReturnNull();
$response = $this->getController()->update($this->request); $response = $this->getController()->update($this->request);
@ -70,13 +70,13 @@ class AccountControllerTest extends ControllerTestCase
public function testUpdateControllerForEmail() public function testUpdateControllerForEmail()
{ {
$this->setRequestMockClass(AccountDataFormRequest::class); $this->setRequestMockClass(AccountDataFormRequest::class);
$user = $this->setRequestUser(); $user = $this->generateRequestUserModel();
$this->request->shouldReceive('input')->with('do_action')->andReturn('email'); $this->request->shouldReceive('input')->with('do_action')->andReturn('email');
$this->request->shouldReceive('input')->with('new_email')->once()->andReturn('test@example.com'); $this->request->shouldReceive('input')->with('new_email')->once()->andReturn('test@example.com');
$this->updateService->shouldReceive('setUserLevel')->with(User::USER_LEVEL_USER)->once()->andReturnNull(); $this->updateService->shouldReceive('setUserLevel')->with(User::USER_LEVEL_USER)->once()->andReturnNull();
$this->updateService->shouldReceive('handle')->with($user, ['email' => 'test@example.com'])->once()->andReturnNull(); $this->updateService->shouldReceive('handle')->with($user, ['email' => 'test@example.com'])->once()->andReturn(collect());
$this->alert->shouldReceive('success->flash')->once()->andReturnNull(); $this->alert->shouldReceive('success->flash')->once()->andReturnNull();
$response = $this->getController()->update($this->request); $response = $this->getController()->update($this->request);
@ -90,7 +90,7 @@ class AccountControllerTest extends ControllerTestCase
public function testUpdateControllerForIdentity() public function testUpdateControllerForIdentity()
{ {
$this->setRequestMockClass(AccountDataFormRequest::class); $this->setRequestMockClass(AccountDataFormRequest::class);
$user = $this->setRequestUser(); $user = $this->generateRequestUserModel();
$this->request->shouldReceive('input')->with('do_action')->andReturn('identity'); $this->request->shouldReceive('input')->with('do_action')->andReturn('identity');
$this->request->shouldReceive('only')->with(['name_first', 'name_last', 'username'])->once()->andReturn([ $this->request->shouldReceive('only')->with(['name_first', 'name_last', 'username'])->once()->andReturn([
@ -98,7 +98,7 @@ class AccountControllerTest extends ControllerTestCase
]); ]);
$this->updateService->shouldReceive('setUserLevel')->with(User::USER_LEVEL_USER)->once()->andReturnNull(); $this->updateService->shouldReceive('setUserLevel')->with(User::USER_LEVEL_USER)->once()->andReturnNull();
$this->updateService->shouldReceive('handle')->with($user, ['test_data' => 'value'])->once()->andReturnNull(); $this->updateService->shouldReceive('handle')->with($user, ['test_data' => 'value'])->once()->andReturn(collect());
$this->alert->shouldReceive('success->flash')->once()->andReturnNull(); $this->alert->shouldReceive('success->flash')->once()->andReturnNull();
$response = $this->getController()->update($this->request); $response = $this->getController()->update($this->request);

View file

@ -58,7 +58,7 @@ class SecurityControllerTest extends ControllerTestCase
*/ */
public function testIndexControllerWithDatabaseDriver() public function testIndexControllerWithDatabaseDriver()
{ {
$model = $this->setRequestUser(); $model = $this->generateRequestUserModel();
$this->config->shouldReceive('get')->with('session.driver')->once()->andReturn('database'); $this->config->shouldReceive('get')->with('session.driver')->once()->andReturn('database');
$this->repository->shouldReceive('getUserSessions')->with($model->id)->once()->andReturn(['sessions']); $this->repository->shouldReceive('getUserSessions')->with($model->id)->once()->andReturn(['sessions']);
@ -89,7 +89,7 @@ class SecurityControllerTest extends ControllerTestCase
*/ */
public function testGenerateTotpController() public function testGenerateTotpController()
{ {
$model = $this->setRequestUser(); $model = $this->generateRequestUserModel();
$this->twoFactorSetupService->shouldReceive('handle')->with($model)->once()->andReturn('qrCodeImage'); $this->twoFactorSetupService->shouldReceive('handle')->with($model)->once()->andReturn('qrCodeImage');
@ -103,10 +103,10 @@ class SecurityControllerTest extends ControllerTestCase
*/ */
public function testDisableTotpControllerSuccess() public function testDisableTotpControllerSuccess()
{ {
$model = $this->setRequestUser(); $model = $this->generateRequestUserModel();
$this->request->shouldReceive('input')->with('token')->once()->andReturn('testToken'); $this->request->shouldReceive('input')->with('token')->once()->andReturn('testToken');
$this->toggleTwoFactorService->shouldReceive('handle')->with($model, 'testToken', false)->once()->andReturnNull(); $this->toggleTwoFactorService->shouldReceive('handle')->with($model, 'testToken', false)->once()->andReturn(true);
$response = $this->getController()->disableTotp($this->request); $response = $this->getController()->disableTotp($this->request);
$this->assertIsRedirectResponse($response); $this->assertIsRedirectResponse($response);
@ -118,7 +118,7 @@ class SecurityControllerTest extends ControllerTestCase
*/ */
public function testDisableTotpControllerWhenExceptionIsThrown() public function testDisableTotpControllerWhenExceptionIsThrown()
{ {
$model = $this->setRequestUser(); $model = $this->generateRequestUserModel();
$this->request->shouldReceive('input')->with('token')->once()->andReturn('testToken'); $this->request->shouldReceive('input')->with('token')->once()->andReturn('testToken');
$this->toggleTwoFactorService->shouldReceive('handle')->with($model, 'testToken', false)->once()->andThrow(new TwoFactorAuthenticationTokenInvalid); $this->toggleTwoFactorService->shouldReceive('handle')->with($model, 'testToken', false)->once()->andThrow(new TwoFactorAuthenticationTokenInvalid);
@ -135,7 +135,7 @@ class SecurityControllerTest extends ControllerTestCase
*/ */
public function testRevokeController() public function testRevokeController()
{ {
$model = $this->setRequestUser(); $model = $this->generateRequestUserModel();
$this->repository->shouldReceive('deleteUserSession')->with($model->id, 123)->once()->andReturnNull(); $this->repository->shouldReceive('deleteUserSession')->with($model->id, 123)->once()->andReturnNull();

View file

@ -133,7 +133,7 @@ class ServerCreationServiceTest extends TestCase
$this->configurationStructureService->shouldReceive('handle')->with($model)->once()->andReturn(['test' => 'struct']); $this->configurationStructureService->shouldReceive('handle')->with($model)->once()->andReturn(['test' => 'struct']);
$this->daemonServerRepository->shouldReceive('setNode')->with($model->node_id)->once()->andReturnSelf(); $this->daemonServerRepository->shouldReceive('setNode')->with($model->node_id)->once()->andReturnSelf();
$this->daemonServerRepository->shouldReceive('create')->with(['test' => 'struct'], ['start_on_completion' => false])->once()->andReturnNull(); $this->daemonServerRepository->shouldReceive('create')->with(['test' => 'struct'], ['start_on_completion' => false])->once();
$this->connection->shouldReceive('commit')->withNoArgs()->once()->andReturnNull(); $this->connection->shouldReceive('commit')->withNoArgs()->once()->andReturnNull();
$response = $this->getService()->create($model->toArray()); $response = $this->getService()->create($model->toArray());