dpgaspar commented on code in PR #38952:
URL: https://github.com/apache/superset/pull/38952#discussion_r3015831379
##########
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:
`test_run_succeeds` was passing without having to mock patch
`raise_for_access` this could be concerning, since we may have broke something.
I mean `raise_for_access` will always succeed if we patch it with `None` but
previously this test just passed, relying on the current permissions. Could be
a false alarm, but I would feel better if we guarantee the actual permissions
for the user
--
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]