66use Keboola \StorageApi \Components ;
77use Keboola \StorageApi \Options \Components \Configuration ;
88use Keboola \StorageApi \Options \Components \ListComponentsOptions ;
9+ use Keboola \StorageApi \WorkspaceLoginType ;
910use Keboola \StorageApi \Workspaces ;
1011use Keboola \Test \Backend \WorkspaceConnectionTrait ;
1112use Keboola \Test \Backend \WorkspaceCredentialsAssertTrait ;
1213use Keboola \Test \Backend \Workspaces \Backend \WorkspaceBackendFactory ;
1314use Keboola \Test \Backend \Workspaces \ParallelWorkspacesTestCase ;
15+ use Keboola \Test \Utils \PemKeyCertificateGenerator ;
1416
1517class WorkspacesReaderTest extends ParallelWorkspacesTestCase
1618{
@@ -55,7 +57,18 @@ public function testLoadToReaderAccount(): void
5557 $ components = new Components ($ branchClient );
5658 $ workspaces = new Workspaces ($ branchClient );
5759
58- $ workspace = $ components ->createConfigurationWorkspace ($ componentId , $ configurationId , ['useCase ' => 'reader ' ],);
60+ $ key = (new PemKeyCertificateGenerator ())->createPemKeyCertificate (null );
61+
62+ $ workspace = $ components ->createConfigurationWorkspace (
63+ $ componentId ,
64+ $ configurationId ,
65+ [
66+ 'useCase ' => 'reader ' ,
67+ 'backend ' => 'snowflake ' ,
68+ 'loginType ' => WorkspaceLoginType::SNOWFLAKE_SERVICE_KEYPAIR ,
69+ 'publicKey ' => $ key ->getPublicKey (),
70+ ],
71+ );
5972
6073 //setup test tables
6174 $ tableId = $ this ->_client ->createTableAsync (
@@ -80,8 +93,11 @@ public function testLoadToReaderAccount(): void
8093 ],
8194 ],
8295 ]);
96+
97+ $ workspace ['connection ' ]['privateKey ' ] = $ key ->getPrivateKey ();
98+
8399 // create the connection after LOAD!! because the schema will be created by LOAD
84- $ db = WorkspaceBackendFactory::createWorkspaceBackend ($ workspace );
100+ $ db = WorkspaceBackendFactory::createWorkspaceBackend ($ workspace, true );
85101
86102 $ data = $ db ->fetchAll ('languages ' );
87103 $ this ->assertCount (5 , $ data );
@@ -107,7 +123,18 @@ public function testLoadCloneToReaderAccount(): void
107123 $ components = new Components ($ branchClient );
108124 $ workspaces = new Workspaces ($ branchClient );
109125
110- $ workspace = $ components ->createConfigurationWorkspace ($ componentId , $ configurationId , ['useCase ' => 'reader ' ]);
126+ $ key = (new PemKeyCertificateGenerator ())->createPemKeyCertificate (null );
127+
128+ $ workspace = $ components ->createConfigurationWorkspace (
129+ $ componentId ,
130+ $ configurationId ,
131+ [
132+ 'useCase ' => 'reader ' ,
133+ 'backend ' => 'snowflake ' ,
134+ 'loginType ' => WorkspaceLoginType::SNOWFLAKE_SERVICE_KEYPAIR ,
135+ 'publicKey ' => $ key ->getPublicKey (),
136+ ],
137+ );
111138
112139 //setup test tables
113140 $ tableId = $ this ->_client ->createTableAsync (
@@ -128,8 +155,11 @@ public function testLoadCloneToReaderAccount(): void
128155 ],
129156 ],
130157 ]);
158+
159+ $ workspace ['connection ' ]['privateKey ' ] = $ key ->getPrivateKey ();
160+
131161 // create the connection after LOAD!! because the schema will be created by LOAD
132- $ db = WorkspaceBackendFactory::createWorkspaceBackend ($ workspace );
162+ $ db = WorkspaceBackendFactory::createWorkspaceBackend ($ workspace, true );
133163
134164 $ data = $ db ->fetchAll ('languages ' );
135165 $ this ->assertCount (5 , $ data );
0 commit comments