tests(integration): fixes EggControllerTest, NestControllerTest, and UserControllerTest
This commit is contained in:
parent
542fd61049
commit
ee5a661e46
3 changed files with 16 additions and 16 deletions
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Pterodactyl\Tests\Integration\Api\Application\Nests;
|
namespace Pterodactyl\Tests\Integration\Api\Application\Eggs;
|
||||||
|
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
|
@ -10,10 +10,7 @@ use Pterodactyl\Tests\Integration\Api\Application\ApplicationApiIntegrationTestC
|
||||||
|
|
||||||
class EggControllerTest extends ApplicationApiIntegrationTestCase
|
class EggControllerTest extends ApplicationApiIntegrationTestCase
|
||||||
{
|
{
|
||||||
/**
|
private EggRepositoryInterface $repository;
|
||||||
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface
|
|
||||||
*/
|
|
||||||
private $repository;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup tests.
|
* Setup tests.
|
||||||
|
@ -76,7 +73,7 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase
|
||||||
{
|
{
|
||||||
$egg = $this->repository->find(1);
|
$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->assertStatus(Response::HTTP_OK);
|
||||||
$response->assertJsonStructure([
|
$response->assertJsonStructure([
|
||||||
'object',
|
'object',
|
||||||
|
@ -98,7 +95,7 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase
|
||||||
{
|
{
|
||||||
$egg = $this->repository->find(1);
|
$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->assertStatus(Response::HTTP_OK);
|
||||||
$response->assertJsonStructure([
|
$response->assertJsonStructure([
|
||||||
'object',
|
'object',
|
||||||
|
@ -117,9 +114,7 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase
|
||||||
*/
|
*/
|
||||||
public function testGetMissingEgg()
|
public function testGetMissingEgg()
|
||||||
{
|
{
|
||||||
$egg = $this->repository->find(1);
|
$response = $this->getJson('/api/application/nests/eggs/nil');
|
||||||
|
|
||||||
$response = $this->getJson('/api/application/nests/' . $egg->nest_id . '/eggs/nil');
|
|
||||||
$this->assertNotFoundJson($response);
|
$this->assertNotFoundJson($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,10 +137,9 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase
|
||||||
*/
|
*/
|
||||||
public function testResourceIsNotExposedWithoutPermissions()
|
public function testResourceIsNotExposedWithoutPermissions()
|
||||||
{
|
{
|
||||||
$egg = $this->repository->find(1);
|
|
||||||
$this->createNewDefaultApiKey($this->getApiUser(), ['r_eggs' => 0]);
|
$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);
|
$this->assertAccessDeniedJson($response);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -38,7 +38,7 @@ class NestControllerTest extends ApplicationApiIntegrationTestCase
|
||||||
$response->assertJsonStructure([
|
$response->assertJsonStructure([
|
||||||
'object',
|
'object',
|
||||||
'data' => [['object', 'attributes' => ['id', 'uuid', 'author', 'name', 'description', 'created_at', 'updated_at']]],
|
'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([
|
$response->assertJson([
|
||||||
|
@ -51,6 +51,7 @@ class NestControllerTest extends ApplicationApiIntegrationTestCase
|
||||||
'per_page' => 50,
|
'per_page' => 50,
|
||||||
'current_page' => 1,
|
'current_page' => 1,
|
||||||
'total_pages' => 1,
|
'total_pages' => 1,
|
||||||
|
'links' => [],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -24,10 +24,10 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
|
||||||
$response->assertJsonStructure([
|
$response->assertJsonStructure([
|
||||||
'object',
|
'object',
|
||||||
'data' => [
|
'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', 'avatar_url', 'role_name', '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']],
|
||||||
],
|
],
|
||||||
'meta' => ['pagination' => ['total', 'count', 'per_page', 'current_page', 'total_pages']],
|
'meta' => ['pagination' => ['total', 'count', 'per_page', 'current_page', 'total_pages', 'links']],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response
|
$response
|
||||||
|
@ -41,6 +41,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
|
||||||
'per_page' => 100,
|
'per_page' => 100,
|
||||||
'current_page' => 1,
|
'current_page' => 1,
|
||||||
'total_pages' => 1,
|
'total_pages' => 1,
|
||||||
|
'links' => [],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
])
|
])
|
||||||
|
@ -57,6 +58,8 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
|
||||||
'language' => $this->getApiUser()->language,
|
'language' => $this->getApiUser()->language,
|
||||||
'root_admin' => (bool) $this->getApiUser()->root_admin,
|
'root_admin' => (bool) $this->getApiUser()->root_admin,
|
||||||
'2fa' => (bool) $this->getApiUser()->totp_enabled,
|
'2fa' => (bool) $this->getApiUser()->totp_enabled,
|
||||||
|
'avatar_url' => $this->getApiUser()->avatarURL(),
|
||||||
|
'role_name' => $this->getApiUser()->adminRoleName(),
|
||||||
'created_at' => $this->formatTimestamp($this->getApiUser()->created_at),
|
'created_at' => $this->formatTimestamp($this->getApiUser()->created_at),
|
||||||
'updated_at' => $this->formatTimestamp($this->getApiUser()->updated_at),
|
'updated_at' => $this->formatTimestamp($this->getApiUser()->updated_at),
|
||||||
],
|
],
|
||||||
|
@ -74,6 +77,8 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
|
||||||
'language' => $user->language,
|
'language' => $user->language,
|
||||||
'root_admin' => (bool) $user->root_admin,
|
'root_admin' => (bool) $user->root_admin,
|
||||||
'2fa' => (bool) $user->totp_enabled,
|
'2fa' => (bool) $user->totp_enabled,
|
||||||
|
'avatar_url' => $user->getApiUser()->avatarURL(),
|
||||||
|
'role_name' => $user->getApiUser()->adminRoleName(),
|
||||||
'created_at' => $this->formatTimestamp($user->created_at),
|
'created_at' => $this->formatTimestamp($user->created_at),
|
||||||
'updated_at' => $this->formatTimestamp($user->updated_at),
|
'updated_at' => $this->formatTimestamp($user->updated_at),
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in a new issue