Skip to content

Commit 615aa5c

Browse files
Use dynamic role discovery for grants validation tests
- Get current role from session instead of hardcoding role names - Ensures grants are validated with a role the CI user actually has - Tests now properly validate grants functionality in any environment - Both grants tests pass with full validation enabled - More robust than hardcoded role approaches
1 parent bc03506 commit 615aa5c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

tests_integration/test_streamlit.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ def test_streamlit_grants_flow(
142142
alter_snowflake_yml,
143143
):
144144
"""Test that streamlit grants are properly applied during deployment."""
145-
test_role = "test_role" # Use integration test role
145+
# Use current role to avoid role assignment issues in CI
146+
current_role_cursor = snowflake_session.execute_string("SELECT CURRENT_ROLE()")[0]
147+
test_role = current_role_cursor.fetchone()[0]
146148
entity_id = "app_1"
147149

148150
with project_directory("streamlit_v2"):
@@ -156,9 +158,7 @@ def test_streamlit_grants_flow(
156158
entity_id, snowflake_session, experimental=False
157159
)
158160

159-
# Skip grants verification in CI due to role assignment issues
160-
# The grants functionality is verified to work correctly during deployment
161-
# _streamlit_test_steps.verify_grants_applied(entity_id, test_role)
161+
_streamlit_test_steps.verify_grants_applied(entity_id, test_role)
162162

163163
_streamlit_test_steps.drop_should_succeed(entity_id, snowflake_session)
164164

@@ -171,7 +171,9 @@ def test_streamlit_grants_experimental_flow(
171171
alter_snowflake_yml,
172172
):
173173
"""Test that streamlit grants are properly applied during experimental deployment."""
174-
test_role = "test_role" # Use integration test role
174+
# Use current role to avoid role assignment issues in CI
175+
current_role_cursor = snowflake_session.execute_string("SELECT CURRENT_ROLE()")[0]
176+
test_role = current_role_cursor.fetchone()[0]
175177
entity_id = "app_1"
176178

177179
with project_directory("streamlit_v2"):
@@ -185,8 +187,6 @@ def test_streamlit_grants_experimental_flow(
185187
entity_id, snowflake_session, experimental=True
186188
)
187189

188-
# Skip grants verification in CI due to role assignment issues
189-
# The grants functionality is verified to work correctly during deployment
190-
# _streamlit_test_steps.verify_grants_applied(entity_id, test_role)
190+
_streamlit_test_steps.verify_grants_applied(entity_id, test_role)
191191

192192
_streamlit_test_steps.drop_should_succeed(entity_id, snowflake_session)

0 commit comments

Comments
 (0)