mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-11 02:23:19 -04:00
Merge branch 'main' into 2721-create-enums-and-replace-hardcoded-status-strings-with-enums-PART5
This commit is contained in:
@@ -52,7 +52,8 @@ def test_services_pages_that_org_users_are_allowed_to_see(
|
||||
api_user_active["services"] = user_services
|
||||
api_user_active["organizations"] = user_organizations
|
||||
api_user_active["permissions"] = {
|
||||
service_id: ["manage_users", ServicePermission.MANAGE_SETTINGS] for service_id in user_services
|
||||
service_id: [ServicePermission.MANAGE_USERS, ServicePermission.MANAGE_SETTINGS]
|
||||
for service_id in user_services
|
||||
}
|
||||
service = service_json(
|
||||
name="SERVICE WITH ORG",
|
||||
|
||||
@@ -5,7 +5,7 @@ from flask import url_for
|
||||
from freezegun import freeze_time
|
||||
|
||||
import app
|
||||
from app.enums import AuthType, ServicePermission
|
||||
from app.enums import ServicePermission
|
||||
from notifications_python_client.errors import HTTPError
|
||||
from tests import service_json
|
||||
from tests.conftest import (
|
||||
@@ -139,7 +139,7 @@ def test_existing_user_accept_invite_calls_api_and_redirects_to_dashboard(
|
||||
client_request.logout()
|
||||
expected_service = service_one["id"]
|
||||
expected_permissions = {
|
||||
"view_activity",
|
||||
ServicePermission.VIEW_ACTIVITY,
|
||||
"send_messages",
|
||||
"manage_service",
|
||||
"manage_api_keys",
|
||||
@@ -418,7 +418,7 @@ def test_existing_signed_out_user_accept_invite_redirects_to_sign_in(
|
||||
client_request.logout()
|
||||
expected_service = service_one["id"]
|
||||
expected_permissions = {
|
||||
"view_activity",
|
||||
ServicePermission.VIEW_ACTIVITY,
|
||||
"send_messages",
|
||||
"manage_service",
|
||||
"manage_api_keys",
|
||||
@@ -650,7 +650,7 @@ def test_new_invited_user_verifies_and_added_to_service(
|
||||
# when they post codes back to admin user should be added to
|
||||
# service and sent on to dash board
|
||||
expected_permissions = {
|
||||
"view_activity",
|
||||
ServicePermission.VIEW_ACTIVITY,
|
||||
"send_messages",
|
||||
"manage_service",
|
||||
"manage_api_keys",
|
||||
|
||||
@@ -372,7 +372,7 @@ def test_route_invalid_permissions(
|
||||
"GET",
|
||||
403,
|
||||
url_for(route, service_id=service_one["id"], key_id=fake_uuid),
|
||||
["view_activity"],
|
||||
[ServicePermission.VIEW_ACTIVITY],
|
||||
api_user_active,
|
||||
service_one,
|
||||
)
|
||||
|
||||
@@ -920,7 +920,12 @@ def test_menu_send_messages(
|
||||
mocker,
|
||||
api_user_active,
|
||||
service_one,
|
||||
["view_activity", ServicePermission.SEND_TEXTS, "send_emails", "manage_service"],
|
||||
[
|
||||
ServicePermission.VIEW_ACTIVITY,
|
||||
ServicePermission.SEND_TEXTS,
|
||||
ServicePermission.SEND_EMAILS,
|
||||
ServicePermission.MANAGE_SERVICE,
|
||||
],
|
||||
)
|
||||
page = str(page)
|
||||
assert (
|
||||
@@ -957,7 +962,12 @@ def test_menu_manage_service(
|
||||
mocker,
|
||||
api_user_active,
|
||||
service_one,
|
||||
["view_activity", ServicePermission.MANAGE_TEMPLATES, "manage_users", ServicePermission.MANAGE_SETTINGS],
|
||||
[
|
||||
ServicePermission.VIEW_ACTIVITY,
|
||||
ServicePermission.MANAGE_TEMPLATES,
|
||||
ServicePermission.MANAGE_USERS,
|
||||
ServicePermission.MANAGE_SETTINGS
|
||||
],
|
||||
)
|
||||
page = str(page)
|
||||
assert (
|
||||
@@ -994,7 +1004,12 @@ def test_menu_main_settings(
|
||||
mocker,
|
||||
api_user_active,
|
||||
service_one,
|
||||
["view_activity", "user_profile", "manage_users", ServicePermission.MANAGE_SETTINGS],
|
||||
[
|
||||
ServicePermission.VIEW_ACTIVITY,
|
||||
"user_profile",
|
||||
ServicePermission.MANAGE_USERS,
|
||||
ServicePermission.MANAGE_SETTINGS,
|
||||
],
|
||||
)
|
||||
page = str(page)
|
||||
assert (
|
||||
@@ -1030,7 +1045,7 @@ def test_menu_manage_api_keys(
|
||||
mocker,
|
||||
api_user_active,
|
||||
service_one,
|
||||
["view_activity"],
|
||||
[ServicePermission.VIEW_ACTIVITY],
|
||||
)
|
||||
|
||||
page = str(page)
|
||||
@@ -1107,7 +1122,7 @@ def test_route_for_service_permissions(
|
||||
"GET",
|
||||
200,
|
||||
url_for("main.service_dashboard", service_id=service_one["id"]),
|
||||
["view_activity"],
|
||||
[ServicePermission.VIEW_ACTIVITY],
|
||||
api_user_active,
|
||||
service_one,
|
||||
)
|
||||
|
||||
@@ -304,7 +304,7 @@ def test_service_without_caseworking_doesnt_show_admin_vs_caseworker(
|
||||
|
||||
for idx in range(len(permission_checkboxes)):
|
||||
assert permission_checkboxes[idx]["name"] == "permissions_field"
|
||||
assert permission_checkboxes[0]["value"] == "view_activity"
|
||||
assert permission_checkboxes[0]["value"] == ServicePermission.VIEW_ACTIVITY
|
||||
assert permission_checkboxes[1]["value"] == ServicePermission.SEND_MESSAGES
|
||||
assert permission_checkboxes[2]["value"] == ServicePermission.MANAGE_TEMPLATES
|
||||
assert permission_checkboxes[3]["value"] == ServicePermission.MANAGE_SERVICE
|
||||
@@ -387,7 +387,7 @@ def test_user_with_no_mobile_number_cant_be_set_to_sms_auth(
|
||||
"main.edit_user_permissions",
|
||||
{"user_id": sample_uuid()},
|
||||
[
|
||||
("view_activity", True),
|
||||
(ServicePermission.VIEW_ACTIVITY, True),
|
||||
(ServicePermission.SEND_MESSAGES, True),
|
||||
(ServicePermission.MANAGE_TEMPLATES, True),
|
||||
(ServicePermission.MANAGE_SERVICE, True),
|
||||
@@ -397,7 +397,7 @@ def test_user_with_no_mobile_number_cant_be_set_to_sms_auth(
|
||||
"main.invite_user",
|
||||
{},
|
||||
[
|
||||
("view_activity", False),
|
||||
(ServicePermission.VIEW_ACTIVITY, False),
|
||||
(ServicePermission.SEND_MESSAGES, False),
|
||||
(ServicePermission.MANAGE_TEMPLATES, False),
|
||||
(ServicePermission.MANAGE_SERVICE, False),
|
||||
@@ -483,14 +483,14 @@ def test_should_not_show_page_for_non_team_member(
|
||||
(
|
||||
{
|
||||
"permissions_field": [
|
||||
"view_activity",
|
||||
ServicePermission.VIEW_ACTIVITY,
|
||||
ServicePermission.SEND_MESSAGES,
|
||||
ServicePermission.MANAGE_TEMPLATES,
|
||||
ServicePermission.MANAGE_SERVICE,
|
||||
]
|
||||
},
|
||||
{
|
||||
"view_activity",
|
||||
ServicePermission.VIEW_ACTIVITY,
|
||||
ServicePermission.SEND_MESSAGES,
|
||||
ServicePermission.MANAGE_SERVICE,
|
||||
ServicePermission.MANAGE_TEMPLATES,
|
||||
@@ -499,13 +499,13 @@ def test_should_not_show_page_for_non_team_member(
|
||||
(
|
||||
{
|
||||
"permissions_field": [
|
||||
"view_activity",
|
||||
ServicePermission.VIEW_ACTIVITY,
|
||||
ServicePermission.SEND_MESSAGES,
|
||||
ServicePermission.MANAGE_TEMPLATES,
|
||||
]
|
||||
},
|
||||
{
|
||||
"view_activity",
|
||||
ServicePermission.VIEW_ACTIVITY,
|
||||
ServicePermission.SEND_MESSAGES,
|
||||
ServicePermission.MANAGE_TEMPLATES,
|
||||
},
|
||||
@@ -668,7 +668,7 @@ def test_cant_edit_user_folder_permissions_for_platform_admin_users(
|
||||
ServicePermission.MANAGE_SERVICE,
|
||||
ServicePermission.MANAGE_TEMPLATES,
|
||||
ServicePermission.SEND_MESSAGES,
|
||||
"view_activity",
|
||||
ServicePermission.VIEW_ACTIVITY,
|
||||
},
|
||||
folder_permissions=None,
|
||||
)
|
||||
@@ -1016,7 +1016,7 @@ def test_invite_user(
|
||||
_data={
|
||||
"email_address": email_address,
|
||||
"permissions_field": [
|
||||
"view_activity",
|
||||
ServicePermission.VIEW_ACTIVITY,
|
||||
ServicePermission.SEND_MESSAGES,
|
||||
ServicePermission.MANAGE_TEMPLATES,
|
||||
ServicePermission.MANAGE_SERVICE,
|
||||
@@ -1032,7 +1032,7 @@ def test_invite_user(
|
||||
ServicePermission.MANAGE_SERVICE,
|
||||
ServicePermission.MANAGE_TEMPLATES,
|
||||
ServicePermission.SEND_MESSAGES,
|
||||
"view_activity",
|
||||
ServicePermission.VIEW_ACTIVITY,
|
||||
}
|
||||
|
||||
app.invite_api_client.create_invite.assert_called_once_with(
|
||||
@@ -1125,7 +1125,7 @@ def test_invite_user_with_email_auth_service(
|
||||
_data={
|
||||
"email_address": email_address,
|
||||
"permissions_field": [
|
||||
"view_activity",
|
||||
ServicePermission.VIEW_ACTIVITY,
|
||||
ServicePermission.SEND_MESSAGES,
|
||||
ServicePermission.MANAGE_TEMPLATES,
|
||||
ServicePermission.MANAGE_SERVICE,
|
||||
@@ -1144,7 +1144,7 @@ def test_invite_user_with_email_auth_service(
|
||||
ServicePermission.MANAGE_SERVICE,
|
||||
ServicePermission.MANAGE_TEMPLATES,
|
||||
ServicePermission.SEND_MESSAGES,
|
||||
"view_activity",
|
||||
ServicePermission.VIEW_ACTIVITY,
|
||||
}
|
||||
|
||||
app.invite_api_client.create_invite.assert_called_once_with(
|
||||
|
||||
@@ -1178,13 +1178,13 @@ def test_get_users_report(client_request, platform_admin_user, mocker):
|
||||
"password_changed_at": "2023-07-21 14:12:54.832850",
|
||||
"permissions": {
|
||||
"test service": [
|
||||
"manage_users",
|
||||
ServicePermission.MANAGE_USERS,
|
||||
"manage_templates",
|
||||
ServicePermission.MANAGE_SETTINGS,
|
||||
ServicePermission.SEND_TEXTS,
|
||||
"send_emails",
|
||||
ServicePermission.SEND_EMAILS,
|
||||
"manage_api_keys",
|
||||
"view_activity",
|
||||
ServicePermission.VIEW_ACTIVITY,
|
||||
]
|
||||
},
|
||||
"platform_admin": True,
|
||||
|
||||
@@ -300,7 +300,7 @@ def test_register_from_email_auth_invite(
|
||||
"manage_api_keys",
|
||||
ServicePermission.MANAGE_SERVICE,
|
||||
ServicePermission.SEND_MESSAGES,
|
||||
"view_activity",
|
||||
ServicePermission.VIEW_ACTIVITY,
|
||||
},
|
||||
[],
|
||||
)
|
||||
|
||||
@@ -1717,7 +1717,7 @@ def test_send_one_off_email_to_self_without_placeholders_redirects_to_check_page
|
||||
{},
|
||||
),
|
||||
(
|
||||
{ServicePermission.SEND_MESSAGES, "view_activity"},
|
||||
{ServicePermission.SEND_MESSAGES, ServicePermission.VIEW_ACTIVITY},
|
||||
"main.choose_template",
|
||||
{},
|
||||
),
|
||||
@@ -2140,7 +2140,7 @@ def test_route_permissions(
|
||||
"GET",
|
||||
response_code,
|
||||
url_for(route, service_id=service_one["id"], template_id=fake_uuid),
|
||||
["view_activity", ServicePermission.SEND_MESSAGES],
|
||||
[ServicePermission.VIEW_ACTIVITY, ServicePermission.SEND_MESSAGES],
|
||||
api_user_active,
|
||||
service_one,
|
||||
)
|
||||
|
||||
@@ -607,10 +607,10 @@ def test_get_manage_folder_viewing_permissions_for_users_not_visible_when_no_man
|
||||
):
|
||||
active_user_with_permissions["permissions"][SERVICE_ONE_ID] = [
|
||||
ServicePermission.SEND_TEXTS,
|
||||
"send_emails",
|
||||
ServicePermission.SEND_EMAILS,
|
||||
"manage_templates",
|
||||
"manage_api_keys",
|
||||
"view_activity",
|
||||
ServicePermission.VIEW_ACTIVITY,
|
||||
]
|
||||
folder_id = str(uuid.uuid4())
|
||||
team_member = create_active_user_view_permissions(with_unique_id=True)
|
||||
@@ -861,10 +861,10 @@ def test_manage_folder_users_doesnt_change_permissions_current_user_cannot_manag
|
||||
):
|
||||
active_user_with_permissions["permissions"][SERVICE_ONE_ID] = [
|
||||
ServicePermission.SEND_TEXTS,
|
||||
"send_emails",
|
||||
ServicePermission.SEND_EMAILS,
|
||||
"manage_templates",
|
||||
"manage_api_keys",
|
||||
"view_activity",
|
||||
ServicePermission.VIEW_ACTIVITY,
|
||||
]
|
||||
team_member = create_active_user_view_permissions(with_unique_id=True)
|
||||
mock_update = mocker.patch("app.template_folder_api_client.update_template_folder")
|
||||
|
||||
@@ -518,7 +518,7 @@ def test_user_with_only_send_and_view_redirected_to_set_sender_for_one_off(
|
||||
):
|
||||
active_user_with_permissions["permissions"][SERVICE_ONE_ID] = [
|
||||
"send_messages",
|
||||
"view_activity",
|
||||
ServicePermission.VIEW_ACTIVITY,
|
||||
]
|
||||
client_request.login(active_user_with_permissions)
|
||||
client_request.get(
|
||||
@@ -538,7 +538,7 @@ def test_user_with_only_send_and_view_redirected_to_set_sender_for_one_off(
|
||||
("permissions", "links_to_be_shown", "permissions_warning_to_be_shown"),
|
||||
[
|
||||
(
|
||||
["view_activity"],
|
||||
[ServicePermission.VIEW_ACTIVITY],
|
||||
[],
|
||||
"If you need to send this text message or edit this template, contact your manager.",
|
||||
),
|
||||
@@ -575,7 +575,7 @@ def test_should_be_able_to_view_a_template_with_links(
|
||||
permissions_warning_to_be_shown,
|
||||
):
|
||||
active_user_with_permissions["permissions"][SERVICE_ONE_ID] = permissions + [
|
||||
"view_activity"
|
||||
ServicePermission.VIEW_ACTIVITY
|
||||
]
|
||||
client_request.login(active_user_with_permissions)
|
||||
|
||||
@@ -1698,7 +1698,7 @@ def test_route_invalid_permissions(
|
||||
template_type="sms",
|
||||
template_id=fake_uuid,
|
||||
),
|
||||
["view_activity"],
|
||||
[ServicePermission.VIEW_ACTIVITY],
|
||||
api_user_active,
|
||||
service_one,
|
||||
)
|
||||
|
||||
@@ -2,6 +2,7 @@ import pytest
|
||||
from flask import url_for
|
||||
|
||||
from app import current_user
|
||||
from app.enums import ServicePermission
|
||||
from tests import validate_route_permission
|
||||
from tests.conftest import SERVICE_ONE_ID, create_template, normalize_spaces
|
||||
|
||||
@@ -113,7 +114,7 @@ def test_should_403_if_user_does_not_have_send_permissions_for_tour_start(
|
||||
service_id=SERVICE_ONE_ID,
|
||||
template_id=fake_uuid,
|
||||
),
|
||||
["view_activity"],
|
||||
[ServicePermission.VIEW_ACTIVITY],
|
||||
api_user_active,
|
||||
service_one,
|
||||
)
|
||||
@@ -255,7 +256,7 @@ def test_should_403_if_user_does_not_have_send_permissions_for_tour_step(
|
||||
template_id=fake_uuid,
|
||||
step_index=1,
|
||||
),
|
||||
["view_activity"],
|
||||
[ServicePermission.VIEW_ACTIVITY],
|
||||
api_user_active,
|
||||
service_one,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user