mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
chore: remove deprecated apis on superset, testconn, validate_sql_json, schemas_access_for_file_upload, extra_table_metadata (#24354)
This commit is contained in:
committed by
GitHub
parent
c04bd4c6a7
commit
6f145dfe36
@@ -342,98 +342,6 @@ class TestCore(SupersetTestCase):
|
||||
assert self.get_resp("/healthcheck") == "OK"
|
||||
assert self.get_resp("/ping") == "OK"
|
||||
|
||||
def test_testconn(self, username="admin"):
|
||||
# need to temporarily allow sqlite dbs, teardown will undo this
|
||||
app.config["PREVENT_UNSAFE_DB_CONNECTIONS"] = False
|
||||
self.login(username=username)
|
||||
database = superset.utils.database.get_example_database()
|
||||
# validate that the endpoint works with the password-masked sqlalchemy uri
|
||||
data = json.dumps(
|
||||
{
|
||||
"uri": database.safe_sqlalchemy_uri(),
|
||||
"name": "examples",
|
||||
"impersonate_user": False,
|
||||
}
|
||||
)
|
||||
response = self.client.post(
|
||||
"/superset/testconn", data=data, content_type="application/json"
|
||||
)
|
||||
assert response.status_code == 200
|
||||
assert response.headers["Content-Type"] == "application/json"
|
||||
|
||||
# validate that the endpoint works with the decrypted sqlalchemy uri
|
||||
data = json.dumps(
|
||||
{
|
||||
"uri": database.sqlalchemy_uri_decrypted,
|
||||
"name": "examples",
|
||||
"impersonate_user": False,
|
||||
}
|
||||
)
|
||||
response = self.client.post(
|
||||
"/superset/testconn", data=data, content_type="application/json"
|
||||
)
|
||||
assert response.status_code == 200
|
||||
assert response.headers["Content-Type"] == "application/json"
|
||||
|
||||
def test_testconn_failed_conn(self, username="admin"):
|
||||
self.login(username=username)
|
||||
|
||||
data = json.dumps(
|
||||
{"uri": "broken://url", "name": "examples", "impersonate_user": False}
|
||||
)
|
||||
response = self.client.post(
|
||||
"/superset/testconn", data=data, content_type="application/json"
|
||||
)
|
||||
assert response.status_code == 400
|
||||
assert response.headers["Content-Type"] == "application/json"
|
||||
response_body = json.loads(response.data.decode("utf-8"))
|
||||
expected_body = {"error": "Could not load database driver: broken"}
|
||||
assert response_body == expected_body, "{} != {}".format(
|
||||
response_body,
|
||||
expected_body,
|
||||
)
|
||||
|
||||
data = json.dumps(
|
||||
{
|
||||
"uri": "mssql+pymssql://url",
|
||||
"name": "examples",
|
||||
"impersonate_user": False,
|
||||
}
|
||||
)
|
||||
response = self.client.post(
|
||||
"/superset/testconn", data=data, content_type="application/json"
|
||||
)
|
||||
assert response.status_code == 400
|
||||
assert response.headers["Content-Type"] == "application/json"
|
||||
response_body = json.loads(response.data.decode("utf-8"))
|
||||
expected_body = {"error": "Could not load database driver: mssql+pymssql"}
|
||||
assert response_body == expected_body, "{} != {}".format(
|
||||
response_body,
|
||||
expected_body,
|
||||
)
|
||||
|
||||
def test_testconn_unsafe_uri(self, username="admin"):
|
||||
self.login(username=username)
|
||||
app.config["PREVENT_UNSAFE_DB_CONNECTIONS"] = True
|
||||
|
||||
response = self.client.post(
|
||||
"/superset/testconn",
|
||||
data=json.dumps(
|
||||
{
|
||||
"uri": "sqlite:///home/superset/unsafe.db",
|
||||
"name": "unsafe",
|
||||
"impersonate_user": False,
|
||||
}
|
||||
),
|
||||
content_type="application/json",
|
||||
)
|
||||
self.assertEqual(400, response.status_code)
|
||||
response_body = json.loads(response.data.decode("utf-8"))
|
||||
expected_body = {
|
||||
"error": "SQLiteDialect_pysqlite cannot be used as a data source for security reasons."
|
||||
}
|
||||
self.assertEqual(expected_body, response_body)
|
||||
|
||||
def test_custom_password_store(self):
|
||||
database = superset.utils.database.get_example_database()
|
||||
conn_pre = sqla.engine.url.make_url(database.sqlalchemy_uri_decrypted)
|
||||
@@ -551,15 +459,6 @@ class TestCore(SupersetTestCase):
|
||||
assert "Charts" in self.get_resp("/chart/list/")
|
||||
assert "Dashboards" in self.get_resp("/dashboard/list/")
|
||||
|
||||
@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
|
||||
def test_extra_table_metadata(self):
|
||||
self.login()
|
||||
example_db = superset.utils.database.get_example_database()
|
||||
schema = "default" if example_db.backend in {"presto", "hive"} else "superset"
|
||||
self.get_json_resp(
|
||||
f"/superset/extra_table_metadata/{example_db.id}/birth_names/{schema}/"
|
||||
)
|
||||
|
||||
def test_templated_sql_json(self):
|
||||
if superset.utils.database.get_example_database().backend == "presto":
|
||||
# TODO: make it work for presto
|
||||
@@ -994,30 +893,6 @@ class TestCore(SupersetTestCase):
|
||||
self.assertEqual(rv.status_code, 404)
|
||||
self.assertEqual(data["error"], "Cached data not found")
|
||||
|
||||
@mock.patch(
|
||||
"superset.security.SupersetSecurityManager.get_schemas_accessible_by_user"
|
||||
)
|
||||
@mock.patch("superset.security.SupersetSecurityManager.can_access_database")
|
||||
@mock.patch("superset.security.SupersetSecurityManager.can_access_all_datasources")
|
||||
def test_schemas_access_for_csv_upload_endpoint(
|
||||
self,
|
||||
mock_can_access_all_datasources,
|
||||
mock_can_access_database,
|
||||
mock_schemas_accessible,
|
||||
):
|
||||
self.login(username="admin")
|
||||
dbobj = self.create_fake_db()
|
||||
mock_can_access_all_datasources.return_value = False
|
||||
mock_can_access_database.return_value = False
|
||||
mock_schemas_accessible.return_value = ["this_schema_is_allowed_too"]
|
||||
data = self.get_json_resp(
|
||||
url="/superset/schemas_access_for_file_upload?db_id={db_id}".format(
|
||||
db_id=dbobj.id
|
||||
)
|
||||
)
|
||||
assert data == ["this_schema_is_allowed_too"]
|
||||
self.delete_fake_db()
|
||||
|
||||
def test_results_default_deserialization(self):
|
||||
use_new_deserialization = False
|
||||
data = [("a", 4, 4.0, "2019-08-18T16:39:16.660000")]
|
||||
|
||||
Reference in New Issue
Block a user