File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -2285,7 +2285,10 @@ class UrlForm(StripWhitespaceForm):
22852285 "URL" ,
22862286 validators = [
22872287 DataRequired (message = "Cannot be empty" ),
2288- Regexp (regex = "^https.*" , message = "Must be a valid https URL" ),
2288+ Regexp (
2289+ regex = r"^https:\/\/docs\.notifications\.service\.gov\.uk\/(python|ruby|node|net|java|php|rest-api)\.html#.+" ,
2290+ message = "Must be a valid https URL, pointing to a section within the GOV.UK Notify API docs." ,
2291+ ),
22892292 ],
22902293 )
22912294
Original file line number Diff line number Diff line change @@ -402,3 +402,24 @@ def test_POST_guidance_api_documentation_section(client_request):
402402 section_tag = "send-a-file-by-email" ,
403403 ),
404404 )
405+
406+
407+ @pytest .mark .parametrize (
408+ "url" ,
409+ [
410+ "" , # empty string
411+ "https://docs.notifications.service.gov.uk/python.html" , # no section
412+ "https://docs.payments.service.gov.uk/making_payments/#creating-a-payment" , # URL is notfor Notify's docs
413+ ],
414+ )
415+ def test_POST_guidance_api_documentation_section_with_incorrect_url (client_request , url ):
416+ page = client_request .post (
417+ "main.guidance_api_documentation_section" ,
418+ _data = {"url" : "https://docs.notifications.service.gov.uk/python.html#send-a-file-by-email" },
419+ _expected_status = 200 ,
420+ )
421+
422+ assert (
423+ "Must be a valid https URL, pointing to a section within the GOV.UK Notify API docs."
424+ in page .select_one (".govuk-error-message" ).text
425+ )
You can’t perform that action at this time.
0 commit comments