From 76cff61b9565d983f5a6d3260dec77aa7dcf8db2 Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Mon, 22 Apr 2024 14:15:57 -0500 Subject: [PATCH] add test --- .../dependencies/test_dependency_secrets.py | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/functional/dependencies/test_dependency_secrets.py diff --git a/tests/functional/dependencies/test_dependency_secrets.py b/tests/functional/dependencies/test_dependency_secrets.py new file mode 100644 index 00000000000..f1ac92e0b98 --- /dev/null +++ b/tests/functional/dependencies/test_dependency_secrets.py @@ -0,0 +1,31 @@ +import os +import pytest + +from dbt.tests.util import run_dbt_and_capture +from dbt_common.constants import SECRET_ENV_PREFIX + + +class TestAllowSecretProfilePackage: + @pytest.fixture(scope="class", autouse=True) + def setUp(self): + os.environ[SECRET_ENV_PREFIX + "FOR_LOGGING"] = "super secret" + yield + del os.environ[SECRET_ENV_PREFIX + "FOR_LOGGING"] + + @pytest.fixture(scope="class") + def packages(self): + return { + "packages": [ + { + "package": "dbt-labs/dbt_utils{{ log(env_var('DBT_ENV_SECRET_FOR_LOGGING'), info = true) }}", + "version": "1.0.0", + } + ] + } + + def test_allow_secrets(self, project): + _, log_output = run_dbt_and_capture(["deps"]) + # this will not be written to logs or lock file + assert not ("super secret" in log_output) + assert "*****" in log_output + assert not ("DBT_ENV_SECRET_FOR_LOGGING" in log_output)