Skip to content

Commit 6b16844

Browse files
authored
Merge pull request #1527 from keboola/jirka/ct-2192-test-ro-role-can-show-workspace
CT-2192 test that RO role can GET workspace detail
2 parents 89d0277 + 9c012e2 commit 6b16844

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace Keboola\Test\Common;
4+
5+
use Keboola\StorageApi\Workspaces;
6+
use Keboola\Test\Backend\Workspaces\ParallelWorkspacesTestCase;
7+
8+
class WorkspaceDetailTest extends ParallelWorkspacesTestCase
9+
{
10+
11+
public function testReadOnlyUserCanGetWorkspaceDetail(): void
12+
{
13+
// Create workspace as normal user
14+
$workspaces = new Workspaces($this->_client);
15+
$workspace = $this->initTestWorkspace();
16+
17+
// Create a client with a read-only token
18+
$readOnlyClient = $this->getReadOnlyStorageApiClient(); // Implement this helper to get a read-only token
19+
$readOnlyWorkspaces = new Workspaces($readOnlyClient);
20+
21+
// Try to get workspace detail
22+
$readOnlyWorkspaces->listWorkspaces();
23+
$workspaceDetail = $readOnlyWorkspaces->getWorkspace($workspace['id']);
24+
25+
// Assert that workspace detail is returned and does not contain sensitive info
26+
$this->assertArrayHasKey('id', $workspaceDetail);
27+
$this->assertEquals($workspace['id'], $workspaceDetail['id']);
28+
$this->assertArrayNotHasKey('password', $workspaceDetail['connection']);
29+
30+
// Cleanup
31+
$workspaces->deleteWorkspace($workspace['id'], [], true);
32+
}
33+
}

0 commit comments

Comments
 (0)