From fdc26306464202405a5e5411d888c53c0c8fdf08 Mon Sep 17 00:00:00 2001 From: Mike Alfare Date: Fri, 27 Sep 2024 18:22:47 -0400 Subject: [PATCH] update the test case with a verified reproduction --- .../auth_tests/test_database_role.py | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/tests/functional/auth_tests/test_database_role.py b/tests/functional/auth_tests/test_database_role.py index 76ea36263..14a3d601a 100644 --- a/tests/functional/auth_tests/test_database_role.py +++ b/tests/functional/auth_tests/test_database_role.py @@ -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") @@ -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"])