mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-12 17:34:16 -04:00
Merge pull request #3479 from alphagov/guest-list
Rename ‘whitelist’ to ‘guest list’
This commit is contained in:
@@ -1241,26 +1241,26 @@ class PDFUploadForm(StripWhitespaceForm):
|
||||
)
|
||||
|
||||
|
||||
class EmailFieldInWhitelist(EmailField, StripWhitespaceStringField):
|
||||
class EmailFieldInGuestList(EmailField, StripWhitespaceStringField):
|
||||
pass
|
||||
|
||||
|
||||
class InternationalPhoneNumberInWhitelist(InternationalPhoneNumber, StripWhitespaceStringField):
|
||||
class InternationalPhoneNumberInGuestList(InternationalPhoneNumber, StripWhitespaceStringField):
|
||||
pass
|
||||
|
||||
|
||||
class Whitelist(StripWhitespaceForm):
|
||||
class GuestList(StripWhitespaceForm):
|
||||
|
||||
def populate(self, email_addresses, phone_numbers):
|
||||
for form_field, existing_whitelist in (
|
||||
for form_field, existing_guest_list in (
|
||||
(self.email_addresses, email_addresses),
|
||||
(self.phone_numbers, phone_numbers)
|
||||
):
|
||||
for index, value in enumerate(existing_whitelist):
|
||||
for index, value in enumerate(existing_guest_list):
|
||||
form_field[index].data = value
|
||||
|
||||
email_addresses = FieldList(
|
||||
EmailFieldInWhitelist(
|
||||
EmailFieldInGuestList(
|
||||
'',
|
||||
validators=[
|
||||
Optional(),
|
||||
@@ -1274,7 +1274,7 @@ class Whitelist(StripWhitespaceForm):
|
||||
)
|
||||
|
||||
phone_numbers = FieldList(
|
||||
InternationalPhoneNumberInWhitelist(
|
||||
InternationalPhoneNumberInGuestList(
|
||||
'',
|
||||
validators=[
|
||||
Optional()
|
||||
|
||||
@@ -18,9 +18,9 @@ from app import (
|
||||
from app.main import main
|
||||
from app.main.forms import (
|
||||
CreateKeyForm,
|
||||
GuestList,
|
||||
ServiceDeliveryStatusCallbackForm,
|
||||
ServiceReceiveMessagesCallbackForm,
|
||||
Whitelist,
|
||||
)
|
||||
from app.notify_client.api_key_api_client import (
|
||||
KEY_TYPE_NORMAL,
|
||||
@@ -52,21 +52,22 @@ def api_documentation(service_id):
|
||||
return redirect(url_for('.documentation'), code=301)
|
||||
|
||||
|
||||
@main.route("/services/<uuid:service_id>/api/whitelist", methods=['GET', 'POST'])
|
||||
@main.route("/services/<uuid:service_id>/api/whitelist", methods=['GET', 'POST'], endpoint='old_guest_list')
|
||||
@main.route("/services/<uuid:service_id>/api/guest-list", methods=['GET', 'POST'])
|
||||
@user_has_permissions('manage_api_keys')
|
||||
def whitelist(service_id):
|
||||
form = Whitelist()
|
||||
def guest_list(service_id):
|
||||
form = GuestList()
|
||||
if form.validate_on_submit():
|
||||
service_api_client.update_whitelist(service_id, {
|
||||
service_api_client.update_guest_list(service_id, {
|
||||
'email_addresses': list(filter(None, form.email_addresses.data)),
|
||||
'phone_numbers': list(filter(None, form.phone_numbers.data))
|
||||
})
|
||||
flash('Whitelist updated', 'default_with_tick')
|
||||
flash('Guest list updated', 'default_with_tick')
|
||||
return redirect(url_for('.api_integration', service_id=service_id))
|
||||
if not form.errors:
|
||||
form.populate(**service_api_client.get_whitelist(service_id))
|
||||
form.populate(**service_api_client.get_guest_list(service_id))
|
||||
return render_template(
|
||||
'views/api/whitelist.html',
|
||||
'views/api/guest-list.html',
|
||||
form=form
|
||||
)
|
||||
|
||||
@@ -85,7 +86,7 @@ def create_api_key(service_id):
|
||||
form = CreateKeyForm(current_service.api_keys)
|
||||
form.key_type.choices = [
|
||||
(KEY_TYPE_NORMAL, 'Live – sends to anyone'),
|
||||
(KEY_TYPE_TEAM, 'Team and whitelist – limits who you can send to'),
|
||||
(KEY_TYPE_TEAM, 'Team and guest list – limits who you can send to'),
|
||||
(KEY_TYPE_TEST, 'Test – pretends to send messages'),
|
||||
]
|
||||
disabled_options, option_hints = [], {}
|
||||
|
||||
@@ -348,7 +348,8 @@ class HeaderNavigation(Navigation):
|
||||
'view_template_version',
|
||||
'no_cookie.view_template_version_preview',
|
||||
'view_template_versions',
|
||||
'whitelist',
|
||||
'guest_list',
|
||||
'old_guest_list',
|
||||
'who_can_use_notify',
|
||||
'who_its_for',
|
||||
}
|
||||
@@ -480,7 +481,8 @@ class MainNavigation(Navigation):
|
||||
'delivery_status_callback',
|
||||
'received_text_messages_callback',
|
||||
'revoke_api_key',
|
||||
'whitelist',
|
||||
'guest_list',
|
||||
'old_guest_list',
|
||||
},
|
||||
}
|
||||
|
||||
@@ -975,7 +977,8 @@ class CaseworkNavigation(Navigation):
|
||||
'view_template_version',
|
||||
'no_cookie.view_template_version_preview',
|
||||
'view_template_versions',
|
||||
'whitelist',
|
||||
'guest_list',
|
||||
'old_guest_list',
|
||||
'who_can_use_notify',
|
||||
'who_its_for',
|
||||
}
|
||||
@@ -1285,7 +1288,8 @@ class OrgNavigation(Navigation):
|
||||
'view_template_version',
|
||||
'no_cookie.view_template_version_preview',
|
||||
'view_template_versions',
|
||||
'whitelist',
|
||||
'guest_list',
|
||||
'old_guest_list',
|
||||
'who_can_use_notify',
|
||||
'who_its_for',
|
||||
}
|
||||
|
||||
@@ -326,11 +326,11 @@ class ServiceAPIClient(NotifyAdminAPIClient):
|
||||
def get_monthly_notification_stats(self, service_id, year):
|
||||
return self.get(url='/service/{}/notifications/monthly?year={}'.format(service_id, year))
|
||||
|
||||
def get_whitelist(self, service_id):
|
||||
def get_guest_list(self, service_id):
|
||||
return self.get(url='/service/{}/whitelist'.format(service_id))
|
||||
|
||||
@cache.delete('service-{service_id}')
|
||||
def update_whitelist(self, service_id, data):
|
||||
def update_guest_list(self, service_id, data):
|
||||
return self.put(url='/service/{}/whitelist'.format(service_id), data=data)
|
||||
|
||||
def get_inbound_sms(self, service_id, user_number=''):
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
{% from "components/form.html" import form_wrapper %}
|
||||
|
||||
{% block service_page_title %}
|
||||
Whitelist
|
||||
Guest list
|
||||
{% endblock %}
|
||||
|
||||
{% block maincolumn_content %}
|
||||
@@ -16,7 +16,7 @@
|
||||
{% if form.email_addresses.errors or form.phone_numbers.errors %}
|
||||
{% call banner_wrapper(type='dangerous') %}
|
||||
<h1 class='banner-title'>
|
||||
There was a problem with your whitelist
|
||||
There was a problem with your guest list
|
||||
</h1>
|
||||
<p class="govuk-body">Fix these errors:</p>
|
||||
<ul>
|
||||
@@ -34,7 +34,7 @@
|
||||
{% endcall %}
|
||||
{% else %}
|
||||
{{ page_header(
|
||||
'Whitelist',
|
||||
'Guest list',
|
||||
back_link=url_for('main.api_integration', service_id=current_service.id)
|
||||
) }}
|
||||
{% endif %}
|
||||
@@ -42,7 +42,7 @@
|
||||
<p class="govuk-body">
|
||||
You and members of
|
||||
<a class="govuk-link govuk-link--no-visited-state" href="{{ url_for('main.manage_users', service_id=current_service.id) }}">your team</a>
|
||||
are included in the whitelist automatically.
|
||||
are included in the guest list automatically.
|
||||
</p>
|
||||
|
||||
{% call form_wrapper() %}
|
||||
@@ -19,7 +19,7 @@
|
||||
<a class="govuk-link govuk-link--no-visited-state pill-separate-item" href="{{ url_for('.api_keys', service_id=current_service.id) }}">API keys</a>
|
||||
</div>
|
||||
<div class="govuk-grid-column-one-third">
|
||||
<a class="govuk-link govuk-link--no-visited-state pill-separate-item" href="{{ url_for('.whitelist', service_id=current_service.id) }}">Whitelist</a>
|
||||
<a class="govuk-link govuk-link--no-visited-state pill-separate-item" href="{{ url_for('.guest_list', service_id=current_service.id) }}">Guest list</a>
|
||||
</div>
|
||||
<div class="govuk-grid-column-one-third">
|
||||
<a class="govuk-link govuk-link--no-visited-state pill-separate-item" href="{{ url_for(callbacks_link, service_id=current_service.id) }}">Callbacks</a>
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
{% if item.key_type == 'normal' %}
|
||||
Live – sends to anyone
|
||||
{% elif item.key_type == 'team' %}
|
||||
Team and whitelist – limits who you can send to
|
||||
Team and guest list – limits who you can send to
|
||||
{% elif item.key_type == 'test' %}
|
||||
Test – pretends to send messages
|
||||
{% endif %}
|
||||
|
||||
@@ -314,7 +314,7 @@ def test_should_return_form_errors_with_duplicate_service_name_regardless_of_cas
|
||||
)
|
||||
|
||||
|
||||
def test_non_whitelist_user_cannot_access_create_service_page(
|
||||
def test_non_government_user_cannot_access_create_service_page(
|
||||
client_request,
|
||||
mock_get_non_govuser,
|
||||
api_nongov_user_active,
|
||||
@@ -327,7 +327,7 @@ def test_non_whitelist_user_cannot_access_create_service_page(
|
||||
)
|
||||
|
||||
|
||||
def test_non_whitelist_user_cannot_create_service(
|
||||
def test_non_government_user_cannot_create_service(
|
||||
client_request,
|
||||
mock_get_non_govuser,
|
||||
api_nongov_user_active,
|
||||
|
||||
@@ -208,18 +208,18 @@ def test_should_show_api_keys_page(
|
||||
'Live – sends to anyone '
|
||||
'Not available because your service is in trial mode'
|
||||
),
|
||||
'Team and whitelist – limits who you can send to',
|
||||
'Team and guest list – limits who you can send to',
|
||||
'Test – pretends to send messages',
|
||||
]),
|
||||
(False, False, [
|
||||
'Live – sends to anyone',
|
||||
'Team and whitelist – limits who you can send to',
|
||||
'Team and guest list – limits who you can send to',
|
||||
'Test – pretends to send messages',
|
||||
]),
|
||||
(False, True, [
|
||||
'Live – sends to anyone',
|
||||
(
|
||||
'Team and whitelist – limits who you can send to '
|
||||
'Team and guest list – limits who you can send to '
|
||||
'Cannot be used to send letters'
|
||||
),
|
||||
'Test – pretends to send messages',
|
||||
@@ -418,10 +418,10 @@ def test_should_show_whitelist_page(
|
||||
api_user_active,
|
||||
mock_get_service,
|
||||
mock_has_permissions,
|
||||
mock_get_whitelist,
|
||||
mock_get_guest_list,
|
||||
):
|
||||
page = client_request.get(
|
||||
'main.whitelist',
|
||||
'main.guest_list',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
)
|
||||
textboxes = page.find_all('input', {'type': 'text'})
|
||||
@@ -433,7 +433,7 @@ def test_should_show_whitelist_page(
|
||||
|
||||
def test_should_update_whitelist(
|
||||
client_request,
|
||||
mock_update_whitelist,
|
||||
mock_update_guest_list,
|
||||
):
|
||||
data = OrderedDict([
|
||||
('email_addresses-1', 'test@example.com'),
|
||||
@@ -443,23 +443,23 @@ def test_should_update_whitelist(
|
||||
])
|
||||
|
||||
client_request.post(
|
||||
'main.whitelist',
|
||||
'main.guest_list',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
_data=data,
|
||||
)
|
||||
|
||||
mock_update_whitelist.assert_called_once_with(SERVICE_ONE_ID, {
|
||||
mock_update_guest_list.assert_called_once_with(SERVICE_ONE_ID, {
|
||||
'email_addresses': ['test@example.com', 'test@example.com'],
|
||||
'phone_numbers': ['07900900000', '+1800-555-555']})
|
||||
|
||||
|
||||
def test_should_validate_whitelist_items(
|
||||
client_request,
|
||||
mock_update_whitelist,
|
||||
mock_update_guest_list,
|
||||
):
|
||||
|
||||
page = client_request.post(
|
||||
'main.whitelist',
|
||||
'main.guest_list',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
_data=OrderedDict([
|
||||
('email_addresses-1', 'abc'),
|
||||
@@ -468,7 +468,7 @@ def test_should_validate_whitelist_items(
|
||||
_expected_status=200,
|
||||
)
|
||||
|
||||
assert page.h1.string.strip() == 'There was a problem with your whitelist'
|
||||
assert page.h1.string.strip() == 'There was a problem with your guest list'
|
||||
jump_links = page.select('.banner-dangerous a')
|
||||
|
||||
assert jump_links[0].string.strip() == 'Enter valid email addresses'
|
||||
@@ -477,7 +477,7 @@ def test_should_validate_whitelist_items(
|
||||
assert jump_links[1].string.strip() == 'Enter valid phone numbers'
|
||||
assert jump_links[1]['href'] == '#phone_numbers'
|
||||
|
||||
assert mock_update_whitelist.called is False
|
||||
assert mock_update_guest_list.called is False
|
||||
|
||||
|
||||
@pytest.mark.parametrize('endpoint', [
|
||||
|
||||
@@ -15,7 +15,7 @@ def test_should_render_forgot_password(client):
|
||||
|
||||
@pytest.mark.parametrize('email_address', [
|
||||
'test@user.gov.uk',
|
||||
'someuser@notonwhitelist.com'
|
||||
'someuser@notgovernment.com'
|
||||
])
|
||||
def test_should_redirect_to_password_reset_sent_for_valid_email(
|
||||
client,
|
||||
|
||||
@@ -684,7 +684,7 @@ def test_should_show_folder_permission_form_if_service_has_folder_permissions_en
|
||||
|
||||
@pytest.mark.parametrize('email_address, gov_user', [
|
||||
('test@example.gov.uk', True),
|
||||
('test@nonwhitelist.com', False)
|
||||
('test@example.com', False)
|
||||
])
|
||||
def test_invite_user(
|
||||
client_request,
|
||||
@@ -735,7 +735,7 @@ def test_invite_user(
|
||||
])
|
||||
@pytest.mark.parametrize('email_address, gov_user', [
|
||||
('test@example.gov.uk', True),
|
||||
('test@nonwhitelist.com', False)
|
||||
('test@example.com', False)
|
||||
])
|
||||
def test_invite_user_with_email_auth_service(
|
||||
client_request,
|
||||
|
||||
@@ -393,7 +393,7 @@ def test_returns_value_from_cache(
|
||||
(service_api_client, 'suspend_service', [SERVICE_ONE_ID], {}),
|
||||
(service_api_client, 'resume_service', [SERVICE_ONE_ID], {}),
|
||||
(service_api_client, 'remove_user_from_service', [SERVICE_ONE_ID, ''], {}),
|
||||
(service_api_client, 'update_whitelist', [SERVICE_ONE_ID, {}], {}),
|
||||
(service_api_client, 'update_guest_list', [SERVICE_ONE_ID, {}], {}),
|
||||
(service_api_client, 'create_service_inbound_api', [SERVICE_ONE_ID] + [''] * 3, {}),
|
||||
(service_api_client, 'update_service_inbound_api', [SERVICE_ONE_ID] + [''] * 4, {}),
|
||||
(service_api_client, 'add_reply_to_email_address', [SERVICE_ONE_ID, ''], {}),
|
||||
|
||||
@@ -1152,7 +1152,7 @@ def api_nongov_user_active(fake_uuid):
|
||||
'id': fake_uuid,
|
||||
'name': 'Test User',
|
||||
'password': 'somepassword',
|
||||
'email_address': 'someuser@notonwhitelist.com',
|
||||
'email_address': 'someuser@example.com',
|
||||
'mobile_number': '07700 900762',
|
||||
'state': 'active',
|
||||
'failed_login_count': 0,
|
||||
@@ -1414,7 +1414,7 @@ def mock_register_user(mocker, api_user_pending):
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def mock_get_non_govuser(mocker, api_user_active):
|
||||
api_user_active['email_address'] = 'someuser@notonwhitelist.com'
|
||||
api_user_active['email_address'] = 'someuser@example.com'
|
||||
|
||||
def _get_user(id_):
|
||||
api_user_active['id'] = id_
|
||||
@@ -2827,22 +2827,22 @@ def mock_update_email_branding(mocker):
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def mock_get_whitelist(mocker):
|
||||
def _get_whitelist(service_id):
|
||||
def mock_get_guest_list(mocker):
|
||||
def _get_guest_list(service_id):
|
||||
return {
|
||||
'email_addresses': ['test@example.com'],
|
||||
'phone_numbers': ['07900900000']
|
||||
}
|
||||
|
||||
return mocker.patch(
|
||||
'app.service_api_client.get_whitelist', side_effect=_get_whitelist
|
||||
'app.service_api_client.get_guest_list', side_effect=_get_guest_list
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def mock_update_whitelist(mocker):
|
||||
def mock_update_guest_list(mocker):
|
||||
return mocker.patch(
|
||||
'app.service_api_client.update_whitelist'
|
||||
'app.service_api_client.update_guest_list'
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user