Skip to content

Commit

Permalink
fix test to use a secret username (#4682)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathaniel May authored Feb 4, 2022
1 parent 8a0bc39 commit 2d0b975
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions test/integration/068_partial_parsing_tests/test_pp_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,11 @@ def profile_config(self):
# calls 'load_config' before the tests are run.
# Note: only the specified profile is rendered, so there's no
# point it setting env_vars in non-used profiles.
os.environ['ENV_VAR_USER'] = 'root'
os.environ[SECRET_ENV_PREFIX + 'PASS'] = 'password'

# user is secret and password is not. postgres on macos doesn't care if the password
# changes so we have to change the user. related: https:/dbt-labs/dbt-core/pull/4250
os.environ[SECRET_ENV_PREFIX + 'USER'] = 'root'
os.environ['ENV_VAR_PASS'] = 'password'
return {
'config': {
'send_anonymous_usage_stats': False
Expand All @@ -378,8 +381,8 @@ def profile_config(self):
'port': 5432,
'user': "root",
'pass': "password",
'user': "{{ env_var('ENV_VAR_USER') }}",
'pass': "{{ env_var('DBT_ENV_SECRET_PASS') }}",
'user': "{{ env_var('DBT_ENV_SECRET_USER') }}",
'pass': "{{ env_var('ENV_VAR_PASS') }}",
'dbname': 'dbt',
'schema': self.unique_schema()
},
Expand All @@ -392,16 +395,16 @@ def profile_config(self):
def test_postgres_profile_secret_env_vars(self):

# Initial run
os.environ['ENV_VAR_USER'] = 'root'
os.environ[SECRET_ENV_PREFIX + 'PASS'] = 'password'
os.environ[SECRET_ENV_PREFIX + 'USER'] = 'root'
os.environ['ENV_VAR_PASS'] = 'password'
self.setup_directories()
self.copy_file('test-files/model_one.sql', 'models/model_one.sql')
results = self.run_dbt(["run"])
manifest = get_manifest()
env_vars_checksum = manifest.state_check.profile_env_vars_hash.checksum

# Change a secret var, it shouldn't register because we shouldn't save secrets.
os.environ[SECRET_ENV_PREFIX + 'PASS'] = 'password2'
os.environ[SECRET_ENV_PREFIX + 'USER'] = 'boop'
# this dbt run is going to fail because the password isn't actually the right one,
# but that doesn't matter because we just want to see if the manifest has included
# the secret in the hash of environment variables.
Expand Down

0 comments on commit 2d0b975

Please sign in to comment.