diff --git a/app/Console/Commands/Maintenance/CleanServiceBackupFilesCommand.php b/app/Console/Commands/Maintenance/CleanServiceBackupFilesCommand.php index 4811a222e..1b5ded4d6 100644 --- a/app/Console/Commands/Maintenance/CleanServiceBackupFilesCommand.php +++ b/app/Console/Commands/Maintenance/CleanServiceBackupFilesCommand.php @@ -2,9 +2,9 @@ namespace Pterodactyl\Console\Commands\Maintenance; +use SplFileInfo; use Carbon\Carbon; use Illuminate\Console\Command; -use Symfony\Component\Finder\SplFileInfo; use Illuminate\Contracts\Filesystem\Factory as FilesystemFactory; class CleanServiceBackupFilesCommand extends Command diff --git a/app/Http/Controllers/Base/SecurityController.php b/app/Http/Controllers/Base/SecurityController.php index 62f07738c..8a7babecb 100644 --- a/app/Http/Controllers/Base/SecurityController.php +++ b/app/Http/Controllers/Base/SecurityController.php @@ -1,27 +1,4 @@ - * Some Modifications (c) 2015 Dylan Seidt . - * - * 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; diff --git a/composer.json b/composer.json index 414ea2238..091416ef3 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,7 @@ "fzaninotto/faker": "^1.6", "mockery/mockery": "^1.0", "php-mock/php-mock-phpunit": "^2.0", - "phpunit/phpunit": "^6.5" + "phpunit/phpunit": "~6.4.0" }, "autoload": { "classmap": [ diff --git a/composer.lock b/composer.lock index 9faac0ced..40dbb34d0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "adc287e0991b3755ac9384a9eb9e58e0", + "content-hash": "5cdbf1cd4e3e64e939ca2201704d0141", "packages": [ { "name": "appstract/laravel-blade-directives", @@ -5061,22 +5061,22 @@ }, { "name": "php-mock/php-mock-phpunit", - "version": "2.0.0", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/php-mock/php-mock-phpunit.git", - "reference": "173781abdc632c59200253e12e2b991ae6a4574f" + "reference": "b42fc41ecb7538564067527f6c30b8854f149d32" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-mock/php-mock-phpunit/zipball/173781abdc632c59200253e12e2b991ae6a4574f", - "reference": "173781abdc632c59200253e12e2b991ae6a4574f", + "url": "https://api.github.com/repos/php-mock/php-mock-phpunit/zipball/b42fc41ecb7538564067527f6c30b8854f149d32", + "reference": "b42fc41ecb7538564067527f6c30b8854f149d32", "shasum": "" }, "require": { "php": ">=7", "php-mock/php-mock-integration": "^2", - "phpunit/phpunit": "^6" + "phpunit/phpunit": "^6 <6.5" }, "type": "library", "autoload": { @@ -5108,7 +5108,7 @@ "test", "test double" ], - "time": "2017-02-17T22:44:38+00:00" + "time": "2017-12-02T09:49:02+00:00" }, { "name": "phpdocumentor/reflection-common", @@ -5576,16 +5576,16 @@ }, { "name": "phpunit/phpunit", - "version": "6.5.4", + "version": "6.4.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "1b2f933d5775f9237369deaa2d2bfbf9d652be4c" + "reference": "562f7dc75d46510a4ed5d16189ae57fbe45a9932" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/1b2f933d5775f9237369deaa2d2bfbf9d652be4c", - "reference": "1b2f933d5775f9237369deaa2d2bfbf9d652be4c", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/562f7dc75d46510a4ed5d16189ae57fbe45a9932", + "reference": "562f7dc75d46510a4ed5d16189ae57fbe45a9932", "shasum": "" }, "require": { @@ -5599,12 +5599,12 @@ "phar-io/version": "^1.0", "php": "^7.0", "phpspec/prophecy": "^1.7", - "phpunit/php-code-coverage": "^5.3", - "phpunit/php-file-iterator": "^1.4.3", + "phpunit/php-code-coverage": "^5.2.2", + "phpunit/php-file-iterator": "^1.4.2", "phpunit/php-text-template": "^1.2.1", "phpunit/php-timer": "^1.0.9", - "phpunit/phpunit-mock-objects": "^5.0.5", - "sebastian/comparator": "^2.1", + "phpunit/phpunit-mock-objects": "^4.0.3", + "sebastian/comparator": "^2.0.2", "sebastian/diff": "^2.0", "sebastian/environment": "^3.1", "sebastian/exporter": "^3.1", @@ -5630,7 +5630,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "6.5.x-dev" + "dev-master": "6.4.x-dev" } }, "autoload": { @@ -5656,33 +5656,33 @@ "testing", "xunit" ], - "time": "2017-12-10T08:06:19+00:00" + "time": "2017-11-08T11:26:09+00:00" }, { "name": "phpunit/phpunit-mock-objects", - "version": "5.0.5", + "version": "4.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "283b9f4f670e3a6fd6c4ff95c51a952eb5c75933" + "reference": "2f789b59ab89669015ad984afa350c4ec577ade0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/283b9f4f670e3a6fd6c4ff95c51a952eb5c75933", - "reference": "283b9f4f670e3a6fd6c4ff95c51a952eb5c75933", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/2f789b59ab89669015ad984afa350c4ec577ade0", + "reference": "2f789b59ab89669015ad984afa350c4ec577ade0", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.5", "php": "^7.0", "phpunit/php-text-template": "^1.2.1", - "sebastian/exporter": "^3.1" + "sebastian/exporter": "^3.0" }, "conflict": { "phpunit/phpunit": "<6.0" }, "require-dev": { - "phpunit/phpunit": "^6.5" + "phpunit/phpunit": "^6.0" }, "suggest": { "ext-soap": "*" @@ -5690,7 +5690,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "5.0.x-dev" + "dev-master": "4.0.x-dev" } }, "autoload": { @@ -5705,7 +5705,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", + "email": "sb@sebastian-bergmann.de", "role": "lead" } ], @@ -5715,7 +5715,7 @@ "mock", "xunit" ], - "time": "2017-12-10T08:01:53+00:00" + "time": "2017-08-03T14:08:16+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", diff --git a/tests/Unit/Commands/Maintenance/CleanServiceBackupFilesCommandTest.php b/tests/Unit/Commands/Maintenance/CleanServiceBackupFilesCommandTest.php index 051e90748..bd13a2c9a 100644 --- a/tests/Unit/Commands/Maintenance/CleanServiceBackupFilesCommandTest.php +++ b/tests/Unit/Commands/Maintenance/CleanServiceBackupFilesCommandTest.php @@ -48,7 +48,7 @@ class CleanServiceBackupFilesCommandTest extends CommandTestCase $file = new SplFileInfo('testfile.txt'); $this->disk->shouldReceive('files')->with('services/.bak')->once()->andReturn([$file]); - $this->disk->shouldReceive('lastModified')->with($file->getPath())->once()->andReturn(Carbon::now()->subDays(100)); + $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()); @@ -65,7 +65,7 @@ class CleanServiceBackupFilesCommandTest extends CommandTestCase $file = new SplFileInfo('testfile.txt'); $this->disk->shouldReceive('files')->with('services/.bak')->once()->andReturn([$file]); - $this->disk->shouldReceive('lastModified')->with($file->getPath())->once()->andReturn(Carbon::now()); + $this->disk->shouldReceive('lastModified')->with($file->getPath())->once()->andReturn(Carbon::now()->getTimestamp()); $display = $this->runCommand($this->getCommand()); diff --git a/tests/Unit/Http/Controllers/Base/AccountControllerTest.php b/tests/Unit/Http/Controllers/Base/AccountControllerTest.php index e2fbb0774..968019ad7 100644 --- a/tests/Unit/Http/Controllers/Base/AccountControllerTest.php +++ b/tests/Unit/Http/Controllers/Base/AccountControllerTest.php @@ -50,13 +50,13 @@ class AccountControllerTest extends ControllerTestCase public function testUpdateControllerForPassword() { $this->setRequestMockClass(AccountDataFormRequest::class); - $user = $this->setRequestUser(); + $user = $this->generateRequestUserModel(); $this->request->shouldReceive('input')->with('do_action')->andReturn('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('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(); $response = $this->getController()->update($this->request); @@ -70,13 +70,13 @@ class AccountControllerTest extends ControllerTestCase public function testUpdateControllerForEmail() { $this->setRequestMockClass(AccountDataFormRequest::class); - $user = $this->setRequestUser(); + $user = $this->generateRequestUserModel(); $this->request->shouldReceive('input')->with('do_action')->andReturn('email'); $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('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(); $response = $this->getController()->update($this->request); @@ -90,7 +90,7 @@ class AccountControllerTest extends ControllerTestCase public function testUpdateControllerForIdentity() { $this->setRequestMockClass(AccountDataFormRequest::class); - $user = $this->setRequestUser(); + $user = $this->generateRequestUserModel(); $this->request->shouldReceive('input')->with('do_action')->andReturn('identity'); $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('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(); $response = $this->getController()->update($this->request); diff --git a/tests/Unit/Http/Controllers/Base/SecurityControllerTest.php b/tests/Unit/Http/Controllers/Base/SecurityControllerTest.php index 3c821729e..7c698a597 100644 --- a/tests/Unit/Http/Controllers/Base/SecurityControllerTest.php +++ b/tests/Unit/Http/Controllers/Base/SecurityControllerTest.php @@ -58,7 +58,7 @@ class SecurityControllerTest extends ControllerTestCase */ public function testIndexControllerWithDatabaseDriver() { - $model = $this->setRequestUser(); + $model = $this->generateRequestUserModel(); $this->config->shouldReceive('get')->with('session.driver')->once()->andReturn('database'); $this->repository->shouldReceive('getUserSessions')->with($model->id)->once()->andReturn(['sessions']); @@ -89,7 +89,7 @@ class SecurityControllerTest extends ControllerTestCase */ public function testGenerateTotpController() { - $model = $this->setRequestUser(); + $model = $this->generateRequestUserModel(); $this->twoFactorSetupService->shouldReceive('handle')->with($model)->once()->andReturn('qrCodeImage'); @@ -103,10 +103,10 @@ class SecurityControllerTest extends ControllerTestCase */ public function testDisableTotpControllerSuccess() { - $model = $this->setRequestUser(); + $model = $this->generateRequestUserModel(); $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); $this->assertIsRedirectResponse($response); @@ -118,7 +118,7 @@ class SecurityControllerTest extends ControllerTestCase */ public function testDisableTotpControllerWhenExceptionIsThrown() { - $model = $this->setRequestUser(); + $model = $this->generateRequestUserModel(); $this->request->shouldReceive('input')->with('token')->once()->andReturn('testToken'); $this->toggleTwoFactorService->shouldReceive('handle')->with($model, 'testToken', false)->once()->andThrow(new TwoFactorAuthenticationTokenInvalid); @@ -135,7 +135,7 @@ class SecurityControllerTest extends ControllerTestCase */ public function testRevokeController() { - $model = $this->setRequestUser(); + $model = $this->generateRequestUserModel(); $this->repository->shouldReceive('deleteUserSession')->with($model->id, 123)->once()->andReturnNull(); diff --git a/tests/Unit/Services/Servers/ServerCreationServiceTest.php b/tests/Unit/Services/Servers/ServerCreationServiceTest.php index c430cc22b..4df486d5c 100644 --- a/tests/Unit/Services/Servers/ServerCreationServiceTest.php +++ b/tests/Unit/Services/Servers/ServerCreationServiceTest.php @@ -133,7 +133,7 @@ class ServerCreationServiceTest extends TestCase $this->configurationStructureService->shouldReceive('handle')->with($model)->once()->andReturn(['test' => 'struct']); $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(); $response = $this->getService()->create($model->toArray());