mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-06 17:28:24 -04:00
Merge pull request #3179 from alphagov/validate-service-and-org-name
Validate service and organisation name
This commit is contained in:
@@ -160,6 +160,29 @@ def test_create_new_organisation_validates(
|
||||
assert mock_create_organisation.called is False
|
||||
|
||||
|
||||
def test_create_new_organisation_fails_if_new_name_has_less_than_2_alphanumeric_characters(
|
||||
client_request,
|
||||
platform_admin_user,
|
||||
mocker,
|
||||
):
|
||||
mock_create_organisation = mocker.patch(
|
||||
'app.organisations_client.create_organisation'
|
||||
)
|
||||
|
||||
client_request.login(platform_admin_user)
|
||||
page = client_request.post(
|
||||
'.add_organisation',
|
||||
_data={
|
||||
'name': ".",
|
||||
'organisation_type': 'local',
|
||||
'crown_status': 'non-crown',
|
||||
},
|
||||
_expected_status=200,
|
||||
)
|
||||
assert mock_create_organisation.called is False
|
||||
assert page.find("span", {"class": "error-message"})
|
||||
|
||||
|
||||
@pytest.mark.parametrize('organisation_type, organisation, expected_status', (
|
||||
('nhs_gp', None, 200),
|
||||
('central', None, 403),
|
||||
|
||||
@@ -277,6 +277,18 @@ def test_should_return_form_errors_when_service_name_is_empty(
|
||||
assert 'Cannot be empty' in page.text
|
||||
|
||||
|
||||
def test_add_service_fails_if_service_name_has_less_than_2_alphanumeric_characters(
|
||||
client_request,
|
||||
mock_get_organisation_by_domain,
|
||||
):
|
||||
page = client_request.post(
|
||||
'main.add_service',
|
||||
data={"name": "."},
|
||||
_expected_status=200,
|
||||
)
|
||||
assert page.find("span", {"class": "error-message"})
|
||||
|
||||
|
||||
def test_should_return_form_errors_with_duplicate_service_name_regardless_of_case(
|
||||
client_request,
|
||||
mock_create_duplicate_service,
|
||||
|
||||
@@ -397,6 +397,22 @@ def test_should_not_hit_api_if_service_name_hasnt_changed(
|
||||
assert not mock_update_service.called
|
||||
|
||||
|
||||
def test_service_name_change_fails_if_new_name_has_less_than_2_alphanumeric_characters(
|
||||
client_request,
|
||||
mock_update_service,
|
||||
mock_service_name_is_unique,
|
||||
):
|
||||
page = client_request.post(
|
||||
'main.service_name_change',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
_data={'name': "."},
|
||||
_expected_status=200,
|
||||
)
|
||||
assert not mock_service_name_is_unique.called
|
||||
assert not mock_update_service.called
|
||||
assert page.find("span", {"class": "error-message"})
|
||||
|
||||
|
||||
@pytest.mark.parametrize('user, expected_text, expected_link', [
|
||||
(
|
||||
active_user_with_permissions,
|
||||
|
||||
Reference in New Issue
Block a user