-
Notifications
You must be signed in to change notification settings - Fork 99
handle ssl cert in dbt cli config #1323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| from typing import Union | ||
| from typing import Union, Optional | ||
| from ninja import Schema | ||
| from pathlib import Path | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| import os | ||
|
|
||
| from ddpui.ddpdbt.schema import DbtProjectParams | ||
| from ddpui.core.dbtfunctions import map_airbyte_destination_spec_to_dbtcli_profile | ||
|
|
||
|
|
@@ -63,7 +65,7 @@ def test_map_airbyte_destination_spec_to_dbtcli_profile_success_tunnel_params(tm | |
|
|
||
|
|
||
| def test_map_airbyte_destination_spec_to_dbtcli_profile_success_ssl_params(tmpdir): | ||
| """Tests all the success cases""" | ||
| """Tests ssl params are stored in conn_info for runtime cert writing""" | ||
| dbt_project_params = DbtProjectParams( | ||
| org_project_dir=str(tmpdir), | ||
| dbt_env_dir="/path/to/dbt_venv", | ||
|
|
@@ -78,7 +80,39 @@ def test_map_airbyte_destination_spec_to_dbtcli_profile_success_ssl_params(tmpdi | |
|
|
||
| conn_info = {"ssl_mode": {"mode": "verify-ca", "ca_certificate": "ca_certificate"}} | ||
| res = map_airbyte_destination_spec_to_dbtcli_profile(conn_info, dbt_project_params) | ||
| assert res["sslmode"] == conn_info["ssl_mode"]["mode"] | ||
| assert res["sslmode"] == "verify-ca" | ||
| assert res["sslrootcert"] == f"{tmpdir}/sslrootcert.pem" | ||
| with open(f"{tmpdir}/sslrootcert.pem") as file: | ||
| assert file.read() == conn_info["ssl_mode"]["ca_certificate"] | ||
| assert res["sslrootcert_content"] == "ca_certificate" | ||
| # cert should NOT be written to disk at setup time | ||
| assert not os.path.exists(f"{tmpdir}/sslrootcert.pem") | ||
|
|
||
|
|
||
| def test_map_airbyte_destination_spec_to_dbtcli_profile_ssl_mode_only(tmpdir): | ||
| """Tests ssl_mode with mode but no ca_certificate""" | ||
| dbt_project_params = DbtProjectParams( | ||
| org_project_dir=str(tmpdir), | ||
| dbt_env_dir="/path/to/dbt_venv", | ||
| dbt_repo_dir="/path/to/dbt_repo", | ||
| project_dir="/path/to/project_dir", | ||
| target="target", | ||
| dbt_binary="dbt_binary", | ||
| venv_binary="path/to/venv/bin", | ||
| clients_base_dir="/path/to/clients_base", | ||
| project_dir_relative="org/dbtrepo", | ||
| ) | ||
|
|
||
| conn_info = {"ssl_mode": {"mode": "require"}} | ||
| res = map_airbyte_destination_spec_to_dbtcli_profile(conn_info, dbt_project_params) | ||
| assert res["sslmode"] == "require" | ||
| assert "sslrootcert" not in res | ||
| assert "sslrootcert_content" not in res | ||
|
|
||
|
|
||
| def test_map_airbyte_destination_spec_to_dbtcli_profile_ssl_no_org_project_dir(): | ||
| """Tests ssl with ca_certificate but no dbt_project_params raises""" | ||
| conn_info = {"ssl_mode": {"mode": "verify-ca", "ca_certificate": "ca_certificate"}} | ||
| try: | ||
| map_airbyte_destination_spec_to_dbtcli_profile(conn_info, None) | ||
| assert False, "should have raised" | ||
| except Exception as e: | ||
| assert "org_project_dir is required" in str(e) | ||
|
Comment on lines
+111
to
+118
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace Two Ruff-flagged problems here:
🛠️ Proposed fix+import pytest
+
def test_map_airbyte_destination_spec_to_dbtcli_profile_ssl_no_org_project_dir():
"""Tests ssl with ca_certificate but no dbt_project_params raises"""
conn_info = {"ssl_mode": {"mode": "verify-ca", "ca_certificate": "ca_certificate"}}
- try:
- map_airbyte_destination_spec_to_dbtcli_profile(conn_info, None)
- assert False, "should have raised"
- except Exception as e:
- assert "org_project_dir is required" in str(e)
+ with pytest.raises(Exception, match="org_project_dir is required"):
+ map_airbyte_destination_spec_to_dbtcli_profile(conn_info, None)🧰 Tools🪛 Ruff (0.15.12)[warning] 116-116: Do not Replace (B011) [warning] 117-117: Do not catch blind exception: (BLE001) 🤖 Prompt for AI Agents |
||
Uh oh!
There was an error while loading. Please reload this page.