We are getting 500 errors when a POST notification has characters that can not be decoded or the json is malformed.

The exception is wrapped and a sensible error message is returned to the client.
This commit is contained in:
Rebecca Law
2018-06-25 16:58:35 +01:00
parent e1a7d99c72
commit 13155e24dc
2 changed files with 18 additions and 3 deletions

View File

@@ -839,3 +839,12 @@ def test_post_notification_without_document_upload_permission(client, notify_db,
headers=[('Content-Type', 'application/json'), auth_header])
assert response.status_code == 400, response.get_data(as_text=True)
def test_post_notification_returns_400_when_get_json_throws_exception(client, sample_email_template, rmock, mocker):
auth_header = create_authorization_header(service_id=sample_email_template.service_id)
response = client.post(
path="v2/notifications/email",
data="[",
headers=[('Content-Type', 'application/json'), auth_header])
assert response.status_code == 400