From 1e19e023983698d852afcef3ac7d6d032f9d501b Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Thu, 27 Aug 2020 21:19:01 -0700 Subject: [PATCH] Fix integration tests to properly account for the rule position in the API --- tests/Integration/Api/Client/AccountControllerTest.php | 6 +++--- tests/Integration/Api/Client/ApiKeyControllerTest.php | 2 +- .../Integration/Api/Client/Server/CommandControllerTest.php | 2 +- .../Api/Client/Server/NetworkAllocationControllerTest.php | 2 +- tests/Integration/Api/Client/Server/PowerControllerTest.php | 2 +- .../Api/Client/Server/Schedule/CreateServerScheduleTest.php | 2 +- .../Server/ScheduleTask/CreateServerScheduleTaskTest.php | 6 +++--- .../Api/Client/Server/SettingsControllerTest.php | 2 +- tests/Integration/Api/Client/TwoFactorControllerTest.php | 3 ++- 9 files changed, 14 insertions(+), 13 deletions(-) diff --git a/tests/Integration/Api/Client/AccountControllerTest.php b/tests/Integration/Api/Client/AccountControllerTest.php index 4fbef8749..75b152090 100644 --- a/tests/Integration/Api/Client/AccountControllerTest.php +++ b/tests/Integration/Api/Client/AccountControllerTest.php @@ -85,7 +85,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase ]); $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); - $response->assertJsonPath('errors.0.code', 'required'); + $response->assertJsonPath('errors.0.meta.rule', 'required'); $response->assertJsonPath('errors.0.detail', 'The email field is required.'); $response = $this->actingAs($user)->putJson('/api/client/account/email', [ @@ -94,7 +94,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase ]); $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); - $response->assertJsonPath('errors.0.code', 'email'); + $response->assertJsonPath('errors.0.meta.rule', 'email'); $response->assertJsonPath('errors.0.detail', 'The email must be a valid email address.'); } @@ -156,7 +156,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase ]); $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); - $response->assertJsonPath('errors.0.code', 'confirmed'); + $response->assertJsonPath('errors.0.meta.rule', 'confirmed'); $response->assertJsonPath('errors.0.detail', 'The password confirmation does not match.'); } } diff --git a/tests/Integration/Api/Client/ApiKeyControllerTest.php b/tests/Integration/Api/Client/ApiKeyControllerTest.php index 13a0b9c84..833562392 100644 --- a/tests/Integration/Api/Client/ApiKeyControllerTest.php +++ b/tests/Integration/Api/Client/ApiKeyControllerTest.php @@ -133,7 +133,7 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase ]); $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); - $response->assertJsonPath('errors.0.code', 'required'); + $response->assertJsonPath('errors.0.meta.rule', 'required'); $response->assertJsonPath('errors.0.detail', 'The description field is required.'); } diff --git a/tests/Integration/Api/Client/Server/CommandControllerTest.php b/tests/Integration/Api/Client/Server/CommandControllerTest.php index de3dacc85..f3e9df7b2 100644 --- a/tests/Integration/Api/Client/Server/CommandControllerTest.php +++ b/tests/Integration/Api/Client/Server/CommandControllerTest.php @@ -41,7 +41,7 @@ class CommandControllerTest extends ClientApiIntegrationTestCase ]); $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); - $response->assertJsonPath('errors.0.code', 'required'); + $response->assertJsonPath('errors.0.meta.rule', 'required'); } /** diff --git a/tests/Integration/Api/Client/Server/NetworkAllocationControllerTest.php b/tests/Integration/Api/Client/Server/NetworkAllocationControllerTest.php index b019b3e62..ffebc83b8 100644 --- a/tests/Integration/Api/Client/Server/NetworkAllocationControllerTest.php +++ b/tests/Integration/Api/Client/Server/NetworkAllocationControllerTest.php @@ -63,7 +63,7 @@ class NetworkAllocationControllerTest extends ClientApiIntegrationTestCase $this->actingAs($user)->postJson($this->link($allocation), []) ->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY) - ->assertJsonPath('errors.0.code', 'present'); + ->assertJsonPath('errors.0.meta.rule', 'present'); $this->actingAs($user)->postJson($this->link($allocation), ['notes' => 'Test notes']) ->assertOk() diff --git a/tests/Integration/Api/Client/Server/PowerControllerTest.php b/tests/Integration/Api/Client/Server/PowerControllerTest.php index 80f58010a..96911cf37 100644 --- a/tests/Integration/Api/Client/Server/PowerControllerTest.php +++ b/tests/Integration/Api/Client/Server/PowerControllerTest.php @@ -40,7 +40,7 @@ class PowerControllerTest extends ClientApiIntegrationTestCase ]); $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); - $response->assertJsonPath('errors.0.code', 'in'); + $response->assertJsonPath('errors.0.meta.rule', 'in'); $response->assertJsonPath('errors.0.detail', 'The selected signal is invalid.'); } diff --git a/tests/Integration/Api/Client/Server/Schedule/CreateServerScheduleTest.php b/tests/Integration/Api/Client/Server/Schedule/CreateServerScheduleTest.php index 5b45e7fe7..78f6253ed 100644 --- a/tests/Integration/Api/Client/Server/Schedule/CreateServerScheduleTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/CreateServerScheduleTest.php @@ -71,7 +71,7 @@ class CreateServerScheduleTest extends ClientApiIntegrationTestCase 'day_of_week' => '*', ]) ->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY) - ->assertJsonPath('errors.0.code', 'boolean'); + ->assertJsonPath('errors.0.meta.rule', 'boolean'); } /** diff --git a/tests/Integration/Api/Client/Server/ScheduleTask/CreateServerScheduleTaskTest.php b/tests/Integration/Api/Client/Server/ScheduleTask/CreateServerScheduleTaskTest.php index 2044221e5..8dba137b5 100644 --- a/tests/Integration/Api/Client/Server/ScheduleTask/CreateServerScheduleTaskTest.php +++ b/tests/Integration/Api/Client/Server/ScheduleTask/CreateServerScheduleTaskTest.php @@ -66,7 +66,7 @@ class CreateServerScheduleTaskTest extends ClientApiIntegrationTestCase 'time_offset' => 0, ]) ->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY) - ->assertJsonPath('errors.0.code', 'in') + ->assertJsonPath('errors.0.meta.rule', 'in') ->assertJsonPath('errors.0.source.field', 'action'); $this->actingAs($user)->postJson($this->link($schedule, '/tasks'), [ @@ -74,7 +74,7 @@ class CreateServerScheduleTaskTest extends ClientApiIntegrationTestCase 'time_offset' => 0, ]) ->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY) - ->assertJsonPath('errors.0.code', 'required_unless') + ->assertJsonPath('errors.0.meta.rule', 'required_unless') ->assertJsonPath('errors.0.source.field', 'payload'); $this->actingAs($user)->postJson($this->link($schedule, '/tasks'), [ @@ -84,7 +84,7 @@ class CreateServerScheduleTaskTest extends ClientApiIntegrationTestCase 'sequence_id' => 'hodor', ]) ->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY) - ->assertJsonPath('errors.0.code', 'numeric') + ->assertJsonPath('errors.0.meta.rule', 'numeric') ->assertJsonPath('errors.0.source.field', 'sequence_id'); } diff --git a/tests/Integration/Api/Client/Server/SettingsControllerTest.php b/tests/Integration/Api/Client/Server/SettingsControllerTest.php index 99c32a56a..44a850a7c 100644 --- a/tests/Integration/Api/Client/Server/SettingsControllerTest.php +++ b/tests/Integration/Api/Client/Server/SettingsControllerTest.php @@ -28,7 +28,7 @@ class SettingsControllerTest extends ClientApiIntegrationTestCase ]); $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); - $response->assertJsonPath('errors.0.code', 'required'); + $response->assertJsonPath('errors.0.meta.rule', 'required'); $server = $server->refresh(); $this->assertSame($originalName, $server->name); diff --git a/tests/Integration/Api/Client/TwoFactorControllerTest.php b/tests/Integration/Api/Client/TwoFactorControllerTest.php index 189a94fa1..1c9b467f6 100644 --- a/tests/Integration/Api/Client/TwoFactorControllerTest.php +++ b/tests/Integration/Api/Client/TwoFactorControllerTest.php @@ -64,7 +64,8 @@ class TwoFactorControllerTest extends ClientApiIntegrationTestCase ]); $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); - $response->assertJsonPath('errors.0.code', 'required'); + $response->assertJsonPath('errors.0.code', 'ValidationException'); + $response->assertJsonPath('errors.0.meta.rule', 'required'); } /**