mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-03 21:21:14 -04:00
Don’t let non-government users request to go live
Only users who work for government can accept the terms of use. This will save us from having to email these requesters back telling them they need to find someone else to submit the request.
This commit is contained in:
@@ -772,6 +772,38 @@ def test_should_check_for_mou_on_request_to_go_live(
|
||||
assert normalize_spaces(checklist_items[2].text) == expected_item
|
||||
|
||||
|
||||
def test_non_gov_user_is_told_they_cant_go_live(
|
||||
client_request,
|
||||
api_nongov_user_active,
|
||||
mocker,
|
||||
):
|
||||
mocker.patch(
|
||||
'app.main.views.service_settings.user_api_client.get_count_of_users_with_permission',
|
||||
return_value=0,
|
||||
)
|
||||
mocker.patch(
|
||||
'app.models.service.Service.all_templates',
|
||||
new_callable=PropertyMock,
|
||||
return_value=[],
|
||||
)
|
||||
mocker.patch(
|
||||
'app.main.views.service_settings.service_api_client.get_sms_senders',
|
||||
return_value=[],
|
||||
)
|
||||
mocker.patch(
|
||||
'app.main.views.service_settings.service_api_client.get_reply_to_email_addresses',
|
||||
return_value=[],
|
||||
)
|
||||
client_request.login(api_nongov_user_active)
|
||||
page = client_request.get(
|
||||
'main.request_to_go_live', service_id=SERVICE_ONE_ID
|
||||
)
|
||||
assert normalize_spaces(page.select_one('main p').text) == (
|
||||
'Only team members with a government email address can request to go live.'
|
||||
)
|
||||
assert page.select('.button') == []
|
||||
|
||||
|
||||
def test_should_show_request_to_go_live(
|
||||
client_request,
|
||||
):
|
||||
@@ -798,6 +830,20 @@ def test_should_show_request_to_go_live(
|
||||
) == label
|
||||
|
||||
|
||||
@pytest.mark.parametrize('method', ('get', 'post'))
|
||||
def test_non_gov_users_cant_request_to_go_live(
|
||||
client_request,
|
||||
api_nongov_user_active,
|
||||
method,
|
||||
):
|
||||
client_request.login(api_nongov_user_active)
|
||||
getattr(client_request, method)(
|
||||
'main.submit_request_to_go_live',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
_expected_status=403,
|
||||
)
|
||||
|
||||
|
||||
@freeze_time("2012-12-21")
|
||||
def test_should_redirect_after_request_to_go_live(
|
||||
client_request,
|
||||
|
||||
@@ -1135,19 +1135,29 @@ def api_user_active_email_auth(fake_uuid, email_address='test@user.gov.uk'):
|
||||
@pytest.fixture(scope='function')
|
||||
def api_nongov_user_active(fake_uuid):
|
||||
from app.notify_client.user_api_client import User
|
||||
user_data = {'id': fake_uuid,
|
||||
'name': 'Test User',
|
||||
'password': 'somepassword',
|
||||
'email_address': 'someuser@notonwhitelist.com',
|
||||
'mobile_number': '07700 900762',
|
||||
'state': 'active',
|
||||
'failed_login_count': 0,
|
||||
'permissions': {},
|
||||
'platform_admin': False,
|
||||
'auth_type': 'sms_auth',
|
||||
'password_changed_at': str(datetime.utcnow()),
|
||||
'organisations': []
|
||||
}
|
||||
user_data = {
|
||||
'id': fake_uuid,
|
||||
'name': 'Test User',
|
||||
'password': 'somepassword',
|
||||
'email_address': 'someuser@notonwhitelist.com',
|
||||
'mobile_number': '07700 900762',
|
||||
'state': 'active',
|
||||
'failed_login_count': 0,
|
||||
'permissions': {SERVICE_ONE_ID: [
|
||||
'send_texts',
|
||||
'send_emails',
|
||||
'send_letters',
|
||||
'manage_users',
|
||||
'manage_templates',
|
||||
'manage_settings',
|
||||
'manage_api_keys',
|
||||
'view_activity',
|
||||
]},
|
||||
'platform_admin': False,
|
||||
'auth_type': 'sms_auth',
|
||||
'password_changed_at': str(datetime.utcnow()),
|
||||
'organisations': []
|
||||
}
|
||||
user = User(user_data)
|
||||
return user
|
||||
|
||||
|
||||
Reference in New Issue
Block a user