sha174n commented on code in PR #38952:
URL: https://github.com/apache/superset/pull/38952#discussion_r3016057373
##########
tests/integration_tests/sql_lab/commands_tests.py:
##########
@@ -346,6 +346,30 @@ def test_validation_query_not_found(self) -> None:
@pytest.mark.usefixtures("create_database_and_query")
@patch("superset.commands.sql_lab.results.results_backend_use_msgpack",
False)
+ def test_validation_unauthorized_access(self) -> None:
+ command = results.SqlExecutionResultsCommand("abc_query", 1000)
+
+ with mock.patch(
+ "superset.models.sql_lab.Query.raise_for_access",
+ side_effect=SupersetSecurityException(
+ SupersetError(
+ "dummy",
+ SupersetErrorType.DATASOURCE_SECURITY_ACCESS_ERROR,
+ ErrorLevel.ERROR,
+ )
+ ),
+ ):
+ with pytest.raises(SupersetErrorException) as ex_info:
+ command.run()
+ assert (
+ ex_info.value.error.error_type
+ == SupersetErrorType.QUERY_SECURITY_ACCESS_ERROR
+ )
+ assert ex_info.value.status == 403
+
+ @pytest.mark.usefixtures("create_database_and_query")
+ @patch("superset.commands.sql_lab.results.results_backend_use_msgpack",
False)
+ @patch("superset.models.sql_lab.Query.raise_for_access", lambda _: None)
Review Comment:
Fixed: the query is now assigned to the admin user, and the test runs under
override_user(admin) so raise_for_access exercises real permission logic.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]