Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit 9cb0e1d

Browse files
authored
Merge pull request #469 from dlawin/issue_442_2
Snowflake support private_key_passphrase
2 parents dadda1b + 4d0f506 commit 9cb0e1d

File tree

4 files changed

+25
-19
lines changed

4 files changed

+25
-19
lines changed

data_diff/dbt.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,8 @@ def set_connection(self):
480480
credentials, conn_type = self._get_connection_creds()
481481

482482
if conn_type == "snowflake":
483-
if credentials.get("authenticator") is not None or credentials.get("private_key_passphrase") is not None:
484-
raise Exception("Federated authentication and key/pair with passphrase is not yet supported for Snowflake.")
483+
if credentials.get("authenticator") is not None:
484+
raise Exception("Federated authentication is not yet supported for Snowflake.")
485485
conn_info = {
486486
"driver": conn_type,
487487
"user": credentials.get("user"),
@@ -498,6 +498,7 @@ def set_connection(self):
498498
if credentials.get("password") is not None:
499499
raise Exception("Cannot use password and key at the same time")
500500
conn_info["key"] = credentials.get("private_key_path")
501+
conn_info["private_key_passphrase"] = credentials.get("private_key_passphrase")
501502
elif credentials.get("password") is not None:
502503
conn_info["password"] = credentials.get("password")
503504
else:

poetry.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ dsnparse = "*"
2929
click = "^8.1"
3030
rich = "*"
3131
toml = "^0.10.2"
32-
sqeleton = "^0.0.7"
32+
sqeleton = "0.0.8"
3333
mysql-connector-python = {version="8.0.29", optional=true}
3434
psycopg2 = {version="*", optional=true}
3535
snowflake-connector-python = {version="^2.7.2", optional=true}

tests/test_dbt.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,22 @@ def test_set_connection_snowflake_success_key(self):
166166
self.assertEqual(mock_self.connection.get("key"), expected_credentials["private_key_path"])
167167
self.assertEqual(mock_self.requires_upper, True)
168168

169+
def test_set_connection_snowflake_success_key_and_passphrase(self):
170+
expected_driver = "snowflake"
171+
expected_credentials = {"user": "user", "private_key_path": "private_key_path", "private_key_passphrase": "private_key_passphrase"}
172+
mock_self = Mock()
173+
mock_self._get_connection_creds.return_value = (expected_credentials, expected_driver)
174+
175+
DbtParser.set_connection(mock_self)
176+
177+
self.assertIsInstance(mock_self.connection, dict)
178+
self.assertEqual(mock_self.connection.get("driver"), expected_driver)
179+
self.assertEqual(mock_self.connection.get("user"), expected_credentials["user"])
180+
self.assertEqual(mock_self.connection.get("password"), None)
181+
self.assertEqual(mock_self.connection.get("key"), expected_credentials["private_key_path"])
182+
self.assertEqual(mock_self.connection.get("private_key_passphrase"), expected_credentials["private_key_passphrase"])
183+
self.assertEqual(mock_self.requires_upper, True)
184+
169185
def test_set_connection_snowflake_no_key_or_password(self):
170186
expected_driver = "snowflake"
171187
expected_credentials = {"user": "user"}
@@ -199,17 +215,6 @@ def test_set_connection_snowflake_key_and_password(self):
199215

200216
self.assertNotIsInstance(mock_self.connection, dict)
201217

202-
def test_set_connection_snowflake_private_key_passphrase(self):
203-
expected_driver = "snowflake"
204-
expected_credentials = {"user": "user", "private_key_passphrase": "private_key_passphrase"}
205-
mock_self = Mock()
206-
mock_self._get_connection_creds.return_value = (expected_credentials, expected_driver)
207-
208-
with self.assertRaises(Exception):
209-
DbtParser.set_connection(mock_self)
210-
211-
self.assertNotIsInstance(mock_self.connection, dict)
212-
213218
def test_set_connection_bigquery_success(self):
214219
expected_driver = "bigquery"
215220
expected_credentials = {

0 commit comments

Comments
 (0)