mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-05 02:41:14 -05:00
Remove whitelist from URLs
The admin app is now[1] using the newer, `…/guest-list` URLs, so we can remove the older, deprecated, `…/whitelist` ones. *** 1. https://github.com/alphagov/notifications-admin/pull/3536
This commit is contained in:
@@ -560,7 +560,6 @@ def get_detailed_services(start_date, end_date, only_active=False, include_from_
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
@service_blueprint.route('/<uuid:service_id>/whitelist', methods=['GET'])
|
|
||||||
@service_blueprint.route('/<uuid:service_id>/guest-list', methods=['GET'])
|
@service_blueprint.route('/<uuid:service_id>/guest-list', methods=['GET'])
|
||||||
def get_guest_list(service_id):
|
def get_guest_list(service_id):
|
||||||
from app.models import (EMAIL_TYPE, MOBILE_TYPE)
|
from app.models import (EMAIL_TYPE, MOBILE_TYPE)
|
||||||
@@ -578,7 +577,6 @@ def get_guest_list(service_id):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@service_blueprint.route('/<uuid:service_id>/whitelist', methods=['PUT'])
|
|
||||||
@service_blueprint.route('/<uuid:service_id>/guest-list', methods=['PUT'])
|
@service_blueprint.route('/<uuid:service_id>/guest-list', methods=['PUT'])
|
||||||
def update_guest_list(service_id):
|
def update_guest_list(service_id):
|
||||||
# doesn't commit so if there are any errors, we preserve old values in db
|
# doesn't commit so if there are any errors, we preserve old values in db
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import pytest
|
|
||||||
import uuid
|
import uuid
|
||||||
import json
|
import json
|
||||||
|
|
||||||
@@ -11,14 +10,10 @@ from app.models import (
|
|||||||
from app.dao.service_guest_list_dao import dao_add_and_commit_guest_list_contacts
|
from app.dao.service_guest_list_dao import dao_add_and_commit_guest_list_contacts
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('url_path', (
|
def test_get_guest_list_returns_data(client, sample_service_guest_list):
|
||||||
'service/{}/whitelist',
|
|
||||||
'service/{}/guest-list',
|
|
||||||
))
|
|
||||||
def test_get_guest_list_returns_data(client, sample_service_guest_list, url_path):
|
|
||||||
service_id = sample_service_guest_list.service_id
|
service_id = sample_service_guest_list.service_id
|
||||||
|
|
||||||
response = client.get(url_path.format(service_id), headers=[create_authorization_header()])
|
response = client.get(f'service/{service_id}/guest-list', headers=[create_authorization_header()])
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert json.loads(response.get_data(as_text=True)) == {
|
assert json.loads(response.get_data(as_text=True)) == {
|
||||||
'email_addresses': [sample_service_guest_list.recipient],
|
'email_addresses': [sample_service_guest_list.recipient],
|
||||||
@@ -59,18 +54,14 @@ def test_get_guest_list_returns_no_data(client, sample_service):
|
|||||||
assert json.loads(response.get_data(as_text=True)) == {'email_addresses': [], 'phone_numbers': []}
|
assert json.loads(response.get_data(as_text=True)) == {'email_addresses': [], 'phone_numbers': []}
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('url_path', (
|
def test_update_guest_list_replaces_old_guest_list(client, sample_service_guest_list):
|
||||||
'service/{}/whitelist',
|
|
||||||
'service/{}/guest-list',
|
|
||||||
))
|
|
||||||
def test_update_guest_list_replaces_old_guest_list(client, sample_service_guest_list, url_path):
|
|
||||||
data = {
|
data = {
|
||||||
'email_addresses': ['foo@bar.com'],
|
'email_addresses': ['foo@bar.com'],
|
||||||
'phone_numbers': ['07123456789']
|
'phone_numbers': ['07123456789']
|
||||||
}
|
}
|
||||||
|
|
||||||
response = client.put(
|
response = client.put(
|
||||||
url_path.format(sample_service_guest_list.service_id),
|
f'service/{sample_service_guest_list.service_id}/guest-list',
|
||||||
data=json.dumps(data),
|
data=json.dumps(data),
|
||||||
headers=[('Content-Type', 'application/json'), create_authorization_header()]
|
headers=[('Content-Type', 'application/json'), create_authorization_header()]
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user