{
return new Promise((resolve, reject) => {
- http.delete('/api/client/account/two-factor', { params: { password } })
+ http.post('/api/client/account/two-factor/disable', { password })
.then(() => resolve())
.catch(reject);
});
-};
+}
+
+export default disableAccountTwoFactor;
diff --git a/resources/views/admin/eggs/view.blade.php b/resources/views/admin/eggs/view.blade.php
index 50b69c3793..0f1e6521f4 100644
--- a/resources/views/admin/eggs/view.blade.php
+++ b/resources/views/admin/eggs/view.blade.php
@@ -118,7 +118,7 @@
diff --git a/routes/api-client.php b/routes/api-client.php
index 64ceecf3e4..6887f1b294 100644
--- a/routes/api-client.php
+++ b/routes/api-client.php
@@ -24,7 +24,7 @@
Route::get('/', [Client\AccountController::class, 'index'])->name('api:client.account');
Route::get('/two-factor', [Client\TwoFactorController::class, 'index']);
Route::post('/two-factor', [Client\TwoFactorController::class, 'store']);
- Route::delete('/two-factor', [Client\TwoFactorController::class, 'delete']);
+ Route::post('/two-factor/disable', [Client\TwoFactorController::class, 'delete']);
});
Route::put('/email', [Client\AccountController::class, 'updateEmail'])->name('api:client.account.update-email');
diff --git a/storage/app/.gitignore b/storage/app/.gitignore
index 104980aa3b..fedb287fec 100755
--- a/storage/app/.gitignore
+++ b/storage/app/.gitignore
@@ -1,6 +1,4 @@
*
+!private/
+!public/
!.gitignore
-!services/*
-packs/**/*
-services/.bak/*
-!packs/.githold
diff --git a/storage/app/packs/.githold b/storage/app/packs/.githold
deleted file mode 100755
index e69de29bb2..0000000000
diff --git a/storage/app/private/.gitignore b/storage/app/private/.gitignore
new file mode 100644
index 0000000000..d6b7ef32c8
--- /dev/null
+++ b/storage/app/private/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
diff --git a/storage/app/public/.gitignore b/storage/app/public/.gitignore
new file mode 100644
index 0000000000..d6b7ef32c8
--- /dev/null
+++ b/storage/app/public/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
diff --git a/storage/debugbar/.gitignore b/storage/debugbar/.gitignore
deleted file mode 100755
index c96a04f008..0000000000
--- a/storage/debugbar/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-*
-!.gitignore
\ No newline at end of file
diff --git a/storage/framework/.gitignore b/storage/framework/.gitignore
index 953edb7a99..05c4471f2b 100755
--- a/storage/framework/.gitignore
+++ b/storage/framework/.gitignore
@@ -1,7 +1,9 @@
-config.php
-routes.php
compiled.php
-services.json
+config.php
+down
events.scanned.php
+maintenance.php
+routes.php
routes.scanned.php
-down
+schedule-*
+services.json
diff --git a/tests/Assertions/AssertsActivityLogged.php b/tests/Assertions/AssertsActivityLogged.php
index 7c3232418c..7bf990d5d3 100644
--- a/tests/Assertions/AssertsActivityLogged.php
+++ b/tests/Assertions/AssertsActivityLogged.php
@@ -11,7 +11,7 @@
trait AssertsActivityLogged
{
/**
- * @param \Illuminate\Database\Eloquent\Model|array $subjects
+ * @param Model|array $subjects
*/
public function assertActivityFor(string $event, ?Model $actor, ...$subjects): void
{
diff --git a/tests/CreatesApplication.php b/tests/CreatesApplication.php
deleted file mode 100644
index e9dc91089f..0000000000
--- a/tests/CreatesApplication.php
+++ /dev/null
@@ -1,21 +0,0 @@
-make(Kernel::class)->bootstrap();
-
- return $app;
- }
-}
diff --git a/tests/Integration/Api/Application/Users/UserControllerTest.php b/tests/Integration/Api/Application/Users/UserControllerTest.php
index 04709e55f2..a2512094b4 100644
--- a/tests/Integration/Api/Application/Users/UserControllerTest.php
+++ b/tests/Integration/Api/Application/Users/UserControllerTest.php
@@ -279,9 +279,8 @@ public function testDeleteUser()
/**
* Test that an API key without write permissions cannot create, update, or
* delete a user model.
- *
- * @dataProvider userWriteEndpointsDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('userWriteEndpointsDataProvider')]
public function testApiKeyWithoutWritePermissions(string $method, string $url)
{
$this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => AdminAcl::READ]);
diff --git a/tests/Integration/Api/Client/AccountControllerTest.php b/tests/Integration/Api/Client/AccountControllerTest.php
index 0fe1813a3e..5edac86e70 100644
--- a/tests/Integration/Api/Client/AccountControllerTest.php
+++ b/tests/Integration/Api/Client/AccountControllerTest.php
@@ -14,7 +14,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase
*/
public function testAccountDetailsAreReturned()
{
- /** @var \Pterodactyl\Models\User $user */
+ /** @var User $user */
$user = User::factory()->create();
$response = $this->actingAs($user)->get('/api/client/account');
@@ -38,7 +38,7 @@ public function testAccountDetailsAreReturned()
*/
public function testEmailIsUpdated()
{
- /** @var \Pterodactyl\Models\User $user */
+ /** @var User $user */
$user = User::factory()->create();
$response = $this->actingAs($user)->putJson('/api/client/account/email', [
@@ -57,7 +57,7 @@ public function testEmailIsUpdated()
*/
public function testEmailIsNotUpdatedWhenPasswordIsInvalid()
{
- /** @var \Pterodactyl\Models\User $user */
+ /** @var User $user */
$user = User::factory()->create();
$response = $this->actingAs($user)->putJson('/api/client/account/email', [
@@ -76,7 +76,7 @@ public function testEmailIsNotUpdatedWhenPasswordIsInvalid()
*/
public function testEmailIsNotUpdatedWhenNotValid()
{
- /** @var \Pterodactyl\Models\User $user */
+ /** @var User $user */
$user = User::factory()->create();
$response = $this->actingAs($user)->putJson('/api/client/account/email', [
@@ -103,7 +103,7 @@ public function testEmailIsNotUpdatedWhenNotValid()
*/
public function testPasswordIsUpdated()
{
- /** @var \Pterodactyl\Models\User $user */
+ /** @var User $user */
$user = User::factory()->create();
$initialHash = $user->password;
@@ -129,7 +129,7 @@ public function testPasswordIsUpdated()
*/
public function testPasswordIsNotUpdatedIfCurrentPasswordIsInvalid()
{
- /** @var \Pterodactyl\Models\User $user */
+ /** @var User $user */
$user = User::factory()->create();
$response = $this->actingAs($user)->putJson('/api/client/account/password', [
@@ -172,7 +172,7 @@ public function testErrorIsReturnedForInvalidRequestData()
*/
public function testErrorIsReturnedIfPasswordIsNotConfirmed()
{
- /** @var \Pterodactyl\Models\User $user */
+ /** @var User $user */
$user = User::factory()->create();
$response = $this->actingAs($user)->putJson('/api/client/account/password', [
diff --git a/tests/Integration/Api/Client/ApiKeyControllerTest.php b/tests/Integration/Api/Client/ApiKeyControllerTest.php
index 39b2055eba..6017a72b29 100644
--- a/tests/Integration/Api/Client/ApiKeyControllerTest.php
+++ b/tests/Integration/Api/Client/ApiKeyControllerTest.php
@@ -25,9 +25,9 @@ protected function tearDown(): void
*/
public function testApiKeysAreReturned()
{
- /** @var \Pterodactyl\Models\User $user */
+ /** @var User $user */
$user = User::factory()->create();
- /** @var \Pterodactyl\Models\ApiKey $key */
+ /** @var ApiKey $key */
$key = ApiKey::factory()->for($user)->create([
'key_type' => ApiKey::TYPE_ACCOUNT,
]);
@@ -44,12 +44,11 @@ public function testApiKeysAreReturned()
* Test that an API key can be created for the client account. This also checks that the
* API key secret is returned as metadata in the response since it will not be returned
* after that point.
- *
- * @dataProvider validIPAddressDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('validIPAddressDataProvider')]
public function testApiKeyCanBeCreatedForAccount(array $data)
{
- /** @var \Pterodactyl\Models\User $user */
+ /** @var User $user */
$user = User::factory()->create();
// Small subtest to ensure we're always comparing the number of keys to the
@@ -67,7 +66,7 @@ public function testApiKeyCanBeCreatedForAccount(array $data)
->assertOk()
->assertJsonPath('object', ApiKey::RESOURCE_NAME);
- /** @var \Pterodactyl\Models\ApiKey $key */
+ /** @var ApiKey $key */
$key = ApiKey::query()->where('identifier', $response->json('attributes.identifier'))->firstOrFail();
$this->assertJsonTransformedWith($response->json('attributes'), $key);
@@ -104,7 +103,7 @@ public function testApiKeyCannotSpecifyMoreThanFiftyIps()
*/
public function testApiKeyLimitIsApplied()
{
- /** @var \Pterodactyl\Models\User $user */
+ /** @var User $user */
$user = User::factory()->create();
ApiKey::factory()->times(25)->for($user)->create([
'key_type' => ApiKey::TYPE_ACCOUNT,
@@ -145,9 +144,9 @@ public function testValidationErrorIsReturnedForBadRequests()
->assertJsonPath('errors.0.detail', 'The description may not be greater than 500 characters.');
$this->postJson('/api/client/account/api-keys', [
- 'description' => 'Foobar',
- 'allowed_ips' => ['hodor', '127.0.0.1', 'hodor/24'],
- ])
+ 'description' => 'Foobar',
+ 'allowed_ips' => ['hodor', '127.0.0.1', 'hodor/24'],
+ ])
->assertUnprocessable()
->assertJsonPath('errors.0.detail', '"hodor" is not a valid IP address or CIDR range.')
->assertJsonPath('errors.0.meta.source_field', 'allowed_ips.0')
@@ -160,9 +159,9 @@ public function testValidationErrorIsReturnedForBadRequests()
*/
public function testApiKeyCanBeDeleted()
{
- /** @var \Pterodactyl\Models\User $user */
+ /** @var User $user */
$user = User::factory()->create();
- /** @var \Pterodactyl\Models\ApiKey $key */
+ /** @var ApiKey $key */
$key = ApiKey::factory()->for($user)->create([
'key_type' => ApiKey::TYPE_ACCOUNT,
]);
@@ -179,9 +178,9 @@ public function testApiKeyCanBeDeleted()
*/
public function testNonExistentApiKeyDeletionReturns404Error()
{
- /** @var \Pterodactyl\Models\User $user */
+ /** @var User $user */
$user = User::factory()->create();
- /** @var \Pterodactyl\Models\ApiKey $key */
+ /** @var ApiKey $key */
$key = ApiKey::factory()->create([
'user_id' => $user->id,
'key_type' => ApiKey::TYPE_ACCOUNT,
@@ -200,11 +199,11 @@ public function testNonExistentApiKeyDeletionReturns404Error()
*/
public function testApiKeyBelongingToAnotherUserCannotBeDeleted()
{
- /** @var \Pterodactyl\Models\User $user */
+ /** @var User $user */
$user = User::factory()->create();
- /** @var \Pterodactyl\Models\User $user2 */
+ /** @var User $user2 */
$user2 = User::factory()->create();
- /** @var \Pterodactyl\Models\ApiKey $key */
+ /** @var ApiKey $key */
$key = ApiKey::factory()->for($user2)->create([
'key_type' => ApiKey::TYPE_ACCOUNT,
]);
@@ -223,9 +222,9 @@ public function testApiKeyBelongingToAnotherUserCannotBeDeleted()
*/
public function testApplicationApiKeyCannotBeDeleted()
{
- /** @var \Pterodactyl\Models\User $user */
+ /** @var User $user */
$user = User::factory()->create();
- /** @var \Pterodactyl\Models\ApiKey $key */
+ /** @var ApiKey $key */
$key = ApiKey::factory()->for($user)->create([
'key_type' => ApiKey::TYPE_APPLICATION,
]);
diff --git a/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php b/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php
index bc515386c7..d7ceb34a22 100644
--- a/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php
+++ b/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php
@@ -43,18 +43,19 @@ protected function tearDown(): void
* to keep re-assigning variables.
*
* @param \Illuminate\Http\Response $response
+ * @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Testing\TestResponse
*/
- protected function createTestResponse($response)
+ protected function createTestResponse($response, $request)
{
- return TestResponse::fromBaseResponse($response);
+ return TestResponse::fromBaseResponse($response, $request);
}
/**
* Returns a link to the specific resource using the client API.
*/
- protected function link(mixed $model, string $append = null): string
+ protected function link(mixed $model, ?string $append = null): string
{
switch (get_class($model)) {
case Server::class:
diff --git a/tests/Integration/Api/Client/ClientControllerTest.php b/tests/Integration/Api/Client/ClientControllerTest.php
index 3a080e23e4..954ca6f53b 100644
--- a/tests/Integration/Api/Client/ClientControllerTest.php
+++ b/tests/Integration/Api/Client/ClientControllerTest.php
@@ -101,8 +101,8 @@ public function testServersAreFilteredUsingNameAndUuidInformation()
*/
public function testServersAreFilteredUsingAllocationInformation()
{
- /** @var \Pterodactyl\Models\User $user */
- /** @var \Pterodactyl\Models\Server $server */
+ /** @var User $user */
+ /** @var Server $server */
[$user, $server] = $this->generateTestAccount();
$server2 = $this->createServerModel(['user_id' => $user->id, 'node_id' => $server->node_id]);
@@ -203,7 +203,7 @@ public function testFilterOnlyOwnerServers()
*/
public function testPermissionsAreReturned()
{
- /** @var \Pterodactyl\Models\User $user */
+ /** @var User $user */
$user = User::factory()->create();
$this->actingAs($user)
@@ -285,9 +285,8 @@ public function testAllServersAreReturnedToAdmin()
/**
* Test that no servers get returned if the user requests all admin level servers by using
* ?type=admin or ?type=admin-all in the request.
- *
- * @dataProvider filterTypeDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('filterTypeDataProvider')]
public function testNoServersAreReturnedIfAdminFilterIsPassedByRegularUser(string $type)
{
/** @var \Pterodactyl\Models\User[] $users */
@@ -309,7 +308,7 @@ public function testNoServersAreReturnedIfAdminFilterIsPassedByRegularUser(strin
*/
public function testOnlyPrimaryAllocationIsReturnedToSubuser()
{
- /** @var \Pterodactyl\Models\Server $server */
+ /** @var Server $server */
[$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]);
$server->allocation->notes = 'Test notes';
$server->allocation->save();
diff --git a/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php b/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php
index 9c5eebd107..c5d6ac127c 100644
--- a/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php
+++ b/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php
@@ -8,9 +8,7 @@
class AllocationAuthorizationTest extends ClientApiIntegrationTestCase
{
- /**
- * @dataProvider methodDataProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('methodDataProvider')]
public function testAccessToAServersAllocationsIsRestrictedProperly(string $method, string $endpoint)
{
// The API $user is the owner of $server1.
diff --git a/tests/Integration/Api/Client/Server/Allocation/CreateNewAllocationTest.php b/tests/Integration/Api/Client/Server/Allocation/CreateNewAllocationTest.php
index 8022fb1e44..61d93a62aa 100644
--- a/tests/Integration/Api/Client/Server/Allocation/CreateNewAllocationTest.php
+++ b/tests/Integration/Api/Client/Server/Allocation/CreateNewAllocationTest.php
@@ -23,9 +23,8 @@ public function setUp(): void
/**
* Tests that a new allocation can be properly assigned to a server.
- *
- * @dataProvider permissionDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('permissionDataProvider')]
public function testNewAllocationCanBeAssignedToServer(array $permission)
{
/** @var \Pterodactyl\Models\Server $server */
diff --git a/tests/Integration/Api/Client/Server/Allocation/DeleteAllocationTest.php b/tests/Integration/Api/Client/Server/Allocation/DeleteAllocationTest.php
index 7d4737b757..f6bd466e63 100644
--- a/tests/Integration/Api/Client/Server/Allocation/DeleteAllocationTest.php
+++ b/tests/Integration/Api/Client/Server/Allocation/DeleteAllocationTest.php
@@ -12,16 +12,15 @@ class DeleteAllocationTest extends ClientApiIntegrationTestCase
/**
* Test that an allocation is deleted from the server and the notes are properly reset
* to an empty value on assignment.
- *
- * @dataProvider permissionDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('permissionDataProvider')]
public function testAllocationCanBeDeletedFromServer(array $permission)
{
/** @var \Pterodactyl\Models\Server $server */
[$user, $server] = $this->generateTestAccount($permission);
$server->update(['allocation_limit' => 2]);
- /** @var \Pterodactyl\Models\Allocation $allocation */
+ /** @var Allocation $allocation */
$allocation = Allocation::factory()->create([
'server_id' => $server->id,
'node_id' => $server->node_id,
@@ -41,7 +40,7 @@ public function testErrorIsReturnedIfUserDoesNotHavePermission()
/** @var \Pterodactyl\Models\Server $server */
[$user, $server] = $this->generateTestAccount([Permission::ACTION_ALLOCATION_CREATE]);
- /** @var \Pterodactyl\Models\Allocation $allocation */
+ /** @var Allocation $allocation */
$allocation = Allocation::factory()->create([
'server_id' => $server->id,
'node_id' => $server->node_id,
@@ -73,7 +72,7 @@ public function testAllocationCannotBeDeletedIfServerLimitIsNotDefined()
{
[$user, $server] = $this->generateTestAccount();
- /** @var \Pterodactyl\Models\Allocation $allocation */
+ /** @var Allocation $allocation */
$allocation = Allocation::factory()->forServer($server)->create(['notes' => 'Test notes']);
$this->actingAs($user)->deleteJson($this->link($allocation))
diff --git a/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php b/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php
index 20d9e13a76..33fde157c6 100644
--- a/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php
+++ b/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php
@@ -10,9 +10,7 @@
class BackupAuthorizationTest extends ClientApiIntegrationTestCase
{
- /**
- * @dataProvider methodDataProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('methodDataProvider')]
public function testAccessToAServersBackupIsRestrictedProperly(string $method, string $endpoint)
{
// The API $user is the owner of $server1.
diff --git a/tests/Integration/Api/Client/Server/Backup/DeleteBackupTest.php b/tests/Integration/Api/Client/Server/Backup/DeleteBackupTest.php
index 5c4d53e496..d6aea997d6 100644
--- a/tests/Integration/Api/Client/Server/Backup/DeleteBackupTest.php
+++ b/tests/Integration/Api/Client/Server/Backup/DeleteBackupTest.php
@@ -43,7 +43,7 @@ public function testBackupCanBeDeleted()
[$user, $server] = $this->generateTestAccount([Permission::ACTION_BACKUP_DELETE]);
- /** @var \Pterodactyl\Models\Backup $backup */
+ /** @var Backup $backup */
$backup = Backup::factory()->create(['server_id' => $server->id]);
$this->repository->expects('setServer->delete')->with(
diff --git a/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php b/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php
index 2ea709ce51..c31aed6e29 100644
--- a/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php
+++ b/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php
@@ -12,9 +12,7 @@
class DatabaseAuthorizationTest extends ClientApiIntegrationTestCase
{
- /**
- * @dataProvider methodDataProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('methodDataProvider')]
public function testAccessToAServersDatabasesIsRestrictedProperly(string $method, string $endpoint)
{
// The API $user is the owner of $server1.
diff --git a/tests/Integration/Api/Client/Server/NetworkAllocationControllerTest.php b/tests/Integration/Api/Client/Server/NetworkAllocationControllerTest.php
index b19be99ccf..0fc9a865b3 100644
--- a/tests/Integration/Api/Client/Server/NetworkAllocationControllerTest.php
+++ b/tests/Integration/Api/Client/Server/NetworkAllocationControllerTest.php
@@ -48,9 +48,8 @@ public function testServerAllocationsAreNotReturnedWithoutPermission()
/**
* Tests that notes on an allocation can be set correctly.
- *
- * @dataProvider updatePermissionsDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('updatePermissionsDataProvider')]
public function testAllocationNotesCanBeUpdated(array $permissions)
{
[$user, $server] = $this->generateTestAccount($permissions);
@@ -96,9 +95,7 @@ public function testAllocationNotesCannotBeUpdatedByInvalidUsers()
$this->actingAs($user)->postJson($this->link($server->allocation))->assertForbidden();
}
- /**
- * @dataProvider updatePermissionsDataProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('updatePermissionsDataProvider')]
public function testPrimaryAllocationCanBeModified(array $permissions)
{
[$user, $server] = $this->generateTestAccount($permissions);
diff --git a/tests/Integration/Api/Client/Server/PowerControllerTest.php b/tests/Integration/Api/Client/Server/PowerControllerTest.php
index f31244948e..54daa0e604 100644
--- a/tests/Integration/Api/Client/Server/PowerControllerTest.php
+++ b/tests/Integration/Api/Client/Server/PowerControllerTest.php
@@ -15,9 +15,8 @@ class PowerControllerTest extends ClientApiIntegrationTestCase
* the command to the server.
*
* @param string[] $permissions
- *
- * @dataProvider invalidPermissionDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('invalidPermissionDataProvider')]
public function testSubuserWithoutPermissionsReceivesError(string $action, array $permissions)
{
[$user, $server] = $this->generateTestAccount($permissions);
@@ -45,9 +44,8 @@ public function testInvalidPowerSignalResultsInError()
/**
* Test that sending a valid power actions works.
- *
- * @dataProvider validPowerActionDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('validPowerActionDataProvider')]
public function testActionCanBeSentToServer(string $action, string $permission)
{
$service = \Mockery::mock(DaemonPowerRepository::class);
diff --git a/tests/Integration/Api/Client/Server/Schedule/CreateServerScheduleTest.php b/tests/Integration/Api/Client/Server/Schedule/CreateServerScheduleTest.php
index f72ef09f57..26ab866e05 100644
--- a/tests/Integration/Api/Client/Server/Schedule/CreateServerScheduleTest.php
+++ b/tests/Integration/Api/Client/Server/Schedule/CreateServerScheduleTest.php
@@ -11,9 +11,8 @@ class CreateServerScheduleTest extends ClientApiIntegrationTestCase
{
/**
* Test that a schedule can be created for the server.
- *
- * @dataProvider permissionsDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('permissionsDataProvider')]
public function testScheduleCanBeCreatedForServer(array $permissions)
{
[$user, $server] = $this->generateTestAccount($permissions);
@@ -32,7 +31,7 @@ public function testScheduleCanBeCreatedForServer(array $permissions)
$this->assertNotNull($id = $response->json('attributes.id'));
- /** @var \Pterodactyl\Models\Schedule $schedule */
+ /** @var Schedule $schedule */
$schedule = Schedule::query()->findOrFail($id);
$this->assertFalse($schedule->is_active);
$this->assertFalse($schedule->is_processing);
diff --git a/tests/Integration/Api/Client/Server/Schedule/DeleteServerScheduleTest.php b/tests/Integration/Api/Client/Server/Schedule/DeleteServerScheduleTest.php
index d444470256..c204ff4f54 100644
--- a/tests/Integration/Api/Client/Server/Schedule/DeleteServerScheduleTest.php
+++ b/tests/Integration/Api/Client/Server/Schedule/DeleteServerScheduleTest.php
@@ -12,9 +12,8 @@ class DeleteServerScheduleTest extends ClientApiIntegrationTestCase
{
/**
* Test that a schedule can be deleted from the system.
- *
- * @dataProvider permissionsDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('permissionsDataProvider')]
public function testScheduleCanBeDeleted(array $permissions)
{
[$user, $server] = $this->generateTestAccount($permissions);
diff --git a/tests/Integration/Api/Client/Server/Schedule/ExecuteScheduleTest.php b/tests/Integration/Api/Client/Server/Schedule/ExecuteScheduleTest.php
index 7ca3552995..eafcf3c05a 100644
--- a/tests/Integration/Api/Client/Server/Schedule/ExecuteScheduleTest.php
+++ b/tests/Integration/Api/Client/Server/Schedule/ExecuteScheduleTest.php
@@ -14,16 +14,15 @@ class ExecuteScheduleTest extends ClientApiIntegrationTestCase
{
/**
* Test that a schedule can be executed and is updated in the database correctly.
- *
- * @dataProvider permissionsDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('permissionsDataProvider')]
public function testScheduleIsExecutedRightAway(array $permissions)
{
[$user, $server] = $this->generateTestAccount($permissions);
Bus::fake();
- /** @var \Pterodactyl\Models\Schedule $schedule */
+ /** @var Schedule $schedule */
$schedule = Schedule::factory()->create([
'server_id' => $server->id,
]);
@@ -33,7 +32,7 @@ public function testScheduleIsExecutedRightAway(array $permissions)
$response->assertJsonPath('errors.0.code', 'DisplayException');
$response->assertJsonPath('errors.0.detail', 'Cannot process schedule for task execution: no tasks are registered.');
- /** @var \Pterodactyl\Models\Task $task */
+ /** @var Task $task */
$task = Task::factory()->create([
'schedule_id' => $schedule->id,
'sequence_id' => 1,
@@ -58,7 +57,7 @@ public function testUserWithoutScheduleUpdatePermissionCannotExecute()
{
[$user, $server] = $this->generateTestAccount([Permission::ACTION_SCHEDULE_CREATE]);
- /** @var \Pterodactyl\Models\Schedule $schedule */
+ /** @var Schedule $schedule */
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
$this->actingAs($user)->postJson($this->link($schedule, '/execute'))->assertForbidden();
diff --git a/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php b/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php
index 483c7ae42f..cc5db4139c 100644
--- a/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php
+++ b/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php
@@ -22,16 +22,15 @@ protected function tearDown(): void
/**
* Test that schedules for a server are returned.
- *
- * @dataProvider permissionsDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('permissionsDataProvider')]
public function testServerSchedulesAreReturned(array $permissions, bool $individual)
{
[$user, $server] = $this->generateTestAccount($permissions);
- /** @var \Pterodactyl\Models\Schedule $schedule */
+ /** @var Schedule $schedule */
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
- /** @var \Pterodactyl\Models\Task $task */
+ /** @var Task $task */
$task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1, 'time_offset' => 0]);
$response = $this->actingAs($user)
diff --git a/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php b/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php
index bf5b8d729d..26a83de4c2 100644
--- a/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php
+++ b/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php
@@ -16,9 +16,8 @@ class ScheduleAuthorizationTest extends ClientApiIntegrationTestCase
*
* The comments within the test code itself are better at explaining exactly what is
* being tested and protected against.
- *
- * @dataProvider methodDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('methodDataProvider')]
public function testAccessToAServersSchedulesIsRestrictedProperly(string $method, string $endpoint)
{
// The API $user is the owner of $server1.
diff --git a/tests/Integration/Api/Client/Server/Schedule/UpdateServerScheduleTest.php b/tests/Integration/Api/Client/Server/Schedule/UpdateServerScheduleTest.php
index 23a054b34d..6b6ad10917 100644
--- a/tests/Integration/Api/Client/Server/Schedule/UpdateServerScheduleTest.php
+++ b/tests/Integration/Api/Client/Server/Schedule/UpdateServerScheduleTest.php
@@ -24,14 +24,13 @@ class UpdateServerScheduleTest extends ClientApiIntegrationTestCase
/**
* Test that a schedule can be updated.
- *
- * @dataProvider permissionsDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('permissionsDataProvider')]
public function testScheduleCanBeUpdated(array $permissions)
{
[$user, $server] = $this->generateTestAccount($permissions);
- /** @var \Pterodactyl\Models\Schedule $schedule */
+ /** @var Schedule $schedule */
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
$expected = Utilities::getScheduleNextRunDate('5', '*', '*', '*', '*');
@@ -89,7 +88,7 @@ public function testScheduleIsProcessingIsSetToFalseWhenActiveStateChanges()
{
[$user, $server] = $this->generateTestAccount();
- /** @var \Pterodactyl\Models\Schedule $schedule */
+ /** @var Schedule $schedule */
$schedule = Schedule::factory()->create([
'server_id' => $server->id,
'is_active' => true,
diff --git a/tests/Integration/Api/Client/Server/ScheduleTask/CreateServerScheduleTaskTest.php b/tests/Integration/Api/Client/Server/ScheduleTask/CreateServerScheduleTaskTest.php
index 736344a689..c2d047a2b3 100644
--- a/tests/Integration/Api/Client/Server/ScheduleTask/CreateServerScheduleTaskTest.php
+++ b/tests/Integration/Api/Client/Server/ScheduleTask/CreateServerScheduleTaskTest.php
@@ -12,14 +12,13 @@ class CreateServerScheduleTaskTest extends ClientApiIntegrationTestCase
{
/**
* Test that a task can be created.
- *
- * @dataProvider permissionsDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('permissionsDataProvider')]
public function testTaskCanBeCreated(array $permissions)
{
[$user, $server] = $this->generateTestAccount($permissions);
- /** @var \Pterodactyl\Models\Schedule $schedule */
+ /** @var Schedule $schedule */
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
$this->assertEmpty($schedule->tasks);
@@ -31,7 +30,7 @@ public function testTaskCanBeCreated(array $permissions)
]);
$response->assertOk();
- /** @var \Pterodactyl\Models\Task $task */
+ /** @var Task $task */
$task = Task::query()->findOrFail($response->json('attributes.id'));
$this->assertSame($schedule->id, $task->schedule_id);
@@ -49,7 +48,7 @@ public function testValidationErrorsAreReturned()
{
[$user, $server] = $this->generateTestAccount();
- /** @var \Pterodactyl\Models\Schedule $schedule */
+ /** @var Schedule $schedule */
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
$response = $this->actingAs($user)->postJson($this->link($schedule, '/tasks'))->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
@@ -94,7 +93,7 @@ public function testBackupsCanNotBeTaskedIfLimit0()
{
[$user, $server] = $this->generateTestAccount();
- /** @var \Pterodactyl\Models\Schedule $schedule */
+ /** @var Schedule $schedule */
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
$this->actingAs($user)->postJson($this->link($schedule, '/tasks'), [
@@ -123,7 +122,7 @@ public function testErrorIsReturnedIfTooManyTasksExistForSchedule()
[$user, $server] = $this->generateTestAccount();
- /** @var \Pterodactyl\Models\Schedule $schedule */
+ /** @var Schedule $schedule */
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
Task::factory()->times(2)->create(['schedule_id' => $schedule->id]);
@@ -146,7 +145,7 @@ public function testErrorIsReturnedIfScheduleDoesNotBelongToServer()
[$user, $server] = $this->generateTestAccount();
$server2 = $this->createServerModel(['owner_id' => $user->id]);
- /** @var \Pterodactyl\Models\Schedule $schedule */
+ /** @var Schedule $schedule */
$schedule = Schedule::factory()->create(['server_id' => $server2->id]);
$this->actingAs($user)
@@ -162,7 +161,7 @@ public function testErrorIsReturnedIfSubuserDoesNotHaveScheduleUpdatePermissions
{
[$user, $server] = $this->generateTestAccount([Permission::ACTION_SCHEDULE_CREATE]);
- /** @var \Pterodactyl\Models\Schedule $schedule */
+ /** @var Schedule $schedule */
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
$this->actingAs($user)
diff --git a/tests/Integration/Api/Client/Server/SettingsControllerTest.php b/tests/Integration/Api/Client/Server/SettingsControllerTest.php
index fcc7a5ce7e..1497927cd1 100644
--- a/tests/Integration/Api/Client/Server/SettingsControllerTest.php
+++ b/tests/Integration/Api/Client/Server/SettingsControllerTest.php
@@ -12,12 +12,11 @@ class SettingsControllerTest extends ClientApiIntegrationTestCase
{
/**
* Test that the server's name can be changed.
- *
- * @dataProvider renamePermissionsDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('renamePermissionsDataProvider')]
public function testServerNameCanBeChanged(array $permissions)
{
- /** @var \Pterodactyl\Models\Server $server */
+ /** @var Server $server */
[$user, $server] = $this->generateTestAccount($permissions);
$originalName = $server->name;
$originalDescription = $server->description;
@@ -68,12 +67,11 @@ public function testSubuserCannotChangeServerNameWithoutPermission()
/**
* Test that a server can be reinstalled. Honestly this test doesn't do much of anything other
* than make sure the endpoint works since.
- *
- * @dataProvider reinstallPermissionsDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('reinstallPermissionsDataProvider')]
public function testServerCanBeReinstalled(array $permissions)
{
- /** @var \Pterodactyl\Models\Server $server */
+ /** @var Server $server */
[$user, $server] = $this->generateTestAccount($permissions);
$this->assertTrue($server->isInstalled());
diff --git a/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php b/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php
index 04150e07f6..493cc6a0a6 100644
--- a/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php
+++ b/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php
@@ -12,9 +12,8 @@ class GetStartupAndVariablesTest extends ClientApiIntegrationTestCase
/**
* Test that the startup command and variables are returned for a server, but only the variables
* that can be viewed by a user (e.g. user_viewable=true).
- *
- * @dataProvider permissionsDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('permissionsDataProvider')]
public function testStartupVariablesAreReturnedForServer(array $permissions)
{
/** @var \Pterodactyl\Models\Server $server */
diff --git a/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php b/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php
index fed4d1377b..cb67cb0952 100644
--- a/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php
+++ b/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php
@@ -12,9 +12,8 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase
{
/**
* Test that a startup variable can be edited successfully for a server.
- *
- * @dataProvider permissionsDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('permissionsDataProvider')]
public function testStartupVariableCanBeUpdated(array $permissions)
{
/** @var \Pterodactyl\Models\Server $server */
@@ -47,9 +46,8 @@ public function testStartupVariableCanBeUpdated(array $permissions)
/**
* Test that variables that are either not user_viewable, or not user_editable, cannot be
* updated via this endpoint.
- *
- * @dataProvider permissionsDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('permissionsDataProvider')]
public function testStartupVariableCannotBeUpdatedIfNotUserViewableOrEditable(array $permissions)
{
/** @var \Pterodactyl\Models\Server $server */
diff --git a/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php b/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php
index c12ede61ae..12aef45e88 100644
--- a/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php
+++ b/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php
@@ -16,9 +16,8 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase
/**
* Test that a subuser can be created for a server.
- *
- * @dataProvider permissionsDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('permissionsDataProvider')]
public function testSubuserCanBeCreated(array $permissions)
{
[$user, $server] = $this->generateTestAccount($permissions);
@@ -32,7 +31,7 @@ public function testSubuserCanBeCreated(array $permissions)
$response->assertOk();
- /** @var \Pterodactyl\Models\User $subuser */
+ /** @var User $subuser */
$subuser = User::query()->where('email', $email)->firstOrFail();
$response->assertJsonPath('object', Subuser::RESOURCE_NAME);
@@ -111,7 +110,7 @@ public function testCreatingSubuserWithSameEmailAsExistingUserWorks()
{
[$user, $server] = $this->generateTestAccount();
- /** @var \Pterodactyl\Models\User $existing */
+ /** @var User $existing */
$existing = User::factory()->create(['email' => $this->faker->email]);
$response = $this->actingAs($user)->postJson($this->link($server) . '/users', [
diff --git a/tests/Integration/Api/Client/Server/Subuser/DeleteSubuserTest.php b/tests/Integration/Api/Client/Server/Subuser/DeleteSubuserTest.php
index 45753ea6cf..921e79fd12 100644
--- a/tests/Integration/Api/Client/Server/Subuser/DeleteSubuserTest.php
+++ b/tests/Integration/Api/Client/Server/Subuser/DeleteSubuserTest.php
@@ -28,14 +28,14 @@ public function testCorrectSubuserIsDeletedFromServer()
[$user, $server] = $this->generateTestAccount();
- /** @var \Pterodactyl\Models\User $differentUser */
+ /** @var User $differentUser */
$differentUser = User::factory()->create();
$real = Uuid::uuid4()->toString();
// Generate a UUID that lines up with a user in the database if it were to be cast to an int.
$uuid = $differentUser->id . substr($real, strlen((string) $differentUser->id));
- /** @var \Pterodactyl\Models\User $subuser */
+ /** @var User $subuser */
$subuser = User::factory()->create(['uuid' => $uuid]);
Subuser::query()->forceCreate([
@@ -51,7 +51,7 @@ public function testCorrectSubuserIsDeletedFromServer()
// Try the same test, but this time with a UUID that if cast to an int (shouldn't) line up with
// anything in the database.
$uuid = '18180000' . substr(Uuid::uuid4()->toString(), 8);
- /** @var \Pterodactyl\Models\User $subuser */
+ /** @var User $subuser */
$subuser = User::factory()->create(['uuid' => $uuid]);
Subuser::query()->forceCreate([
diff --git a/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php b/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php
index c7935aa341..6d43df3b96 100644
--- a/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php
+++ b/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php
@@ -11,13 +11,12 @@ class SubuserAuthorizationTest extends ClientApiIntegrationTestCase
{
/**
* Test that mismatched subusers are not accessible to a server.
- *
- * @dataProvider methodDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('methodDataProvider')]
public function testUserCannotAccessResourceBelongingToOtherServers(string $method)
{
// Generic subuser, the specific resource we're trying to access.
- /** @var \Pterodactyl\Models\User $internal */
+ /** @var User $internal */
$internal = User::factory()->create();
// The API $user is the owner of $server1.
diff --git a/tests/Integration/Api/Client/Server/Subuser/UpdateSubuserTest.php b/tests/Integration/Api/Client/Server/Subuser/UpdateSubuserTest.php
index 5990b96188..58e48e2324 100644
--- a/tests/Integration/Api/Client/Server/Subuser/UpdateSubuserTest.php
+++ b/tests/Integration/Api/Client/Server/Subuser/UpdateSubuserTest.php
@@ -57,7 +57,7 @@ public function testPermissionsAreSavedToAccount()
{
[$user, $server] = $this->generateTestAccount();
- /** @var \Pterodactyl\Models\Subuser $subuser */
+ /** @var Subuser $subuser */
$subuser = Subuser::factory()
->for(User::factory()->create())
->for($server)
diff --git a/tests/Integration/Api/Client/TwoFactorControllerTest.php b/tests/Integration/Api/Client/TwoFactorControllerTest.php
index 6cc086fc7e..5c3d80388d 100644
--- a/tests/Integration/Api/Client/TwoFactorControllerTest.php
+++ b/tests/Integration/Api/Client/TwoFactorControllerTest.php
@@ -17,7 +17,7 @@ class TwoFactorControllerTest extends ClientApiIntegrationTestCase
*/
public function testTwoFactorImageDataIsReturned()
{
- /** @var \Pterodactyl\Models\User $user */
+ /** @var User $user */
$user = User::factory()->create(['use_totp' => false]);
$this->assertFalse($user->use_totp);
@@ -41,7 +41,7 @@ public function testTwoFactorImageDataIsReturned()
*/
public function testErrorIsReturnedWhenTwoFactorIsAlreadyEnabled()
{
- /** @var \Pterodactyl\Models\User $user */
+ /** @var User $user */
$user = User::factory()->create(['use_totp' => true]);
$response = $this->actingAs($user)->getJson('/api/client/account/two-factor');
@@ -56,7 +56,7 @@ public function testErrorIsReturnedWhenTwoFactorIsAlreadyEnabled()
*/
public function testValidationErrorIsReturnedIfInvalidDataIsPassedToEnabled2FA()
{
- /** @var \Pterodactyl\Models\User $user */
+ /** @var User $user */
$user = User::factory()->create(['use_totp' => false]);
$this->actingAs($user)
@@ -73,7 +73,7 @@ public function testValidationErrorIsReturnedIfInvalidDataIsPassedToEnabled2FA()
*/
public function testTwoFactorCanBeEnabledOnAccount()
{
- /** @var \Pterodactyl\Models\User $user */
+ /** @var User $user */
$user = User::factory()->create(['use_totp' => false]);
// Make the initial call to get the account setup for 2FA.
@@ -82,7 +82,7 @@ public function testTwoFactorCanBeEnabledOnAccount()
$user = $user->refresh();
$this->assertNotNull($user->totp_secret);
- /** @var \PragmaRX\Google2FA\Google2FA $service */
+ /** @var Google2FA $service */
$service = $this->app->make(Google2FA::class);
$secret = decrypt($user->totp_secret);
@@ -129,10 +129,10 @@ public function testTwoFactorCanBeDisabledOnAccount()
{
Carbon::setTestNow(Carbon::now());
- /** @var \Pterodactyl\Models\User $user */
+ /** @var User $user */
$user = User::factory()->create(['use_totp' => true]);
- $response = $this->actingAs($user)->deleteJson('/api/client/account/two-factor', [
+ $response = $this->actingAs($user)->postJson('/api/client/account/two-factor/disable', [
'password' => 'invalid',
]);
@@ -140,7 +140,7 @@ public function testTwoFactorCanBeDisabledOnAccount()
$response->assertJsonPath('errors.0.code', 'BadRequestHttpException');
$response->assertJsonPath('errors.0.detail', 'The password provided was not valid.');
- $response = $this->actingAs($user)->deleteJson('/api/client/account/two-factor', [
+ $response = $this->actingAs($user)->postJson('/api/client/account/two-factor/disable', [
'password' => 'password',
]);
@@ -160,10 +160,10 @@ public function testNoErrorIsReturnedIfTwoFactorIsNotEnabled()
{
Carbon::setTestNow(Carbon::now());
- /** @var \Pterodactyl\Models\User $user */
+ /** @var User $user */
$user = User::factory()->create(['use_totp' => false]);
- $response = $this->actingAs($user)->deleteJson('/api/client/account/two-factor', [
+ $response = $this->actingAs($user)->postJson('/api/client/account/two-factor/disable', [
'password' => 'password',
]);
@@ -196,7 +196,7 @@ public function testDisablingTwoFactorRequiresValidPassword()
$user = User::factory()->create(['use_totp' => true]);
$this->actingAs($user)
- ->deleteJson('/api/client/account/two-factor', [
+ ->postJson('/api/client/account/two-factor/disable', [
'password' => 'foo',
])
->assertStatus(Response::HTTP_BAD_REQUEST)
diff --git a/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php b/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php
index 38d4ccc656..c793435d69 100644
--- a/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php
+++ b/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php
@@ -2,12 +2,12 @@
namespace Pterodactyl\Tests\Integration\Api\Remote;
+use phpseclib3\Crypt\EC;
use Pterodactyl\Models\Node;
use Pterodactyl\Models\User;
use Pterodactyl\Models\Server;
use Pterodactyl\Models\Permission;
use Pterodactyl\Models\UserSSHKey;
-use phpseclib3\Crypt\EC\PrivateKey;
use Pterodactyl\Tests\Integration\IntegrationTestCase;
class SftpAuthenticationControllerTest extends IntegrationTestCase
@@ -94,9 +94,8 @@ public function testPasswordIsValidatedCorrectly()
/**
* Test that providing an invalid key and/or invalid username triggers the throttle on
* the endpoint.
- *
- * @dataProvider authorizationTypeDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('authorizationTypeDataProvider')]
public function testUserIsThrottledIfInvalidCredentialsAreProvided()
{
for ($i = 0; $i <= 10; ++$i) {
@@ -119,7 +118,7 @@ public function testUserIsNotThrottledIfNoPublicKeyMatches()
$this->postJson('/api/remote/sftp/auth', [
'type' => 'public_key',
'username' => $this->getUsername(),
- 'password' => PrivateKey::createKey('Ed25519')->getPublicKey()->toString('OpenSSH'),
+ 'password' => EC::createKey('Ed25519')->getPublicKey()->toString('OpenSSH'),
])
->assertForbidden();
}
@@ -128,9 +127,8 @@ public function testUserIsNotThrottledIfNoPublicKeyMatches()
/**
* Test that a request is rejected if the credentials are valid but the username indicates
* a server on a different node.
- *
- * @dataProvider authorizationTypeDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('authorizationTypeDataProvider')]
public function testRequestIsRejectedIfServerBelongsToDifferentNode(string $type)
{
$node2 = $this->createServerModel()->node;
@@ -165,9 +163,7 @@ public function testRequestIsDeniedIfUserLacksSftpPermission()
->assertJsonPath('errors.0.detail', 'You do not have permission to access SFTP for this server.');
}
- /**
- * @dataProvider serverStateDataProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('serverStateDataProvider')]
public function testInvalidServerStateReturnsConflictError(string $status)
{
$this->server->update(['status' => $status]);
@@ -241,7 +237,7 @@ protected function getUsername(bool $long = false): string
/**
* Sets the authorization header for the rest of the test.
*/
- protected function setAuthorization(Node $node = null): void
+ protected function setAuthorization(?Node $node = null): void
{
$node = $node ?? $this->server->node;
diff --git a/tests/Integration/Http/Controllers/Admin/UserControllerTest.php b/tests/Integration/Http/Controllers/Admin/UserControllerTest.php
deleted file mode 100644
index 34cf9f938d..0000000000
--- a/tests/Integration/Http/Controllers/Admin/UserControllerTest.php
+++ /dev/null
@@ -1,59 +0,0 @@
-create(['username' => $unique . '_1']),
- User::factory()->create(['username' => $unique . '_2']),
- ];
-
- $servers = [
- $this->createServerModel(['owner_id' => $users[0]->id]),
- $this->createServerModel(['owner_id' => $users[0]->id]),
- $this->createServerModel(['owner_id' => $users[0]->id]),
- $this->createServerModel(['owner_id' => $users[1]->id]),
- ];
-
- Subuser::query()->forceCreate(['server_id' => $servers[0]->id, 'user_id' => $users[1]->id]);
- Subuser::query()->forceCreate(['server_id' => $servers[1]->id, 'user_id' => $users[1]->id]);
-
- /** @var \Pterodactyl\Http\Controllers\Admin\UserController $controller */
- $controller = $this->app->make(UserController::class);
-
- $request = Request::create('/admin/users?filter[username]=' . $unique);
- $this->app->instance(Request::class, $request);
-
- $data = $controller->index($request)->getData();
- $this->assertArrayHasKey('users', $data);
- $this->assertInstanceOf(LengthAwarePaginator::class, $data['users']);
-
- /** @var \Pterodactyl\Models\User[] $response */
- $response = $data['users']->items();
- $this->assertCount(2, $response);
- $this->assertInstanceOf(User::class, $response[0]);
- $this->assertSame(3, (int) $response[0]->servers_count);
- $this->assertSame(0, (int) $response[0]->subuser_of_count);
- $this->assertSame(1, (int) $response[1]->servers_count);
- $this->assertSame(2, (int) $response[1]->subuser_of_count);
- }
-}
diff --git a/tests/Integration/Jobs/Schedule/RunTaskJobTest.php b/tests/Integration/Jobs/Schedule/RunTaskJobTest.php
index c1c3244255..907454a84a 100644
--- a/tests/Integration/Jobs/Schedule/RunTaskJobTest.php
+++ b/tests/Integration/Jobs/Schedule/RunTaskJobTest.php
@@ -25,14 +25,14 @@ public function testInactiveJobIsNotRun()
{
$server = $this->createServerModel();
- /** @var \Pterodactyl\Models\Schedule $schedule */
+ /** @var Schedule $schedule */
$schedule = Schedule::factory()->create([
'server_id' => $server->id,
'is_processing' => true,
'last_run_at' => null,
'is_active' => false,
]);
- /** @var \Pterodactyl\Models\Task $task */
+ /** @var Task $task */
$task = Task::factory()->create(['schedule_id' => $schedule->id, 'is_queued' => true]);
$job = new RunTaskJob($task);
@@ -52,9 +52,9 @@ public function testJobWithInvalidActionThrowsException()
{
$server = $this->createServerModel();
- /** @var \Pterodactyl\Models\Schedule $schedule */
+ /** @var Schedule $schedule */
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
- /** @var \Pterodactyl\Models\Task $task */
+ /** @var Task $task */
$task = Task::factory()->create(['schedule_id' => $schedule->id, 'action' => 'foobar']);
$job = new RunTaskJob($task);
@@ -64,21 +64,19 @@ public function testJobWithInvalidActionThrowsException()
Bus::dispatchSync($job);
}
- /**
- * @dataProvider isManualRunDataProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('isManualRunDataProvider')]
public function testJobIsExecuted(bool $isManualRun)
{
$server = $this->createServerModel();
- /** @var \Pterodactyl\Models\Schedule $schedule */
+ /** @var Schedule $schedule */
$schedule = Schedule::factory()->create([
'server_id' => $server->id,
'is_active' => !$isManualRun,
'is_processing' => true,
'last_run_at' => null,
]);
- /** @var \Pterodactyl\Models\Task $task */
+ /** @var Task $task */
$task = Task::factory()->create([
'schedule_id' => $schedule->id,
'action' => Task::ACTION_POWER,
@@ -105,16 +103,14 @@ public function testJobIsExecuted(bool $isManualRun)
$this->assertTrue(CarbonImmutable::now()->isSameAs(\DateTimeInterface::ATOM, $schedule->last_run_at));
}
- /**
- * @dataProvider isManualRunDataProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('isManualRunDataProvider')]
public function testExceptionDuringRunIsHandledCorrectly(bool $continueOnFailure)
{
$server = $this->createServerModel();
- /** @var \Pterodactyl\Models\Schedule $schedule */
+ /** @var Schedule $schedule */
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
- /** @var \Pterodactyl\Models\Task $task */
+ /** @var Task $task */
$task = Task::factory()->create([
'schedule_id' => $schedule->id,
'action' => Task::ACTION_POWER,
diff --git a/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php b/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php
index b68a3521ea..7ccfb83380 100644
--- a/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php
+++ b/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php
@@ -69,9 +69,8 @@ public function testDatabaseCannotBeCreatedIfServerHasReachedLimit()
/**
* Test that a missing or invalid database name format causes an exception to be thrown.
- *
- * @dataProvider invalidDataDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('invalidDataDataProvider')]
public function testEmptyDatabaseNameOrInvalidNameTriggersAnException(array $data)
{
$server = $this->createServerModel();
diff --git a/tests/Integration/Services/Databases/DeployServerDatabaseServiceTest.php b/tests/Integration/Services/Databases/DeployServerDatabaseServiceTest.php
index eb8f4dbaa5..f9afd85643 100644
--- a/tests/Integration/Services/Databases/DeployServerDatabaseServiceTest.php
+++ b/tests/Integration/Services/Databases/DeployServerDatabaseServiceTest.php
@@ -41,9 +41,8 @@ protected function tearDown(): void
/**
* Test that an error is thrown if either the database name or the remote host are empty.
- *
- * @dataProvider invalidDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('invalidDataProvider')]
public function testErrorIsThrownIfDatabaseNameIsEmpty(array $data)
{
$server = $this->createServerModel();
diff --git a/tests/Integration/Services/Schedules/ProcessScheduleServiceTest.php b/tests/Integration/Services/Schedules/ProcessScheduleServiceTest.php
index eaed38a16d..29c91f4633 100644
--- a/tests/Integration/Services/Schedules/ProcessScheduleServiceTest.php
+++ b/tests/Integration/Services/Schedules/ProcessScheduleServiceTest.php
@@ -36,13 +36,13 @@ public function testErrorDuringScheduleDataUpdateDoesNotPersistChanges()
{
$server = $this->createServerModel();
- /** @var \Pterodactyl\Models\Schedule $schedule */
+ /** @var Schedule $schedule */
$schedule = Schedule::factory()->create([
'server_id' => $server->id,
'cron_minute' => 'hodor', // this will break the getNextRunDate() function.
]);
- /** @var \Pterodactyl\Models\Task $task */
+ /** @var Task $task */
$task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1]);
$this->expectException(\InvalidArgumentException::class);
@@ -55,19 +55,18 @@ public function testErrorDuringScheduleDataUpdateDoesNotPersistChanges()
/**
* Test that a job is dispatched as expected using the initial delay.
- *
- * @dataProvider dispatchNowDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dispatchNowDataProvider')]
public function testJobCanBeDispatchedWithExpectedInitialDelay(bool $now)
{
Bus::fake();
$server = $this->createServerModel();
- /** @var \Pterodactyl\Models\Schedule $schedule */
+ /** @var Schedule $schedule */
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
- /** @var \Pterodactyl\Models\Task $task */
+ /** @var Task $task */
$task = Task::factory()->create(['schedule_id' => $schedule->id, 'time_offset' => 10, 'sequence_id' => 1]);
$this->getService()->handle($schedule, $now);
@@ -96,10 +95,10 @@ public function testFirstSequenceTaskIsFound()
Bus::fake();
$server = $this->createServerModel();
- /** @var \Pterodactyl\Models\Schedule $schedule */
+ /** @var Schedule $schedule */
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
- /** @var \Pterodactyl\Models\Task $task */
+ /** @var Task $task */
$task2 = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 4]);
$task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 2]);
$task3 = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 3]);
@@ -127,9 +126,9 @@ public function testTaskDispatchedNowIsResetProperlyIfErrorIsEncountered()
$this->swap(Dispatcher::class, $dispatcher = \Mockery::mock(Dispatcher::class));
$server = $this->createServerModel();
- /** @var \Pterodactyl\Models\Schedule $schedule */
+ /** @var Schedule $schedule */
$schedule = Schedule::factory()->create(['server_id' => $server->id, 'last_run_at' => null]);
- /** @var \Pterodactyl\Models\Task $task */
+ /** @var Task $task */
$task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1]);
$dispatcher->expects('dispatchNow')->andThrows(new \Exception('Test thrown exception'));
diff --git a/tests/Integration/Services/Servers/BuildModificationServiceTest.php b/tests/Integration/Services/Servers/BuildModificationServiceTest.php
index f63efee9ef..52d69685c2 100644
--- a/tests/Integration/Services/Servers/BuildModificationServiceTest.php
+++ b/tests/Integration/Services/Servers/BuildModificationServiceTest.php
@@ -168,7 +168,7 @@ public function testConnectionExceptionIsIgnoredWhenUpdatingServerSettings()
public function testNoExceptionIsThrownIfOnlyRemovingAllocation()
{
$server = $this->createServerModel();
- /** @var \Pterodactyl\Models\Allocation $allocation */
+ /** @var Allocation $allocation */
$allocation = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => $server->id]);
$this->daemonServerRepository->expects('setServer->sync')->andReturnUndefined();
@@ -191,7 +191,7 @@ public function testNoExceptionIsThrownIfOnlyRemovingAllocation()
public function testAllocationInBothAddAndRemoveIsAdded()
{
$server = $this->createServerModel();
- /** @var \Pterodactyl\Models\Allocation $allocation */
+ /** @var Allocation $allocation */
$allocation = Allocation::factory()->create(['node_id' => $server->node_id]);
$this->daemonServerRepository->expects('setServer->sync')->andReturnUndefined();
@@ -210,9 +210,9 @@ public function testAllocationInBothAddAndRemoveIsAdded()
public function testUsingSameAllocationIdMultipleTimesDoesNotError()
{
$server = $this->createServerModel();
- /** @var \Pterodactyl\Models\Allocation $allocation */
+ /** @var Allocation $allocation */
$allocation = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => $server->id]);
- /** @var \Pterodactyl\Models\Allocation $allocation2 */
+ /** @var Allocation $allocation2 */
$allocation2 = Allocation::factory()->create(['node_id' => $server->node_id]);
$this->daemonServerRepository->expects('setServer->sync')->andReturnUndefined();
@@ -235,7 +235,7 @@ public function testUsingSameAllocationIdMultipleTimesDoesNotError()
public function testThatUpdatesAreRolledBackIfExceptionIsEncountered()
{
$server = $this->createServerModel();
- /** @var \Pterodactyl\Models\Allocation $allocation */
+ /** @var Allocation $allocation */
$allocation = Allocation::factory()->create(['node_id' => $server->node_id]);
$this->daemonServerRepository->expects('setServer->sync')->andThrows(new DisplayException('Test'));
diff --git a/tests/Integration/Services/Servers/ServerCreationServiceTest.php b/tests/Integration/Services/Servers/ServerCreationServiceTest.php
index b6adb9b60d..e840bb30da 100644
--- a/tests/Integration/Services/Servers/ServerCreationServiceTest.php
+++ b/tests/Integration/Services/Servers/ServerCreationServiceTest.php
@@ -54,13 +54,13 @@ public function setUp(): void
*/
public function testServerIsCreatedWithDeploymentObject()
{
- /** @var \Pterodactyl\Models\User $user */
+ /** @var User $user */
$user = User::factory()->create();
- /** @var \Pterodactyl\Models\Location $location */
+ /** @var Location $location */
$location = Location::factory()->create();
- /** @var \Pterodactyl\Models\Node $node */
+ /** @var Node $node */
$node = Node::factory()->create([
'location_id' => $location->id,
]);
@@ -156,18 +156,18 @@ public function testServerIsCreatedWithDeploymentObject()
*/
public function testErrorEncounteredByWingsCausesServerToBeDeleted()
{
- /** @var \Pterodactyl\Models\User $user */
+ /** @var User $user */
$user = User::factory()->create();
- /** @var \Pterodactyl\Models\Location $location */
+ /** @var Location $location */
$location = Location::factory()->create();
- /** @var \Pterodactyl\Models\Node $node */
+ /** @var Node $node */
$node = Node::factory()->create([
'location_id' => $location->id,
]);
- /** @var \Pterodactyl\Models\Allocation $allocation */
+ /** @var Allocation $allocation */
$allocation = Allocation::factory()->create([
'node_id' => $node->id,
]);
diff --git a/tests/Integration/Services/Servers/ServerDeletionServiceTest.php b/tests/Integration/Services/Servers/ServerDeletionServiceTest.php
index 676a60416b..1a1446467e 100644
--- a/tests/Integration/Services/Servers/ServerDeletionServiceTest.php
+++ b/tests/Integration/Services/Servers/ServerDeletionServiceTest.php
@@ -112,7 +112,7 @@ public function testExceptionWhileDeletingStopsProcess()
$server = $this->createServerModel();
$host = DatabaseHost::factory()->create();
- /** @var \Pterodactyl\Models\Database $db */
+ /** @var Database $db */
$db = Database::factory()->create(['database_host_id' => $host->id, 'server_id' => $server->id]);
$server->refresh();
@@ -137,7 +137,7 @@ public function testExceptionWhileDeletingDatabasesDoesNotAbortIfForceDeleted()
$server = $this->createServerModel();
$host = DatabaseHost::factory()->create();
- /** @var \Pterodactyl\Models\Database $db */
+ /** @var Database $db */
$db = Database::factory()->create(['database_host_id' => $host->id, 'server_id' => $server->id]);
$server->refresh();
diff --git a/tests/Integration/Services/Servers/StartupModificationServiceTest.php b/tests/Integration/Services/Servers/StartupModificationServiceTest.php
index 0d310a9f11..4f9ae90f0d 100644
--- a/tests/Integration/Services/Servers/StartupModificationServiceTest.php
+++ b/tests/Integration/Services/Servers/StartupModificationServiceTest.php
@@ -37,7 +37,7 @@ public function testNonAdminCanModifyServerVariables()
} catch (\Exception $exception) {
$this->assertInstanceOf(ValidationException::class, $exception);
- /** @var \Illuminate\Validation\ValidationException $exception */
+ /** @var ValidationException $exception */
$errors = $exception->validator->errors()->toArray();
$this->assertCount(1, $errors);
diff --git a/tests/TestCase.php b/tests/TestCase.php
index 5e131fa8bb..955f9dfaf7 100644
--- a/tests/TestCase.php
+++ b/tests/TestCase.php
@@ -8,8 +8,6 @@
abstract class TestCase extends BaseTestCase
{
- use CreatesApplication;
-
/**
* Setup tests.
*/
diff --git a/tests/Traits/Http/RequestMockHelpers.php b/tests/Traits/Http/RequestMockHelpers.php
index aa3607e51a..54cc0bd078 100644
--- a/tests/Traits/Http/RequestMockHelpers.php
+++ b/tests/Traits/Http/RequestMockHelpers.php
@@ -27,7 +27,7 @@ public function setRequestMockClass(string $class): void
/**
* Configure the user model that the request mock should return with.
*/
- public function setRequestUserModel(User $user = null): void
+ public function setRequestUserModel(?User $user = null): void
{
$this->request->shouldReceive('user')->andReturn($user);
}
@@ -37,7 +37,7 @@ public function setRequestUserModel(User $user = null): void
*/
public function generateRequestUserModel(array $args = []): User
{
- /** @var \Pterodactyl\Models\User $user */
+ /** @var User $user */
$user = User::factory()->make($args);
$this->setRequestUserModel($user);
@@ -79,7 +79,7 @@ protected function buildRequestMock(): void
*
* @deprecated
*/
- protected function setRequestUser(User $user = null): User
+ protected function setRequestUser(?User $user = null): User
{
$user = $user instanceof User ? $user : User::factory()->make();
$this->request->shouldReceive('user')->withNoArgs()->andReturn($user);
diff --git a/tests/Traits/Integration/CreatesTestModels.php b/tests/Traits/Integration/CreatesTestModels.php
index 62245d72b9..a90de9f6cb 100644
--- a/tests/Traits/Integration/CreatesTestModels.php
+++ b/tests/Traits/Integration/CreatesTestModels.php
@@ -27,25 +27,25 @@ public function createServerModel(array $attributes = []): Server
}
if (!isset($attributes['owner_id'])) {
- /** @var \Pterodactyl\Models\User $user */
+ /** @var User $user */
$user = User::factory()->create();
$attributes['owner_id'] = $user->id;
}
if (!isset($attributes['node_id'])) {
if (!isset($attributes['location_id'])) {
- /** @var \Pterodactyl\Models\Location $location */
+ /** @var Location $location */
$location = Location::factory()->create();
$attributes['location_id'] = $location->id;
}
- /** @var \Pterodactyl\Models\Node $node */
+ /** @var Node $node */
$node = Node::factory()->create(['location_id' => $attributes['location_id']]);
$attributes['node_id'] = $node->id;
}
if (!isset($attributes['allocation_id'])) {
- /** @var \Pterodactyl\Models\Allocation $allocation */
+ /** @var Allocation $allocation */
$allocation = Allocation::factory()->create(['node_id' => $attributes['node_id']]);
$attributes['allocation_id'] = $allocation->id;
}
@@ -65,7 +65,7 @@ public function createServerModel(array $attributes = []): Server
unset($attributes['user_id'], $attributes['location_id']);
- /** @var \Pterodactyl\Models\Server $server */
+ /** @var Server $server */
$server = Server::factory()->create($attributes);
Allocation::query()->where('id', $server->allocation_id)->update(['server_id' => $server->id]);
@@ -85,7 +85,7 @@ public function createServerModel(array $attributes = []): Server
*/
public function generateTestAccount(array $permissions = []): array
{
- /** @var \Pterodactyl\Models\User $user */
+ /** @var User $user */
$user = User::factory()->create();
if (empty($permissions)) {
@@ -113,7 +113,7 @@ protected function cloneEggAndVariables(Egg $egg): Egg
$model->uuid = Uuid::uuid4()->toString();
$model->push();
- /** @var \Pterodactyl\Models\Egg $model */
+ /** @var Egg $model */
$model = $model->fresh();
foreach ($egg->variables as $variable) {
@@ -129,7 +129,7 @@ protected function cloneEggAndVariables(Egg $egg): Egg
*/
private function getBungeecordEgg(): Egg
{
- /** @var \Pterodactyl\Models\Egg $egg */
+ /** @var Egg $egg */
$egg = Egg::query()->where('author', 'support@pterodactyl.io')->where('name', 'Bungeecord')->firstOrFail();
return $egg;
diff --git a/tests/Unit/Helpers/EnvironmentWriterTraitTest.php b/tests/Unit/Helpers/EnvironmentWriterTraitTest.php
index 0680da0dbb..588bb8e980 100644
--- a/tests/Unit/Helpers/EnvironmentWriterTraitTest.php
+++ b/tests/Unit/Helpers/EnvironmentWriterTraitTest.php
@@ -7,9 +7,7 @@
class EnvironmentWriterTraitTest extends TestCase
{
- /**
- * @dataProvider variableDataProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('variableDataProvider')]
public function testVariableIsEscapedProperly($input, $expected)
{
$output = (new FooClass())->escapeEnvironmentValue($input);
diff --git a/tests/Unit/Helpers/IsDigitTest.php b/tests/Unit/Helpers/IsDigitTest.php
index af19c732e9..273de64aee 100644
--- a/tests/Unit/Helpers/IsDigitTest.php
+++ b/tests/Unit/Helpers/IsDigitTest.php
@@ -8,9 +8,8 @@ class IsDigitTest extends TestCase
{
/**
* Test the is_digit helper.
- *
- * @dataProvider helperDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('helperDataProvider')]
public function testHelper($value, $response)
{
$this->assertSame($response, is_digit($value));
diff --git a/tests/Unit/Http/Middleware/Api/Daemon/DaemonAuthenticateTest.php b/tests/Unit/Http/Middleware/Api/Daemon/DaemonAuthenticateTest.php
index 84562f6c93..f3ff026c3f 100644
--- a/tests/Unit/Http/Middleware/Api/Daemon/DaemonAuthenticateTest.php
+++ b/tests/Unit/Http/Middleware/Api/Daemon/DaemonAuthenticateTest.php
@@ -64,9 +64,8 @@ public function testResponseShouldFailIfNoTokenIsProvided()
/**
* Test that passing in an invalid node daemon secret will result in a bad request
* exception being returned.
- *
- * @dataProvider badTokenDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('badTokenDataProvider')]
public function testResponseShouldFailIfTokenFormatIsIncorrect(string $token)
{
$this->expectException(BadRequestHttpException::class);
@@ -85,7 +84,7 @@ public function testResponseShouldFailIfTokenIsNotValid()
{
$this->expectException(AccessDeniedHttpException::class);
- /** @var \Pterodactyl\Models\Node $model */
+ /** @var Node $model */
$model = Node::factory()->make();
$this->request->expects('route->getName')->withNoArgs()->andReturn('random.route');
@@ -118,7 +117,7 @@ public function testResponseShouldFailIfNodeIsNotFound()
*/
public function testSuccessfulMiddlewareProcess()
{
- /** @var \Pterodactyl\Models\Node $model */
+ /** @var Node $model */
$model = Node::factory()->make();
$this->request->expects('route->getName')->withNoArgs()->andReturn('random.route');
diff --git a/tests/Unit/Http/Middleware/HeaderAuthenticationTest.php b/tests/Unit/Http/Middleware/HeaderAuthenticationTest.php
new file mode 100644
index 0000000000..68605504bb
--- /dev/null
+++ b/tests/Unit/Http/Middleware/HeaderAuthenticationTest.php
@@ -0,0 +1,127 @@
+set('auth.header.enabled', true);
+ }
+
+ public function test_middleware_does_nothing_when_disabled()
+ {
+ config()->set('auth.header.enabled', false);
+
+ $middleware = new HeaderAuthentication();
+ $request = new Request();
+
+ $response = $middleware->handle($request, function ($req) {
+ return response('OK');
+ });
+
+ $this->assertEquals('OK', $response->getContent());
+ $this->assertFalse(Auth::check());
+ }
+
+ public function test_middleware_authenticates_existing_user()
+ {
+ $user = User::factory()->create([
+ 'username' => 'testuser',
+ 'email' => 'test@example.com',
+ 'name_first' => 'Test',
+ 'name_last' => 'User',
+ 'external_id' => '',
+ ]);
+
+ $middleware = new HeaderAuthentication();
+ $request = new Request();
+ $request->headers->set('X-Auth-Username', 'testuser');
+ $request->headers->set('X-Auth-Email', 'test@example.com');
+
+ $response = $middleware->handle($request, function ($req) {
+ return response('OK');
+ });
+
+ $this->assertEquals('OK', $response->getContent());
+ $this->assertTrue(Auth::check());
+ $this->assertEquals($user->id, Auth::id());
+ }
+
+ public function test_middleware_creates_new_user_when_enabled()
+ {
+ config()->set('auth.header.auto_create', true);
+
+ $middleware = new HeaderAuthentication();
+ $request = new Request();
+ $request->headers->set('X-Auth-Username', 'testuser');
+ $request->headers->set('X-Auth-Email', 'test@example.com');
+
+ $response = $middleware->handle($request, function ($req) {
+ return response('OK');
+ });
+
+ $this->assertEquals('OK', $response->getContent());
+ $this->assertTrue(Auth::check());
+ $user = Auth::user();
+ $this->assertEquals('testuser', $user->username);
+ $this->assertEquals('test@example.com', $user->email);
+ $this->assertEquals('', $user->external_id);
+ $this->assertNotNull($user->uuid);
+ }
+
+ public function test_middleware_does_not_create_user_when_auto_create_disabled()
+ {
+ config()->set('auth.header.auto_create', false);
+
+ $middleware = new HeaderAuthentication();
+ $request = new Request();
+ $request->headers->set('X-Auth-Username', 'testuser');
+ $request->headers->set('X-Auth-Email', 'test@example.com');
+
+ $response = $middleware->handle($request, function ($req) {
+ return response('OK');
+ });
+
+ $this->assertEquals('OK', $response->getContent());
+ $this->assertFalse(Auth::check());
+ }
+
+ public function test_middleware_uses_custom_header_names()
+ {
+ config()->set('auth.header.username_header', 'HTTP_X_USERNAME');
+ config()->set('auth.header.email_header', 'HTTP_X_EMAIL');
+
+ $user = User::factory()->create([
+ 'username' => 'testuser',
+ 'email' => 'test@example.com',
+ 'name_first' => 'Test',
+ 'name_last' => 'User',
+ 'external_id' => '',
+ ]);
+
+ $middleware = new HeaderAuthentication();
+ $request = new Request();
+ $request->headers->set('HTTP_X_USERNAME', 'testuser');
+ $request->headers->set('HTTP_X_EMAIL', 'test@example.com');
+
+ $response = $middleware->handle($request, function ($req) {
+ return response('OK');
+ });
+
+ $this->assertEquals('OK', $response->getContent());
+ $this->assertTrue(Auth::check());
+ $this->assertEquals($user->id, Auth::id());
+ }
+}
\ No newline at end of file
diff --git a/tests/Unit/Rules/UsernameTest.php b/tests/Unit/Rules/UsernameTest.php
index 003e3e8ddf..f01589e959 100644
--- a/tests/Unit/Rules/UsernameTest.php
+++ b/tests/Unit/Rules/UsernameTest.php
@@ -17,9 +17,8 @@ public function testRuleIsStringable()
/**
* Test valid usernames.
- *
- * @dataProvider validUsernameDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('validUsernameDataProvider')]
public function testValidUsernames(string $username)
{
$this->assertTrue((new Username())->passes('test', $username), 'Assert username is valid.');
@@ -27,9 +26,8 @@ public function testValidUsernames(string $username)
/**
* Test invalid usernames return false.
- *
- * @dataProvider invalidUsernameDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('invalidUsernameDataProvider')]
public function testInvalidUsernames(string $username)
{
$this->assertFalse((new Username())->passes('test', $username), 'Assert username is not valid.');
diff --git a/tests/Unit/Services/Acl/Api/AdminAclTest.php b/tests/Unit/Services/Acl/Api/AdminAclTest.php
index 3f89659a2d..b135bd92a0 100644
--- a/tests/Unit/Services/Acl/Api/AdminAclTest.php
+++ b/tests/Unit/Services/Acl/Api/AdminAclTest.php
@@ -10,9 +10,8 @@ class AdminAclTest extends TestCase
{
/**
* Test that permissions return the expects values.
- *
- * @dataProvider permissionsDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('permissionsDataProvider')]
public function testPermissions(int $permission, int $check, bool $outcome)
{
$this->assertSame($outcome, AdminAcl::can($permission, $check));