-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add require_certificate_validation Behavior Flag
- Loading branch information
1 parent
7846fae
commit b63c640
Showing
4 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
kind: Under the Hood | ||
body: Revert cert default to False. Add require_certificate_validation Behavior Flag | ||
time: 2024-11-20T19:18:09.725288+01:00 | ||
custom: | ||
Author: damian3031 | ||
Issue: "" | ||
PR: "447" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
tests/functional/adapter/behavior_flags/test_require_certificate_validation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import warnings | ||
|
||
import pytest | ||
from dbt.tests.util import run_dbt, run_dbt_and_capture | ||
from urllib3.exceptions import InsecureRequestWarning | ||
|
||
|
||
class TestRequireCertificateValidationDefault: | ||
@pytest.fixture(scope="class") | ||
def project_config_update(self): | ||
return {"flags": {}} | ||
|
||
def test_require_certificate_validation_logs(self, project): | ||
dbt_args = ["show", "--inline", "select 1"] | ||
_, logs = run_dbt_and_capture(dbt_args) | ||
assert "It is strongly advised to enable `require_certificate_validation` flag" in logs | ||
|
||
@pytest.mark.skip_profile("trino_starburst") | ||
def test_require_certificate_validation_insecure_request_warning(self, project): | ||
with warnings.catch_warnings(record=True) as w: | ||
dbt_args = ["show", "--inline", "select 1"] | ||
run_dbt(dbt_args) | ||
|
||
# Check if any InsecureRequestWarning was raised | ||
assert any( | ||
issubclass(warning.category, InsecureRequestWarning) for warning in w | ||
), "InsecureRequestWarning was not raised" | ||
|
||
|
||
class TestRequireCertificateValidationFalse: | ||
@pytest.fixture(scope="class") | ||
def project_config_update(self): | ||
return {"flags": {"require_certificate_validation": False}} | ||
|
||
def test_require_certificate_validation_logs(self, project): | ||
dbt_args = ["show", "--inline", "select 1"] | ||
_, logs = run_dbt_and_capture(dbt_args) | ||
assert "It is strongly advised to enable `require_certificate_validation` flag" in logs | ||
|
||
@pytest.mark.skip_profile("trino_starburst") | ||
def test_require_certificate_validation_insecure_request_warning(self, project): | ||
with warnings.catch_warnings(record=True) as w: | ||
dbt_args = ["show", "--inline", "select 1"] | ||
run_dbt(dbt_args) | ||
|
||
# Check if any InsecureRequestWarning was raised | ||
assert any( | ||
issubclass(warning.category, InsecureRequestWarning) for warning in w | ||
), "InsecureRequestWarning was not raised" | ||
|
||
|
||
class TestRequireCertificateValidationTrue: | ||
@pytest.fixture(scope="class") | ||
def project_config_update(self): | ||
return {"flags": {"require_certificate_validation": True}} | ||
|
||
def test_require_certificate_validation_logs(self, project): | ||
dbt_args = ["show", "--inline", "select 1"] | ||
_, logs = run_dbt_and_capture(dbt_args) | ||
assert "It is strongly advised to enable `require_certificate_validation` flag" not in logs | ||
|
||
@pytest.mark.skip_profile("trino_starburst") | ||
def test_require_certificate_validation_insecure_request_warning(self, project): | ||
with warnings.catch_warnings(record=True) as w: | ||
dbt_args = ["show", "--inline", "select 1"] | ||
run_dbt(dbt_args) | ||
|
||
# Check if not any InsecureRequestWarning was raised | ||
assert not any( | ||
issubclass(warning.category, InsecureRequestWarning) for warning in w | ||
), "InsecureRequestWarning was not raised" |