Skip to content

Commit

Permalink
fix ApiKeyControllerTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy132 committed Jun 10, 2024
1 parent 48a1390 commit 580c62f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/Integration/Api/Client/ApiKeyControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function testApiKeysAreReturned(): void
/** @var \App\Models\ApiKey $key */
$key = ApiKey::factory()->for($user)->create([
'key_type' => ApiKey::TYPE_ACCOUNT,
'permissions' => [],
]);

$response = $this->actingAs($user)->get('/api/client/account/api-keys')
Expand Down Expand Up @@ -58,6 +59,7 @@ public function testApiKeyCanBeCreatedForAccount(array $data): void
ApiKey::factory()->times(10)->create([
'user_id' => User::factory()->create()->id,
'key_type' => ApiKey::TYPE_ACCOUNT,
'permissions' => [],
]);

$response = $this->actingAs($user)->postJson('/api/client/account/api-keys', [
Expand Down Expand Up @@ -105,6 +107,7 @@ public function testApiKeyLimitIsApplied(): void
$user = User::factory()->create();
ApiKey::factory()->times(25)->for($user)->create([
'key_type' => ApiKey::TYPE_ACCOUNT,
'permissions' => [],
]);

$this->actingAs($user)->postJson('/api/client/account/api-keys', [
Expand Down Expand Up @@ -160,6 +163,7 @@ public function testApiKeyCanBeDeleted(): void
/** @var \App\Models\ApiKey $key */
$key = ApiKey::factory()->for($user)->create([
'key_type' => ApiKey::TYPE_ACCOUNT,
'permissions' => [],
]);

$response = $this->actingAs($user)->delete('/api/client/account/api-keys/' . $key->identifier);
Expand All @@ -180,6 +184,7 @@ public function testNonExistentApiKeyDeletionReturns404Error(): void
$key = ApiKey::factory()->create([
'user_id' => $user->id,
'key_type' => ApiKey::TYPE_ACCOUNT,
'permissions' => [],
]);

$response = $this->actingAs($user)->delete('/api/client/account/api-keys/1234');
Expand All @@ -202,6 +207,7 @@ public function testApiKeyBelongingToAnotherUserCannotBeDeleted(): void
/** @var \App\Models\ApiKey $key */
$key = ApiKey::factory()->for($user2)->create([
'key_type' => ApiKey::TYPE_ACCOUNT,
'permissions' => [],
]);

$this->actingAs($user)
Expand All @@ -223,6 +229,7 @@ public function testApplicationApiKeyCannotBeDeleted(): void
/** @var \App\Models\ApiKey $key */
$key = ApiKey::factory()->for($user)->create([
'key_type' => ApiKey::TYPE_APPLICATION,
'permissions' => [],
]);

$this->actingAs($user)
Expand Down

0 comments on commit 580c62f

Please sign in to comment.