Skip to content

Commit

Permalink
update test to connect initially, then swap out token for a invalid one
Browse files Browse the repository at this point in the history
  • Loading branch information
McKnight-42 committed Jun 14, 2024
1 parent 78b9c86 commit 502d448
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tests/functional/oauth/test_oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
"""

import os

import yaml
from dbt.adapters.exceptions.connection import FailedToConnectError
from dbt.tests.util import check_relations_equal, run_dbt
from dbt.tests.util import check_relations_equal, run_dbt, write_file
import pytest


Expand Down Expand Up @@ -93,7 +93,7 @@ def test_snowflake_basic(self, project):


class TestSnowflakeOAuthExpiration:
@pytest.fixture(scope="class")
@pytest.fixture(scope="class", autouse=True)
def dbt_profile_target(self):
return {
"type": "snowflake",
Expand All @@ -102,7 +102,7 @@ def dbt_profile_target(self):
"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": "THIS_TOKEN_DOES_NOT_EXIST",
"token": os.getenv("SNOWFLAKE_TEST_OAUTH_REFRESH_TOKEN"),
"database": os.getenv("SNOWFLAKE_TEST_DATABASE"),
"warehouse": os.getenv("SNOWFLAKE_TEST_WAREHOUSE"),
"authenticator": "oauth",
Expand All @@ -112,6 +112,10 @@ def dbt_profile_target(self):
def models(self):
return {"model_1.sql": _MODELS__MODEL_1_SQL}

def test_token_expiration(self, project):
def test_token_expiration(self, project, dbt_profile_data):
# 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")

with pytest.raises(FailedToConnectError):
run_dbt(["run"], expect_pass=False)

0 comments on commit 502d448

Please sign in to comment.