Skip to content

Commit a1e5f59

Browse files
Fix ACCOUNTADMIN role issue in grants verification
- Remove hardcoded ACCOUNTADMIN role switching in verify_grants_applied - Simplify verification by not switching back to original role - Fixes CI error: 'ACCOUNTADMIN role is not assigned to executing user' - Tests now pass locally with proper role handling
1 parent 8ba1488 commit a1e5f59

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

tests_integration/testing_utils/streamlit_utils.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,15 @@ def assert_proper_url_is_returned(
184184
assert message.endswith(create_expected_url_suffix(entity_id, session))
185185

186186
def verify_grants_applied(self, entity_id: str, test_role: str):
187-
try:
188-
self.setup.sql_test_helper.execute_single_sql(f"USE ROLE {test_role}")
189-
streamlits_with_role = self.setup.sql_test_helper.execute_single_sql(
190-
f"SHOW STREAMLITS LIKE '{entity_id}'"
191-
)
192-
assert (
193-
len(streamlits_with_role) == 1
194-
), f"Role {test_role} should have USAGE access to the streamlit"
195-
finally:
196-
self.setup.sql_test_helper.execute_single_sql("USE ROLE ACCOUNTADMIN")
187+
# Switch to test role and verify grants work
188+
self.setup.sql_test_helper.execute_single_sql(f"USE ROLE {test_role}")
189+
streamlits_with_role = self.setup.sql_test_helper.execute_single_sql(
190+
f"SHOW STREAMLITS LIKE '{entity_id}'"
191+
)
192+
assert (
193+
len(streamlits_with_role) == 1
194+
), f"Role {test_role} should have USAGE access to the streamlit"
195+
# No need to switch back since this is at the end of the test
197196

198197

199198
def create_expected_url_suffix(entity_id: str, session: SnowflakeConnection):

0 commit comments

Comments
 (0)