From 6917362d786850b4b8db678d8292eb3e7836f4d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20H=C3=B6xtermann?= Date: Tue, 18 Mar 2025 22:15:10 +0100 Subject: [PATCH] fix: ensure datasource permission in explore (#32679) (cherry picked from commit 9e3052968b8709ee4d9c35aef63c13abbc785233) --- superset/commands/explore/get.py | 2 +- tests/integration_tests/explore/api_tests.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/superset/commands/explore/get.py b/superset/commands/explore/get.py index dc600bbf971..df71a931b2c 100644 --- a/superset/commands/explore/get.py +++ b/superset/commands/explore/get.py @@ -120,7 +120,7 @@ class GetExploreCommand(BaseCommand, ABC): if datasource: datasource_name = datasource.name - security_manager.can_access_datasource(datasource) + security_manager.raise_for_access(datasource=datasource) viz_type = form_data.get("viz_type") if not viz_type and datasource and datasource.default_endpoint: diff --git a/tests/integration_tests/explore/api_tests.py b/tests/integration_tests/explore/api_tests.py index 730e013f827..cc65870ca61 100644 --- a/tests/integration_tests/explore/api_tests.py +++ b/tests/integration_tests/explore/api_tests.py @@ -214,12 +214,12 @@ def test_get_dataset_access_denied_with_form_data_key( assert data["message"] == message -@patch("superset.security.SupersetSecurityManager.can_access_datasource") +@patch("superset.security.SupersetSecurityManager.raise_for_access") def test_get_dataset_access_denied( - mock_can_access_datasource, test_client, login_as_admin, dataset + mock_raise_for_access, test_client, login_as_admin, dataset ): message = "Dataset access denied" - mock_can_access_datasource.side_effect = DatasetAccessDeniedError( + mock_raise_for_access.side_effect = DatasetAccessDeniedError( message=message, datasource_id=dataset.id, datasource_type=dataset.type ) resp = test_client.get(