sha174n commented on code in PR #41425:
URL: https://github.com/apache/superset/pull/41425#discussion_r3525792901
##########
tests/integration_tests/core_tests.py:
##########
@@ -899,6 +899,23 @@ def test_explore_redirect(self, mock_command: mock.Mock):
rv =
self.client.get(f"/explore/?form_data={quote(json.dumps(form_data))}")
assert rv.headers["Location"] ==
f"/explore/?form_data_key={random_key}"
+ @pytest.mark.usefixtures("load_energy_table_with_slice")
+ @mock.patch("superset.security.SupersetSecurityManager.raise_for_access")
+ def test_explore_view_checks_datasource_access(
+ self, mock_raise_for_access: mock.Mock
+ ) -> None:
+ """The explore view runs the per-datasource access check on the loaded
+ datasource, consistent with the explore command, before rendering its
+ metadata."""
+ self.login(ADMIN_USERNAME)
+ tbl_id = self.table_ids.get("energy_usage")
Review Comment:
Annotated the local as `tbl_id: int | None` in 41f6fd22e3.
##########
tests/integration_tests/core_tests.py:
##########
@@ -899,6 +899,23 @@ def test_explore_redirect(self, mock_command: mock.Mock):
rv =
self.client.get(f"/explore/?form_data={quote(json.dumps(form_data))}")
assert rv.headers["Location"] ==
f"/explore/?form_data_key={random_key}"
+ @pytest.mark.usefixtures("load_energy_table_with_slice")
+ @mock.patch("superset.security.SupersetSecurityManager.raise_for_access")
+ def test_explore_view_checks_datasource_access(
+ self, mock_raise_for_access: mock.Mock
+ ) -> None:
+ """The explore view runs the per-datasource access check on the loaded
+ datasource, consistent with the explore command, before rendering its
+ metadata."""
+ self.login(ADMIN_USERNAME)
+ tbl_id = self.table_ids.get("energy_usage")
+
+ self.client.post(f"/explore/table/{tbl_id}/")
+
+ mock_raise_for_access.assert_called_once()
+ _, kwargs = mock_raise_for_access.call_args
Review Comment:
Inlined the assertion in 41f6fd22e3 so there is no untyped local to annotate
(dropped the `kwargs` variable).
--
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]