diff --git a/tests/functional/oauth/test_oauth.py b/tests/functional/oauth/test_oauth.py index 618486809..97847770b 100644 --- a/tests/functional/oauth/test_oauth.py +++ b/tests/functional/oauth/test_oauth.py @@ -93,29 +93,32 @@ def test_snowflake_basic(self, project): class TestSnowflakeOAuthExpiration: + profile = { + "type": "snowflake", + "threads": 4, + "account": os.getenv("SNOWFLAKE_TEST_ACCOUNT"), + "user": os.getenv("SNOWFLAKE_TEST_USER"), + "oauth_client_id": os.getenv("SNOWFLAKE_TEST_OAUTH_CLIENT_ID"), + "oauth_client_secret": os.getenv("SNOWFLAKE_TEST_OAUTH_CLIENT_SECRET"), + "token": os.getenv("SNOWFLAKE_TEST_OAUTH_REFRESH_TOKEN"), + "database": os.getenv("SNOWFLAKE_TEST_DATABASE"), + "warehouse": os.getenv("SNOWFLAKE_TEST_WAREHOUSE"), + "authenticator": "oauth", + } + @pytest.fixture(scope="class", autouse=True) def dbt_profile_target(self): - return { - "type": "snowflake", - "threads": 4, - "account": os.getenv("SNOWFLAKE_TEST_ACCOUNT"), - "user": os.getenv("SNOWFLAKE_TEST_USER"), - "oauth_client_id": os.getenv("SNOWFLAKE_TEST_OAUTH_CLIENT_ID"), - "oauth_client_secret": os.getenv("SNOWFLAKE_TEST_OAUTH_CLIENT_SECRET"), - "token": os.getenv("SNOWFLAKE_TEST_OAUTH_REFRESH_TOKEN"), - "database": os.getenv("SNOWFLAKE_TEST_DATABASE"), - "warehouse": os.getenv("SNOWFLAKE_TEST_WAREHOUSE"), - "authenticator": "oauth", - } + return self.profile @pytest.fixture(scope="class") def models(self): return {"model_1.sql": _MODELS__MODEL_1_SQL} - def test_token_expiration(self, project, dbt_profile_data): + def test_token_expiration(self, project): # change token which is included in the connection_info - dbt_profile_data["test"]["outputs"]["default"]["token"] = "THIS_TOKEN_DOES_NOT_EXIST" - write_file(yaml.safe_dump(dbt_profile_data), project.profiles_dir, "profiles.yml") + project.adapter.config.credentials.token = "THIS_TOKEN_DOES_NOT_EXIST" + + self.profile["token"] = "THIS_TOKEN_DOES_NOT_EXIST" with pytest.raises(FailedToConnectError): - run_dbt(["run"], expect_pass=False) + run_dbt(["run", "--profile", self.profile], expect_pass=False)