Skip to content

Commit 00db1dd

Browse files
authored
Merge pull request #1533 from keboola/jirka/ct-2192-fix-tests
CT-2192 Fix tests for RO role for listing WS
2 parents 6b16844 + 45acc2b commit 00db1dd

2 files changed

Lines changed: 11 additions & 42 deletions

File tree

tests/Backend/Workspaces/ReadOnlyUserTest.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,19 @@ public function testWorkspaceRestrictionsForReadOnlyUser(): void
1818

1919
$readOnlyWorkspaces = new Workspaces($readOnlyClient);
2020

21-
try {
22-
$readOnlyWorkspaces->createWorkspace([], true);
23-
$this->fail('Workspace request should be restricted for readOnly user');
24-
} catch (ClientException $e) {
25-
$this->assertSame(403, $e->getCode());
26-
$this->assertSame('accessDenied', $e->getStringCode());
27-
$this->assertSame($expectedError, $e->getMessage());
28-
}
21+
// Try to get workspace detail
22+
$workspaceDetail = $readOnlyWorkspaces->getWorkspace($workspace['id']);
23+
24+
// Assert that workspace detail is returned and does not contain sensitive info
25+
$this->assertArrayHasKey('id', $workspaceDetail);
26+
$this->assertEquals($workspace['id'], $workspaceDetail['id']);
27+
$this->assertArrayNotHasKey('password', $workspaceDetail['connection']);
28+
29+
// listing workspaces should be allowed for readOnly user
30+
$readOnlyWorkspaces->listWorkspaces();
2931

3032
try {
31-
$readOnlyWorkspaces->listWorkspaces();
33+
$readOnlyWorkspaces->createWorkspace([], true);
3234
$this->fail('Workspace request should be restricted for readOnly user');
3335
} catch (ClientException $e) {
3436
$this->assertSame(403, $e->getCode());

tests/Common/WorkspaceDetailTest.php

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)