-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
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,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) |