Do not show stacktraces on some intentionally-thrown errors (#9056)

* Do not show stacktraces on some intentionally-thrown errors

* Fix pylint error

* Fix JavaScript looking for the wrong key in error response from connection check

* format -> f-string

* Run black because PyCharm missed it on the last save
This commit is contained in:
Will Barrett
2020-02-04 21:01:43 -08:00
committed by GitHub
parent 6cb4ce0e19
commit fc1c9428e3
4 changed files with 31 additions and 25 deletions

View File

@@ -418,6 +418,26 @@ class CoreTests(SupersetTestCase):
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": "Connection failed!\n\nThe error message returned was:\nCan't load plugin: sqlalchemy.dialects:broken"
}
assert response_body == expected_body, "%s != %s" % (
response_body,
expected_body,
)
def test_custom_password_store(self):
database = utils.get_example_database()
conn_pre = sqla.engine.url.make_url(database.sqlalchemy_uri_decrypted)