Merge pull request #707 from alphagov/loosen-get-notification-key-restriction

Loosen key restriction on get notification
This commit is contained in:
Chris Hill-Scott
2016-10-11 10:40:02 +01:00
committed by GitHub
2 changed files with 3 additions and 6 deletions

View File

@@ -159,7 +159,7 @@ def process_firetext_response():
def get_notification_by_id(notification_id): def get_notification_by_id(notification_id):
notification = notifications_dao.get_notification_with_personalisation(str(api_user.service_id), notification = notifications_dao.get_notification_with_personalisation(str(api_user.service_id),
notification_id, notification_id,
key_type=api_user.key_type) key_type=None)
return jsonify(data={"notification": notification_with_personalisation_schema.dump(notification).data}), 200 return jsonify(data={"notification": notification_with_personalisation_schema.dump(notification).data}), 200

View File

@@ -93,7 +93,7 @@ def test_get_notifications_empty_result(notify_api, sample_api_key):
(KEY_TYPE_TEAM, KEY_TYPE_NORMAL), (KEY_TYPE_TEAM, KEY_TYPE_NORMAL),
(KEY_TYPE_TEAM, KEY_TYPE_TEST), (KEY_TYPE_TEAM, KEY_TYPE_TEST),
]) ])
def test_get_notification_from_different_api_key_fails( def test_get_notification_from_different_api_key_works(
notify_api, notify_api,
sample_notification, sample_notification,
api_key_type, api_key_type,
@@ -110,10 +110,7 @@ def test_get_notification_from_different_api_key_fails(
response = client.get( response = client.get(
path='/notifications/{}'.format(sample_notification.id), path='/notifications/{}'.format(sample_notification.id),
headers=_create_auth_header_from_key(api_key)) headers=_create_auth_header_from_key(api_key))
notification = json.loads(response.get_data(as_text=True)) assert response.status_code == 200
assert response.status_code == 404
assert notification['result'] == "error"
assert notification['message'] == "No result found"
@pytest.mark.parametrize('key_type', [KEY_TYPE_NORMAL, KEY_TYPE_TEAM, KEY_TYPE_TEST]) @pytest.mark.parametrize('key_type', [KEY_TYPE_NORMAL, KEY_TYPE_TEAM, KEY_TYPE_TEST])