Skip to content

Commit 98b41dc

Browse files
committed
test w/ keyPair
1 parent 7eb6584 commit 98b41dc

1 file changed

Lines changed: 34 additions & 4 deletions

File tree

tests/Backend/Snowflake/WorkspacesReaderTest.php

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
use Keboola\StorageApi\Components;
77
use Keboola\StorageApi\Options\Components\Configuration;
88
use Keboola\StorageApi\Options\Components\ListComponentsOptions;
9+
use Keboola\StorageApi\WorkspaceLoginType;
910
use Keboola\StorageApi\Workspaces;
1011
use Keboola\Test\Backend\WorkspaceConnectionTrait;
1112
use Keboola\Test\Backend\WorkspaceCredentialsAssertTrait;
1213
use Keboola\Test\Backend\Workspaces\Backend\WorkspaceBackendFactory;
1314
use Keboola\Test\Backend\Workspaces\ParallelWorkspacesTestCase;
15+
use Keboola\Test\Utils\PemKeyCertificateGenerator;
1416

1517
class 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

Comments
 (0)