@@ -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 ());
0 commit comments