diff --git a/.changes/unreleased/Features-20240604-154856.yaml b/.changes/unreleased/Features-20240604-154856.yaml new file mode 100644 index 000000000..7d83b1da7 --- /dev/null +++ b/.changes/unreleased/Features-20240604-154856.yaml @@ -0,0 +1,6 @@ +kind: Features +body: Replace underscores with hyphens in account IDs to prevent SSL issues +time: 2024-06-04T15:48:56.845374-07:00 +custom: + Author: colin-rogers-dbt + Issue: "1068" diff --git a/dbt/adapters/snowflake/connections.py b/dbt/adapters/snowflake/connections.py index 1d6e31c93..aca115b4b 100644 --- a/dbt/adapters/snowflake/connections.py +++ b/dbt/adapters/snowflake/connections.py @@ -105,6 +105,7 @@ def __post_init__(self): base_msg="Authenticator is not set to oauth, but an oauth-only parameter is set! Did you mean to set authenticator: oauth?" ) ) + self.account = self.account.replace("_", "-") @property def type(self): diff --git a/tests/unit/test_connections.py b/tests/unit/test_connections.py index 555091c57..dd452b3cb 100644 --- a/tests/unit/test_connections.py +++ b/tests/unit/test_connections.py @@ -23,3 +23,16 @@ def test_connections_does_not_set_logs_in_response_to_env_var(monkeypatch): assert log_mock.debug.call_count == 0 assert log_mock.set_adapter_dependency_log_level.call_count == 0 + + +def test_connnections_credentials_replaces_underscores_with_hyphens(): + credentials = { + "account": "account_id_with_underscores", + "user": "user", + "password": "password", + "database": "database", + "warehouse": "warehouse", + "schema": "schema", + } + creds = connections.SnowflakeCredentials(**credentials) + assert creds.account == "account-id-with-underscores" diff --git a/tests/unit/test_snowflake_adapter.py b/tests/unit/test_snowflake_adapter.py index 2666e7557..ff92b9b65 100644 --- a/tests/unit/test_snowflake_adapter.py +++ b/tests/unit/test_snowflake_adapter.py @@ -278,7 +278,7 @@ def test_client_session_keep_alive_false_by_default(self): self.snowflake.assert_has_calls( [ mock.call( - account="test_account", + account="test-account", autocommit=True, client_session_keep_alive=False, database="test_database", @@ -305,7 +305,7 @@ def test_client_session_keep_alive_true(self): self.snowflake.assert_has_calls( [ mock.call( - account="test_account", + account="test-account", autocommit=True, client_session_keep_alive=True, database="test_database", @@ -332,7 +332,7 @@ def test_client_has_query_tag(self): self.snowflake.assert_has_calls( [ mock.call( - account="test_account", + account="test-account", autocommit=True, client_session_keep_alive=False, database="test_database", @@ -366,7 +366,7 @@ def test_user_pass_authentication(self): self.snowflake.assert_has_calls( [ mock.call( - account="test_account", + account="test-account", autocommit=True, client_session_keep_alive=False, database="test_database", @@ -397,7 +397,7 @@ def test_authenticator_user_pass_authentication(self): self.snowflake.assert_has_calls( [ mock.call( - account="test_account", + account="test-account", autocommit=True, client_session_keep_alive=False, database="test_database", @@ -428,7 +428,7 @@ def test_authenticator_externalbrowser_authentication(self): self.snowflake.assert_has_calls( [ mock.call( - account="test_account", + account="test-account", autocommit=True, client_session_keep_alive=False, database="test_database", @@ -461,7 +461,7 @@ def test_authenticator_oauth_authentication(self): self.snowflake.assert_has_calls( [ mock.call( - account="test_account", + account="test-account", autocommit=True, client_session_keep_alive=False, database="test_database", @@ -499,7 +499,7 @@ def test_authenticator_private_key_authentication(self, mock_get_private_key): self.snowflake.assert_has_calls( [ mock.call( - account="test_account", + account="test-account", autocommit=True, client_session_keep_alive=False, database="test_database", @@ -533,7 +533,7 @@ def test_authenticator_private_key_authentication_no_passphrase(self, mock_get_p self.snowflake.assert_has_calls( [ mock.call( - account="test_account", + account="test-account", autocommit=True, client_session_keep_alive=False, database="test_database", @@ -562,7 +562,7 @@ def test_query_tag(self): self.snowflake.assert_has_calls( [ mock.call( - account="test_account", + account="test-account", autocommit=True, client_session_keep_alive=False, database="test_database", @@ -592,7 +592,7 @@ def test_reuse_connections_with_keep_alive(self): self.snowflake.assert_has_calls( [ mock.call( - account="test_account", + account="test-account", autocommit=True, client_session_keep_alive=True, database="test_database", @@ -626,7 +626,7 @@ def test_authenticator_private_key_string_authentication(self, mock_get_private_ self.snowflake.assert_has_calls( [ mock.call( - account="test_account", + account="test-account", autocommit=True, client_session_keep_alive=False, database="test_database", @@ -662,7 +662,7 @@ def test_authenticator_private_key_string_authentication_no_passphrase( self.snowflake.assert_has_calls( [ mock.call( - account="test_account", + account="test-account", autocommit=True, client_session_keep_alive=False, database="test_database", @@ -907,7 +907,7 @@ class TestSnowflakeAdapterCredentials(unittest.TestCase): def test_private_key_string(self): creds = SnowflakeCredentials( - account="test_account", + account="test-account", user="test_user", database="test_database", schema="public", @@ -917,7 +917,7 @@ def test_private_key_string(self): def test_private_key_string_encrypted(self): creds = SnowflakeCredentials( - account="test_account", + account="test-account", user="test_user", database="test_database", schema="public", @@ -928,7 +928,7 @@ def test_private_key_string_encrypted(self): def test_malformed_private_key_string(self): creds = SnowflakeCredentials( - account="test_account", + account="test-account", user="test_user", database="test_database", schema="public", @@ -938,7 +938,7 @@ def test_malformed_private_key_string(self): def test_invalid_private_key_string(self): creds = SnowflakeCredentials( - account="test_account", + account="test-account", user="test_user", database="test_database", schema="public", @@ -948,7 +948,7 @@ def test_invalid_private_key_string(self): def test_invalid_private_key_path(self): creds = SnowflakeCredentials( - account="test_account", + account="test-account", user="test_user", database="test_database", schema="public",