From 9300e1116df67f11ad6b03b30ddeaedc9ffe7f8f Mon Sep 17 00:00:00 2001 From: DaneEveritt Date: Sun, 29 May 2022 20:39:51 -0400 Subject: [PATCH] Fix failing tests --- app/Http/Controllers/Api/Client/ApiKeyController.php | 5 +++-- tests/Integration/Api/Client/SSHKeyControllerTest.php | 4 ++-- tests/Integration/IntegrationTestCase.php | 4 ++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Api/Client/ApiKeyController.php b/app/Http/Controllers/Api/Client/ApiKeyController.php index 5e888e91d..5f0af6c8b 100644 --- a/app/Http/Controllers/Api/Client/ApiKeyController.php +++ b/app/Http/Controllers/Api/Client/ApiKeyController.php @@ -60,13 +60,14 @@ class ApiKeyController extends ClientApiController */ public function delete(ClientApiRequest $request, string $identifier) { + /** @var \Pterodactyl\Models\ApiKey $key */ $key = $request->user()->apiKeys() ->where('key_type', ApiKey::TYPE_ACCOUNT) ->where('identifier', $identifier) - ->first(); + ->firstOrFail(); Activity::event('user:api-key.delete') - ->property('identifer', $key->identifer) + ->property('identifer', $key->identifier) ->log(); $key->delete(); diff --git a/tests/Integration/Api/Client/SSHKeyControllerTest.php b/tests/Integration/Api/Client/SSHKeyControllerTest.php index 6744a1295..2af492f56 100644 --- a/tests/Integration/Api/Client/SSHKeyControllerTest.php +++ b/tests/Integration/Api/Client/SSHKeyControllerTest.php @@ -46,8 +46,8 @@ class SSHKeyControllerTest extends ClientApiIntegrationTestCase $this->assertSoftDeleted($key); $this->assertNotSoftDeleted($key2); - $this->deleteJson($this->link($key))->assertNoContent(); - $this->deleteJson($this->link($key2))->assertNoContent(); + $this->deleteJson($this->link($key))->assertNotFound(); + $this->deleteJson($this->link($key2))->assertNotFound(); $this->assertNotSoftDeleted($key2); } diff --git a/tests/Integration/IntegrationTestCase.php b/tests/Integration/IntegrationTestCase.php index c290f6070..252d14d8c 100644 --- a/tests/Integration/IntegrationTestCase.php +++ b/tests/Integration/IntegrationTestCase.php @@ -13,6 +13,10 @@ abstract class IntegrationTestCase extends TestCase protected array $connectionsToTransact = ['mysql']; + protected $defaultHeaders = [ + 'Accept' => 'application/json', + ]; + /** * Return an ISO-8601 formatted timestamp to use in the API response. */