2017-11-14 11:31:20 +00:00
|
|
|
|
from functools import partial
|
2023-12-20 10:44:38 -05:00
|
|
|
|
from unittest.mock import Mock, PropertyMock, call
|
2022-12-05 15:33:44 -05:00
|
|
|
|
from uuid import uuid4
|
2016-10-26 18:37:26 +01:00
|
|
|
|
|
2016-04-26 13:31:57 +01:00
|
|
|
|
import pytest
|
2017-08-15 13:34:29 +01:00
|
|
|
|
from flask import url_for
|
2018-02-20 11:22:17 +00:00
|
|
|
|
from freezegun import freeze_time
|
2018-04-25 14:12:58 +01:00
|
|
|
|
|
|
|
|
|
|
import app
|
2025-07-21 16:37:55 -07:00
|
|
|
|
from app.enums import ServicePermission
|
2025-06-10 11:40:14 -07:00
|
|
|
|
from notifications_python_client.errors import HTTPError
|
2019-02-19 17:26:16 +00:00
|
|
|
|
from tests import (
|
2020-02-17 15:36:46 +00:00
|
|
|
|
find_element_by_tag_and_partial_text,
|
2023-07-12 12:09:44 -04:00
|
|
|
|
organization_json,
|
2019-02-19 17:26:16 +00:00
|
|
|
|
sample_uuid,
|
|
|
|
|
|
service_json,
|
|
|
|
|
|
validate_route_permission,
|
|
|
|
|
|
)
|
2018-02-20 11:22:17 +00:00
|
|
|
|
from tests.conftest import (
|
2019-02-19 17:26:16 +00:00
|
|
|
|
ORGANISATION_ID,
|
2018-02-20 11:22:17 +00:00
|
|
|
|
SERVICE_ONE_ID,
|
2019-05-14 13:37:16 +01:00
|
|
|
|
TEMPLATE_ONE_ID,
|
2019-12-19 16:59:07 +00:00
|
|
|
|
create_active_user_no_api_key_permission,
|
|
|
|
|
|
create_active_user_no_settings_permission,
|
|
|
|
|
|
create_active_user_with_permissions,
|
2019-12-20 14:34:45 +00:00
|
|
|
|
create_multiple_email_reply_to_addresses,
|
|
|
|
|
|
create_multiple_sms_senders,
|
2019-12-19 16:59:07 +00:00
|
|
|
|
create_platform_admin_user,
|
2019-12-20 14:34:45 +00:00
|
|
|
|
create_reply_to_email_address,
|
|
|
|
|
|
create_sms_sender,
|
2018-02-20 11:22:17 +00:00
|
|
|
|
normalize_spaces,
|
|
|
|
|
|
)
|
2016-03-30 17:12:00 +01:00
|
|
|
|
|
2019-01-23 10:16:43 +00:00
|
|
|
|
FAKE_TEMPLATE_ID = uuid4()
|
|
|
|
|
|
|
2017-04-19 16:11:28 +01:00
|
|
|
|
|
2024-07-15 08:07:18 -07:00
|
|
|
|
@pytest.fixture
|
2023-09-29 16:37:11 -04:00
|
|
|
|
def _mock_get_service_settings_page_common(
|
2017-11-09 13:18:09 +00:00
|
|
|
|
mock_get_inbound_number_for_service,
|
|
|
|
|
|
mock_get_free_sms_fragment_limit,
|
2018-07-17 14:39:04 +01:00
|
|
|
|
mock_get_service_data_retention,
|
2023-07-12 12:09:44 -04:00
|
|
|
|
mock_get_organization,
|
2017-11-09 13:18:09 +00:00
|
|
|
|
):
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-09-29 16:37:11 -04:00
|
|
|
|
@pytest.mark.usefixtures("_mock_get_service_settings_page_common")
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("user", "expected_rows"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
(
|
|
|
|
|
|
create_active_user_with_permissions(),
|
|
|
|
|
|
[
|
2023-10-03 15:28:27 -04:00
|
|
|
|
"",
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"Service name Test Service Change service name",
|
2025-06-16 15:56:43 -07:00
|
|
|
|
"Send text messages On",
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"Start text messages with service name On Change your settings "
|
|
|
|
|
|
"for starting text messages with service name",
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
(
|
|
|
|
|
|
create_platform_admin_user(),
|
|
|
|
|
|
[
|
2023-10-03 15:28:27 -04:00
|
|
|
|
"",
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"Service name Test Service Change service name",
|
2025-06-16 15:56:43 -07:00
|
|
|
|
"Send text messages On",
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"Text message senders (Only visible to Platform Admins) GOVUK Manage text message senders",
|
|
|
|
|
|
"Start text messages with service name On Change your settings "
|
|
|
|
|
|
"for starting text messages with service name",
|
|
|
|
|
|
"Send international text messages Off Change your settings for sending international text messages",
|
|
|
|
|
|
"Label Value Action",
|
|
|
|
|
|
"Live Off Change service status",
|
|
|
|
|
|
"Count in list of live services Yes Change if service is counted in list of live services",
|
|
|
|
|
|
"Billing details None Change billing details for service",
|
|
|
|
|
|
"Notes None Change the notes for the service",
|
|
|
|
|
|
"Organization Test organization Federal government Change organization for service",
|
|
|
|
|
|
"Rate limit 3,000 per minute Change rate limit",
|
2023-12-06 12:26:33 -07:00
|
|
|
|
"Message batch limit 1,000 per send Change message batch limit",
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"Free text message allowance 250,000 per year Change free text message allowance",
|
|
|
|
|
|
"Custom data retention Email – 7 days Change data retention",
|
|
|
|
|
|
"Receive inbound SMS Off Change your settings for Receive inbound SMS",
|
|
|
|
|
|
"Email authentication Off Change your settings for Email authentication",
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2016-08-22 11:43:35 +01:00
|
|
|
|
def test_should_show_overview(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
client_request,
|
|
|
|
|
|
mocker,
|
|
|
|
|
|
api_user_active,
|
|
|
|
|
|
no_reply_to_email_addresses,
|
|
|
|
|
|
single_sms_sender,
|
|
|
|
|
|
user,
|
|
|
|
|
|
expected_rows,
|
2016-08-22 11:43:35 +01:00
|
|
|
|
):
|
2020-02-25 11:27:43 +00:00
|
|
|
|
service_one = service_json(
|
|
|
|
|
|
SERVICE_ONE_ID,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
users=[api_user_active["id"]],
|
|
|
|
|
|
permissions=["sms", "email"],
|
2023-07-12 12:09:44 -04:00
|
|
|
|
organization_id=ORGANISATION_ID,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
contact_link="contact_us@gsa.gov",
|
|
|
|
|
|
)
|
|
|
|
|
|
mocker.patch(
|
|
|
|
|
|
"app.service_api_client.get_service", return_value={"data": service_one}
|
2020-02-25 11:27:43 +00:00
|
|
|
|
)
|
2017-06-26 15:22:06 +01:00
|
|
|
|
|
2022-01-04 10:56:25 +00:00
|
|
|
|
client_request.login(user, service_one)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
page = client_request.get("main.service_settings", service_id=SERVICE_ONE_ID)
|
|
|
|
|
|
assert page.find("h1").text == "Settings"
|
|
|
|
|
|
rows = page.select("tr")
|
2017-04-19 16:11:28 +01:00
|
|
|
|
assert len(rows) == len(expected_rows)
|
|
|
|
|
|
for index, row in enumerate(expected_rows):
|
|
|
|
|
|
assert row == " ".join(rows[index].text.split())
|
2019-07-08 09:44:22 +01:00
|
|
|
|
app.service_api_client.get_service.assert_called_with(SERVICE_ONE_ID)
|
2016-08-22 11:43:35 +01:00
|
|
|
|
|
|
|
|
|
|
|
2023-09-29 16:37:11 -04:00
|
|
|
|
@pytest.mark.usefixtures("_mock_get_service_settings_page_common")
|
2023-07-12 12:09:44 -04:00
|
|
|
|
def test_organization_name_links_to_org_dashboard(
|
2019-07-08 09:44:22 +01:00
|
|
|
|
client_request,
|
|
|
|
|
|
platform_admin_user,
|
|
|
|
|
|
no_reply_to_email_addresses,
|
|
|
|
|
|
single_sms_sender,
|
|
|
|
|
|
mocker,
|
|
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
service_one = service_json(
|
|
|
|
|
|
SERVICE_ONE_ID, permissions=["sms", "email"], organization_id=ORGANISATION_ID
|
2019-07-08 09:44:22 +01:00
|
|
|
|
)
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mocker.patch(
|
|
|
|
|
|
"app.service_api_client.get_service", return_value={"data": service_one}
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
client_request.login(platform_admin_user, service_one)
|
|
|
|
|
|
response = client_request.get("main.service_settings", service_id=SERVICE_ONE_ID)
|
|
|
|
|
|
|
|
|
|
|
|
org_row = find_element_by_tag_and_partial_text(
|
|
|
|
|
|
response, tag="tr", string="Organization"
|
|
|
|
|
|
)
|
|
|
|
|
|
assert org_row.find("a")["href"] == url_for(
|
|
|
|
|
|
"main.organization_dashboard", org_id=ORGANISATION_ID
|
|
|
|
|
|
)
|
|
|
|
|
|
assert normalize_spaces(org_row.find("a").text) == "Test organization"
|
2019-07-08 09:44:22 +01:00
|
|
|
|
|
|
|
|
|
|
|
2022-12-02 10:30:37 -05:00
|
|
|
|
@pytest.mark.skip(reason="Email currently deactivated")
|
2023-09-29 16:37:11 -04:00
|
|
|
|
@pytest.mark.usefixtures("_mock_get_service_settings_page_common")
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("service_contact_link", "expected_text"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
(
|
|
|
|
|
|
"contact.me@gsa.gov",
|
|
|
|
|
|
"Send files by email contact.me@gsa.gov Manage sending files by email",
|
|
|
|
|
|
),
|
|
|
|
|
|
(None, "Send files by email Not set up Manage sending files by email"),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2020-02-25 11:27:43 +00:00
|
|
|
|
def test_send_files_by_email_row_on_settings_page(
|
|
|
|
|
|
client_request,
|
|
|
|
|
|
platform_admin_user,
|
|
|
|
|
|
no_reply_to_email_addresses,
|
|
|
|
|
|
single_sms_sender,
|
|
|
|
|
|
mocker,
|
|
|
|
|
|
service_contact_link,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
expected_text,
|
2020-02-25 11:27:43 +00:00
|
|
|
|
):
|
|
|
|
|
|
service_one = service_json(
|
|
|
|
|
|
SERVICE_ONE_ID,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
permissions=["sms", "email"],
|
2023-07-12 12:09:44 -04:00
|
|
|
|
organization_id=ORGANISATION_ID,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
contact_link=service_contact_link,
|
2020-02-25 11:27:43 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mocker.patch(
|
|
|
|
|
|
"app.service_api_client.get_service", return_value={"data": service_one}
|
|
|
|
|
|
)
|
2020-02-25 11:27:43 +00:00
|
|
|
|
|
|
|
|
|
|
client_request.login(platform_admin_user, service_one)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
response = client_request.get("main.service_settings", service_id=SERVICE_ONE_ID)
|
2020-02-25 11:27:43 +00:00
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
org_row = find_element_by_tag_and_partial_text(
|
|
|
|
|
|
response, tag="tr", string="Send files by email"
|
|
|
|
|
|
)
|
2020-02-25 11:27:43 +00:00
|
|
|
|
assert normalize_spaces(org_row.get_text()) == expected_text
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-09-29 16:37:11 -04:00
|
|
|
|
@pytest.mark.usefixtures("_mock_get_service_settings_page_common")
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("permissions", "expected_rows"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
(
|
|
|
|
|
|
["email", "sms", "international_sms"],
|
|
|
|
|
|
[
|
|
|
|
|
|
"Service name service one Change service name",
|
2025-06-16 15:56:43 -07:00
|
|
|
|
"Send text messages On",
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"Start text messages with service name On Change your settings "
|
|
|
|
|
|
"for starting text messages with service name",
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
(
|
2025-07-21 16:37:55 -07:00
|
|
|
|
["email", "sms", ServicePermission.EMAIL_AUTH],
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
"Service name service one Change service name",
|
2025-06-16 15:56:43 -07:00
|
|
|
|
"Send text messages On",
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"Start text messages with service name On Change your settings "
|
|
|
|
|
|
"for starting text messages with service name",
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2016-08-22 11:43:35 +01:00
|
|
|
|
def test_should_show_overview_for_service_with_more_things_set(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
client_request,
|
|
|
|
|
|
active_user_with_permissions,
|
|
|
|
|
|
mocker,
|
|
|
|
|
|
service_one,
|
|
|
|
|
|
single_reply_to_email_address,
|
|
|
|
|
|
single_sms_sender,
|
|
|
|
|
|
permissions,
|
|
|
|
|
|
expected_rows,
|
2016-08-22 11:43:35 +01:00
|
|
|
|
):
|
2022-01-04 10:56:25 +00:00
|
|
|
|
client_request.login(active_user_with_permissions)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
service_one["permissions"] = permissions
|
|
|
|
|
|
page = client_request.get("main.service_settings", service_id=service_one["id"])
|
2017-06-21 12:15:53 +01:00
|
|
|
|
for index, row in enumerate(expected_rows):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert row == " ".join(page.find_all("tr")[index + 1].text.split())
|
2016-01-07 12:29:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
2017-02-03 10:42:01 +00:00
|
|
|
|
def test_should_show_service_name(
|
2018-01-11 17:33:04 +00:00
|
|
|
|
client_request,
|
2017-02-03 10:42:01 +00:00
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
page = client_request.get("main.service_name_change", service_id=SERVICE_ONE_ID)
|
|
|
|
|
|
assert page.find("h1").text == "Change your service name"
|
|
|
|
|
|
assert page.find("input", attrs={"type": "text"})["value"] == "service one"
|
|
|
|
|
|
assert (
|
2023-08-28 12:12:21 -04:00
|
|
|
|
page.select_one("main .usa-body").text
|
2023-08-25 09:12:23 -07:00
|
|
|
|
== "Your service name should tell users what the message is about as well as who it’s from."
|
|
|
|
|
|
)
|
2023-07-21 08:24:10 -07:00
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert (
|
|
|
|
|
|
"The service name you enter here will appear at the beginning of each text message, unless"
|
|
|
|
|
|
in page.text
|
|
|
|
|
|
)
|
2023-07-21 08:24:10 -07:00
|
|
|
|
|
2018-01-11 17:33:04 +00:00
|
|
|
|
app.service_api_client.get_service.assert_called_with(SERVICE_ONE_ID)
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-07-01 12:16:32 +01:00
|
|
|
|
def test_should_show_different_change_service_name_page_for_local_services(
|
|
|
|
|
|
client_request,
|
|
|
|
|
|
service_one,
|
|
|
|
|
|
mocker,
|
|
|
|
|
|
):
|
|
|
|
|
|
mocker.patch(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"app.organizations_client.get_organization_by_domain",
|
|
|
|
|
|
return_value=organization_json(organization_type="local"),
|
2020-07-01 12:16:32 +01:00
|
|
|
|
)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
service_one["organization_type"] = "local"
|
|
|
|
|
|
page = client_request.get("main.service_name_change", service_id=SERVICE_ONE_ID)
|
|
|
|
|
|
assert page.find("h1").text == "Change your service name"
|
|
|
|
|
|
assert page.find("input", attrs={"type": "text"})["value"] == "service one"
|
2023-08-28 12:12:21 -04:00
|
|
|
|
assert page.select_one("main .usa-body").text.strip() == (
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"Your service name should tell users what the message is about as well as who it’s from. For example:"
|
2020-07-01 12:16:32 +01:00
|
|
|
|
)
|
2023-07-12 12:09:44 -04:00
|
|
|
|
# when no organization on the service object, default org for the user is used for hint
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert (
|
|
|
|
|
|
"School admissions - Test Org"
|
2023-08-28 12:12:21 -04:00
|
|
|
|
in page.find_all("ul", class_="usa-list usa-list--bullet")[0].text
|
2023-08-25 09:12:23 -07:00
|
|
|
|
)
|
2020-07-01 12:16:32 +01:00
|
|
|
|
|
|
|
|
|
|
app.service_api_client.get_service.assert_called_with(SERVICE_ONE_ID)
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-07-02 11:56:05 +01:00
|
|
|
|
def test_should_show_service_org_in_hint_on_change_service_name_page_for_local_services_if_service_has_org(
|
|
|
|
|
|
client_request,
|
|
|
|
|
|
service_one,
|
|
|
|
|
|
mocker,
|
|
|
|
|
|
):
|
|
|
|
|
|
mocker.patch(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"app.organizations_client.get_organization_by_domain",
|
|
|
|
|
|
return_value=organization_json(organization_type="local"),
|
2020-07-02 11:56:05 +01:00
|
|
|
|
)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mocker.patch(
|
|
|
|
|
|
"app.organizations_client.get_organization",
|
|
|
|
|
|
return_value=organization_json(
|
|
|
|
|
|
organization_type="local", name="Local Authority"
|
|
|
|
|
|
),
|
2020-07-02 11:56:05 +01:00
|
|
|
|
)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
service_one["organization_type"] = "local"
|
|
|
|
|
|
service_one["organization"] = "1234"
|
|
|
|
|
|
page = client_request.get("main.service_name_change", service_id=SERVICE_ONE_ID)
|
2023-07-12 12:09:44 -04:00
|
|
|
|
# when there is organization on the service object, it is used for hint text instead of user default org
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert (
|
|
|
|
|
|
"School admissions - Local Authority"
|
2023-08-28 12:12:21 -04:00
|
|
|
|
in page.find_all("ul", class_="usa-list usa-list--bullet")[0].text
|
2023-08-25 09:12:23 -07:00
|
|
|
|
)
|
2020-07-02 11:56:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
2018-01-11 17:33:04 +00:00
|
|
|
|
def test_should_show_service_name_with_no_prefixing(
|
|
|
|
|
|
client_request,
|
|
|
|
|
|
service_one,
|
|
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
service_one["prefix_sms"] = False
|
|
|
|
|
|
page = client_request.get("main.service_name_change", service_id=SERVICE_ONE_ID)
|
|
|
|
|
|
assert page.find("h1").text == "Change your service name"
|
|
|
|
|
|
assert (
|
2023-08-28 12:12:21 -04:00
|
|
|
|
page.select_one("main .usa-body").text
|
2023-08-25 09:12:23 -07:00
|
|
|
|
== "Your service name should tell users what the message is about as well as who it’s from."
|
|
|
|
|
|
)
|
2016-01-11 16:03:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("name", "error_message"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
("", "Cannot be empty"),
|
|
|
|
|
|
(".", "Must include at least two alphanumeric characters"),
|
|
|
|
|
|
("a" * 256, "Service name must be 255 characters or fewer"),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2020-11-30 17:08:40 +00:00
|
|
|
|
def test_service_name_change_fails_if_new_name_fails_validation(
|
2019-11-08 17:12:32 +00:00
|
|
|
|
client_request,
|
|
|
|
|
|
mock_update_service,
|
2020-11-30 17:08:40 +00:00
|
|
|
|
name,
|
|
|
|
|
|
error_message,
|
2019-11-08 17:12:32 +00:00
|
|
|
|
):
|
|
|
|
|
|
page = client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_name_change",
|
2019-11-08 17:12:32 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
_data={"name": name},
|
2019-11-08 17:12:32 +00:00
|
|
|
|
_expected_status=200,
|
|
|
|
|
|
)
|
|
|
|
|
|
assert not mock_update_service.called
|
2023-06-08 13:12:00 -04:00
|
|
|
|
assert error_message in page.find("span", {"class": "usa-error-message"}).text
|
2019-11-08 17:12:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
2023-09-29 16:37:11 -04:00
|
|
|
|
@pytest.mark.usefixtures("_mock_get_service_settings_page_common")
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("user", "expected_text", "expected_link"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
(
|
|
|
|
|
|
create_active_user_with_permissions(),
|
|
|
|
|
|
"To remove these restrictions, you can send us a request to go live.",
|
|
|
|
|
|
True,
|
|
|
|
|
|
),
|
|
|
|
|
|
(
|
|
|
|
|
|
create_active_user_no_settings_permission(),
|
|
|
|
|
|
"Your service manager can ask to have these restrictions removed.",
|
|
|
|
|
|
False,
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2016-09-05 14:01:28 +01:00
|
|
|
|
def test_show_restricted_service(
|
2019-03-26 12:35:32 +00:00
|
|
|
|
client_request,
|
2020-07-13 09:34:49 +01:00
|
|
|
|
service_one,
|
2018-02-22 13:13:57 +00:00
|
|
|
|
single_reply_to_email_address,
|
|
|
|
|
|
single_sms_sender,
|
|
|
|
|
|
user,
|
|
|
|
|
|
expected_text,
|
|
|
|
|
|
expected_link,
|
2016-09-05 14:01:28 +01:00
|
|
|
|
):
|
2019-12-19 16:59:07 +00:00
|
|
|
|
client_request.login(user)
|
2019-03-26 12:35:32 +00:00
|
|
|
|
page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_settings",
|
2019-03-26 12:35:32 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert page.find("h1").text == "Settings"
|
|
|
|
|
|
assert page.select("main h2")[0].text == "Your service is in trial mode"
|
2016-09-05 14:01:28 +01:00
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
request_to_live = page.select("main p")[1]
|
|
|
|
|
|
request_to_live_link = request_to_live.select_one("a")
|
2018-02-22 13:13:57 +00:00
|
|
|
|
assert normalize_spaces(request_to_live.text) == expected_text
|
|
|
|
|
|
|
|
|
|
|
|
if expected_link:
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert request_to_live_link.text.strip() == "request to go live"
|
|
|
|
|
|
email_address = "notify-support@gsa.gov"
|
|
|
|
|
|
assert request_to_live_link["href"] == f"mailto:{email_address}"
|
2018-02-22 13:13:57 +00:00
|
|
|
|
else:
|
|
|
|
|
|
assert not request_to_live_link
|
|
|
|
|
|
|
2016-09-05 14:01:28 +01:00
|
|
|
|
|
2022-09-13 13:34:45 -07:00
|
|
|
|
@freeze_time("2017-04-01 11:09:00.061258")
|
2016-08-24 09:34:14 +01:00
|
|
|
|
def test_switch_service_to_live(
|
2019-03-26 12:35:32 +00:00
|
|
|
|
client_request,
|
|
|
|
|
|
platform_admin_user,
|
|
|
|
|
|
mock_update_service,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mock_get_inbound_number_for_service,
|
2016-08-24 09:34:14 +01:00
|
|
|
|
):
|
2019-03-26 12:35:32 +00:00
|
|
|
|
client_request.login(platform_admin_user)
|
|
|
|
|
|
client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_switch_live",
|
2019-03-26 12:35:32 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
_data={"enabled": "True"},
|
2019-03-26 12:35:32 +00:00
|
|
|
|
_expected_status=302,
|
|
|
|
|
|
_expected_redirect=url_for(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_settings",
|
2019-03-26 12:35:32 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
),
|
2019-02-18 16:56:43 +00:00
|
|
|
|
)
|
2017-02-03 12:07:21 +00:00
|
|
|
|
mock_update_service.assert_called_with(
|
2019-03-26 12:35:32 +00:00
|
|
|
|
SERVICE_ONE_ID,
|
2017-02-03 12:07:21 +00:00
|
|
|
|
message_limit=250000,
|
2019-04-16 15:01:54 +01:00
|
|
|
|
restricted=False,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
go_live_at="2017-04-01 11:09:00.061258",
|
2017-02-03 12:07:21 +00:00
|
|
|
|
)
|
2016-04-14 15:38:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
2023-09-29 16:37:11 -04:00
|
|
|
|
@pytest.mark.usefixtures("_mock_get_service_settings_page_common")
|
2016-09-05 14:01:28 +01:00
|
|
|
|
def test_show_live_service(
|
2019-03-26 12:35:32 +00:00
|
|
|
|
client_request,
|
|
|
|
|
|
mock_get_live_service,
|
|
|
|
|
|
single_reply_to_email_address,
|
|
|
|
|
|
single_sms_sender,
|
2016-09-05 14:01:28 +01:00
|
|
|
|
):
|
2019-03-26 12:35:32 +00:00
|
|
|
|
page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_settings",
|
2019-03-26 12:35:32 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert page.find("h1").text.strip() == "Settings"
|
|
|
|
|
|
assert "Your service is in trial mode" not in page.text
|
2016-09-05 14:01:28 +01:00
|
|
|
|
|
|
|
|
|
|
|
2016-08-24 09:34:14 +01:00
|
|
|
|
def test_switch_service_to_restricted(
|
2019-03-26 12:35:32 +00:00
|
|
|
|
client_request,
|
|
|
|
|
|
platform_admin_user,
|
|
|
|
|
|
mock_get_live_service,
|
|
|
|
|
|
mock_update_service,
|
|
|
|
|
|
mock_get_inbound_number_for_service,
|
2016-08-24 09:34:14 +01:00
|
|
|
|
):
|
2019-03-26 12:35:32 +00:00
|
|
|
|
client_request.login(platform_admin_user)
|
|
|
|
|
|
client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_switch_live",
|
2019-03-26 12:35:32 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
_data={"enabled": "False"},
|
2019-03-26 12:35:32 +00:00
|
|
|
|
_expected_status=302,
|
|
|
|
|
|
_expected_response=url_for(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_settings",
|
2019-03-26 12:35:32 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
),
|
2019-02-18 16:56:43 +00:00
|
|
|
|
)
|
2017-02-03 12:07:21 +00:00
|
|
|
|
mock_update_service.assert_called_with(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
SERVICE_ONE_ID, message_limit=50, restricted=True, go_live_at=None
|
2017-02-03 12:07:21 +00:00
|
|
|
|
)
|
2016-04-14 15:38:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("count_as_live", "selected", "labelled"),
|
|
|
|
|
|
[
|
2023-08-25 09:12:23 -07:00
|
|
|
|
(True, "True", "Yes"),
|
|
|
|
|
|
(False, "False", "No"),
|
2023-09-29 16:37:11 -04:00
|
|
|
|
],
|
2023-08-25 09:12:23 -07:00
|
|
|
|
)
|
2019-03-25 14:46:42 +00:00
|
|
|
|
def test_show_switch_service_to_count_as_live_page(
|
|
|
|
|
|
mocker,
|
|
|
|
|
|
client_request,
|
|
|
|
|
|
platform_admin_user,
|
|
|
|
|
|
mock_update_service,
|
|
|
|
|
|
count_as_live,
|
|
|
|
|
|
selected,
|
|
|
|
|
|
labelled,
|
|
|
|
|
|
):
|
|
|
|
|
|
mocker.patch(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"app.models.service.Service.count_as_live",
|
2019-03-25 14:46:42 +00:00
|
|
|
|
create=True,
|
|
|
|
|
|
new_callable=PropertyMock,
|
|
|
|
|
|
return_value=count_as_live,
|
|
|
|
|
|
)
|
|
|
|
|
|
client_request.login(platform_admin_user)
|
|
|
|
|
|
page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_switch_count_as_live",
|
2019-03-25 14:46:42 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
)
|
2025-02-27 14:21:43 -05:00
|
|
|
|
|
|
|
|
|
|
client_request.login(platform_admin_user)
|
|
|
|
|
|
page = client_request.get(
|
|
|
|
|
|
"main.service_switch_count_as_live",
|
|
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
)
|
2019-03-25 14:46:42 +00:00
|
|
|
|
|
2025-02-27 14:21:43 -05:00
|
|
|
|
# Find the checked radio button
|
|
|
|
|
|
checked_input = page.select_one("[checked]")
|
|
|
|
|
|
|
|
|
|
|
|
# Ensure we actually found a checked input
|
|
|
|
|
|
assert checked_input is not None, "No checked radio button found"
|
|
|
|
|
|
|
|
|
|
|
|
# Check that the selected value is as expected
|
|
|
|
|
|
assert checked_input["value"] == selected
|
|
|
|
|
|
|
|
|
|
|
|
# Find all labels
|
|
|
|
|
|
labels = page.select("label.usa-radio__label")
|
|
|
|
|
|
|
|
|
|
|
|
# Extract label text and see if it matches the expected label
|
|
|
|
|
|
label_texts = [label.text.strip() for label in labels]
|
|
|
|
|
|
|
2025-03-13 21:49:40 -07:00
|
|
|
|
assert (
|
|
|
|
|
|
labelled in label_texts
|
|
|
|
|
|
), f"Expected label '{labelled}' not found. Found labels: {label_texts}"
|
2025-02-27 14:21:43 -05:00
|
|
|
|
|
2019-03-25 14:46:42 +00:00
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("post_data", "expected_persisted_value"),
|
|
|
|
|
|
[
|
2023-08-25 09:12:23 -07:00
|
|
|
|
("True", True),
|
|
|
|
|
|
("False", False),
|
2023-09-29 16:37:11 -04:00
|
|
|
|
],
|
2023-08-25 09:12:23 -07:00
|
|
|
|
)
|
2019-03-25 14:46:42 +00:00
|
|
|
|
def test_switch_service_to_count_as_live(
|
|
|
|
|
|
client_request,
|
|
|
|
|
|
platform_admin_user,
|
|
|
|
|
|
mock_update_service,
|
|
|
|
|
|
post_data,
|
|
|
|
|
|
expected_persisted_value,
|
|
|
|
|
|
):
|
|
|
|
|
|
client_request.login(platform_admin_user)
|
|
|
|
|
|
client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_switch_count_as_live",
|
2019-03-25 14:46:42 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
_data={"enabled": post_data},
|
2019-03-25 14:46:42 +00:00
|
|
|
|
_expected_status=302,
|
|
|
|
|
|
_expected_redirect=url_for(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_settings",
|
2019-03-25 14:46:42 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
),
|
2019-03-25 14:46:42 +00:00
|
|
|
|
)
|
|
|
|
|
|
mock_update_service.assert_called_with(
|
|
|
|
|
|
SERVICE_ONE_ID,
|
|
|
|
|
|
count_as_live=expected_persisted_value,
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-12-01 12:07:00 +00:00
|
|
|
|
def test_should_not_allow_duplicate_service_names(
|
2019-03-26 12:35:32 +00:00
|
|
|
|
client_request,
|
2021-12-01 12:07:00 +00:00
|
|
|
|
mock_update_service_raise_httperror_duplicate_name,
|
2019-03-26 12:35:32 +00:00
|
|
|
|
service_one,
|
2017-02-03 10:42:01 +00:00
|
|
|
|
):
|
2019-03-26 12:35:32 +00:00
|
|
|
|
page = client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_name_change",
|
2019-03-26 12:35:32 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
_data={"name": "SErvICE TWO"},
|
2019-03-26 12:35:32 +00:00
|
|
|
|
_expected_status=200,
|
|
|
|
|
|
)
|
2016-03-10 14:29:31 +00:00
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert "This service name is already in use" in page.text
|
2016-01-07 16:24:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
2021-12-07 14:30:56 +00:00
|
|
|
|
def test_should_redirect_after_service_name_change(
|
2019-03-26 12:35:32 +00:00
|
|
|
|
client_request,
|
|
|
|
|
|
mock_update_service,
|
2016-08-24 09:34:14 +01:00
|
|
|
|
):
|
2019-03-26 12:35:32 +00:00
|
|
|
|
client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_name_change",
|
2019-03-26 12:35:32 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
_data={"name": "New Name"},
|
2019-03-26 12:35:32 +00:00
|
|
|
|
_expected_status=302,
|
|
|
|
|
|
_expected_redirect=url_for(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_settings",
|
2019-03-26 12:35:32 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
),
|
|
|
|
|
|
)
|
2016-01-07 16:24:43 +00:00
|
|
|
|
|
2017-02-03 12:07:21 +00:00
|
|
|
|
mock_update_service.assert_called_once_with(
|
2019-03-26 12:35:32 +00:00
|
|
|
|
SERVICE_ONE_ID,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
name="New Name",
|
|
|
|
|
|
email_from="new.name",
|
2017-02-03 12:07:21 +00:00
|
|
|
|
)
|
2020-05-22 12:25:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
2023-09-29 16:37:11 -04:00
|
|
|
|
@pytest.mark.usefixtures("_mock_get_service_settings_page_common")
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
|
|
|
|
|
"route",
|
|
|
|
|
|
[
|
|
|
|
|
|
"main.service_settings",
|
|
|
|
|
|
"main.service_name_change",
|
|
|
|
|
|
"main.archive_service",
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2017-02-03 10:42:01 +00:00
|
|
|
|
def test_route_permissions(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mocker,
|
|
|
|
|
|
notify_admin,
|
|
|
|
|
|
client_request,
|
|
|
|
|
|
api_user_active,
|
|
|
|
|
|
service_one,
|
|
|
|
|
|
single_reply_to_email_address,
|
|
|
|
|
|
mock_get_invites_for_service,
|
|
|
|
|
|
single_sms_sender,
|
|
|
|
|
|
route,
|
|
|
|
|
|
mock_get_service_templates,
|
2017-02-03 10:42:01 +00:00
|
|
|
|
):
|
2017-02-03 12:07:21 +00:00
|
|
|
|
validate_route_permission(
|
|
|
|
|
|
mocker,
|
2021-05-12 14:57:21 +01:00
|
|
|
|
notify_admin,
|
2017-02-03 12:07:21 +00:00
|
|
|
|
"GET",
|
|
|
|
|
|
200,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
url_for(route, service_id=service_one["id"]),
|
|
|
|
|
|
["manage_service"],
|
2017-02-03 12:07:21 +00:00
|
|
|
|
api_user_active,
|
2020-05-22 12:25:44 +01:00
|
|
|
|
service_one,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
session={"service_name_change": "New Service Name"},
|
2020-05-22 12:25:44 +01:00
|
|
|
|
)
|
2016-03-09 12:10:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
|
|
|
|
|
"route",
|
|
|
|
|
|
[
|
|
|
|
|
|
"main.service_settings",
|
|
|
|
|
|
"main.service_name_change",
|
|
|
|
|
|
"main.service_switch_live",
|
|
|
|
|
|
"main.archive_service",
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2017-02-03 10:42:01 +00:00
|
|
|
|
def test_route_invalid_permissions(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mocker,
|
|
|
|
|
|
notify_admin,
|
|
|
|
|
|
client_request,
|
|
|
|
|
|
api_user_active,
|
|
|
|
|
|
service_one,
|
|
|
|
|
|
route,
|
|
|
|
|
|
mock_get_service_templates,
|
|
|
|
|
|
mock_get_invites_for_service,
|
2017-02-03 10:42:01 +00:00
|
|
|
|
):
|
2017-02-03 12:07:21 +00:00
|
|
|
|
validate_route_permission(
|
|
|
|
|
|
mocker,
|
2021-05-12 14:57:21 +01:00
|
|
|
|
notify_admin,
|
2017-02-03 12:07:21 +00:00
|
|
|
|
"GET",
|
|
|
|
|
|
403,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
url_for(route, service_id=service_one["id"]),
|
|
|
|
|
|
["blah"],
|
2017-02-03 12:07:21 +00:00
|
|
|
|
api_user_active,
|
2017-08-11 09:17:01 +01:00
|
|
|
|
service_one,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-09-29 16:37:11 -04:00
|
|
|
|
@pytest.mark.usefixtures("_mock_get_service_settings_page_common")
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
|
|
|
|
|
"route",
|
|
|
|
|
|
[
|
|
|
|
|
|
"main.service_settings",
|
|
|
|
|
|
"main.service_name_change",
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
|
|
|
|
|
def test_route_for_platform_admin(
|
|
|
|
|
|
mocker,
|
|
|
|
|
|
notify_admin,
|
|
|
|
|
|
client_request,
|
|
|
|
|
|
platform_admin_user,
|
|
|
|
|
|
service_one,
|
|
|
|
|
|
single_reply_to_email_address,
|
|
|
|
|
|
single_sms_sender,
|
|
|
|
|
|
route,
|
|
|
|
|
|
mock_get_service_templates,
|
|
|
|
|
|
mock_get_invites_for_service,
|
2017-02-03 10:42:01 +00:00
|
|
|
|
):
|
2020-05-22 12:25:44 +01:00
|
|
|
|
validate_route_permission(
|
|
|
|
|
|
mocker,
|
2021-05-12 14:57:21 +01:00
|
|
|
|
notify_admin,
|
2020-05-22 12:25:44 +01:00
|
|
|
|
"GET",
|
|
|
|
|
|
200,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
url_for(route, service_id=service_one["id"]),
|
2020-05-22 12:25:44 +01:00
|
|
|
|
[],
|
|
|
|
|
|
platform_admin_user,
|
|
|
|
|
|
service_one,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
session={"service_name_change": "New Service Name"},
|
2020-05-22 12:25:44 +01:00
|
|
|
|
)
|
2016-05-16 13:09:58 +01:00
|
|
|
|
|
|
|
|
|
|
|
2023-09-29 16:37:11 -04:00
|
|
|
|
@pytest.mark.usefixtures("_mock_get_service_settings_page_common")
|
2022-12-02 10:30:37 -05:00
|
|
|
|
@pytest.mark.skip(reason="Email currently deactivated")
|
2017-10-05 15:47:12 +01:00
|
|
|
|
def test_and_more_hint_appears_on_settings_with_more_than_just_a_single_sender(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
client_request, service_one, multiple_reply_to_email_addresses, multiple_sms_senders
|
2016-08-24 09:34:14 +01:00
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
service_one["permissions"] = ["email", "sms"]
|
2017-10-05 15:47:12 +01:00
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
page = client_request.get("main.service_settings", service_id=service_one["id"])
|
2017-09-25 15:14:13 +01:00
|
|
|
|
|
2020-02-17 15:36:46 +00:00
|
|
|
|
def get_row(page, label):
|
2017-10-24 15:37:44 +01:00
|
|
|
|
return normalize_spaces(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
find_element_by_tag_and_partial_text(page, tag="tr", string=label).text
|
2017-10-24 15:37:44 +01:00
|
|
|
|
)
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert (
|
|
|
|
|
|
get_row(page, "Reply-to email addresses")
|
|
|
|
|
|
== "Reply-to email addresses test@example.com …and 2 more Manage reply-to email addresses"
|
|
|
|
|
|
)
|
|
|
|
|
|
assert (
|
|
|
|
|
|
get_row(page, "Text message senders")
|
|
|
|
|
|
== "Text message senders Example …and 2 more Manage text message senders"
|
|
|
|
|
|
)
|
2017-09-25 15:14:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("sender_list_page", "index", "expected_output"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
(
|
|
|
|
|
|
"main.service_email_reply_to",
|
|
|
|
|
|
0,
|
|
|
|
|
|
"test@example.com (default) Change test@example.com",
|
|
|
|
|
|
),
|
|
|
|
|
|
("main.service_sms_senders", 0, "GOVUK (default) Change GOVUK"),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2017-10-05 15:47:12 +01:00
|
|
|
|
def test_api_ids_dont_show_on_option_pages_with_a_single_sender(
|
2017-09-28 11:35:52 +01:00
|
|
|
|
client_request,
|
2017-10-05 15:47:12 +01:00
|
|
|
|
single_reply_to_email_address,
|
2023-07-12 12:09:44 -04:00
|
|
|
|
mock_get_organization,
|
2017-10-24 15:37:44 +01:00
|
|
|
|
single_sms_sender,
|
2017-10-05 15:47:12 +01:00
|
|
|
|
sender_list_page,
|
2019-07-05 13:17:48 +01:00
|
|
|
|
index,
|
|
|
|
|
|
expected_output,
|
2017-09-28 11:35:52 +01:00
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
rows = client_request.get(sender_list_page, service_id=SERVICE_ONE_ID).select(
|
|
|
|
|
|
".user-list-item"
|
2017-09-28 11:35:52 +01:00
|
|
|
|
)
|
|
|
|
|
|
|
2019-07-05 13:17:48 +01:00
|
|
|
|
assert normalize_spaces(rows[index].text) == expected_output
|
|
|
|
|
|
assert len(rows) == index + 1
|
2017-09-25 15:14:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
2022-09-13 13:30:52 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("sender_list_page", "endpoint_to_mock", "sample_data", "expected_items"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
(
|
|
|
|
|
|
"main.service_email_reply_to",
|
|
|
|
|
|
"app.service_api_client.get_reply_to_email_addresses",
|
|
|
|
|
|
create_multiple_email_reply_to_addresses(),
|
|
|
|
|
|
[
|
|
|
|
|
|
"test@example.com (default) Change test@example.com ID: 1234",
|
|
|
|
|
|
"test2@example.com Change test2@example.com ID: 5678",
|
|
|
|
|
|
"test3@example.com Change test3@example.com ID: 9457",
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
(
|
|
|
|
|
|
"main.service_sms_senders",
|
|
|
|
|
|
"app.service_api_client.get_sms_senders",
|
|
|
|
|
|
create_multiple_sms_senders(),
|
|
|
|
|
|
[
|
|
|
|
|
|
"Example (default and receives replies) Change Example ID: 1234",
|
|
|
|
|
|
"Example 2 Change Example 2 ID: 5678",
|
2023-11-17 11:19:26 -07:00
|
|
|
|
"US Notify Change US Notify ID: 9457",
|
|
|
|
|
|
"Notify.gov Change Notify.gov ID: 9897",
|
2023-08-25 09:12:23 -07:00
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
2017-10-05 15:47:12 +01:00
|
|
|
|
)
|
|
|
|
|
|
def test_default_option_shows_for_default_sender(
|
|
|
|
|
|
client_request,
|
|
|
|
|
|
mocker,
|
|
|
|
|
|
sender_list_page,
|
2019-12-20 14:34:45 +00:00
|
|
|
|
endpoint_to_mock,
|
2017-10-05 15:47:12 +01:00
|
|
|
|
sample_data,
|
2019-07-05 13:17:48 +01:00
|
|
|
|
expected_items,
|
2017-10-05 15:47:12 +01:00
|
|
|
|
):
|
2019-12-20 14:34:45 +00:00
|
|
|
|
mocker.patch(endpoint_to_mock, return_value=sample_data)
|
2017-10-05 15:47:12 +01:00
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
rows = client_request.get(sender_list_page, service_id=SERVICE_ONE_ID).select(
|
|
|
|
|
|
".user-list-item"
|
2017-09-25 15:14:13 +01:00
|
|
|
|
)
|
|
|
|
|
|
|
2019-07-05 13:17:48 +01:00
|
|
|
|
assert [normalize_spaces(row.text) for row in rows] == expected_items
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("sender_list_page", "endpoint_to_mock", "expected_output"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
(
|
|
|
|
|
|
"main.service_email_reply_to",
|
|
|
|
|
|
"app.service_api_client.get_reply_to_email_addresses",
|
|
|
|
|
|
"You have not added any reply-to email addresses yet",
|
|
|
|
|
|
),
|
|
|
|
|
|
(
|
|
|
|
|
|
"main.service_sms_senders",
|
|
|
|
|
|
"app.service_api_client.get_sms_senders",
|
|
|
|
|
|
"You have not added any text message senders yet",
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2017-10-05 15:47:12 +01:00
|
|
|
|
def test_no_senders_message_shows(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
client_request, sender_list_page, endpoint_to_mock, expected_output, mocker
|
2017-10-05 15:47:12 +01:00
|
|
|
|
):
|
2019-12-20 14:34:45 +00:00
|
|
|
|
mocker.patch(endpoint_to_mock, return_value=[])
|
2017-10-05 15:47:12 +01:00
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
rows = client_request.get(sender_list_page, service_id=SERVICE_ONE_ID).select(
|
|
|
|
|
|
".user-list-item"
|
2017-09-25 15:14:13 +01:00
|
|
|
|
)
|
|
|
|
|
|
|
2017-10-05 15:47:12 +01:00
|
|
|
|
assert normalize_spaces(rows[0].text) == expected_output
|
2017-09-26 15:51:36 +01:00
|
|
|
|
assert len(rows) == 1
|
2017-09-25 15:14:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("reply_to_input", "expected_error"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
("", "Cannot be empty"),
|
|
|
|
|
|
("testtest", "Enter a valid email address"),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2017-10-24 15:37:44 +01:00
|
|
|
|
def test_incorrect_reply_to_email_address_input(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
reply_to_input, expected_error, client_request, no_reply_to_email_addresses
|
2017-09-25 15:14:13 +01:00
|
|
|
|
):
|
|
|
|
|
|
page = client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_add_email_reply_to",
|
2017-09-25 15:14:13 +01:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
_data={"email_address": reply_to_input},
|
|
|
|
|
|
_expected_status=200,
|
2017-09-25 15:14:13 +01:00
|
|
|
|
)
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert expected_error in normalize_spaces(
|
|
|
|
|
|
page.select_one(".usa-error-message").text
|
|
|
|
|
|
)
|
2017-09-25 15:14:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("sms_sender_input", "expected_error"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
("elevenchars", None),
|
|
|
|
|
|
("11 chars", None),
|
|
|
|
|
|
("", "Cannot be empty"),
|
|
|
|
|
|
("abcdefghijkhgkg", "Enter 11 characters or fewer"),
|
|
|
|
|
|
(r" ¯\_(ツ)_/¯ ", "Use letters and numbers only"),
|
|
|
|
|
|
("blood.co.uk", None),
|
|
|
|
|
|
("00123", "Cannot start with 00"),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2017-10-24 15:37:44 +01:00
|
|
|
|
def test_incorrect_sms_sender_input(
|
|
|
|
|
|
sms_sender_input,
|
|
|
|
|
|
expected_error,
|
|
|
|
|
|
client_request,
|
2018-01-31 10:35:55 +00:00
|
|
|
|
no_sms_senders,
|
|
|
|
|
|
mock_add_sms_sender,
|
2017-10-24 15:37:44 +01:00
|
|
|
|
):
|
|
|
|
|
|
page = client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_add_sms_sender",
|
2017-10-24 15:37:44 +01:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
_data={"sms_sender": sms_sender_input},
|
|
|
|
|
|
_expected_status=(200 if expected_error else 302),
|
2017-10-24 15:37:44 +01:00
|
|
|
|
)
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
error_message = page.select_one(".usa-error-message")
|
2018-01-31 10:35:55 +00:00
|
|
|
|
count_of_api_calls = len(mock_add_sms_sender.call_args_list)
|
|
|
|
|
|
|
|
|
|
|
|
if not expected_error:
|
|
|
|
|
|
assert not error_message
|
|
|
|
|
|
assert count_of_api_calls == 1
|
|
|
|
|
|
else:
|
2020-08-04 16:58:04 +01:00
|
|
|
|
assert expected_error in error_message.text
|
2018-01-31 10:35:55 +00:00
|
|
|
|
assert count_of_api_calls == 0
|
2017-10-24 15:37:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
2021-12-10 14:59:18 +00:00
|
|
|
|
def test_incorrect_sms_sender_input_with_multiple_errors_only_shows_the_first(
|
|
|
|
|
|
client_request,
|
|
|
|
|
|
no_sms_senders,
|
|
|
|
|
|
mock_add_sms_sender,
|
|
|
|
|
|
):
|
|
|
|
|
|
# There are two errors with the SMS sender - the length and characters used. Only one
|
|
|
|
|
|
# should be displayed on the page.
|
|
|
|
|
|
page = client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_add_sms_sender",
|
2021-12-10 14:59:18 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
_data={"sms_sender": "{}"},
|
|
|
|
|
|
_expected_status=200,
|
2021-12-10 14:59:18 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
error_message = page.select_one(".usa-error-message")
|
2021-12-10 14:59:18 +00:00
|
|
|
|
count_of_api_calls = len(mock_add_sms_sender.call_args_list)
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert normalize_spaces(error_message.text) == "Error: Enter 3 characters or more"
|
2021-12-10 14:59:18 +00:00
|
|
|
|
assert count_of_api_calls == 0
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("reply_to_addresses", "data", "api_default_args"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
([], {}, True),
|
|
|
|
|
|
(create_multiple_email_reply_to_addresses(), {}, False),
|
|
|
|
|
|
(create_multiple_email_reply_to_addresses(), {"is_default": "y"}, True),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2019-05-09 17:55:10 +01:00
|
|
|
|
def test_add_reply_to_email_address_sends_test_notification(
|
2019-12-20 14:34:45 +00:00
|
|
|
|
mocker, client_request, reply_to_addresses, data, api_default_args
|
2019-05-09 17:55:10 +01:00
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mocker.patch(
|
|
|
|
|
|
"app.service_api_client.get_reply_to_email_addresses",
|
|
|
|
|
|
return_value=reply_to_addresses,
|
|
|
|
|
|
)
|
|
|
|
|
|
data["email_address"] = "test@example.com"
|
2019-05-16 17:05:55 +01:00
|
|
|
|
mock_verify = mocker.patch(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"app.service_api_client.verify_reply_to_email_address",
|
|
|
|
|
|
return_value={"data": {"id": "123"}},
|
2019-05-16 17:05:55 +01:00
|
|
|
|
)
|
2019-05-09 17:55:10 +01:00
|
|
|
|
client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_add_email_reply_to",
|
2019-05-09 17:55:10 +01:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
_data=data,
|
|
|
|
|
|
_expected_status=302,
|
|
|
|
|
|
_expected_redirect=url_for(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_verify_reply_to_address",
|
2019-05-09 17:55:10 +01:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
notification_id="123",
|
2023-08-25 09:12:23 -07:00
|
|
|
|
)
|
|
|
|
|
|
+ "?is_default={}".format(api_default_args),
|
2019-05-09 17:55:10 +01:00
|
|
|
|
)
|
2019-05-16 17:05:55 +01:00
|
|
|
|
mock_verify.assert_called_once_with(SERVICE_ONE_ID, "test@example.com")
|
2019-05-09 17:55:10 +01:00
|
|
|
|
|
|
|
|
|
|
|
2021-05-28 15:06:31 +01:00
|
|
|
|
def test_service_add_reply_to_email_address_without_verification_for_platform_admin(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mocker, client_request, platform_admin_user
|
2021-05-28 15:06:31 +01:00
|
|
|
|
):
|
|
|
|
|
|
client_request.login(platform_admin_user)
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mock_update = mocker.patch("app.service_api_client.add_reply_to_email_address")
|
2021-05-28 15:06:31 +01:00
|
|
|
|
mocker.patch(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"app.service_api_client.get_reply_to_email_addresses",
|
|
|
|
|
|
return_value=[create_reply_to_email_address(is_default=True)],
|
2021-05-28 15:06:31 +01:00
|
|
|
|
)
|
2022-08-05 00:25:03 -07:00
|
|
|
|
data = {"is_default": "y", "email_address": "test@example.gsa.gov"}
|
2021-05-28 15:06:31 +01:00
|
|
|
|
|
|
|
|
|
|
client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_add_email_reply_to",
|
2021-05-28 15:06:31 +01:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
_data=data,
|
|
|
|
|
|
_expected_status=302,
|
|
|
|
|
|
_expected_redirect=url_for(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_email_reply_to",
|
2021-05-28 15:06:31 +01:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
),
|
2021-05-28 15:06:31 +01:00
|
|
|
|
)
|
|
|
|
|
|
mock_update.assert_called_once_with(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
SERVICE_ONE_ID, email_address="test@example.gsa.gov", is_default=True
|
|
|
|
|
|
)
|
2021-05-28 15:06:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("is_default", "replace", "expected_header"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[(True, "&replace=123", "Change"), (False, "", "Add")],
|
|
|
|
|
|
)
|
|
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("status", "expected_failure", "expected_success"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
("delivered", 0, 1),
|
|
|
|
|
|
("sending", 0, 0),
|
|
|
|
|
|
("permanent-failure", 1, 0),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2022-09-13 13:34:45 -07:00
|
|
|
|
@freeze_time("2018-06-01 11:11:00.061258")
|
2019-05-16 17:05:55 +01:00
|
|
|
|
def test_service_verify_reply_to_address(
|
2019-06-05 16:32:08 +01:00
|
|
|
|
mocker,
|
|
|
|
|
|
client_request,
|
|
|
|
|
|
fake_uuid,
|
|
|
|
|
|
get_non_default_reply_to_email_address,
|
|
|
|
|
|
status,
|
|
|
|
|
|
expected_failure,
|
|
|
|
|
|
expected_success,
|
|
|
|
|
|
is_default,
|
|
|
|
|
|
replace,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
expected_header,
|
2019-05-13 10:17:20 +01:00
|
|
|
|
):
|
2019-05-14 13:37:16 +01:00
|
|
|
|
notification = {
|
|
|
|
|
|
"id": fake_uuid,
|
|
|
|
|
|
"status": status,
|
2022-08-05 00:25:03 -07:00
|
|
|
|
"to": "email@example.gsa.gov",
|
2019-05-14 13:37:16 +01:00
|
|
|
|
"service_id": SERVICE_ONE_ID,
|
|
|
|
|
|
"template_id": TEMPLATE_ONE_ID,
|
2019-05-16 17:05:55 +01:00
|
|
|
|
"notification_type": "email",
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"created_at": "2018-06-01T11:10:52.499230+00:00",
|
2019-05-14 13:37:16 +01:00
|
|
|
|
}
|
2019-05-16 17:05:55 +01:00
|
|
|
|
mocker.patch(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"app.notification_api_client.get_notification", return_value=notification
|
2019-05-16 17:05:55 +01:00
|
|
|
|
)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mock_add_reply_to_email_address = mocker.patch(
|
|
|
|
|
|
"app.service_api_client.add_reply_to_email_address"
|
|
|
|
|
|
)
|
|
|
|
|
|
mock_update_reply_to_email_address = mocker.patch(
|
|
|
|
|
|
"app.service_api_client.update_reply_to_email_address"
|
|
|
|
|
|
)
|
|
|
|
|
|
mocker.patch("app.service_api_client.get_reply_to_email_addresses", return_value=[])
|
2019-05-13 10:17:20 +01:00
|
|
|
|
page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_verify_reply_to_address",
|
2019-05-13 10:17:20 +01:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2019-05-14 13:37:16 +01:00
|
|
|
|
notification_id=notification["id"],
|
2023-08-25 09:12:23 -07:00
|
|
|
|
_optional_args="?is_default={}{}".format(is_default, replace),
|
2019-05-13 10:17:20 +01:00
|
|
|
|
)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert page.find("h1").text == "{} email reply-to address".format(expected_header)
|
2019-05-21 13:10:17 +01:00
|
|
|
|
if replace:
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert "/email-reply-to/123/edit" in page.find("a", text="Back").attrs["href"]
|
2019-05-21 13:10:17 +01:00
|
|
|
|
else:
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert "/email-reply-to/add" in page.find("a", text="Back").attrs["href"]
|
2019-05-21 13:10:17 +01:00
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert len(page.find_all("div", class_="banner-dangerous")) == expected_failure
|
|
|
|
|
|
assert (
|
|
|
|
|
|
len(page.find_all("div", class_="banner-default-with-tick")) == expected_success
|
|
|
|
|
|
)
|
2019-05-09 17:55:10 +01:00
|
|
|
|
|
2019-05-14 13:37:16 +01:00
|
|
|
|
if status == "delivered":
|
2019-05-20 18:05:55 +01:00
|
|
|
|
if replace:
|
|
|
|
|
|
mock_update_reply_to_email_address.assert_called_once_with(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
SERVICE_ONE_ID,
|
|
|
|
|
|
"123",
|
|
|
|
|
|
email_address=notification["to"],
|
|
|
|
|
|
is_default=is_default,
|
2019-05-20 18:05:55 +01:00
|
|
|
|
)
|
2020-08-28 13:26:14 +01:00
|
|
|
|
assert mock_add_reply_to_email_address.called is False
|
2019-05-20 18:05:55 +01:00
|
|
|
|
else:
|
|
|
|
|
|
mock_add_reply_to_email_address.assert_called_once_with(
|
|
|
|
|
|
SERVICE_ONE_ID, email_address=notification["to"], is_default=is_default
|
|
|
|
|
|
)
|
2020-08-28 13:26:14 +01:00
|
|
|
|
assert mock_update_reply_to_email_address.called is False
|
2019-05-14 13:37:16 +01:00
|
|
|
|
else:
|
2020-08-28 13:26:14 +01:00
|
|
|
|
assert mock_add_reply_to_email_address.called is False
|
2019-05-14 15:05:52 +01:00
|
|
|
|
if status == "permanent-failure":
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert page.find("input", type="email").attrs["value"] == notification["to"]
|
2019-05-14 13:37:16 +01:00
|
|
|
|
|
2019-05-09 17:55:10 +01:00
|
|
|
|
|
2022-09-13 13:34:45 -07:00
|
|
|
|
@freeze_time("2018-06-01 11:11:00.061258")
|
2023-08-25 09:12:23 -07:00
|
|
|
|
def test_add_reply_to_email_address_fails_if_notification_not_delivered_in_45_sec(
|
|
|
|
|
|
mocker, client_request, fake_uuid
|
|
|
|
|
|
):
|
2019-05-16 15:31:23 +01:00
|
|
|
|
notification = {
|
|
|
|
|
|
"id": fake_uuid,
|
|
|
|
|
|
"status": "sending",
|
2022-08-05 00:25:03 -07:00
|
|
|
|
"to": "email@example.gsa.gov",
|
2019-05-16 15:31:23 +01:00
|
|
|
|
"service_id": SERVICE_ONE_ID,
|
|
|
|
|
|
"template_id": TEMPLATE_ONE_ID,
|
|
|
|
|
|
"notification_type": "email",
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"created_at": "2018-06-01T11:10:12.499230+00:00",
|
2019-05-16 15:31:23 +01:00
|
|
|
|
}
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mocker.patch("app.service_api_client.get_reply_to_email_addresses", return_value=[])
|
2019-05-20 18:05:55 +01:00
|
|
|
|
mocker.patch(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"app.notification_api_client.get_notification", return_value=notification
|
|
|
|
|
|
)
|
|
|
|
|
|
mock_add_reply_to_email_address = mocker.patch(
|
|
|
|
|
|
"app.service_api_client.add_reply_to_email_address"
|
2019-05-20 18:05:55 +01:00
|
|
|
|
)
|
2019-05-16 15:31:23 +01:00
|
|
|
|
page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_verify_reply_to_address",
|
2019-05-16 15:31:23 +01:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
notification_id=notification["id"],
|
2023-08-25 09:12:23 -07:00
|
|
|
|
_optional_args="?is_default={}".format(False),
|
|
|
|
|
|
)
|
|
|
|
|
|
expected_banner = page.find_all("div", class_="banner-dangerous")[0]
|
|
|
|
|
|
assert (
|
|
|
|
|
|
"There’s a problem with your reply-to address" in expected_banner.text.strip()
|
2019-05-16 15:31:23 +01:00
|
|
|
|
)
|
2020-08-28 13:26:14 +01:00
|
|
|
|
assert mock_add_reply_to_email_address.called is False
|
2019-05-09 17:55:10 +01:00
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("sms_senders", "data", "api_default_args"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
([], {}, True),
|
|
|
|
|
|
(create_multiple_sms_senders(), {}, False),
|
|
|
|
|
|
(create_multiple_sms_senders(), {"is_default": "y"}, True),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2017-10-24 15:37:44 +01:00
|
|
|
|
def test_add_sms_sender(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
sms_senders, data, api_default_args, mocker, client_request, mock_add_sms_sender
|
2017-10-24 15:37:44 +01:00
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mocker.patch("app.service_api_client.get_sms_senders", return_value=sms_senders)
|
|
|
|
|
|
data["sms_sender"] = "Example"
|
2017-10-24 15:37:44 +01:00
|
|
|
|
client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_add_sms_sender", service_id=SERVICE_ONE_ID, _data=data
|
2017-10-24 15:37:44 +01:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
mock_add_sms_sender.assert_called_once_with(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
SERVICE_ONE_ID, sms_sender="Example", is_default=api_default_args
|
2017-10-24 15:37:44 +01:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("reply_to_addresses", "checkbox_present"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
([], False),
|
|
|
|
|
|
(create_multiple_email_reply_to_addresses(), True),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2019-12-20 14:34:45 +00:00
|
|
|
|
def test_default_box_doesnt_show_on_first_email_sender(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
reply_to_addresses, mocker, checkbox_present, client_request
|
2017-02-03 10:42:01 +00:00
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mocker.patch(
|
|
|
|
|
|
"app.service_api_client.get_reply_to_email_addresses",
|
|
|
|
|
|
return_value=reply_to_addresses,
|
|
|
|
|
|
)
|
2019-12-20 14:34:45 +00:00
|
|
|
|
|
2017-09-25 15:14:13 +01:00
|
|
|
|
page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_add_email_reply_to", service_id=SERVICE_ONE_ID
|
2017-09-25 15:14:13 +01:00
|
|
|
|
)
|
2016-05-17 11:34:49 +01:00
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert bool(page.select_one("[name=is_default]")) == checkbox_present
|
2017-09-25 15:14:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("reply_to_address", "data", "api_default_args"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
(create_reply_to_email_address(is_default=True), {"is_default": "y"}, True),
|
|
|
|
|
|
(create_reply_to_email_address(is_default=True), {}, True),
|
|
|
|
|
|
(create_reply_to_email_address(is_default=False), {}, False),
|
|
|
|
|
|
(create_reply_to_email_address(is_default=False), {"is_default": "y"}, True),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2019-05-23 14:40:18 +01:00
|
|
|
|
def test_edit_reply_to_email_address_sends_verification_notification_if_address_is_changed(
|
2019-12-20 14:34:45 +00:00
|
|
|
|
reply_to_address,
|
2017-09-25 15:14:13 +01:00
|
|
|
|
data,
|
|
|
|
|
|
api_default_args,
|
|
|
|
|
|
mocker,
|
|
|
|
|
|
fake_uuid,
|
|
|
|
|
|
client_request,
|
|
|
|
|
|
):
|
2019-05-16 17:05:55 +01:00
|
|
|
|
mock_verify = mocker.patch(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"app.service_api_client.verify_reply_to_email_address",
|
|
|
|
|
|
return_value={"data": {"id": "123"}},
|
2019-05-16 17:05:55 +01:00
|
|
|
|
)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mocker.patch(
|
|
|
|
|
|
"app.service_api_client.get_reply_to_email_address",
|
|
|
|
|
|
return_value=reply_to_address,
|
|
|
|
|
|
)
|
|
|
|
|
|
data["email_address"] = "test@example.gsa.gov"
|
2017-10-18 14:51:26 +01:00
|
|
|
|
client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_edit_email_reply_to",
|
2017-09-25 15:14:13 +01:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
reply_to_email_id=fake_uuid,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
_data=data,
|
2017-09-25 15:14:13 +01:00
|
|
|
|
)
|
2022-08-05 00:25:03 -07:00
|
|
|
|
mock_verify.assert_called_once_with(SERVICE_ONE_ID, "test@example.gsa.gov")
|
2017-09-25 15:14:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
2021-05-28 15:06:31 +01:00
|
|
|
|
def test_service_edit_email_reply_to_updates_email_address_without_verification_for_platform_admin(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mocker, fake_uuid, client_request, platform_admin_user
|
2021-05-28 15:06:31 +01:00
|
|
|
|
):
|
|
|
|
|
|
client_request.login(platform_admin_user)
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mock_update = mocker.patch("app.service_api_client.update_reply_to_email_address")
|
2021-05-28 15:06:31 +01:00
|
|
|
|
mocker.patch(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"app.service_api_client.get_reply_to_email_address",
|
|
|
|
|
|
return_value=create_reply_to_email_address(is_default=True),
|
2021-05-28 15:06:31 +01:00
|
|
|
|
)
|
2022-08-05 00:25:03 -07:00
|
|
|
|
data = {"is_default": "y", "email_address": "test@example.gsa.gov"}
|
2021-05-28 15:06:31 +01:00
|
|
|
|
|
|
|
|
|
|
client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_edit_email_reply_to",
|
2021-05-28 15:06:31 +01:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
reply_to_email_id=fake_uuid,
|
|
|
|
|
|
_data=data,
|
|
|
|
|
|
_expected_status=302,
|
|
|
|
|
|
_expected_redirect=url_for(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_email_reply_to",
|
2021-05-28 15:06:31 +01:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
),
|
2021-05-28 15:06:31 +01:00
|
|
|
|
)
|
|
|
|
|
|
mock_update.assert_called_once_with(
|
|
|
|
|
|
SERVICE_ONE_ID,
|
|
|
|
|
|
reply_to_email_id=fake_uuid,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
email_address="test@example.gsa.gov",
|
|
|
|
|
|
is_default=True,
|
|
|
|
|
|
)
|
2021-05-28 15:06:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("reply_to_address", "data", "api_default_args"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
(create_reply_to_email_address(), {"is_default": "y"}, True),
|
|
|
|
|
|
(create_reply_to_email_address(), {}, True),
|
|
|
|
|
|
(create_reply_to_email_address(is_default=False), {}, False),
|
|
|
|
|
|
(create_reply_to_email_address(is_default=False), {"is_default": "y"}, True),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2019-05-23 14:40:18 +01:00
|
|
|
|
def test_edit_reply_to_email_address_goes_straight_to_update_if_address_not_changed(
|
2019-12-20 14:34:45 +00:00
|
|
|
|
reply_to_address,
|
2019-05-23 14:40:18 +01:00
|
|
|
|
data,
|
|
|
|
|
|
api_default_args,
|
|
|
|
|
|
mocker,
|
|
|
|
|
|
fake_uuid,
|
|
|
|
|
|
client_request,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mock_update_reply_to_email_address,
|
2019-05-23 14:40:18 +01:00
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mocker.patch(
|
|
|
|
|
|
"app.service_api_client.get_reply_to_email_address",
|
|
|
|
|
|
return_value=reply_to_address,
|
|
|
|
|
|
)
|
|
|
|
|
|
mock_verify = mocker.patch("app.service_api_client.verify_reply_to_email_address")
|
|
|
|
|
|
data["email_address"] = "test@example.com"
|
2019-05-23 14:40:18 +01:00
|
|
|
|
client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_edit_email_reply_to",
|
2019-05-23 14:40:18 +01:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
reply_to_email_id=fake_uuid,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
_data=data,
|
2019-05-23 14:40:18 +01:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
mock_update_reply_to_email_address.assert_called_once_with(
|
|
|
|
|
|
SERVICE_ONE_ID,
|
|
|
|
|
|
reply_to_email_id=fake_uuid,
|
|
|
|
|
|
email_address="test@example.com",
|
2023-08-25 09:12:23 -07:00
|
|
|
|
is_default=api_default_args,
|
2019-05-23 14:40:18 +01:00
|
|
|
|
)
|
2020-08-28 13:26:14 +01:00
|
|
|
|
assert mock_verify.called is False
|
2019-05-23 14:40:18 +01:00
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
|
|
|
|
|
"url",
|
|
|
|
|
|
[
|
|
|
|
|
|
"main.service_edit_email_reply_to",
|
|
|
|
|
|
"main.service_add_email_reply_to",
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2020-04-02 12:11:14 +01:00
|
|
|
|
def test_add_edit_reply_to_email_address_goes_straight_to_update_if_address_not_changed(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mocker, fake_uuid, client_request, mock_update_reply_to_email_address, url
|
2020-04-02 12:11:14 +01:00
|
|
|
|
):
|
|
|
|
|
|
reply_to_email_address = create_reply_to_email_address()
|
|
|
|
|
|
mocker.patch(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"app.service_api_client.get_reply_to_email_addresses",
|
|
|
|
|
|
return_value=[reply_to_email_address],
|
2020-04-02 12:11:14 +01:00
|
|
|
|
)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mocker.patch(
|
|
|
|
|
|
"app.service_api_client.get_reply_to_email_address",
|
|
|
|
|
|
return_value=reply_to_email_address,
|
|
|
|
|
|
)
|
|
|
|
|
|
error_message = (
|
|
|
|
|
|
"Your service already uses ‘reply_to@example.com’ as an email reply-to address."
|
|
|
|
|
|
)
|
|
|
|
|
|
mocker.patch(
|
|
|
|
|
|
"app.service_api_client.verify_reply_to_email_address",
|
|
|
|
|
|
side_effect=[
|
|
|
|
|
|
HTTPError(
|
|
|
|
|
|
response=Mock(
|
|
|
|
|
|
status_code=409, json={"result": "error", "message": error_message}
|
|
|
|
|
|
),
|
|
|
|
|
|
message=error_message,
|
|
|
|
|
|
)
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
|
|
|
|
|
data = {"is_default": "y", "email_address": "reply_to@example.com"}
|
2020-04-02 12:11:14 +01:00
|
|
|
|
page = client_request.post(
|
|
|
|
|
|
url,
|
|
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
reply_to_email_id=fake_uuid,
|
|
|
|
|
|
_data=data,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
_follow_redirects=True,
|
2020-04-02 12:11:14 +01:00
|
|
|
|
)
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert page.find("h1").text == "Reply-to email addresses"
|
|
|
|
|
|
assert error_message in page.find("div", class_="banner-dangerous").text
|
2020-04-02 12:11:14 +01:00
|
|
|
|
|
2020-08-28 13:26:14 +01:00
|
|
|
|
assert mock_update_reply_to_email_address.called is False
|
2020-04-02 12:11:14 +01:00
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("reply_to_address", "default_choice_and_delete_link_expected"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
(
|
|
|
|
|
|
create_reply_to_email_address(is_default=False),
|
|
|
|
|
|
True,
|
|
|
|
|
|
),
|
|
|
|
|
|
(
|
|
|
|
|
|
create_reply_to_email_address(is_default=True),
|
|
|
|
|
|
False,
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2021-11-04 11:21:58 +00:00
|
|
|
|
def test_shows_delete_link_for_get_request_for_edit_email_reply_to_address(
|
2017-11-14 11:31:20 +00:00
|
|
|
|
mocker,
|
2019-12-20 14:34:45 +00:00
|
|
|
|
reply_to_address,
|
2021-11-04 11:28:32 +00:00
|
|
|
|
default_choice_and_delete_link_expected,
|
2017-11-14 11:31:20 +00:00
|
|
|
|
fake_uuid,
|
|
|
|
|
|
client_request,
|
|
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mocker.patch(
|
|
|
|
|
|
"app.service_api_client.get_reply_to_email_address",
|
|
|
|
|
|
return_value=reply_to_address,
|
|
|
|
|
|
)
|
2017-11-14 11:31:20 +00:00
|
|
|
|
|
|
|
|
|
|
page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_edit_email_reply_to",
|
2017-11-14 11:31:20 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2018-09-26 16:41:04 +01:00
|
|
|
|
reply_to_email_id=sample_uuid(),
|
2017-11-14 11:31:20 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert page.select_one(".usa-back-link").text.strip() == "Back"
|
|
|
|
|
|
assert page.select_one(".usa-back-link")["href"] == url_for(
|
|
|
|
|
|
".service_email_reply_to",
|
2019-04-29 11:44:05 +01:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
)
|
2017-11-14 11:31:20 +00:00
|
|
|
|
|
2021-11-04 11:28:32 +00:00
|
|
|
|
if default_choice_and_delete_link_expected:
|
2023-08-25 09:12:23 -07:00
|
|
|
|
link = page.select_one(".page-footer a")
|
|
|
|
|
|
assert normalize_spaces(link.text) == "Delete"
|
|
|
|
|
|
assert link["href"] == url_for(
|
|
|
|
|
|
"main.service_confirm_delete_email_reply_to",
|
2021-11-04 11:28:32 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
reply_to_email_id=sample_uuid(),
|
2021-11-04 11:28:32 +00:00
|
|
|
|
)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert not page.select_one("input#is_default").has_attr("checked")
|
2021-11-04 11:28:32 +00:00
|
|
|
|
|
2019-04-29 11:44:05 +01:00
|
|
|
|
else:
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert not page.select(".page-footer a")
|
2017-11-14 11:31:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
(
|
|
|
|
|
|
"reply_to_address",
|
|
|
|
|
|
"default_choice_and_delete_link_expected",
|
|
|
|
|
|
"default_checkbox_checked",
|
|
|
|
|
|
),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
(create_reply_to_email_address(is_default=False), True, False),
|
|
|
|
|
|
(create_reply_to_email_address(is_default=False), True, True),
|
|
|
|
|
|
(
|
|
|
|
|
|
create_reply_to_email_address(is_default=True),
|
|
|
|
|
|
False,
|
|
|
|
|
|
False, # not expecting a checkbox to even be shown to be ticked
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2021-11-04 11:21:58 +00:00
|
|
|
|
def test_shows_delete_link_for_error_on_post_request_for_edit_email_reply_to_address(
|
|
|
|
|
|
mocker,
|
|
|
|
|
|
reply_to_address,
|
|
|
|
|
|
default_choice_and_delete_link_expected,
|
|
|
|
|
|
default_checkbox_checked,
|
|
|
|
|
|
fake_uuid,
|
|
|
|
|
|
client_request,
|
|
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mocker.patch(
|
|
|
|
|
|
"app.service_api_client.get_reply_to_email_address",
|
|
|
|
|
|
return_value=reply_to_address,
|
|
|
|
|
|
)
|
2021-11-04 11:21:58 +00:00
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
data = {"email_address": "not a valid email address"}
|
2021-11-04 11:21:58 +00:00
|
|
|
|
if default_checkbox_checked:
|
|
|
|
|
|
data["is_default"] = "y"
|
|
|
|
|
|
|
|
|
|
|
|
page = client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_edit_email_reply_to",
|
2021-11-04 11:21:58 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
reply_to_email_id=sample_uuid(),
|
|
|
|
|
|
_data=data,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
_expected_status=200,
|
2021-11-04 11:21:58 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert page.select_one(".usa-back-link").text.strip() == "Back"
|
|
|
|
|
|
assert page.select_one(".usa-back-link")["href"] == url_for(
|
|
|
|
|
|
".service_email_reply_to",
|
2021-11-04 11:21:58 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert (
|
|
|
|
|
|
page.select_one(".usa-error-message").text.strip()
|
|
|
|
|
|
== "Error: Enter a valid email address"
|
|
|
|
|
|
)
|
2025-05-02 11:59:13 -04:00
|
|
|
|
|
|
|
|
|
|
assert page.select_one("input[name='email_address']")
|
2021-11-04 11:21:58 +00:00
|
|
|
|
|
|
|
|
|
|
if default_choice_and_delete_link_expected:
|
2023-08-25 09:12:23 -07:00
|
|
|
|
link = page.select_one(".page-footer a")
|
2021-11-04 11:21:58 +00:00
|
|
|
|
assert normalize_spaces(link.text) == "Delete"
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert link["href"] == url_for(
|
|
|
|
|
|
"main.service_confirm_delete_email_reply_to",
|
2021-11-04 11:21:58 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
reply_to_email_id=sample_uuid(),
|
|
|
|
|
|
)
|
|
|
|
|
|
assert (
|
|
|
|
|
|
page.select_one("input#is_default").has_attr("checked")
|
|
|
|
|
|
== default_checkbox_checked
|
2021-11-04 11:21:58 +00:00
|
|
|
|
)
|
|
|
|
|
|
else:
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert not page.select(".page-footer a")
|
2021-11-04 11:21:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
2017-11-14 11:31:20 +00:00
|
|
|
|
def test_confirm_delete_reply_to_email_address(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
fake_uuid, client_request, get_non_default_reply_to_email_address
|
2017-11-14 11:31:20 +00:00
|
|
|
|
):
|
|
|
|
|
|
page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_confirm_delete_email_reply_to",
|
2017-11-14 11:31:20 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
reply_to_email_id=fake_uuid,
|
|
|
|
|
|
_test_page_title=False,
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert normalize_spaces(page.select_one(".banner-dangerous").text) == (
|
|
|
|
|
|
"Are you sure you want to delete this reply-to email address? " "Yes, delete"
|
2017-11-14 11:31:20 +00:00
|
|
|
|
)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert "action" not in page.select_one(".banner-dangerous form")
|
|
|
|
|
|
assert page.select_one(".banner-dangerous form")["method"] == "post"
|
2017-11-14 11:31:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_delete_reply_to_email_address(
|
|
|
|
|
|
client_request,
|
|
|
|
|
|
service_one,
|
|
|
|
|
|
fake_uuid,
|
|
|
|
|
|
get_non_default_reply_to_email_address,
|
2018-04-26 15:09:37 +01:00
|
|
|
|
mocker,
|
2017-11-14 11:31:20 +00:00
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mock_delete = mocker.patch("app.service_api_client.delete_reply_to_email_address")
|
2017-11-14 11:31:20 +00:00
|
|
|
|
client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
".service_delete_email_reply_to",
|
2017-11-14 11:31:20 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
reply_to_email_id=fake_uuid,
|
|
|
|
|
|
_expected_redirect=url_for(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_email_reply_to",
|
2017-11-14 11:31:20 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
),
|
|
|
|
|
|
)
|
|
|
|
|
|
mock_delete.assert_called_once_with(
|
|
|
|
|
|
service_id=SERVICE_ONE_ID, reply_to_email_id=fake_uuid
|
2017-11-14 11:31:20 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("sms_sender", "data", "api_default_args"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
(create_sms_sender(), {"is_default": "y", "sms_sender": "test"}, True),
|
|
|
|
|
|
(create_sms_sender(), {"sms_sender": "test"}, True),
|
|
|
|
|
|
(create_sms_sender(is_default=False), {"sms_sender": "test"}, False),
|
|
|
|
|
|
(
|
|
|
|
|
|
create_sms_sender(is_default=False),
|
|
|
|
|
|
{"is_default": "y", "sms_sender": "test"},
|
|
|
|
|
|
True,
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2017-10-24 15:37:44 +01:00
|
|
|
|
def test_edit_sms_sender(
|
2019-12-20 14:34:45 +00:00
|
|
|
|
sms_sender,
|
2017-10-24 15:37:44 +01:00
|
|
|
|
data,
|
|
|
|
|
|
api_default_args,
|
|
|
|
|
|
mocker,
|
|
|
|
|
|
fake_uuid,
|
|
|
|
|
|
client_request,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mock_update_sms_sender,
|
2017-10-24 15:37:44 +01:00
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mocker.patch("app.service_api_client.get_sms_sender", return_value=sms_sender)
|
2019-12-20 14:34:45 +00:00
|
|
|
|
|
2017-10-24 15:37:44 +01:00
|
|
|
|
client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_edit_sms_sender",
|
2017-10-24 15:37:44 +01:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
sms_sender_id=fake_uuid,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
_data=data,
|
2017-10-24 15:37:44 +01:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
mock_update_sms_sender.assert_called_once_with(
|
|
|
|
|
|
SERVICE_ONE_ID,
|
|
|
|
|
|
sms_sender_id=fake_uuid,
|
2017-10-30 14:30:43 +00:00
|
|
|
|
sms_sender="test",
|
2023-08-25 09:12:23 -07:00
|
|
|
|
is_default=api_default_args,
|
2017-10-24 15:37:44 +01:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
(
|
|
|
|
|
|
"sender_page",
|
|
|
|
|
|
"endpoint_to_mock",
|
|
|
|
|
|
"sender_details",
|
|
|
|
|
|
"default_message",
|
|
|
|
|
|
"params",
|
|
|
|
|
|
"checkbox_present",
|
|
|
|
|
|
),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
(
|
|
|
|
|
|
"main.service_edit_email_reply_to",
|
|
|
|
|
|
"app.service_api_client.get_reply_to_email_address",
|
|
|
|
|
|
create_reply_to_email_address(is_default=True),
|
|
|
|
|
|
"This is the default reply-to address for service one emails",
|
|
|
|
|
|
"reply_to_email_id",
|
|
|
|
|
|
False,
|
|
|
|
|
|
),
|
|
|
|
|
|
(
|
|
|
|
|
|
"main.service_edit_email_reply_to",
|
|
|
|
|
|
"app.service_api_client.get_reply_to_email_address",
|
|
|
|
|
|
create_reply_to_email_address(is_default=False),
|
|
|
|
|
|
"This is the default reply-to address for service one emails",
|
|
|
|
|
|
"reply_to_email_id",
|
|
|
|
|
|
True,
|
|
|
|
|
|
),
|
|
|
|
|
|
(
|
|
|
|
|
|
"main.service_edit_sms_sender",
|
|
|
|
|
|
"app.service_api_client.get_sms_sender",
|
|
|
|
|
|
create_sms_sender(is_default=True),
|
|
|
|
|
|
"This is the default text message sender.",
|
|
|
|
|
|
"sms_sender_id",
|
|
|
|
|
|
False,
|
|
|
|
|
|
),
|
|
|
|
|
|
(
|
|
|
|
|
|
"main.service_edit_sms_sender",
|
|
|
|
|
|
"app.service_api_client.get_sms_sender",
|
|
|
|
|
|
create_sms_sender(is_default=False),
|
|
|
|
|
|
"This is the default text message sender.",
|
|
|
|
|
|
"sms_sender_id",
|
|
|
|
|
|
True,
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2017-10-05 15:47:12 +01:00
|
|
|
|
def test_default_box_shows_on_non_default_sender_details_while_editing(
|
2017-09-25 15:14:13 +01:00
|
|
|
|
fake_uuid,
|
|
|
|
|
|
mocker,
|
2017-10-05 15:47:12 +01:00
|
|
|
|
sender_page,
|
2019-12-20 14:34:45 +00:00
|
|
|
|
endpoint_to_mock,
|
|
|
|
|
|
sender_details,
|
2017-10-05 15:47:12 +01:00
|
|
|
|
client_request,
|
|
|
|
|
|
default_message,
|
2017-09-25 15:14:13 +01:00
|
|
|
|
checkbox_present,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
params,
|
2017-09-25 15:14:13 +01:00
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
page_arguments = {"service_id": SERVICE_ONE_ID}
|
2017-10-05 15:47:12 +01:00
|
|
|
|
page_arguments[params] = fake_uuid
|
|
|
|
|
|
|
2019-12-20 14:34:45 +00:00
|
|
|
|
mocker.patch(endpoint_to_mock, return_value=sender_details)
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
page = client_request.get(sender_page, **page_arguments)
|
2017-09-25 15:14:13 +01:00
|
|
|
|
|
|
|
|
|
|
if checkbox_present:
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert page.select_one("[name=is_default]")
|
2017-09-25 15:14:13 +01:00
|
|
|
|
else:
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert normalize_spaces(page.select_one("form p").text) == (default_message)
|
2016-06-01 16:07:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("sms_sender", "expected_link_text", "partial_href"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
(
|
|
|
|
|
|
create_sms_sender(is_default=False),
|
|
|
|
|
|
"Delete",
|
|
|
|
|
|
partial(
|
|
|
|
|
|
url_for,
|
|
|
|
|
|
"main.service_confirm_delete_sms_sender",
|
|
|
|
|
|
sms_sender_id=sample_uuid(),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
(
|
|
|
|
|
|
create_sms_sender(is_default=True),
|
|
|
|
|
|
None,
|
|
|
|
|
|
None,
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2017-11-14 11:31:20 +00:00
|
|
|
|
def test_shows_delete_link_for_sms_sender(
|
|
|
|
|
|
mocker,
|
2019-12-20 14:34:45 +00:00
|
|
|
|
sms_sender,
|
2017-11-14 11:31:20 +00:00
|
|
|
|
expected_link_text,
|
|
|
|
|
|
partial_href,
|
|
|
|
|
|
fake_uuid,
|
|
|
|
|
|
client_request,
|
|
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mocker.patch("app.service_api_client.get_sms_sender", return_value=sms_sender)
|
2017-11-14 11:31:20 +00:00
|
|
|
|
|
|
|
|
|
|
page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_edit_sms_sender",
|
2017-11-14 11:31:20 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2018-09-26 16:41:04 +01:00
|
|
|
|
sms_sender_id=sample_uuid(),
|
2017-11-14 11:31:20 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
link = page.select_one(".page-footer a")
|
|
|
|
|
|
back_link = page.select_one(".usa-back-link")
|
2017-11-14 11:31:20 +00:00
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert back_link.text.strip() == "Back"
|
|
|
|
|
|
assert back_link["href"] == url_for(
|
|
|
|
|
|
".service_sms_senders",
|
2019-04-29 11:44:05 +01:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
if expected_link_text:
|
|
|
|
|
|
assert normalize_spaces(link.text) == expected_link_text
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert link["href"] == partial_href(service_id=SERVICE_ONE_ID)
|
2019-04-29 11:44:05 +01:00
|
|
|
|
else:
|
|
|
|
|
|
assert not link
|
2017-11-14 11:31:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_confirm_delete_sms_sender(
|
|
|
|
|
|
fake_uuid,
|
|
|
|
|
|
client_request,
|
|
|
|
|
|
get_non_default_sms_sender,
|
|
|
|
|
|
):
|
|
|
|
|
|
page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_confirm_delete_sms_sender",
|
2017-11-14 11:31:20 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
sms_sender_id=fake_uuid,
|
|
|
|
|
|
_test_page_title=False,
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert normalize_spaces(page.select_one(".banner-dangerous").text) == (
|
|
|
|
|
|
"Are you sure you want to delete this text message sender? " "Yes, delete"
|
2017-11-14 11:31:20 +00:00
|
|
|
|
)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert "action" not in page.select_one(".banner-dangerous form")
|
|
|
|
|
|
assert page.select_one(".banner-dangerous form")["method"] == "post"
|
2017-11-14 11:31:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("sms_sender", "expected_link_text"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
(create_sms_sender(is_default=False, inbound_number_id="1234"), None),
|
|
|
|
|
|
(create_sms_sender(is_default=True), None),
|
|
|
|
|
|
(create_sms_sender(is_default=False), "Delete"),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2017-11-14 11:31:20 +00:00
|
|
|
|
def test_inbound_sms_sender_is_not_deleteable(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
client_request, service_one, fake_uuid, sms_sender, expected_link_text, mocker
|
2017-11-14 11:31:20 +00:00
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mocker.patch("app.service_api_client.get_sms_sender", return_value=sms_sender)
|
2017-11-14 11:31:20 +00:00
|
|
|
|
|
|
|
|
|
|
page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
".service_edit_sms_sender",
|
2017-11-14 11:31:20 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2019-11-04 11:07:55 +00:00
|
|
|
|
sms_sender_id=fake_uuid,
|
2017-11-14 11:31:20 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
back_link = page.select_one(".usa-back-link")
|
|
|
|
|
|
footer_link = page.select_one(".page-footer a")
|
|
|
|
|
|
assert normalize_spaces(back_link.text) == "Back"
|
2019-04-29 11:44:05 +01:00
|
|
|
|
|
|
|
|
|
|
if expected_link_text:
|
|
|
|
|
|
assert normalize_spaces(footer_link.text) == expected_link_text
|
|
|
|
|
|
else:
|
|
|
|
|
|
assert not footer_link
|
2017-11-14 11:31:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_delete_sms_sender(
|
|
|
|
|
|
client_request,
|
|
|
|
|
|
service_one,
|
|
|
|
|
|
fake_uuid,
|
|
|
|
|
|
get_non_default_sms_sender,
|
2018-04-26 15:09:37 +01:00
|
|
|
|
mocker,
|
2017-11-14 11:31:20 +00:00
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mock_delete = mocker.patch("app.service_api_client.delete_sms_sender")
|
2017-11-14 11:31:20 +00:00
|
|
|
|
client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
".service_delete_sms_sender",
|
2017-11-14 11:31:20 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2019-11-04 11:07:55 +00:00
|
|
|
|
sms_sender_id=fake_uuid,
|
2017-11-14 11:31:20 +00:00
|
|
|
|
_expected_redirect=url_for(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_sms_senders",
|
2017-11-14 11:31:20 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
),
|
|
|
|
|
|
)
|
|
|
|
|
|
mock_delete.assert_called_once_with(
|
|
|
|
|
|
service_id=SERVICE_ONE_ID, sms_sender_id=fake_uuid
|
2017-11-14 11:31:20 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("sms_sender", "hide_textbox"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
(create_sms_sender(is_default=False, inbound_number_id="1234"), True),
|
|
|
|
|
|
(create_sms_sender(is_default=True), False),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2017-10-24 15:37:44 +01:00
|
|
|
|
def test_inbound_sms_sender_is_not_editable(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
client_request, service_one, fake_uuid, sms_sender, hide_textbox, mocker
|
2017-10-24 15:37:44 +01:00
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mocker.patch("app.service_api_client.get_sms_sender", return_value=sms_sender)
|
2017-10-24 15:37:44 +01:00
|
|
|
|
|
|
|
|
|
|
page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
".service_edit_sms_sender",
|
2017-10-24 15:37:44 +01:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2019-11-04 11:07:55 +00:00
|
|
|
|
sms_sender_id=fake_uuid,
|
2017-10-24 15:37:44 +01:00
|
|
|
|
)
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert bool(page.find("input", attrs={"name": "sms_sender"})) != hide_textbox
|
2017-10-24 15:37:44 +01:00
|
|
|
|
if hide_textbox:
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert (
|
|
|
|
|
|
normalize_spaces(page.select_one('form[method="post"] p').text)
|
|
|
|
|
|
== "GOVUK This phone number receives replies and cannot be changed"
|
|
|
|
|
|
)
|
2017-10-24 15:37:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
2023-09-29 16:37:11 -04:00
|
|
|
|
@pytest.mark.usefixtures("_mock_get_service_settings_page_common")
|
2016-06-01 16:07:43 +01:00
|
|
|
|
def test_shows_research_mode_indicator(
|
2019-03-26 12:35:32 +00:00
|
|
|
|
client_request,
|
2017-10-18 14:51:26 +01:00
|
|
|
|
service_one,
|
|
|
|
|
|
mocker,
|
|
|
|
|
|
single_reply_to_email_address,
|
2017-10-24 15:37:44 +01:00
|
|
|
|
single_sms_sender,
|
2016-08-24 09:34:14 +01:00
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
service_one["research_mode"] = True
|
|
|
|
|
|
mocker.patch("app.service_api_client.update_service", return_value=service_one)
|
2016-06-01 16:07:43 +01:00
|
|
|
|
|
2019-03-26 12:35:32 +00:00
|
|
|
|
page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_settings",
|
2019-03-26 12:35:32 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
)
|
2016-06-01 16:07:43 +01:00
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
element = page.find("span", {"id": "research-mode"})
|
|
|
|
|
|
assert element.text == "research mode"
|
2016-06-01 16:07:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
2023-09-29 16:37:11 -04:00
|
|
|
|
@pytest.mark.usefixtures("_mock_get_service_settings_page_common")
|
2016-06-01 16:07:43 +01:00
|
|
|
|
def test_does_not_show_research_mode_indicator(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
client_request, single_reply_to_email_address, single_sms_sender
|
2016-08-24 09:34:14 +01:00
|
|
|
|
):
|
2019-03-26 12:35:32 +00:00
|
|
|
|
page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_settings",
|
2019-03-26 12:35:32 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
)
|
2016-06-01 16:07:43 +01:00
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
element = page.find("span", {"id": "research-mode"})
|
2017-02-03 12:07:21 +00:00
|
|
|
|
assert not element
|
2016-07-01 13:47:22 +01:00
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize("method", ["get", "post"])
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
|
|
|
|
"endpoint",
|
|
|
|
|
|
[
|
|
|
|
|
|
"main.set_free_sms_allowance",
|
|
|
|
|
|
"main.set_message_limit",
|
|
|
|
|
|
"main.set_rate_limit",
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2023-07-12 12:09:44 -04:00
|
|
|
|
def test_organization_type_pages_are_platform_admin_only(
|
2017-10-05 12:06:40 +01:00
|
|
|
|
client_request,
|
|
|
|
|
|
method,
|
2017-10-05 13:49:43 +01:00
|
|
|
|
endpoint,
|
2017-10-05 12:06:40 +01:00
|
|
|
|
):
|
|
|
|
|
|
getattr(client_request, method)(
|
2017-10-05 13:49:43 +01:00
|
|
|
|
endpoint,
|
2017-10-05 12:06:40 +01:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
_expected_status=403,
|
|
|
|
|
|
_test_page_title=False,
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-10-05 13:49:43 +01:00
|
|
|
|
def test_should_show_page_to_set_sms_allowance(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
client_request, platform_admin_user, mock_get_free_sms_fragment_limit
|
2017-10-05 13:49:43 +01:00
|
|
|
|
):
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request.login(platform_admin_user)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
page = client_request.get("main.set_free_sms_allowance", service_id=SERVICE_ONE_ID)
|
2017-10-05 13:49:43 +01:00
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert (
|
|
|
|
|
|
normalize_spaces(page.select_one("label").text)
|
|
|
|
|
|
== "Numbers of text message fragments per year"
|
|
|
|
|
|
)
|
2017-11-09 13:18:09 +00:00
|
|
|
|
mock_get_free_sms_fragment_limit.assert_called_once_with(SERVICE_ONE_ID)
|
2017-10-05 13:49:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
2022-09-13 13:34:45 -07:00
|
|
|
|
@freeze_time("2017-04-01 11:09:00.061258")
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("given_allowance", "expected_api_argument"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
("0", 0),
|
|
|
|
|
|
("1", 1),
|
|
|
|
|
|
("250000", 250000),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2017-10-05 13:49:43 +01:00
|
|
|
|
def test_should_set_sms_allowance(
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request,
|
|
|
|
|
|
platform_admin_user,
|
2017-10-05 13:49:43 +01:00
|
|
|
|
given_allowance,
|
|
|
|
|
|
expected_api_argument,
|
2017-11-09 13:18:09 +00:00
|
|
|
|
mock_get_free_sms_fragment_limit,
|
2017-10-31 11:56:51 +00:00
|
|
|
|
mock_create_or_update_free_sms_fragment_limit,
|
2017-10-05 13:49:43 +01:00
|
|
|
|
):
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request.login(platform_admin_user)
|
|
|
|
|
|
client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.set_free_sms_allowance",
|
2021-12-30 16:13:49 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
_data={
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"free_sms_allowance": given_allowance,
|
2017-10-05 13:49:43 +01:00
|
|
|
|
},
|
2021-12-30 16:13:49 +00:00
|
|
|
|
_expected_redirect=url_for(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_settings",
|
2021-12-30 16:13:49 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
),
|
2017-10-05 13:49:43 +01:00
|
|
|
|
)
|
|
|
|
|
|
|
2017-12-04 16:03:11 +00:00
|
|
|
|
mock_create_or_update_free_sms_fragment_limit.assert_called_with(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
SERVICE_ONE_ID, expected_api_argument
|
2017-10-05 13:49:43 +01:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-05-26 12:35:48 -07:00
|
|
|
|
@freeze_time("2017-04-01 11:09:00.061258")
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("given_allowance", "expected_api_argument"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
pytest.param("foo", "foo"),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2023-05-26 12:35:48 -07:00
|
|
|
|
def test_should_set_sms_allowance_fails(
|
|
|
|
|
|
client_request,
|
|
|
|
|
|
platform_admin_user,
|
|
|
|
|
|
given_allowance,
|
|
|
|
|
|
expected_api_argument,
|
|
|
|
|
|
mock_get_free_sms_fragment_limit,
|
|
|
|
|
|
mock_create_or_update_free_sms_fragment_limit,
|
|
|
|
|
|
):
|
2023-10-30 08:42:11 -07:00
|
|
|
|
client_request.login(platform_admin_user)
|
|
|
|
|
|
with pytest.raises(expected_exception=AssertionError):
|
2023-05-26 12:35:48 -07:00
|
|
|
|
client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.set_free_sms_allowance",
|
2023-05-26 12:35:48 -07:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
_data={
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"free_sms_allowance": given_allowance,
|
2023-05-26 12:35:48 -07:00
|
|
|
|
},
|
|
|
|
|
|
_expected_redirect=url_for(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_settings",
|
2023-05-26 12:35:48 -07:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
),
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-19 17:19:32 +01:00
|
|
|
|
def test_should_show_page_to_set_message_limit(
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request,
|
|
|
|
|
|
platform_admin_user,
|
2020-10-19 17:19:32 +01:00
|
|
|
|
):
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request.login(platform_admin_user)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
page = client_request.get("main.set_message_limit", service_id=SERVICE_ONE_ID)
|
|
|
|
|
|
assert normalize_spaces(page.select_one("label").text) == (
|
2023-12-06 12:26:33 -07:00
|
|
|
|
"Max number of messages the service has per send"
|
2020-10-19 17:19:32 +01:00
|
|
|
|
)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert normalize_spaces(page.select_one("input[type=text]")["value"]) == ("1000")
|
2020-10-19 17:19:32 +01:00
|
|
|
|
|
|
|
|
|
|
|
2020-10-21 14:30:35 +01:00
|
|
|
|
def test_should_show_page_to_set_rate_limit(
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request,
|
|
|
|
|
|
platform_admin_user,
|
2020-10-21 14:30:35 +01:00
|
|
|
|
):
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request.login(platform_admin_user)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
page = client_request.get("main.set_rate_limit", service_id=SERVICE_ONE_ID)
|
|
|
|
|
|
assert normalize_spaces(page.select_one("label").text) == (
|
|
|
|
|
|
"Number of messages the service can send in a rolling 60 second window"
|
2020-10-21 14:30:35 +01:00
|
|
|
|
)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert normalize_spaces(page.select_one("input[type=text]")["value"]) == ("3000")
|
2020-10-21 14:30:35 +01:00
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("endpoint", "field_name"),
|
|
|
|
|
|
[
|
2023-08-25 09:12:23 -07:00
|
|
|
|
("main.set_message_limit", "message_limit"),
|
|
|
|
|
|
("main.set_rate_limit", "rate_limit"),
|
2023-09-29 16:37:11 -04:00
|
|
|
|
],
|
2023-08-25 09:12:23 -07:00
|
|
|
|
)
|
|
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("new_limit", "expected_api_argument"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
("1", 1),
|
|
|
|
|
|
("250000", 250000),
|
|
|
|
|
|
pytest.param("foo", "foo", marks=pytest.mark.xfail),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2020-10-19 17:19:32 +01:00
|
|
|
|
def test_should_set_message_limit(
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request,
|
|
|
|
|
|
platform_admin_user,
|
2020-10-19 17:19:32 +01:00
|
|
|
|
new_limit,
|
|
|
|
|
|
expected_api_argument,
|
|
|
|
|
|
mock_update_service,
|
2020-10-21 14:30:35 +01:00
|
|
|
|
endpoint,
|
|
|
|
|
|
field_name,
|
2020-10-19 17:19:32 +01:00
|
|
|
|
):
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request.login(platform_admin_user)
|
|
|
|
|
|
client_request.post(
|
|
|
|
|
|
endpoint,
|
|
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
_data={
|
2020-10-21 14:30:35 +01:00
|
|
|
|
field_name: new_limit,
|
2020-10-19 17:19:32 +01:00
|
|
|
|
},
|
|
|
|
|
|
)
|
|
|
|
|
|
mock_update_service.assert_called_once_with(
|
|
|
|
|
|
SERVICE_ONE_ID,
|
2020-10-21 14:30:35 +01:00
|
|
|
|
**{field_name: expected_api_argument},
|
2020-10-19 17:19:32 +01:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-01-29 14:51:31 +00:00
|
|
|
|
def test_unknown_channel_404s(
|
|
|
|
|
|
client_request,
|
|
|
|
|
|
):
|
|
|
|
|
|
client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_set_channel",
|
2019-01-29 14:51:31 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
channel="message-in-a-bottle",
|
2019-01-29 14:51:31 +00:00
|
|
|
|
_expected_status=404,
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2019-01-29 14:51:31 +00:00
|
|
|
|
(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
"channel",
|
|
|
|
|
|
"expected_first_para",
|
|
|
|
|
|
"expected_legend",
|
|
|
|
|
|
"initial_permissions",
|
|
|
|
|
|
"expected_initial_value",
|
|
|
|
|
|
"posted_value",
|
|
|
|
|
|
"expected_updated_permissions",
|
2019-01-29 14:51:31 +00:00
|
|
|
|
),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
(
|
|
|
|
|
|
"sms",
|
|
|
|
|
|
"You may send up to 250,000 text messages during the pilot period.",
|
|
|
|
|
|
"Send text messages",
|
|
|
|
|
|
[],
|
|
|
|
|
|
"False",
|
|
|
|
|
|
"True",
|
|
|
|
|
|
["sms"],
|
|
|
|
|
|
),
|
|
|
|
|
|
(
|
|
|
|
|
|
"email",
|
|
|
|
|
|
"It’s free to send emails through Notify.gov.",
|
|
|
|
|
|
"Send emails",
|
|
|
|
|
|
[],
|
|
|
|
|
|
"False",
|
|
|
|
|
|
"True",
|
|
|
|
|
|
["email"],
|
|
|
|
|
|
),
|
|
|
|
|
|
(
|
|
|
|
|
|
"email",
|
|
|
|
|
|
"It’s free to send emails through Notify.gov.",
|
|
|
|
|
|
"Send emails",
|
|
|
|
|
|
["email", "sms"],
|
|
|
|
|
|
"True",
|
|
|
|
|
|
"True",
|
|
|
|
|
|
["email", "sms"],
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2020-07-14 10:43:48 +01:00
|
|
|
|
def test_switch_service_channels_on_and_off(
|
2018-01-19 13:45:54 +00:00
|
|
|
|
client_request,
|
2017-10-18 14:51:26 +01:00
|
|
|
|
service_one,
|
|
|
|
|
|
mocker,
|
2019-01-29 14:51:31 +00:00
|
|
|
|
mock_get_free_sms_fragment_limit,
|
|
|
|
|
|
channel,
|
|
|
|
|
|
expected_first_para,
|
|
|
|
|
|
expected_legend,
|
2020-07-14 10:43:48 +01:00
|
|
|
|
initial_permissions,
|
2018-01-19 13:45:54 +00:00
|
|
|
|
expected_initial_value,
|
|
|
|
|
|
posted_value,
|
|
|
|
|
|
expected_updated_permissions,
|
2017-02-03 10:42:01 +00:00
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mocked_fn = mocker.patch(
|
|
|
|
|
|
"app.service_api_client.update_service", return_value=service_one
|
|
|
|
|
|
)
|
|
|
|
|
|
service_one["permissions"] = initial_permissions
|
2016-10-26 18:37:26 +01:00
|
|
|
|
|
2018-01-19 13:45:54 +00:00
|
|
|
|
page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_set_channel",
|
|
|
|
|
|
service_id=service_one["id"],
|
2019-01-29 14:51:31 +00:00
|
|
|
|
channel=channel,
|
2017-02-14 14:06:02 +00:00
|
|
|
|
)
|
2016-10-26 18:37:26 +01:00
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert normalize_spaces(page.select_one("main p").text) == expected_first_para
|
|
|
|
|
|
assert normalize_spaces(page.select_one("legend").text) == expected_legend
|
2019-01-29 14:51:31 +00:00
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert page.select_one("input[checked]")["value"] == expected_initial_value
|
|
|
|
|
|
assert len(page.select("input[checked]")) == 1
|
2018-01-19 13:45:54 +00:00
|
|
|
|
|
|
|
|
|
|
client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_set_channel",
|
|
|
|
|
|
service_id=service_one["id"],
|
2019-01-29 14:51:31 +00:00
|
|
|
|
channel=channel,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
_data={"enabled": posted_value},
|
2018-01-19 13:45:54 +00:00
|
|
|
|
_expected_redirect=url_for(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_settings",
|
|
|
|
|
|
service_id=service_one["id"],
|
|
|
|
|
|
),
|
2018-01-19 13:45:54 +00:00
|
|
|
|
)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert set(mocked_fn.call_args[1]["permissions"]) == set(
|
|
|
|
|
|
expected_updated_permissions
|
|
|
|
|
|
)
|
|
|
|
|
|
assert mocked_fn.call_args[0][0] == service_one["id"]
|
2016-10-26 18:37:26 +01:00
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("permission", "permissions", "expected_checked"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
("international_sms", ["international_sms"], "True"),
|
|
|
|
|
|
("international_sms", [""], "False"),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2022-12-05 15:33:44 -05:00
|
|
|
|
def test_show_international_sms_as_radio_button(
|
2017-09-26 14:05:02 +01:00
|
|
|
|
client_request,
|
|
|
|
|
|
service_one,
|
|
|
|
|
|
mocker,
|
2020-05-29 10:47:52 +01:00
|
|
|
|
permission,
|
2017-09-26 14:05:02 +01:00
|
|
|
|
permissions,
|
|
|
|
|
|
expected_checked,
|
|
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
service_one["permissions"] = permissions
|
2017-09-26 14:05:02 +01:00
|
|
|
|
|
|
|
|
|
|
checked_radios = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
f"main.service_set_{permission}",
|
|
|
|
|
|
service_id=service_one["id"],
|
2023-08-28 12:12:21 -04:00
|
|
|
|
).select(".usa-radio input[checked]")
|
2017-09-26 14:05:02 +01:00
|
|
|
|
|
|
|
|
|
|
assert len(checked_radios) == 1
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert checked_radios[0]["value"] == expected_checked
|
2017-09-26 14:05:02 +01:00
|
|
|
|
|
|
|
|
|
|
|
2023-09-29 16:37:11 -04:00
|
|
|
|
@pytest.mark.parametrize("permission", ["international_sms"])
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("post_value", "permission_expected_in_api_call"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
("True", True),
|
|
|
|
|
|
("False", False),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2022-12-05 15:33:44 -05:00
|
|
|
|
def test_switch_service_enable_international_sms(
|
2017-09-26 14:05:02 +01:00
|
|
|
|
client_request,
|
|
|
|
|
|
service_one,
|
|
|
|
|
|
mocker,
|
2020-05-29 10:47:52 +01:00
|
|
|
|
permission,
|
2017-09-26 14:05:02 +01:00
|
|
|
|
post_value,
|
2020-05-29 10:47:52 +01:00
|
|
|
|
permission_expected_in_api_call,
|
2017-04-24 14:02:07 +01:00
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mocked_fn = mocker.patch(
|
|
|
|
|
|
"app.service_api_client.update_service", return_value=service_one
|
|
|
|
|
|
)
|
2017-10-18 14:51:26 +01:00
|
|
|
|
client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
f"main.service_set_{permission}",
|
|
|
|
|
|
service_id=service_one["id"],
|
|
|
|
|
|
_data={"enabled": post_value},
|
|
|
|
|
|
_expected_redirect=url_for(
|
|
|
|
|
|
"main.service_settings", service_id=service_one["id"]
|
|
|
|
|
|
),
|
2017-04-24 14:02:07 +01:00
|
|
|
|
)
|
|
|
|
|
|
|
2020-05-29 10:47:52 +01:00
|
|
|
|
if permission_expected_in_api_call:
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert permission in mocked_fn.call_args[1]["permissions"]
|
2017-09-26 14:05:02 +01:00
|
|
|
|
else:
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert permission not in mocked_fn.call_args[1]["permissions"]
|
2017-09-26 14:05:02 +01:00
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert mocked_fn.call_args[0][0] == service_one["id"]
|
2017-04-24 14:02:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("user", "is_trial_service"),
|
|
|
|
|
|
[
|
|
|
|
|
|
(create_platform_admin_user(), True),
|
|
|
|
|
|
(create_platform_admin_user(), False),
|
|
|
|
|
|
(create_active_user_with_permissions(), True),
|
|
|
|
|
|
],
|
2023-08-25 09:12:23 -07:00
|
|
|
|
)
|
2017-02-03 10:42:01 +00:00
|
|
|
|
def test_archive_service_after_confirm(
|
2019-05-29 16:51:25 +01:00
|
|
|
|
client_request,
|
2017-10-18 14:51:26 +01:00
|
|
|
|
mocker,
|
2023-07-12 12:09:44 -04:00
|
|
|
|
mock_get_organizations,
|
|
|
|
|
|
mock_get_service_and_organization_counts,
|
|
|
|
|
|
mock_get_organizations_and_services_for_user,
|
2020-05-22 11:19:49 +01:00
|
|
|
|
mock_get_users_by_service,
|
2021-01-25 14:03:16 +00:00
|
|
|
|
mock_get_service_templates,
|
2021-07-14 14:43:04 +01:00
|
|
|
|
service_one,
|
2019-05-29 16:51:25 +01:00
|
|
|
|
user,
|
2021-07-14 14:43:04 +01:00
|
|
|
|
is_trial_service,
|
2017-02-03 10:42:01 +00:00
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
service_one["restricted"] = is_trial_service
|
|
|
|
|
|
mock_api = mocker.patch("app.service_api_client.post")
|
|
|
|
|
|
mock_event = mocker.patch(
|
|
|
|
|
|
"app.main.views.service_settings.create_archive_service_event"
|
|
|
|
|
|
)
|
|
|
|
|
|
redis_delete_mock = mocker.patch(
|
|
|
|
|
|
"app.notify_client.service_api_client.redis_client.delete"
|
|
|
|
|
|
)
|
|
|
|
|
|
mocker.patch("app.notify_client.service_api_client.redis_client.delete_by_pattern")
|
2021-07-08 15:30:31 +01:00
|
|
|
|
|
2019-12-19 16:59:07 +00:00
|
|
|
|
client_request.login(user)
|
2019-05-29 16:51:25 +01:00
|
|
|
|
page = client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.archive_service",
|
2019-05-29 16:51:25 +01:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
_follow_redirects=True,
|
|
|
|
|
|
)
|
2016-11-02 16:53:40 +00:00
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mock_api.assert_called_once_with(
|
|
|
|
|
|
"/service/{}/archive".format(SERVICE_ONE_ID), data=None
|
|
|
|
|
|
)
|
|
|
|
|
|
mock_event.assert_called_once_with(
|
|
|
|
|
|
service_id=SERVICE_ONE_ID, archived_by_id=user["id"]
|
|
|
|
|
|
)
|
2021-07-08 15:30:31 +01:00
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert normalize_spaces(page.select_one("h1").text) == "Choose service"
|
|
|
|
|
|
assert normalize_spaces(page.select_one(".banner-default-with-tick").text) == (
|
|
|
|
|
|
"‘service one’ was deleted"
|
2019-05-29 16:51:25 +01:00
|
|
|
|
)
|
2020-05-22 11:19:49 +01:00
|
|
|
|
# The one user which is part of this service has the sample_uuid as it's user ID
|
2020-05-27 11:56:07 +01:00
|
|
|
|
assert call(f"user-{sample_uuid()}") in redis_delete_mock.call_args_list
|
2016-11-02 16:53:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("user", "is_trial_service"),
|
|
|
|
|
|
[
|
2023-08-25 09:12:23 -07:00
|
|
|
|
pytest.param(create_active_user_with_permissions(), False),
|
|
|
|
|
|
pytest.param(create_active_user_no_settings_permission(), True),
|
2023-09-29 16:37:11 -04:00
|
|
|
|
],
|
2023-08-25 09:12:23 -07:00
|
|
|
|
)
|
2023-05-26 12:35:48 -07:00
|
|
|
|
def test_archive_service_after_confirm_error(
|
|
|
|
|
|
client_request,
|
|
|
|
|
|
mocker,
|
2023-07-12 12:09:44 -04:00
|
|
|
|
mock_get_organizations,
|
|
|
|
|
|
mock_get_service_and_organization_counts,
|
|
|
|
|
|
mock_get_organizations_and_services_for_user,
|
2023-05-26 12:35:48 -07:00
|
|
|
|
mock_get_users_by_service,
|
|
|
|
|
|
mock_get_service_templates,
|
|
|
|
|
|
service_one,
|
|
|
|
|
|
user,
|
|
|
|
|
|
is_trial_service,
|
|
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
service_one["restricted"] = is_trial_service
|
|
|
|
|
|
mocker.patch("app.service_api_client.post")
|
|
|
|
|
|
mocker.patch("app.main.views.service_settings.create_archive_service_event")
|
|
|
|
|
|
mocker.patch("app.notify_client.service_api_client.redis_client.delete")
|
|
|
|
|
|
mocker.patch("app.notify_client.service_api_client.redis_client.delete_by_pattern")
|
2023-05-26 12:35:48 -07:00
|
|
|
|
|
2023-10-30 08:42:11 -07:00
|
|
|
|
client_request.login(user)
|
|
|
|
|
|
with pytest.raises(expected_exception=AssertionError):
|
2023-05-26 12:35:48 -07:00
|
|
|
|
client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.archive_service",
|
2023-05-26 12:35:48 -07:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
_follow_redirects=True,
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-09-29 16:37:11 -04:00
|
|
|
|
@pytest.mark.usefixtures("_mock_get_service_settings_page_common")
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("user", "is_trial_service"),
|
|
|
|
|
|
[
|
|
|
|
|
|
(create_platform_admin_user(), True),
|
|
|
|
|
|
(create_platform_admin_user(), False),
|
|
|
|
|
|
(create_active_user_with_permissions(), True),
|
|
|
|
|
|
],
|
2023-08-25 09:12:23 -07:00
|
|
|
|
)
|
2017-02-03 10:42:01 +00:00
|
|
|
|
def test_archive_service_prompts_user(
|
2019-05-29 16:51:25 +01:00
|
|
|
|
client_request,
|
2017-10-18 14:51:26 +01:00
|
|
|
|
mocker,
|
|
|
|
|
|
single_reply_to_email_address,
|
2021-07-14 14:43:04 +01:00
|
|
|
|
service_one,
|
2017-10-24 15:37:44 +01:00
|
|
|
|
single_sms_sender,
|
2019-05-29 16:51:25 +01:00
|
|
|
|
user,
|
2021-07-14 14:43:04 +01:00
|
|
|
|
is_trial_service,
|
2017-02-03 10:42:01 +00:00
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mock_api = mocker.patch("app.service_api_client.post")
|
|
|
|
|
|
service_one["restricted"] = is_trial_service
|
2019-12-19 16:59:07 +00:00
|
|
|
|
client_request.login(user)
|
2016-11-08 14:33:53 +00:00
|
|
|
|
|
2019-05-29 16:51:25 +01:00
|
|
|
|
settings_page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.archive_service", service_id=SERVICE_ONE_ID
|
2019-05-29 16:51:25 +01:00
|
|
|
|
)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
delete_link = settings_page.select(".page-footer-link a")[0]
|
|
|
|
|
|
assert normalize_spaces(delete_link.text) == "Delete this service"
|
|
|
|
|
|
assert delete_link["href"] == url_for(
|
|
|
|
|
|
"main.archive_service",
|
2019-05-29 16:51:25 +01:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
)
|
2016-11-08 14:33:53 +00:00
|
|
|
|
|
2019-05-29 16:51:25 +01:00
|
|
|
|
delete_page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.archive_service",
|
2019-05-29 16:51:25 +01:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert normalize_spaces(delete_page.select_one(".banner-dangerous").text) == (
|
|
|
|
|
|
"Are you sure you want to delete ‘service one’? "
|
|
|
|
|
|
"There’s no way to undo this. "
|
|
|
|
|
|
"Yes, delete"
|
2019-05-29 16:51:25 +01:00
|
|
|
|
)
|
2021-07-14 14:43:04 +01:00
|
|
|
|
assert mock_api.called is False
|
2016-11-08 14:33:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
2023-09-29 16:37:11 -04:00
|
|
|
|
@pytest.mark.usefixtures("_mock_get_service_settings_page_common")
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("user", "is_trial_service"),
|
|
|
|
|
|
[
|
2023-08-25 09:12:23 -07:00
|
|
|
|
pytest.param(create_active_user_with_permissions(), False),
|
|
|
|
|
|
pytest.param(create_active_user_no_settings_permission(), True),
|
2023-09-29 16:37:11 -04:00
|
|
|
|
],
|
2023-08-25 09:12:23 -07:00
|
|
|
|
)
|
2023-05-26 12:35:48 -07:00
|
|
|
|
def test_archive_service_prompts_user_error(
|
|
|
|
|
|
client_request,
|
|
|
|
|
|
mocker,
|
|
|
|
|
|
single_reply_to_email_address,
|
|
|
|
|
|
service_one,
|
|
|
|
|
|
single_sms_sender,
|
|
|
|
|
|
user,
|
|
|
|
|
|
is_trial_service,
|
|
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mocker.patch("app.service_api_client.post")
|
|
|
|
|
|
service_one["restricted"] = is_trial_service
|
2023-05-26 12:35:48 -07:00
|
|
|
|
client_request.login(user)
|
|
|
|
|
|
|
|
|
|
|
|
with pytest.raises(expected_exception=AssertionError):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
client_request.get("main.archive_service", service_id=SERVICE_ONE_ID)
|
2023-05-26 12:35:48 -07:00
|
|
|
|
|
|
|
|
|
|
|
2023-09-29 16:37:11 -04:00
|
|
|
|
@pytest.mark.usefixtures("_mock_get_service_settings_page_common")
|
2017-02-03 10:42:01 +00:00
|
|
|
|
def test_cant_archive_inactive_service(
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request,
|
|
|
|
|
|
platform_admin_user,
|
2017-10-18 14:51:26 +01:00
|
|
|
|
service_one,
|
|
|
|
|
|
single_reply_to_email_address,
|
2017-10-24 15:37:44 +01:00
|
|
|
|
single_sms_sender,
|
2017-02-03 10:42:01 +00:00
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
service_one["active"] = False
|
2016-11-02 16:53:40 +00:00
|
|
|
|
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request.login(platform_admin_user)
|
|
|
|
|
|
page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_settings",
|
|
|
|
|
|
service_id=service_one["id"],
|
2021-12-30 16:13:49 +00:00
|
|
|
|
)
|
2016-11-02 16:53:40 +00:00
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert "Delete service" not in {a.text for a in page.find_all("a", class_="button")}
|
2017-01-31 15:56:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
2023-09-29 16:37:11 -04:00
|
|
|
|
@pytest.mark.parametrize("user", [create_platform_admin_user()])
|
2017-02-03 10:42:01 +00:00
|
|
|
|
def test_suspend_service_after_confirm(
|
2021-07-08 15:56:58 +01:00
|
|
|
|
client_request,
|
|
|
|
|
|
user,
|
2017-10-18 14:51:26 +01:00
|
|
|
|
mocker,
|
2017-02-03 10:42:01 +00:00
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mock_api = mocker.patch("app.service_api_client.post")
|
|
|
|
|
|
mock_event = mocker.patch(
|
|
|
|
|
|
"app.main.views.service_settings.create_suspend_service_event"
|
|
|
|
|
|
)
|
2017-01-31 15:56:06 +00:00
|
|
|
|
|
2021-07-08 15:56:58 +01:00
|
|
|
|
client_request.login(user)
|
|
|
|
|
|
client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.suspend_service",
|
2021-07-08 15:56:58 +01:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
_expected_redirect=url_for(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_settings",
|
2021-07-08 15:56:58 +01:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
),
|
|
|
|
|
|
)
|
2017-01-31 15:56:06 +00:00
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mock_api.assert_called_once_with(
|
|
|
|
|
|
"/service/{}/suspend".format(SERVICE_ONE_ID), data=None
|
|
|
|
|
|
)
|
|
|
|
|
|
mock_event.assert_called_once_with(
|
|
|
|
|
|
service_id=SERVICE_ONE_ID, suspended_by_id=user["id"]
|
|
|
|
|
|
)
|
2017-01-31 15:56:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
2023-09-29 16:37:11 -04:00
|
|
|
|
@pytest.mark.parametrize("user", [pytest.param(create_active_user_with_permissions())])
|
2023-05-26 12:35:48 -07:00
|
|
|
|
def test_suspend_service_after_confirm_error(
|
|
|
|
|
|
client_request,
|
|
|
|
|
|
user,
|
|
|
|
|
|
mocker,
|
|
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mocker.patch("app.service_api_client.post")
|
|
|
|
|
|
mocker.patch("app.main.views.service_settings.create_suspend_service_event")
|
2023-10-30 08:42:11 -07:00
|
|
|
|
client_request.login(user)
|
|
|
|
|
|
with pytest.raises(expected_exception=AssertionError):
|
2023-05-26 12:35:48 -07:00
|
|
|
|
client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.suspend_service",
|
2023-05-26 12:35:48 -07:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
_expected_redirect=url_for(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_settings",
|
2023-05-26 12:35:48 -07:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
),
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-09-29 16:37:11 -04:00
|
|
|
|
@pytest.mark.usefixtures("_mock_get_service_settings_page_common")
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
|
|
|
|
|
"user",
|
2023-09-29 16:37:11 -04:00
|
|
|
|
[
|
2023-08-25 09:12:23 -07:00
|
|
|
|
create_platform_admin_user(),
|
|
|
|
|
|
pytest.param(create_active_user_with_permissions()),
|
2023-09-29 16:37:11 -04:00
|
|
|
|
],
|
2023-08-25 09:12:23 -07:00
|
|
|
|
)
|
2017-02-03 10:42:01 +00:00
|
|
|
|
def test_suspend_service_prompts_user(
|
2021-07-08 15:56:58 +01:00
|
|
|
|
client_request,
|
|
|
|
|
|
user,
|
2017-10-18 14:51:26 +01:00
|
|
|
|
service_one,
|
|
|
|
|
|
mocker,
|
|
|
|
|
|
single_reply_to_email_address,
|
2017-10-24 15:37:44 +01:00
|
|
|
|
single_sms_sender,
|
2017-02-03 10:42:01 +00:00
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mock_api = mocker.patch("app.service_api_client.post")
|
2017-01-31 15:56:06 +00:00
|
|
|
|
|
2021-07-08 15:56:58 +01:00
|
|
|
|
client_request.login(user)
|
2023-05-26 14:52:33 -07:00
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
if user["email_address"] != "platform@admin.gsa.gov":
|
2023-05-26 14:52:33 -07:00
|
|
|
|
with pytest.raises(expected_exception=AssertionError):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
client_request.get("main.suspend_service", service_id=service_one["id"])
|
2023-05-26 14:52:33 -07:00
|
|
|
|
return
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
page = client_request.get("main.suspend_service", service_id=service_one["id"])
|
2017-01-31 15:56:06 +00:00
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert (
|
|
|
|
|
|
"This will suspend the service and revoke all api keys. Are you sure you want to suspend this service?"
|
|
|
|
|
|
in page.find("div", class_="banner-dangerous").text
|
|
|
|
|
|
)
|
2021-07-08 15:56:58 +01:00
|
|
|
|
assert mock_api.called is False
|
2017-01-31 15:56:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
2023-09-29 16:37:11 -04:00
|
|
|
|
@pytest.mark.usefixtures("_mock_get_service_settings_page_common")
|
2017-02-03 10:42:01 +00:00
|
|
|
|
def test_cant_suspend_inactive_service(
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request,
|
|
|
|
|
|
platform_admin_user,
|
2017-10-18 14:51:26 +01:00
|
|
|
|
service_one,
|
|
|
|
|
|
single_reply_to_email_address,
|
2017-10-24 15:37:44 +01:00
|
|
|
|
single_sms_sender,
|
2017-02-03 10:42:01 +00:00
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
service_one["active"] = False
|
2017-01-31 15:56:06 +00:00
|
|
|
|
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request.login(platform_admin_user)
|
|
|
|
|
|
page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_settings",
|
|
|
|
|
|
service_id=service_one["id"],
|
2021-12-30 16:13:49 +00:00
|
|
|
|
)
|
2017-01-31 15:56:06 +00:00
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert "Suspend service" not in {
|
|
|
|
|
|
a.text for a in page.find_all("a", class_="button")
|
|
|
|
|
|
}
|
2017-01-31 15:56:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
|
|
|
|
|
"user",
|
2023-09-29 16:37:11 -04:00
|
|
|
|
[
|
2023-08-25 09:12:23 -07:00
|
|
|
|
create_platform_admin_user(),
|
|
|
|
|
|
create_active_user_with_permissions(),
|
2023-09-29 16:37:11 -04:00
|
|
|
|
],
|
2023-08-25 09:12:23 -07:00
|
|
|
|
)
|
2017-02-03 10:42:01 +00:00
|
|
|
|
def test_resume_service_after_confirm(
|
2017-10-18 14:51:26 +01:00
|
|
|
|
mocker,
|
2021-07-12 15:54:37 +01:00
|
|
|
|
user,
|
|
|
|
|
|
service_one,
|
|
|
|
|
|
client_request,
|
2017-02-03 10:42:01 +00:00
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
service_one["active"] = False
|
|
|
|
|
|
mock_api = mocker.patch("app.service_api_client.post")
|
|
|
|
|
|
mock_event = mocker.patch(
|
|
|
|
|
|
"app.main.views.service_settings.create_resume_service_event"
|
|
|
|
|
|
)
|
2017-01-31 15:56:06 +00:00
|
|
|
|
|
2021-07-12 15:54:37 +01:00
|
|
|
|
client_request.login(user)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
if user["email_address"] != "platform@admin.gsa.gov":
|
2023-05-29 07:01:35 -07:00
|
|
|
|
client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.resume_service",
|
2023-05-29 07:01:35 -07:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
_expected_status=403,
|
|
|
|
|
|
)
|
|
|
|
|
|
return
|
|
|
|
|
|
|
2021-07-12 15:54:37 +01:00
|
|
|
|
client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.resume_service",
|
2021-07-12 15:54:37 +01:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
_expected_redirect=url_for(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_settings",
|
2021-07-12 15:54:37 +01:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
),
|
2021-07-12 15:54:37 +01:00
|
|
|
|
)
|
2017-01-31 15:56:06 +00:00
|
|
|
|
|
2024-03-13 14:46:34 -07:00
|
|
|
|
mock_api.assert_called_once_with(f"/service/{SERVICE_ONE_ID}/resume", data=None)
|
2024-03-08 15:00:48 -08:00
|
|
|
|
mock_event.assert_called_once_with(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
service_id=SERVICE_ONE_ID, resumed_by_id=user["id"]
|
|
|
|
|
|
)
|
2017-01-31 15:56:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
2023-09-29 16:37:11 -04:00
|
|
|
|
@pytest.mark.usefixtures("_mock_get_service_settings_page_common")
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
|
|
|
|
|
"user",
|
2023-09-29 16:37:11 -04:00
|
|
|
|
[
|
2023-08-25 09:12:23 -07:00
|
|
|
|
create_platform_admin_user(),
|
|
|
|
|
|
pytest.param(create_active_user_with_permissions(), marks=pytest.mark.xfail),
|
2023-09-29 16:37:11 -04:00
|
|
|
|
],
|
2023-08-25 09:12:23 -07:00
|
|
|
|
)
|
2017-02-03 10:42:01 +00:00
|
|
|
|
def test_resume_service_prompts_user(
|
2021-07-12 15:54:37 +01:00
|
|
|
|
client_request,
|
|
|
|
|
|
user,
|
2017-10-18 14:51:26 +01:00
|
|
|
|
service_one,
|
|
|
|
|
|
single_reply_to_email_address,
|
2017-10-24 15:37:44 +01:00
|
|
|
|
single_sms_sender,
|
2017-10-18 14:51:26 +01:00
|
|
|
|
mocker,
|
2017-02-03 10:42:01 +00:00
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
service_one["active"] = False
|
|
|
|
|
|
mock_api = mocker.patch("app.service_api_client.post")
|
2017-01-31 15:56:06 +00:00
|
|
|
|
|
2021-07-12 15:54:37 +01:00
|
|
|
|
client_request.login(user)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
page = client_request.get("main.resume_service", service_id=service_one["id"])
|
2017-01-31 15:56:06 +00:00
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert (
|
|
|
|
|
|
"This will resume the service. New api key are required for this service to use the API."
|
|
|
|
|
|
in page.find("div", class_="banner-dangerous").text
|
|
|
|
|
|
)
|
2021-07-12 15:54:37 +01:00
|
|
|
|
assert mock_api.called is False
|
2017-01-31 15:56:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
2023-09-29 16:37:11 -04:00
|
|
|
|
@pytest.mark.usefixtures("_mock_get_service_settings_page_common")
|
2017-02-03 10:42:01 +00:00
|
|
|
|
def test_cant_resume_active_service(
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request,
|
|
|
|
|
|
platform_admin_user,
|
2017-10-18 14:51:26 +01:00
|
|
|
|
service_one,
|
|
|
|
|
|
single_reply_to_email_address,
|
2017-10-24 15:37:44 +01:00
|
|
|
|
single_sms_sender,
|
2017-02-03 10:42:01 +00:00
|
|
|
|
):
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request.login(platform_admin_user)
|
|
|
|
|
|
page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_settings",
|
|
|
|
|
|
service_id=service_one["id"],
|
2021-12-30 16:13:49 +00:00
|
|
|
|
)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert "Resume service" not in {a.text for a in page.find_all("a", class_="button")}
|
2017-05-02 11:03:10 +01:00
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("contact_details_type", "contact_details_value"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
("url", "http://example.com/"),
|
|
|
|
|
|
("email_address", "me@example.com"),
|
|
|
|
|
|
("phone_number", "202 867 5309"),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2020-02-25 11:27:43 +00:00
|
|
|
|
def test_send_files_by_email_contact_details_prefills_the_form_with_the_existing_contact_details(
|
2018-08-09 11:59:05 +01:00
|
|
|
|
client_request,
|
|
|
|
|
|
service_one,
|
|
|
|
|
|
contact_details_type,
|
|
|
|
|
|
contact_details_value,
|
|
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
service_one["contact_link"] = contact_details_value
|
2018-06-05 10:37:41 +01:00
|
|
|
|
|
|
|
|
|
|
page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.send_files_by_email_contact_details", service_id=SERVICE_ONE_ID
|
|
|
|
|
|
)
|
2025-02-24 16:11:42 -05:00
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert page.find(
|
|
|
|
|
|
"input", attrs={"name": "contact_details_type", "value": contact_details_type}
|
|
|
|
|
|
).has_attr("checked")
|
2025-02-24 16:11:42 -05:00
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert (
|
2025-02-24 16:11:42 -05:00
|
|
|
|
page.find("input", {"name": contact_details_type}).get("value")
|
2023-08-25 09:12:23 -07:00
|
|
|
|
== contact_details_value
|
2018-06-05 10:37:41 +01:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-09-29 16:37:11 -04:00
|
|
|
|
@pytest.mark.usefixtures("_mock_get_service_settings_page_common")
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("contact_details_type", "old_value", "new_value"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
("url", "http://example.com/", "http://new-link.com/"),
|
|
|
|
|
|
("email_address", "old@example.com", "new@example.com"),
|
|
|
|
|
|
("phone_number", "2021234567", "2028901234"),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2020-02-25 11:27:43 +00:00
|
|
|
|
def test_send_files_by_email_contact_details_updates_contact_details_and_redirects_to_settings_page(
|
2018-08-09 11:59:05 +01:00
|
|
|
|
client_request,
|
|
|
|
|
|
service_one,
|
|
|
|
|
|
mock_update_service,
|
|
|
|
|
|
no_reply_to_email_addresses,
|
|
|
|
|
|
single_sms_sender,
|
|
|
|
|
|
contact_details_type,
|
|
|
|
|
|
old_value,
|
|
|
|
|
|
new_value,
|
|
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
service_one["contact_link"] = old_value
|
2018-08-09 11:59:05 +01:00
|
|
|
|
|
|
|
|
|
|
page = client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.send_files_by_email_contact_details",
|
|
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2018-08-09 11:59:05 +01:00
|
|
|
|
_data={
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"contact_details_type": contact_details_type,
|
2018-08-09 11:59:05 +01:00
|
|
|
|
contact_details_type: new_value,
|
|
|
|
|
|
},
|
2023-08-25 09:12:23 -07:00
|
|
|
|
_follow_redirects=True,
|
2018-08-09 11:59:05 +01:00
|
|
|
|
)
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert page.h1.text == "Settings"
|
2018-08-09 11:59:05 +01:00
|
|
|
|
mock_update_service.assert_called_once_with(SERVICE_ONE_ID, contact_link=new_value)
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-09-29 16:37:11 -04:00
|
|
|
|
@pytest.mark.usefixtures("_mock_get_service_settings_page_common")
|
2020-02-25 11:27:43 +00:00
|
|
|
|
def test_send_files_by_email_contact_details_uses_the_selected_field_when_multiple_textboxes_contain_data(
|
2018-06-05 10:37:41 +01:00
|
|
|
|
client_request,
|
|
|
|
|
|
service_one,
|
|
|
|
|
|
mock_update_service,
|
|
|
|
|
|
no_reply_to_email_addresses,
|
|
|
|
|
|
single_sms_sender,
|
|
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
service_one["contact_link"] = "http://www.old-url.com"
|
2018-06-05 10:37:41 +01:00
|
|
|
|
|
|
|
|
|
|
page = client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.send_files_by_email_contact_details",
|
|
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2018-06-05 10:37:41 +01:00
|
|
|
|
_data={
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"contact_details_type": "url",
|
|
|
|
|
|
"url": "http://www.new-url.com",
|
|
|
|
|
|
"email_address": "me@example.com",
|
|
|
|
|
|
"phone_number": "202 867 5309",
|
2018-06-05 10:37:41 +01:00
|
|
|
|
},
|
2023-08-25 09:12:23 -07:00
|
|
|
|
_follow_redirects=True,
|
2018-06-05 10:37:41 +01:00
|
|
|
|
)
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert page.h1.text == "Settings"
|
|
|
|
|
|
mock_update_service.assert_called_once_with(
|
|
|
|
|
|
SERVICE_ONE_ID, contact_link="http://www.new-url.com"
|
|
|
|
|
|
)
|
2018-08-09 11:59:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
2022-09-13 13:30:52 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("contact_link", "subheader", "button_selected"),
|
2020-02-25 11:27:43 +00:00
|
|
|
|
[
|
2023-08-25 09:12:23 -07:00
|
|
|
|
(
|
|
|
|
|
|
"contact.me@gsa.gov",
|
|
|
|
|
|
"Change contact details for the file download page",
|
|
|
|
|
|
True,
|
|
|
|
|
|
),
|
|
|
|
|
|
(None, "Add contact details to the file download page", False),
|
|
|
|
|
|
],
|
2020-02-25 11:27:43 +00:00
|
|
|
|
)
|
|
|
|
|
|
def test_send_files_by_email_contact_details_page(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
client_request,
|
|
|
|
|
|
service_one,
|
|
|
|
|
|
active_user_with_permissions,
|
|
|
|
|
|
contact_link,
|
|
|
|
|
|
subheader,
|
|
|
|
|
|
button_selected,
|
2020-02-25 11:27:43 +00:00
|
|
|
|
):
|
|
|
|
|
|
service_one["contact_link"] = contact_link
|
|
|
|
|
|
page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.send_files_by_email_contact_details", service_id=SERVICE_ONE_ID
|
2020-02-25 11:27:43 +00:00
|
|
|
|
)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert normalize_spaces(page.find_all("h2")[0].text) == subheader
|
2020-02-25 11:27:43 +00:00
|
|
|
|
if button_selected:
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert (
|
|
|
|
|
|
"checked"
|
|
|
|
|
|
in page.find(
|
|
|
|
|
|
"input", {"name": "contact_details_type", "value": "email_address"}
|
|
|
|
|
|
).attrs
|
|
|
|
|
|
)
|
2020-02-25 11:27:43 +00:00
|
|
|
|
else:
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert (
|
|
|
|
|
|
"checked"
|
|
|
|
|
|
not in page.find(
|
|
|
|
|
|
"input", {"name": "contact_details_type", "value": "email_address"}
|
|
|
|
|
|
).attrs
|
|
|
|
|
|
)
|
2020-02-25 11:27:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_send_files_by_email_contact_details_displays_error_message_when_no_radio_button_selected(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
client_request, service_one
|
2018-08-09 11:59:05 +01:00
|
|
|
|
):
|
|
|
|
|
|
page = client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.send_files_by_email_contact_details",
|
|
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2018-08-09 11:59:05 +01:00
|
|
|
|
_data={
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"contact_details_type": None,
|
|
|
|
|
|
"url": "",
|
|
|
|
|
|
"email_address": "",
|
|
|
|
|
|
"phone_number": "",
|
2018-08-09 11:59:05 +01:00
|
|
|
|
},
|
2023-08-25 09:12:23 -07:00
|
|
|
|
_follow_redirects=True,
|
|
|
|
|
|
)
|
|
|
|
|
|
assert (
|
|
|
|
|
|
normalize_spaces(page.find("span", class_="error-message").text)
|
|
|
|
|
|
== "Select an option"
|
2018-06-05 10:37:41 +01:00
|
|
|
|
)
|
2020-02-25 11:27:43 +00:00
|
|
|
|
assert normalize_spaces(page.h1.text) == "Send files by email"
|
2018-06-05 10:37:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("contact_details_type", "invalid_value", "error"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
("url", "invalid.com/", "Must be a valid URL"),
|
|
|
|
|
|
("email_address", "me@co", "Enter a valid email address"),
|
|
|
|
|
|
("phone_number", "abcde", "Must be a valid phone number"),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2020-02-25 11:27:43 +00:00
|
|
|
|
def test_send_files_by_email_contact_details_does_not_update_invalid_contact_details(
|
2018-06-05 10:37:41 +01:00
|
|
|
|
mocker,
|
|
|
|
|
|
client_request,
|
|
|
|
|
|
service_one,
|
2018-08-09 11:59:05 +01:00
|
|
|
|
contact_details_type,
|
|
|
|
|
|
invalid_value,
|
|
|
|
|
|
error,
|
2018-06-05 10:37:41 +01:00
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
service_one["contact_link"] = "http://example.com/"
|
2025-07-21 16:37:55 -07:00
|
|
|
|
service_one["permissions"].append(ServicePermission.UPLOAD_DOCUMENT)
|
2018-06-05 10:37:41 +01:00
|
|
|
|
|
|
|
|
|
|
page = client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.send_files_by_email_contact_details",
|
|
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2018-06-05 10:37:41 +01:00
|
|
|
|
_data={
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"contact_details_type": contact_details_type,
|
2018-08-09 11:59:05 +01:00
|
|
|
|
contact_details_type: invalid_value,
|
2018-06-05 10:37:41 +01:00
|
|
|
|
},
|
2023-08-25 09:12:23 -07:00
|
|
|
|
_follow_redirects=True,
|
2018-06-05 10:37:41 +01:00
|
|
|
|
)
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert error in page.find("span", class_="usa-error-message").text
|
2020-02-25 11:27:43 +00:00
|
|
|
|
assert normalize_spaces(page.h1.text) == "Send files by email"
|
2018-06-05 15:28:22 +01:00
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("endpoint", "permissions", "expected_p"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
2024-04-17 12:01:37 -04:00
|
|
|
|
(
|
|
|
|
|
|
"main.service_set_auth_type",
|
|
|
|
|
|
[],
|
|
|
|
|
|
(
|
|
|
|
|
|
"Your username, password, and multi-factor authentication options are handled by Login.gov."
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
2017-11-23 09:59:34 +00:00
|
|
|
|
(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_set_auth_type",
|
2025-07-21 16:37:55 -07:00
|
|
|
|
[ServicePermission.EMAIL_AUTH],
|
2024-04-17 12:01:37 -04:00
|
|
|
|
(
|
|
|
|
|
|
"Your username, password, and multi-factor authentication options are handled by Login.gov."
|
|
|
|
|
|
),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2017-05-02 11:03:10 +01:00
|
|
|
|
def test_invitation_pages(
|
2019-03-26 12:35:32 +00:00
|
|
|
|
client_request,
|
2017-08-24 09:57:43 +01:00
|
|
|
|
service_one,
|
2017-08-24 10:02:02 +01:00
|
|
|
|
mock_get_inbound_number_for_service,
|
2019-08-23 13:52:41 +01:00
|
|
|
|
single_sms_sender,
|
2017-08-24 10:13:14 +01:00
|
|
|
|
endpoint,
|
|
|
|
|
|
permissions,
|
|
|
|
|
|
expected_p,
|
2017-05-02 11:03:10 +01:00
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
service_one["permissions"] = permissions
|
2019-03-26 12:35:32 +00:00
|
|
|
|
page = client_request.get(
|
|
|
|
|
|
endpoint,
|
|
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
)
|
2017-05-02 11:03:10 +01:00
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert normalize_spaces(page.select("main p")[0].text) == expected_p
|
2017-09-05 16:35:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_service_settings_when_inbound_number_is_not_set(
|
2019-03-26 12:35:32 +00:00
|
|
|
|
client_request,
|
2017-09-05 16:35:33 +01:00
|
|
|
|
service_one,
|
2017-10-05 15:47:12 +01:00
|
|
|
|
single_reply_to_email_address,
|
2023-07-12 12:09:44 -04:00
|
|
|
|
mock_get_organization,
|
2017-10-24 15:37:44 +01:00
|
|
|
|
single_sms_sender,
|
2017-09-05 16:35:33 +01:00
|
|
|
|
mocker,
|
2017-11-09 13:18:09 +00:00
|
|
|
|
mock_get_free_sms_fragment_limit,
|
2018-07-17 14:39:04 +01:00
|
|
|
|
mock_get_service_data_retention,
|
2017-09-05 16:35:33 +01:00
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mocker.patch(
|
|
|
|
|
|
"app.inbound_number_client.get_inbound_sms_number_for_service",
|
|
|
|
|
|
return_value={"data": {}},
|
|
|
|
|
|
)
|
2019-03-26 12:35:32 +00:00
|
|
|
|
client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_settings",
|
2019-03-26 12:35:32 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
)
|
2017-09-05 16:35:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_set_inbound_sms_when_inbound_number_is_not_set(
|
2019-03-26 12:35:32 +00:00
|
|
|
|
client_request,
|
2017-09-05 16:35:33 +01:00
|
|
|
|
service_one,
|
2017-10-05 15:47:12 +01:00
|
|
|
|
single_reply_to_email_address,
|
2019-08-23 13:52:41 +01:00
|
|
|
|
single_sms_sender,
|
2017-09-05 16:35:33 +01:00
|
|
|
|
mocker,
|
|
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mocker.patch(
|
|
|
|
|
|
"app.inbound_number_client.get_inbound_sms_number_for_service",
|
|
|
|
|
|
return_value={"data": {}},
|
|
|
|
|
|
)
|
2019-03-26 12:35:32 +00:00
|
|
|
|
client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_set_inbound_sms",
|
2019-03-26 12:35:32 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
)
|
2017-09-26 14:41:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
2023-09-29 16:37:11 -04:00
|
|
|
|
("user", "expected_paragraphs"),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
[
|
|
|
|
|
|
(
|
|
|
|
|
|
create_active_user_with_permissions(),
|
|
|
|
|
|
[
|
|
|
|
|
|
"Your service can receive text messages sent to 2028675309.",
|
|
|
|
|
|
"You can still send text messages from a sender name if you "
|
|
|
|
|
|
"need to, but users will not be able to reply to those messages.",
|
|
|
|
|
|
"Contact us if you want to switch this feature off.",
|
|
|
|
|
|
"You can set up callbacks for received text messages on the API integration page.",
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
(
|
|
|
|
|
|
create_active_user_no_api_key_permission(),
|
|
|
|
|
|
[
|
|
|
|
|
|
"Your service can receive text messages sent to 2028675309.",
|
|
|
|
|
|
"You can still send text messages from a sender name if you "
|
|
|
|
|
|
"need to, but users will not be able to reply to those messages.",
|
|
|
|
|
|
"Contact us if you want to switch this feature off.",
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2018-01-11 17:22:27 +00:00
|
|
|
|
def test_set_inbound_sms_when_inbound_number_is_set(
|
2019-03-26 12:35:32 +00:00
|
|
|
|
client_request,
|
2018-01-11 17:22:27 +00:00
|
|
|
|
service_one,
|
|
|
|
|
|
mocker,
|
|
|
|
|
|
user,
|
|
|
|
|
|
expected_paragraphs,
|
|
|
|
|
|
):
|
2025-07-21 16:37:55 -07:00
|
|
|
|
service_one["permissions"] = [ServicePermission.INBOUND_SMS]
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mocker.patch(
|
|
|
|
|
|
"app.inbound_number_client.get_inbound_sms_number_for_service",
|
|
|
|
|
|
return_value={"data": {"number": "2028675309"}},
|
|
|
|
|
|
)
|
2019-12-19 16:59:07 +00:00
|
|
|
|
client_request.login(user)
|
2019-03-26 12:35:32 +00:00
|
|
|
|
page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_set_inbound_sms",
|
2019-03-26 12:35:32 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
paragraphs = page.select("main p")
|
2018-01-11 17:22:27 +00:00
|
|
|
|
|
|
|
|
|
|
assert len(paragraphs) == len(expected_paragraphs)
|
|
|
|
|
|
|
|
|
|
|
|
for index, p in enumerate(expected_paragraphs):
|
|
|
|
|
|
assert normalize_spaces(paragraphs[index].text) == p
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-03 15:01:41 +00:00
|
|
|
|
def test_show_sms_prefixing_setting_page(
|
|
|
|
|
|
client_request,
|
|
|
|
|
|
mock_update_service,
|
|
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
page = client_request.get("main.service_set_sms_prefix", service_id=SERVICE_ONE_ID)
|
|
|
|
|
|
assert normalize_spaces(page.select_one("legend").text) == (
|
|
|
|
|
|
"Start all text messages with ‘service one:’"
|
2017-11-03 15:01:41 +00:00
|
|
|
|
)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
radios = page.select("input[type=radio]")
|
2017-11-03 15:01:41 +00:00
|
|
|
|
assert len(radios) == 2
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert radios[0]["value"] == "True"
|
|
|
|
|
|
assert radios[0]["checked"] == ""
|
|
|
|
|
|
assert radios[1]["value"] == "False"
|
2017-11-03 15:01:41 +00:00
|
|
|
|
with pytest.raises(KeyError):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert radios[1]["checked"]
|
2017-11-03 15:01:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
@pytest.mark.parametrize(
|
|
|
|
|
|
"post_value",
|
|
|
|
|
|
[
|
|
|
|
|
|
True,
|
|
|
|
|
|
False,
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
2017-11-03 15:01:41 +00:00
|
|
|
|
def test_updates_sms_prefixing(
|
|
|
|
|
|
client_request,
|
|
|
|
|
|
mock_update_service,
|
|
|
|
|
|
post_value,
|
|
|
|
|
|
):
|
|
|
|
|
|
client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_set_sms_prefix",
|
|
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
_data={"enabled": post_value},
|
2017-11-03 15:01:41 +00:00
|
|
|
|
_expected_redirect=url_for(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_settings",
|
|
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
),
|
2017-11-03 15:01:41 +00:00
|
|
|
|
)
|
|
|
|
|
|
mock_update_service.assert_called_once_with(
|
2018-04-06 13:37:49 +01:00
|
|
|
|
SERVICE_ONE_ID,
|
2020-07-03 11:48:17 +01:00
|
|
|
|
prefix_sms=post_value,
|
2017-11-03 15:01:41 +00:00
|
|
|
|
)
|
2018-02-12 09:26:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
2023-07-12 12:09:44 -04:00
|
|
|
|
def test_select_organization(
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request,
|
|
|
|
|
|
platform_admin_user,
|
2018-02-12 09:26:13 +00:00
|
|
|
|
service_one,
|
2023-07-12 12:09:44 -04:00
|
|
|
|
mock_get_organization,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mock_get_organizations,
|
2018-02-12 09:26:13 +00:00
|
|
|
|
):
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request.login(platform_admin_user)
|
|
|
|
|
|
page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
".link_service_to_organization",
|
|
|
|
|
|
service_id=service_one["id"],
|
2018-02-12 09:26:13 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
2023-08-28 12:12:21 -04:00
|
|
|
|
assert len(page.select(".usa-radio")) == 3
|
2018-02-12 09:26:13 +00:00
|
|
|
|
for i in range(0, 3):
|
|
|
|
|
|
assert normalize_spaces(
|
2023-08-28 12:12:21 -04:00
|
|
|
|
page.select(".usa-radio label")[i].text
|
2023-08-25 09:12:23 -07:00
|
|
|
|
) == "Org {}".format(i + 1)
|
2018-02-12 09:26:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
2023-07-12 12:09:44 -04:00
|
|
|
|
def test_select_organization_shows_message_if_no_orgs(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
client_request, platform_admin_user, service_one, mock_get_organization, mocker
|
2018-02-14 16:13:11 +00:00
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mocker.patch("app.organizations_client.get_organizations", return_value=[])
|
2018-02-14 16:13:11 +00:00
|
|
|
|
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request.login(platform_admin_user)
|
|
|
|
|
|
page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
".link_service_to_organization",
|
|
|
|
|
|
service_id=service_one["id"],
|
2018-02-14 16:13:11 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert normalize_spaces(page.select_one("main p").text) == "No organizations"
|
|
|
|
|
|
assert not page.select_one("main button")
|
2018-02-14 16:13:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2023-07-12 12:09:44 -04:00
|
|
|
|
def test_update_service_organization(
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request,
|
|
|
|
|
|
platform_admin_user,
|
2018-02-12 09:26:13 +00:00
|
|
|
|
service_one,
|
2023-07-12 12:09:44 -04:00
|
|
|
|
mock_get_organization,
|
|
|
|
|
|
mock_get_organizations,
|
|
|
|
|
|
mock_update_service_organization,
|
2018-02-12 09:26:13 +00:00
|
|
|
|
):
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request.login(platform_admin_user)
|
|
|
|
|
|
client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
".link_service_to_organization",
|
|
|
|
|
|
service_id=service_one["id"],
|
|
|
|
|
|
_data={"organizations": "7aa5d4e9-4385-4488-a489-07812ba13384"},
|
2018-02-12 09:26:13 +00:00
|
|
|
|
)
|
2023-07-12 12:09:44 -04:00
|
|
|
|
mock_update_service_organization.assert_called_once_with(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
service_one["id"], "7aa5d4e9-4385-4488-a489-07812ba13384"
|
2018-02-12 09:26:13 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-07-12 12:09:44 -04:00
|
|
|
|
def test_update_service_organization_does_not_update_if_same_value(
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request,
|
|
|
|
|
|
platform_admin_user,
|
2018-02-12 09:26:13 +00:00
|
|
|
|
service_one,
|
2023-07-12 12:09:44 -04:00
|
|
|
|
mock_get_organization,
|
|
|
|
|
|
mock_get_organizations,
|
|
|
|
|
|
mock_update_service_organization,
|
2018-02-12 09:26:13 +00:00
|
|
|
|
):
|
2021-03-08 15:36:23 +00:00
|
|
|
|
org_id = "7aa5d4e9-4385-4488-a489-07812ba13383"
|
2023-08-25 09:12:23 -07:00
|
|
|
|
service_one["organization"] = org_id
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request.login(platform_admin_user)
|
|
|
|
|
|
client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
".link_service_to_organization",
|
|
|
|
|
|
service_id=service_one["id"],
|
|
|
|
|
|
_data={"organizations": org_id},
|
2018-02-12 09:26:13 +00:00
|
|
|
|
)
|
2023-07-12 12:09:44 -04:00
|
|
|
|
assert mock_update_service_organization.called is False
|
2018-05-18 14:05:48 +01:00
|
|
|
|
|
|
|
|
|
|
|
2018-07-17 15:50:40 +01:00
|
|
|
|
def test_show_service_data_retention(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
client_request,
|
|
|
|
|
|
platform_admin_user,
|
|
|
|
|
|
service_one,
|
|
|
|
|
|
mock_get_service_data_retention,
|
2018-07-17 15:50:40 +01:00
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mock_get_service_data_retention.return_value[0]["days_of_retention"] = 5
|
2018-12-03 17:19:38 +00:00
|
|
|
|
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request.login(platform_admin_user)
|
|
|
|
|
|
page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.data_retention",
|
|
|
|
|
|
service_id=service_one["id"],
|
2021-12-30 16:13:49 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
rows = page.select("tbody tr")
|
2018-07-18 15:31:34 +01:00
|
|
|
|
assert len(rows) == 1
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert normalize_spaces(rows[0].text) == "Email 5 days Change"
|
2018-07-17 15:50:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_view_add_service_data_retention(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
client_request,
|
|
|
|
|
|
platform_admin_user,
|
|
|
|
|
|
service_one,
|
2018-07-17 15:50:40 +01:00
|
|
|
|
):
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request.login(platform_admin_user)
|
|
|
|
|
|
page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.add_data_retention",
|
|
|
|
|
|
service_id=service_one["id"],
|
2021-12-30 16:13:49 +00:00
|
|
|
|
)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert normalize_spaces(page.select_one("input")["value"]) == "email"
|
|
|
|
|
|
assert page.find("input", attrs={"name": "days_of_retention"})
|
2018-07-17 15:50:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_add_service_data_retention(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
client_request, platform_admin_user, service_one, mock_create_service_data_retention
|
2018-07-17 15:50:40 +01:00
|
|
|
|
):
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request.login(platform_admin_user)
|
|
|
|
|
|
client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.add_data_retention",
|
|
|
|
|
|
service_id=service_one["id"],
|
|
|
|
|
|
_data={"notification_type": "email", "days_of_retention": 5},
|
2021-12-30 16:13:49 +00:00
|
|
|
|
_expected_redirect=url_for(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.data_retention",
|
|
|
|
|
|
service_id=service_one["id"],
|
2021-12-30 16:13:49 +00:00
|
|
|
|
),
|
2019-08-27 16:01:28 +01:00
|
|
|
|
)
|
2018-07-17 15:50:40 +01:00
|
|
|
|
assert mock_create_service_data_retention.called
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_update_service_data_retention(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
client_request,
|
|
|
|
|
|
platform_admin_user,
|
|
|
|
|
|
service_one,
|
|
|
|
|
|
fake_uuid,
|
|
|
|
|
|
mock_get_service_data_retention,
|
|
|
|
|
|
mock_update_service_data_retention,
|
2018-07-17 15:50:40 +01:00
|
|
|
|
):
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request.login(platform_admin_user)
|
|
|
|
|
|
client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.edit_data_retention",
|
|
|
|
|
|
service_id=service_one["id"],
|
2021-12-30 16:13:49 +00:00
|
|
|
|
data_retention_id=str(fake_uuid),
|
2023-08-25 09:12:23 -07:00
|
|
|
|
_data={"days_of_retention": 5},
|
2021-12-30 16:13:49 +00:00
|
|
|
|
_expected_redirect=url_for(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.data_retention",
|
|
|
|
|
|
service_id=service_one["id"],
|
2021-12-30 16:13:49 +00:00
|
|
|
|
),
|
2019-08-27 16:01:28 +01:00
|
|
|
|
)
|
2018-07-17 15:50:40 +01:00
|
|
|
|
assert mock_update_service_data_retention.called
|
2018-07-18 15:31:34 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_update_service_data_retention_return_validation_error_for_negative_days_of_retention(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
client_request,
|
|
|
|
|
|
platform_admin_user,
|
|
|
|
|
|
service_one,
|
|
|
|
|
|
fake_uuid,
|
|
|
|
|
|
mock_get_service_data_retention,
|
|
|
|
|
|
mock_update_service_data_retention,
|
2018-07-18 15:31:34 +01:00
|
|
|
|
):
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request.login(platform_admin_user)
|
|
|
|
|
|
page = client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.edit_data_retention",
|
|
|
|
|
|
service_id=service_one["id"],
|
2021-12-30 16:13:49 +00:00
|
|
|
|
data_retention_id=fake_uuid,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
_data={"days_of_retention": -5},
|
2021-12-30 16:13:49 +00:00
|
|
|
|
_expected_status=200,
|
2019-08-27 16:01:28 +01:00
|
|
|
|
)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert (
|
|
|
|
|
|
"Must be between 3 and 90" in page.find("span", class_="usa-error-message").text
|
|
|
|
|
|
)
|
2018-12-03 17:19:38 +00:00
|
|
|
|
assert mock_get_service_data_retention.called
|
2018-07-18 15:31:34 +01:00
|
|
|
|
assert not mock_update_service_data_retention.called
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_update_service_data_retention_populates_form(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
client_request,
|
|
|
|
|
|
platform_admin_user,
|
|
|
|
|
|
service_one,
|
|
|
|
|
|
fake_uuid,
|
|
|
|
|
|
mock_get_service_data_retention,
|
2018-07-18 15:31:34 +01:00
|
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
|
mock_get_service_data_retention.return_value[0]["days_of_retention"] = 5
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request.login(platform_admin_user)
|
|
|
|
|
|
page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.edit_data_retention",
|
|
|
|
|
|
service_id=service_one["id"],
|
2021-12-30 16:13:49 +00:00
|
|
|
|
data_retention_id=fake_uuid,
|
|
|
|
|
|
)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert page.find("input", attrs={"name": "days_of_retention"})["value"] == "5"
|
2021-01-14 18:00:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
2023-09-29 16:37:11 -04:00
|
|
|
|
@pytest.mark.usefixtures("_mock_get_service_settings_page_common")
|
2021-01-14 18:00:44 +00:00
|
|
|
|
def test_service_settings_links_to_edit_service_notes_page_for_platform_admins(
|
|
|
|
|
|
mocker,
|
|
|
|
|
|
service_one,
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request,
|
|
|
|
|
|
platform_admin_user,
|
2021-01-14 18:00:44 +00:00
|
|
|
|
no_reply_to_email_addresses,
|
|
|
|
|
|
single_sms_sender,
|
|
|
|
|
|
):
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request.login(platform_admin_user)
|
|
|
|
|
|
page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
".service_settings",
|
2021-12-30 16:13:49 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert (
|
|
|
|
|
|
len(
|
|
|
|
|
|
page.find_all(
|
|
|
|
|
|
"a", attrs={"href": "/services/{}/notes".format(SERVICE_ONE_ID)}
|
|
|
|
|
|
)
|
|
|
|
|
|
)
|
|
|
|
|
|
== 1
|
|
|
|
|
|
)
|
2021-01-15 13:36:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_view_edit_service_notes(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
client_request,
|
|
|
|
|
|
platform_admin_user,
|
|
|
|
|
|
service_one,
|
2021-01-15 13:36:12 +00:00
|
|
|
|
):
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request.login(platform_admin_user)
|
|
|
|
|
|
page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.edit_service_notes",
|
2021-12-30 16:13:49 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert page.select_one("h1").text == "Edit service notes"
|
|
|
|
|
|
assert page.find("label", class_="usa-label").text.strip() == "Notes"
|
|
|
|
|
|
assert page.find("textarea").attrs["name"] == "notes"
|
2021-01-15 15:38:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_update_service_notes(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
client_request, platform_admin_user, service_one, mock_update_service
|
2021-01-15 15:38:39 +00:00
|
|
|
|
):
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request.login(platform_admin_user)
|
|
|
|
|
|
client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.edit_service_notes",
|
2021-12-30 16:13:49 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
_data={"notes": "Very fluffy"},
|
2021-12-30 16:13:49 +00:00
|
|
|
|
_expected_redirect=url_for(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_settings",
|
2021-01-15 15:38:39 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
),
|
2021-01-15 15:38:39 +00:00
|
|
|
|
)
|
|
|
|
|
|
mock_update_service.assert_called_with(SERVICE_ONE_ID, notes="Very fluffy")
|
2021-01-25 14:52:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
2023-09-29 16:37:11 -04:00
|
|
|
|
@pytest.mark.usefixtures("_mock_get_service_settings_page_common")
|
2021-01-25 14:52:07 +00:00
|
|
|
|
def test_service_settings_links_to_edit_service_billing_details_page_for_platform_admins(
|
|
|
|
|
|
mocker,
|
|
|
|
|
|
service_one,
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request,
|
|
|
|
|
|
platform_admin_user,
|
2021-01-25 14:52:07 +00:00
|
|
|
|
no_reply_to_email_addresses,
|
|
|
|
|
|
single_sms_sender,
|
|
|
|
|
|
):
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request.login(platform_admin_user)
|
|
|
|
|
|
page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
".service_settings",
|
2021-12-30 16:13:49 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
)
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert (
|
|
|
|
|
|
len(
|
|
|
|
|
|
page.find_all(
|
|
|
|
|
|
"a",
|
|
|
|
|
|
attrs={
|
|
|
|
|
|
"href": "/services/{}/edit-billing-details".format(SERVICE_ONE_ID)
|
|
|
|
|
|
},
|
|
|
|
|
|
)
|
|
|
|
|
|
)
|
|
|
|
|
|
== 1
|
|
|
|
|
|
)
|
2021-01-25 15:40:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_view_edit_service_billing_details(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
client_request,
|
|
|
|
|
|
platform_admin_user,
|
|
|
|
|
|
service_one,
|
2021-01-25 15:40:49 +00:00
|
|
|
|
):
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request.login(platform_admin_user)
|
|
|
|
|
|
page = client_request.get(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.edit_service_billing_details",
|
2021-12-30 16:13:49 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert page.select_one("h1").text == "Change billing details"
|
|
|
|
|
|
labels = page.find_all("label", class_="form-label")
|
2021-01-25 15:40:49 +00:00
|
|
|
|
labels_list = [
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"Contact email addresses",
|
|
|
|
|
|
"Contact names",
|
|
|
|
|
|
"Reference",
|
|
|
|
|
|
"Purchase order number",
|
|
|
|
|
|
"Notes",
|
2021-01-25 15:40:49 +00:00
|
|
|
|
]
|
|
|
|
|
|
for label in labels:
|
|
|
|
|
|
assert label.text.strip() in labels_list
|
2023-08-28 14:40:33 -04:00
|
|
|
|
textbox_names = page.find_all("input", class_="usa-input ")
|
2021-01-26 10:41:22 +00:00
|
|
|
|
names_list = [
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"billing_contact_email_addresses",
|
|
|
|
|
|
"billing_contact_names",
|
|
|
|
|
|
"billing_reference",
|
|
|
|
|
|
"purchase_order_number",
|
2021-01-26 10:41:22 +00:00
|
|
|
|
]
|
2021-01-25 15:40:49 +00:00
|
|
|
|
|
|
|
|
|
|
for name in textbox_names:
|
|
|
|
|
|
assert name.attrs["name"] in names_list
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
assert page.find("textarea").attrs["name"] == "notes"
|
2021-01-27 18:20:25 +00:00
|
|
|
|
|
2021-01-25 15:40:49 +00:00
|
|
|
|
|
|
|
|
|
|
def test_update_service_billing_details(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
client_request, platform_admin_user, service_one, mock_update_service
|
2021-01-25 15:40:49 +00:00
|
|
|
|
):
|
2021-12-30 16:13:49 +00:00
|
|
|
|
client_request.login(platform_admin_user)
|
|
|
|
|
|
client_request.post(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.edit_service_billing_details",
|
2021-12-30 16:13:49 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
_data={
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"billing_contact_email_addresses": "accounts@fluff.gsa.gov",
|
|
|
|
|
|
"billing_contact_names": "Flannellette von Fluff",
|
|
|
|
|
|
"billing_reference": "",
|
|
|
|
|
|
"purchase_order_number": "PO1234",
|
|
|
|
|
|
"notes": "very fluffy, give extra allowance",
|
2021-12-30 16:13:49 +00:00
|
|
|
|
},
|
|
|
|
|
|
_expected_redirect=url_for(
|
2023-08-25 09:12:23 -07:00
|
|
|
|
"main.service_settings",
|
2021-12-30 16:13:49 +00:00
|
|
|
|
service_id=SERVICE_ONE_ID,
|
|
|
|
|
|
),
|
2021-01-25 15:40:49 +00:00
|
|
|
|
)
|
|
|
|
|
|
mock_update_service.assert_called_with(
|
|
|
|
|
|
SERVICE_ONE_ID,
|
2023-08-25 09:12:23 -07:00
|
|
|
|
billing_contact_email_addresses="accounts@fluff.gsa.gov",
|
|
|
|
|
|
billing_contact_names="Flannellette von Fluff",
|
|
|
|
|
|
billing_reference="",
|
|
|
|
|
|
purchase_order_number="PO1234",
|
|
|
|
|
|
notes="very fluffy, give extra allowance",
|
2021-01-25 15:40:49 +00:00
|
|
|
|
)
|