Skip to content

Commit

Permalink
Revert "CT-1402 - Create storage token management endpoint tests"
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasfejfar committed May 6, 2024
1 parent 2cbcde4 commit 637fe8a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 29 deletions.
2 changes: 1 addition & 1 deletion apiary.apib
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 5 additions & 6 deletions openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4248,6 +4248,7 @@ paths:
example:
description: Test Token
canManageBuckets: true
canManageTokens: true
canReadAllFileUploads: true
canPurgeTrash: true
expiresIn: 60
Expand All @@ -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
Expand All @@ -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:
Expand Down
1 change: 1 addition & 0 deletions tests/ProjectDeleteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ public function testPurgeExpiredProjectRemoveMetadata()
$params = [
'canManageBuckets' => true,
'canReadAllFileUploads' => true,
'canManageTokens' => true,
'canPurgeTrash' => true,
'description' => $this->generateDescriptionForTestObject(),
];
Expand Down
26 changes: 4 additions & 22 deletions tests/ProjectsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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',
Expand All @@ -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([
Expand All @@ -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()
Expand Down

0 comments on commit 637fe8a

Please sign in to comment.