From 637fe8aaba1c5868ba8ca713189df47cd57605fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Fejfar?= Date: Mon, 6 May 2024 08:54:12 +0200 Subject: [PATCH] Revert "CT-1402 - Create storage token management endpoint tests" --- apiary.apib | 2 +- openapi.yml | 11 +++++------ tests/ProjectDeleteTest.php | 1 + tests/ProjectsTest.php | 26 ++++---------------------- 4 files changed, 11 insertions(+), 29 deletions(-) diff --git a/apiary.apib b/apiary.apib index f49beef..325ad48 100644 --- a/apiary.apib +++ b/apiary.apib @@ -2125,12 +2125,12 @@ can be called with an application token with scope `manage:storage-tokens`. + description: Test Token (required) - Token description + canManageBuckets: true (boolean) - Token has full permissions on tabular storage + + canManageTokens: true (boolean) - Token has permission to create tokens in project + canReadAllFileUploads: true (boolean) - Token has full permissions to files staging + canPurgeTrash: true (boolean) - Allows permanently remove deleted configurations. + expiresIn: 60 (number) - Token lifetime + bucketPermissions (object) - in.c-main: read - + componentAccess[] (optional) - Grants access for component configurations. Allowed values are [valid component IDs](https://components.keboola.com/components). + Request (application/json) + Headers diff --git a/openapi.yml b/openapi.yml index c7a9805..e7fd65c 100644 --- a/openapi.yml +++ b/openapi.yml @@ -4248,6 +4248,7 @@ paths: example: description: Test Token canManageBuckets: true + canManageTokens: true canReadAllFileUploads: true canPurgeTrash: true expiresIn: 60 @@ -4266,6 +4267,10 @@ paths: type: boolean example: true description: Token has full permissions on tabular storage + canManageTokens: + type: boolean + example: true + description: Token has permission to create tokens in project canReadAllFileUploads: type: boolean example: true @@ -4284,12 +4289,6 @@ paths: in.c: type: string description: 'main: read' - componentAccess[]: - type: string - description: >- - Grants access for component configurations. Allowed values - are [valid component - IDs](https://components.keboola.com/components). /manage/projects/{project_id}/credits: post: responses: diff --git a/tests/ProjectDeleteTest.php b/tests/ProjectDeleteTest.php index 79a7c60..10ea383 100644 --- a/tests/ProjectDeleteTest.php +++ b/tests/ProjectDeleteTest.php @@ -149,6 +149,7 @@ public function testPurgeExpiredProjectRemoveMetadata() $params = [ 'canManageBuckets' => true, 'canReadAllFileUploads' => true, + 'canManageTokens' => true, 'canPurgeTrash' => true, 'description' => $this->generateDescriptionForTestObject(), ]; diff --git a/tests/ProjectsTest.php b/tests/ProjectsTest.php index e645bb1..9ca96d0 100644 --- a/tests/ProjectsTest.php +++ b/tests/ProjectsTest.php @@ -6,7 +6,6 @@ use Keboola\ManageApi\Backend; use Keboola\ManageApi\Client; use Keboola\ManageApi\ClientException; -use Keboola\ManageApi\Exception; use Keboola\ManageApi\ProjectRole; use Keboola\StorageApi\ClientException as StorageApiClientException; use Keboola\StorageApi\Options\ListFilesOptions; @@ -1150,7 +1149,7 @@ public function testCreateProjectStorageTokenWithBucketPermissions() $this->assertEquals([$newBucketId => 'read'], $verified['bucketPermissions']); } - public function testCreateProjectStorageTokenWithMangeTokensPermissionAndComponentAccess() + public function testCreateProjectStorageTokenWithMangeTokensPermission() { $organization = $this->client->createOrganization($this->testMaintainerId, [ 'name' => 'My org', @@ -1160,29 +1159,13 @@ public function testCreateProjectStorageTokenWithMangeTokensPermissionAndCompone 'name' => 'My test', ]); - try { - // new token with canManageTokens - $this->client->createProjectStorageToken($project['id'], [ - 'description' => 'test', - 'expiresIn' => 60, - 'canManageBuckets' => true, - 'canReadAllFileUploads' => true, - 'canManageTokens' => true, - ]); - $this->fail('Should fail.'); - } catch (ClientException $e) { - $this->assertEquals(400, $e->getCode()); - $this->assertEquals('CanManageTokens is not allowed.', $e->getMessage()); - } - - $requestedComponents = ['component1', 'component2', 'component3']; - + // new token with canManageTokens $token = $this->client->createProjectStorageToken($project['id'], [ 'description' => 'test', 'expiresIn' => 60, 'canManageBuckets' => true, 'canReadAllFileUploads' => true, - 'componentAccess' => $requestedComponents, + 'canManageTokens' => true, ]); $client = $this->getStorageClient([ @@ -1193,9 +1176,8 @@ public function testCreateProjectStorageTokenWithMangeTokensPermissionAndCompone $verified = $client->verifyToken(); $this->assertEquals($project['id'], $verified['owner']['id']); $this->assertTrue($verified['canManageBuckets']); - $this->assertFalse($verified['canManageTokens']); + $this->assertTrue($verified['canManageTokens']); $this->assertTrue($verified['canReadAllFileUploads']); - $this->assertEquals($requestedComponents, $verified['componentAccess']); } public function testSuperAdminCanDisableAndEnableProject()