tests(integration): fixes EggControllerTest, NestControllerTest, and UserControllerTest

This commit is contained in:
Matthew Penner 2021-03-05 09:01:29 -07:00
parent 542fd61049
commit ee5a661e46
3 changed files with 16 additions and 16 deletions

View file

@ -1,6 +1,6 @@
<?php
namespace Pterodactyl\Tests\Integration\Api\Application\Nests;
namespace Pterodactyl\Tests\Integration\Api\Application\Eggs;
use Illuminate\Support\Arr;
use Illuminate\Http\Response;
@ -10,10 +10,7 @@ use Pterodactyl\Tests\Integration\Api\Application\ApplicationApiIntegrationTestC
class EggControllerTest extends ApplicationApiIntegrationTestCase
{
/**
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface
*/
private $repository;
private EggRepositoryInterface $repository;
/**
* Setup tests.
@ -76,7 +73,7 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase
{
$egg = $this->repository->find(1);
$response = $this->getJson('/api/application/nests/' . $egg->nest_id . '/eggs/' . $egg->id);
$response = $this->getJson('/api/application/eggs/' . $egg->id);
$response->assertStatus(Response::HTTP_OK);
$response->assertJsonStructure([
'object',
@ -98,7 +95,7 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase
{
$egg = $this->repository->find(1);
$response = $this->getJson('/api/application/nests/' . $egg->nest_id . '/eggs/' . $egg->id . '?include=servers,variables,nest');
$response = $this->getJson('/api/application/eggs/' . $egg->id . '?include=servers,variables,nest');
$response->assertStatus(Response::HTTP_OK);
$response->assertJsonStructure([
'object',
@ -117,9 +114,7 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase
*/
public function testGetMissingEgg()
{
$egg = $this->repository->find(1);
$response = $this->getJson('/api/application/nests/' . $egg->nest_id . '/eggs/nil');
$response = $this->getJson('/api/application/nests/eggs/nil');
$this->assertNotFoundJson($response);
}
@ -142,10 +137,9 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase
*/
public function testResourceIsNotExposedWithoutPermissions()
{
$egg = $this->repository->find(1);
$this->createNewDefaultApiKey($this->getApiUser(), ['r_eggs' => 0]);
$response = $this->getJson('/api/application/nests/' . $egg->nest_id . '/eggs/nil');
$response = $this->getJson('/api/application/nests/eggs/nil');
$this->assertAccessDeniedJson($response);
}
}

View file

@ -38,7 +38,7 @@ class NestControllerTest extends ApplicationApiIntegrationTestCase
$response->assertJsonStructure([
'object',
'data' => [['object', 'attributes' => ['id', 'uuid', 'author', 'name', 'description', 'created_at', 'updated_at']]],
'meta' => ['pagination' => ['total', 'count', 'per_page', 'current_page', 'total_pages']],
'meta' => ['pagination' => ['total', 'count', 'per_page', 'current_page', 'total_pages', 'links']],
]);
$response->assertJson([
@ -51,6 +51,7 @@ class NestControllerTest extends ApplicationApiIntegrationTestCase
'per_page' => 50,
'current_page' => 1,
'total_pages' => 1,
'links' => [],
],
],
]);

View file

@ -24,10 +24,10 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
$response->assertJsonStructure([
'object',
'data' => [
['object', 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'first_name', 'last_name', 'language', 'root_admin', '2fa', 'created_at', 'updated_at']],
['object', 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'first_name', 'last_name', 'language', 'root_admin', '2fa', 'created_at', 'updated_at']],
['object', 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'first_name', 'last_name', 'language', 'root_admin', '2fa', 'avatar_url', 'role_name', 'created_at', 'updated_at']],
['object', 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'first_name', 'last_name', 'language', 'root_admin', '2fa', 'avatar_url', 'role_name', 'created_at', 'updated_at']],
],
'meta' => ['pagination' => ['total', 'count', 'per_page', 'current_page', 'total_pages']],
'meta' => ['pagination' => ['total', 'count', 'per_page', 'current_page', 'total_pages', 'links']],
]);
$response
@ -41,6 +41,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
'per_page' => 100,
'current_page' => 1,
'total_pages' => 1,
'links' => [],
],
],
])
@ -57,6 +58,8 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
'language' => $this->getApiUser()->language,
'root_admin' => (bool) $this->getApiUser()->root_admin,
'2fa' => (bool) $this->getApiUser()->totp_enabled,
'avatar_url' => $this->getApiUser()->avatarURL(),
'role_name' => $this->getApiUser()->adminRoleName(),
'created_at' => $this->formatTimestamp($this->getApiUser()->created_at),
'updated_at' => $this->formatTimestamp($this->getApiUser()->updated_at),
],
@ -74,6 +77,8 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
'language' => $user->language,
'root_admin' => (bool) $user->root_admin,
'2fa' => (bool) $user->totp_enabled,
'avatar_url' => $user->getApiUser()->avatarURL(),
'role_name' => $user->getApiUser()->adminRoleName(),
'created_at' => $this->formatTimestamp($user->created_at),
'updated_at' => $this->formatTimestamp($user->updated_at),
],