mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
fix(sqllab): remove link to sqllab if missing perms (#22566)
This commit is contained in:
@@ -98,7 +98,7 @@ class TestSavedQueryApi(SupersetTestCase):
|
||||
self.insert_default_saved_query(
|
||||
label=f"label{SAVED_QUERIES_FIXTURE_COUNT}",
|
||||
schema=f"schema{SAVED_QUERIES_FIXTURE_COUNT}",
|
||||
username="gamma",
|
||||
username="gamma_sqllab",
|
||||
)
|
||||
)
|
||||
|
||||
@@ -157,12 +157,12 @@ class TestSavedQueryApi(SupersetTestCase):
|
||||
"""
|
||||
Saved Query API: Test get list saved query
|
||||
"""
|
||||
gamma = self.get_user("gamma")
|
||||
user = self.get_user("gamma_sqllab")
|
||||
saved_queries = (
|
||||
db.session.query(SavedQuery).filter(SavedQuery.created_by == gamma).all()
|
||||
db.session.query(SavedQuery).filter(SavedQuery.created_by == user).all()
|
||||
)
|
||||
|
||||
self.login(username="gamma")
|
||||
self.login(username=user.username)
|
||||
uri = f"api/v1/saved_query/"
|
||||
rv = self.get_assert_metric(uri, "get_list")
|
||||
assert rv.status_code == 200
|
||||
|
||||
@@ -257,6 +257,22 @@ class TestSqlLab(SupersetTestCase):
|
||||
db.session.commit()
|
||||
self.assertLess(0, len(data["data"]))
|
||||
|
||||
def test_sqllab_has_access(self):
|
||||
for username in ("admin", "gamma_sqllab"):
|
||||
self.login(username)
|
||||
for endpoint in ("/superset/sqllab/", "/superset/sqllab/history/"):
|
||||
resp = self.client.get(endpoint)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
|
||||
self.logout()
|
||||
|
||||
def test_sqllab_no_access(self):
|
||||
self.login("gamma")
|
||||
for endpoint in ("/superset/sqllab/", "/superset/sqllab/history/"):
|
||||
resp = self.client.get(endpoint)
|
||||
# Redirects to the main page
|
||||
self.assertEqual(302, resp.status_code)
|
||||
|
||||
def test_sql_json_schema_access(self):
|
||||
examples_db = get_example_database()
|
||||
db_backend = examples_db.backend
|
||||
|
||||
Reference in New Issue
Block a user