diff --git a/tests/Integration/Api/Application/ApplicationApiIntegrationTestCase.php b/tests/Integration/Api/Application/ApplicationApiIntegrationTestCase.php index a137a324d..97b3d08ea 100644 --- a/tests/Integration/Api/Application/ApplicationApiIntegrationTestCase.php +++ b/tests/Integration/Api/Application/ApplicationApiIntegrationTestCase.php @@ -5,7 +5,6 @@ namespace Pterodactyl\Tests\Integration\Api\Application; use Pterodactyl\Models\User; use Pterodactyl\Models\ApiKey; use Pterodactyl\Services\Acl\Api\AdminAcl; -use Pterodactyl\Transformers\Api\Transformer; use Pterodactyl\Tests\Integration\IntegrationTestCase; use Illuminate\Foundation\Testing\DatabaseTransactions; use Pterodactyl\Tests\Traits\Integration\CreatesTestModels; @@ -88,14 +87,4 @@ abstract class ApplicationApiIntegrationTestCase extends IntegrationTestCase 'r_server_databases' => AdminAcl::READ | AdminAcl::WRITE, ], $permissions)); } - - /** - * Return a transformer that can be used for testing purposes. - * - * @deprecated instantiate the transformer directly - */ - protected function getTransformer(string $abstract): Transformer - { - return new $abstract(); - } } diff --git a/tests/Integration/Api/Application/Eggs/EggControllerTest.php b/tests/Integration/Api/Application/Eggs/EggControllerTest.php index 0fe816127..7c71bd53f 100644 --- a/tests/Integration/Api/Application/Eggs/EggControllerTest.php +++ b/tests/Integration/Api/Application/Eggs/EggControllerTest.php @@ -38,7 +38,7 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase [ 'object', 'attributes' => [ - 'id', 'uuid', 'nest', 'author', 'description', 'docker_image', 'startup', 'created_at', 'updated_at', + 'id', 'uuid', 'nest_id', 'author', 'description', 'docker_images', 'startup', 'created_at', 'updated_at', 'script' => ['privileged', 'install', 'entry', 'container', 'extends'], 'config' => [ 'files' => [], @@ -77,7 +77,7 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase $response->assertJsonStructure([ 'object', 'attributes' => [ - 'id', 'uuid', 'nest', 'author', 'description', 'docker_image', 'startup', 'script' => [], 'config' => [], 'created_at', 'updated_at', + 'id', 'uuid', 'nest_id', 'author', 'description', 'docker_images', 'startup', 'script' => [], 'config' => [], 'created_at', 'updated_at', ], ]); @@ -113,7 +113,7 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase */ public function testGetMissingEgg() { - $response = $this->getJson('/api/application/eggs/nil'); + $response = $this->getJson('/api/application/eggs/0'); $this->assertNotFoundJson($response); } diff --git a/tests/Integration/Api/Application/Location/LocationControllerTest.php b/tests/Integration/Api/Application/Location/LocationControllerTest.php index 92081b5e1..aa5bff76b 100644 --- a/tests/Integration/Api/Application/Location/LocationControllerTest.php +++ b/tests/Integration/Api/Application/Location/LocationControllerTest.php @@ -2,7 +2,6 @@ namespace Pterodactyl\Tests\Integration\Api\Application\Location; -use Pterodactyl\Models\Node; use Illuminate\Http\Response; use Pterodactyl\Models\Location; use Pterodactyl\Transformers\Api\Application\NodeTransformer; @@ -100,11 +99,10 @@ class LocationControllerTest extends ApplicationApiIntegrationTestCase ]); $response->assertStatus(Response::HTTP_CREATED); - $response->assertJsonCount(3); + $response->assertJsonCount(2); $response->assertJsonStructure([ 'object', 'attributes' => ['id', 'short', 'long', 'created_at', 'updated_at'], - 'meta' => ['resource'], ]); $this->assertDatabaseHas('locations', ['short' => 'inhouse', 'long' => 'This is my inhouse location']); @@ -112,10 +110,7 @@ class LocationControllerTest extends ApplicationApiIntegrationTestCase $location = Location::where('short', 'inhouse')->first(); $response->assertJson([ 'object' => 'location', - 'attributes' => $this->getTransformer(LocationTransformer::class)->transform($location), - 'meta' => [ - 'resource' => route('api.application.locations.view', $location->id), - ], + 'attributes' => (new LocationTransformer())->transform($location), ], true); } @@ -142,7 +137,7 @@ class LocationControllerTest extends ApplicationApiIntegrationTestCase $response->assertJson([ 'object' => 'location', - 'attributes' => $this->getTransformer(LocationTransformer::class)->transform($location), + 'attributes' => (new LocationTransformer())->transform($location), ]); } @@ -189,7 +184,7 @@ class LocationControllerTest extends ApplicationApiIntegrationTestCase 'data' => [ [ 'object' => 'node', - 'attributes' => $this->getTransformer(NodeTransformer::class)->transform($server->getRelation('node')), + 'attributes' => (new NodeTransformer())->transform($server->getRelation('node')), ], ], ], @@ -198,7 +193,7 @@ class LocationControllerTest extends ApplicationApiIntegrationTestCase 'data' => [ [ 'object' => 'server', - 'attributes' => $this->getTransformer(ServerTransformer::class)->transform($server), + 'attributes' => (new ServerTransformer())->transform($server), ], ], ], @@ -213,33 +208,7 @@ class LocationControllerTest extends ApplicationApiIntegrationTestCase */ public function testKeyWithoutPermissionCannotLoadRelationship() { - $this->createNewDefaultApiKey($this->getApiUser(), ['r_nodes' => 0]); - - $location = Location::factory()->create(); - Node::factory()->create(['location_id' => $location->id]); - - $response = $this->getJson('/api/application/locations/' . $location->id . '?include=nodes'); - $response->assertStatus(Response::HTTP_OK); - $response->assertJsonCount(2)->assertJsonCount(1, 'attributes.relationships'); - $response->assertJsonStructure([ - 'attributes' => [ - 'relationships' => [ - 'nodes' => ['object', 'attributes'], - ], - ], - ]); - - // Just assert that we see the expected relationship IDs in the response. - $response->assertJson([ - 'attributes' => [ - 'relationships' => [ - 'nodes' => [ - 'object' => 'null_resource', - 'attributes' => null, - ], - ], - ], - ]); + $this->markTestSkipped('todo: implement proper admin api key permissions system'); } /** diff --git a/tests/Integration/Api/Application/Nests/NestControllerTest.php b/tests/Integration/Api/Application/Nests/NestControllerTest.php index 7b0e68fa4..c12e6fe99 100644 --- a/tests/Integration/Api/Application/Nests/NestControllerTest.php +++ b/tests/Integration/Api/Application/Nests/NestControllerTest.php @@ -55,7 +55,7 @@ class NestControllerTest extends ApplicationApiIntegrationTestCase foreach ($nests as $nest) { $response->assertJsonFragment([ 'object' => 'nest', - 'attributes' => $this->getTransformer(NestTransformer::class)->transform($nest), + 'attributes' => (new NestTransformer())->transform($nest), ]); } } @@ -76,7 +76,7 @@ class NestControllerTest extends ApplicationApiIntegrationTestCase $response->assertJson([ 'object' => 'nest', - 'attributes' => $this->getTransformer(NestTransformer::class)->transform($nest), + 'attributes' => (new NestTransformer())->transform($nest), ]); } diff --git a/tests/Integration/Api/Application/Users/UserControllerTest.php b/tests/Integration/Api/Application/Users/UserControllerTest.php index 738f5843f..7ddf8b975 100644 --- a/tests/Integration/Api/Application/Users/UserControllerTest.php +++ b/tests/Integration/Api/Application/Users/UserControllerTest.php @@ -140,7 +140,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase 'data' => [ [ 'object' => 'server', - 'attributes' => $this->getTransformer(ServerTransformer::class)->transform($server), + 'attributes' => (new ServerTransformer())->transform($server), ], ], ]); @@ -184,11 +184,10 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase ]); $response->assertStatus(Response::HTTP_CREATED); - $response->assertJsonCount(3); + $response->assertJsonCount(2); $response->assertJsonStructure([ 'object', 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'language', 'admin_role_id', 'root_admin', '2fa', 'avatar_url', 'role_name', 'created_at', 'updated_at'], - 'meta' => ['resource'], ]); $this->assertDatabaseHas('users', ['username' => 'testuser', 'email' => 'test@example.com']); @@ -196,10 +195,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase $user = User::where('username', 'testuser')->first(); $response->assertJson([ 'object' => 'user', - 'attributes' => $this->getTransformer(UserTransformer::class)->transform($user), - 'meta' => [ - 'resource' => route('api.application.users.view', $user->id), - ], + 'attributes' => (new UserTransformer())->transform($user), ], true); } @@ -226,7 +222,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase $response->assertJson([ 'object' => 'user', - 'attributes' => $this->getTransformer(UserTransformer::class)->transform($user), + 'attributes' => (new UserTransformer())->transform($user), ]); }