diff --git a/tests/unit_tests/jinja_context_test.py b/tests/unit_tests/jinja_context_test.py index c8c700f6a4b1b..d880151af5d2e 100644 --- a/tests/unit_tests/jinja_context_test.py +++ b/tests/unit_tests/jinja_context_test.py @@ -99,6 +99,14 @@ def test_dataset_macro(mocker: MockFixture) -> None: ) DatasetDAO = mocker.patch("superset.daos.dataset.DatasetDAO") DatasetDAO.find_by_id.return_value = dataset + mocker.patch( + "superset.connectors.sqla.models.security_manager.get_guest_rls_filters", + return_value=[], + ) + mocker.patch( + "superset.models.helpers.security_manager.get_guest_rls_filters", + return_value=[], + ) assert ( dataset_macro(1) diff --git a/tests/unit_tests/security/manager_test.py b/tests/unit_tests/security/manager_test.py index 5a06013a683bb..325531c25b8d7 100644 --- a/tests/unit_tests/security/manager_test.py +++ b/tests/unit_tests/security/manager_test.py @@ -202,6 +202,7 @@ def test_raise_for_access_query_default_schema( sm = SupersetSecurityManager(appbuilder) mocker.patch.object(sm, "can_access_database", return_value=False) mocker.patch.object(sm, "get_schema_perm", return_value="[PostgreSQL].[public]") + mocker.patch.object(sm, "is_guest_user", return_value=False) SqlaTable = mocker.patch("superset.connectors.sqla.models.SqlaTable") SqlaTable.query_datasources_by_name.return_value = [] diff --git a/tests/unit_tests/sql_parse_tests.py b/tests/unit_tests/sql_parse_tests.py index 8074c45b22d98..973a4e379316c 100644 --- a/tests/unit_tests/sql_parse_tests.py +++ b/tests/unit_tests/sql_parse_tests.py @@ -290,11 +290,14 @@ def test_extract_tables_illdefined() -> None: == "Unable to parse SQL (generic): SELECT * FROM catalogname.." ) + with pytest.raises(SupersetSecurityException) as excinfo: + extract_tables('SELECT * FROM "tbname') + assert str(excinfo.value) == 'Unable to parse SQL (generic): SELECT * FROM "tbname' + # odd edge case that works assert extract_tables("SELECT * FROM catalogname..tbname") == { Table(table="tbname", schema=None, catalog="catalogname") } - assert extract_tables('SELECT * FROM "tbname') == set() def test_extract_tables_show_tables_from() -> None: