Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: removes old deprecated sqllab endpoints #27117

Merged
merged 6 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions UPDATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ assists people when migrating to a new version.

### Breaking Changes

- [27117](https://github.com/apache/superset/pull/27117): Removes the following deprecated endpoints: `/superset/sqllab`, `/superset/sqllab/history`, `/sqllab/my_queries` use `/sqllab`, `/sqllab/history`, `/savedqueryview/list/?_flt_0_user={get_user_id()}` instead.
- [26347](https://github.com/apache/superset/issues/26347): Removes the deprecated `VERSIONED_EXPORT` feature flag. The previous value of the feature flag was `True` and now the feature is permanently enabled.
- [26328](https://github.com/apache/superset/issues/26328): Removes the deprecated Filter Box code and it's associated dependencies `react-select` and `array-move`. It also removes the `DeprecatedSelect` and `AsyncSelect` components that were exclusively used by filter boxes. Existing filter boxes will be automatically migrated to native filters.
- [26330](https://github.com/apache/superset/issues/26330): Removes the deprecated `DASHBOARD_FILTERS_EXPERIMENTAL` feature flag. The previous value of the feature flag was `False` and now the feature is permanently removed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@ describe('SqlLab query panel', () => {
.eq(0) // save
.click();

// visit saved queries
cy.visit('/sqllab/my_queries/');

// first row contains most recent link, follow back to SqlLab
cy.get('table tr:first-child a[href*="savedQueryId"').click();

Expand Down
2 changes: 0 additions & 2 deletions superset/initialization/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ def init_views(self) -> None:
from superset.views.sql_lab.views import (
SavedQueryView,
SavedQueryViewApi,
SqlLab,
TableSchemaView,
TabStateView,
)
Expand Down Expand Up @@ -310,7 +309,6 @@ def init_views(self) -> None:
appbuilder.add_view_no_menu(SavedQueryView)
appbuilder.add_view_no_menu(SavedQueryViewApi)
appbuilder.add_view_no_menu(SliceAsync)
appbuilder.add_view_no_menu(SqlLab)
appbuilder.add_view_no_menu(SqllabView)
appbuilder.add_view_no_menu(SqlMetricInlineView)
appbuilder.add_view_no_menu(Superset)
Expand Down
1 change: 0 additions & 1 deletion superset/security/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ class SupersetSecurityManager( # pylint: disable=too-many-public-methods
ACCESSIBLE_PERMS = {"can_userinfo", "resetmypassword", "can_recent_activity"}

SQLLAB_ONLY_PERMISSIONS = {
("can_my_queries", "SqlLab"),
("can_read", "SavedQuery"),
("can_write", "SavedQuery"),
("can_export", "SavedQuery"),
Expand Down
20 changes: 1 addition & 19 deletions superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
SqlResults = dict[str, Any]


class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
class Superset(BaseSupersetView):
"""The base views for Superset!"""

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -916,24 +916,6 @@ def welcome(self) -> FlaskResponse:
),
)

@has_access
@event_logger.log_this
@expose(
"/sqllab/",
methods=(
"GET",
"POST",
),
)
@deprecated(new_target="/sqllab")
def sqllab(self) -> FlaskResponse:
"""SQL Editor"""
url = "/sqllab"
if url_params := request.args:
params = parse.urlencode(url_params)
url = f"{url}?{params}"
return redirect(url)

@has_access
@event_logger.log_this
@expose("/sqllab/history/", methods=("GET",))
Expand Down
15 changes: 1 addition & 14 deletions superset/views/sql_lab/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import logging

import simplejson as json
from flask import redirect, request, Response
from flask import request, Response
from flask_appbuilder import expose
from flask_appbuilder.models.sqla.interface import SQLAInterface
from flask_appbuilder.security.decorators import has_access, has_access_api
Expand Down Expand Up @@ -264,16 +264,3 @@ def expanded(self, table_schema_id: int) -> FlaskResponse:
db.session.commit()
response = json.dumps({"id": table_schema_id, "expanded": payload})
return json_success(response)


class SqlLab(BaseSupersetView):
"""The base views for Superset!"""

@expose("/my_queries/")
@has_access
def my_queries(self) -> FlaskResponse:
"""Assigns a list of found users to the given role."""
logger.warning(
"This endpoint is deprecated and will be removed in the next major release"
)
return redirect(f"/savedqueryview/list/?_flt_0_user={get_user_id()}")
19 changes: 0 additions & 19 deletions tests/integration_tests/core_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1190,25 +1190,6 @@ def test_has_table_by_name(self):
is True
)

def test_redirect_new_sqllab(self):
self.login(username="admin")
resp = self.client.get(
"/superset/sqllab?savedQueryId=1&testParams=2",
follow_redirects=True,
)
assert resp.request.path == "/sqllab/"
assert (
resp.request.query_string.decode("utf-8") == "savedQueryId=1&testParams=2"
)

resp = self.client.post("/superset/sqllab/")
assert resp.status_code == 302

def test_redirect_new_sqllab_history(self):
self.login(username="admin")
resp = self.client.get("/superset/sqllab/history/")
assert resp.status_code == 302


if __name__ == "__main__":
unittest.main()
36 changes: 27 additions & 9 deletions tests/integration_tests/security_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1470,15 +1470,33 @@ def test_admin_permissions(self):

def test_sql_lab_permissions(self):
sql_lab_set = get_perm_tuples("sql_lab")
self.assertIn(("can_csv", "Superset"), sql_lab_set)
self.assertIn(("can_read", "Database"), sql_lab_set)
self.assertIn(("can_read", "SavedQuery"), sql_lab_set)
self.assertIn(("can_sqllab", "Superset"), sql_lab_set)

self.assertIn(("menu_access", "SQL Lab"), sql_lab_set)
self.assertIn(("menu_access", "SQL Editor"), sql_lab_set)
self.assertIn(("menu_access", "Saved Queries"), sql_lab_set)
self.assertIn(("menu_access", "Query Search"), sql_lab_set)
self.assertEqual(
sql_lab_set,
{
("can_activate", "TabStateView"),
("can_csv", "Superset"),
("can_delete_query", "TabStateView"),
("can_delete", "TabStateView"),
("can_execute_sql_query", "SQLLab"),
("can_export", "SavedQuery"),
("can_export_csv", "SQLLab"),
("can_get", "TabStateView"),
("can_get_results", "SQLLab"),
("can_migrate_query", "TabStateView"),
("can_sqllab_history", "Superset"),
("can_put", "TabStateView"),
("can_post", "TabStateView"),
("can_write", "SavedQuery"),
("can_read", "Query"),
("can_read", "Database"),
("can_read", "SQLLab"),
("can_read", "SavedQuery"),
("menu_access", "Query Search"),
("menu_access", "Saved Queries"),
("menu_access", "SQL Editor"),
("menu_access", "SQL Lab"),
},
)

self.assert_cannot_alpha(sql_lab_set)

Expand Down
Loading