Skip to content

Commit

Permalink
update the test case with a verified reproduction
Browse files Browse the repository at this point in the history
  • Loading branch information
mikealfare committed Sep 27, 2024
1 parent c0e6d09 commit fdc2630
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions tests/functional/auth_tests/test_database_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
from dbt.tests.util import run_dbt


BLOCKING_DB_ROLE = "BLOCKING_DB_ROLE"


class TestDatabaseRole:
"""
This test addresses https://github.com/dbt-labs/dbt-snowflake/issues/1151
Run this manually while investigating:
CREATE DATABASE ROLE BLOCKING_DB_ROLE;
GRANT ALL PRIVILEGES ON FUTURE TABLES IN DATABASE DBT_TEST TO DATABASE ROLE BLOCKING_DB_ROLE;
"""

@pytest.fixture(scope="class")
Expand All @@ -18,7 +17,20 @@ def models(self):

@pytest.fixture(scope="class")
def project_config_update(self):
return {"models": {"+copy_grants": True}}
return {"models": {"+grants": {"select": [BLOCKING_DB_ROLE]}}}

@pytest.fixture(scope="class", autouse=True)
def setup(self, project):
project.run_sql(f"CREATE DATABASE ROLE {BLOCKING_DB_ROLE}")
sql = f"""
GRANT
ALL PRIVILEGES ON FUTURE TABLES
IN DATABASE {project.database}
TO DATABASE ROLE {BLOCKING_DB_ROLE}
"""
project.run_sql(sql)
yield
project.run_sql(f"DROP DATABASE ROLE {BLOCKING_DB_ROLE}")

def test_database_role(self, project):
run_dbt(["run"])
Expand Down

0 comments on commit fdc2630

Please sign in to comment.