mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-04 00:18:25 -04:00
Stop using _external=True in tests
It looks like, by default, Flask no longer makes full URLs, for example `https://example.com/path`. Instead it does `/path`. This will still work fine, and if anything is better because it reduces the number of bytes of HTML we are sending. It won’t mean that requests go over `http` instead of `https` without the protocol because we set the appropriate HSTS header here:0c57da7781/ansible/roles/paas-proxy/templates/admin.conf.j2 (L11)This commit changes all our tests to reflect that URLs no longer have the protocol and domain in them. `_external=True` is Flask’s way of saying whether a URL should be generated with the domain and protocol (`True`) or without it (`False`). Again, I can’t find the changelog or diff where this was introuduced, but if you’d like to go spelunking then here’s a starting point:50374e3cfe/src/flask/helpers.py (L192)
This commit is contained in:
@@ -145,7 +145,6 @@ def test_user_invite_already_accepted(
|
||||
_expected_redirect=url_for(
|
||||
'main.organisation_dashboard',
|
||||
org_id=ORGANISATION_ID,
|
||||
_external=True,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -170,7 +169,6 @@ def test_existing_user_invite_already_is_member_of_organisation(
|
||||
_expected_redirect=url_for(
|
||||
'main.organisation_dashboard',
|
||||
org_id=ORGANISATION_ID,
|
||||
_external=True
|
||||
),
|
||||
)
|
||||
|
||||
@@ -203,7 +201,6 @@ def test_existing_user_invite_not_a_member_of_organisation(
|
||||
_expected_redirect=url_for(
|
||||
'main.organisation_dashboard',
|
||||
org_id=ORGANISATION_ID,
|
||||
_external=True,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -231,7 +228,7 @@ def test_user_accepts_invite(
|
||||
client_request.get(
|
||||
'main.accept_org_invite',
|
||||
token='thisisnotarealtoken',
|
||||
_expected_redirect=url_for('main.register_from_org_invite', _external=True)
|
||||
_expected_redirect=url_for('main.register_from_org_invite')
|
||||
)
|
||||
|
||||
mock_check_org_invite_token.assert_called_once_with('thisisnotarealtoken')
|
||||
@@ -337,7 +334,7 @@ def test_org_user_registers_with_email_already_in_use(
|
||||
'email_address': sample_org_invite['email_address'],
|
||||
'organisation': sample_org_invite['organisation'],
|
||||
},
|
||||
_expected_redirect=url_for('main.verify', _external=True),
|
||||
_expected_redirect=url_for('main.verify'),
|
||||
)
|
||||
|
||||
mock_get_user_by_email.assert_called_once_with(
|
||||
@@ -372,7 +369,7 @@ def test_org_user_registration(
|
||||
'password': 'validPassword!',
|
||||
'organisation': sample_org_invite['organisation'],
|
||||
},
|
||||
_expected_redirect=url_for('main.verify', _external=True)
|
||||
_expected_redirect=url_for('main.verify')
|
||||
)
|
||||
|
||||
assert mock_get_user_by_email.called is False
|
||||
@@ -412,6 +409,5 @@ def test_verified_org_user_redirects_to_dashboard(
|
||||
_expected_redirect=url_for(
|
||||
'main.organisation_dashboard',
|
||||
org_id=invited_org_user['organisation'],
|
||||
_external=True
|
||||
),
|
||||
)
|
||||
|
||||
@@ -139,7 +139,6 @@ def test_create_new_organisation(
|
||||
_expected_redirect=url_for(
|
||||
'main.organisation_settings',
|
||||
org_id=ORGANISATION_ID,
|
||||
_external=True,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -366,7 +365,6 @@ def test_gps_can_name_their_organisation(
|
||||
_expected_redirect=url_for(
|
||||
'main.service_agreement',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
_external=True,
|
||||
)
|
||||
)
|
||||
|
||||
@@ -436,7 +434,6 @@ def test_nhs_local_assigns_to_selected_organisation(
|
||||
_expected_redirect=url_for(
|
||||
'main.service_agreement',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
_external=True
|
||||
)
|
||||
)
|
||||
mock_update_service_organisation.assert_called_once_with(SERVICE_ONE_ID, ORGANISATION_ID)
|
||||
@@ -904,7 +901,6 @@ def test_remove_user_from_organisation_makes_api_request_to_remove_user(
|
||||
user_id=fake_uuid,
|
||||
_expected_redirect=url_for(
|
||||
'main.show_accounts_or_dashboard',
|
||||
_external=True,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -1123,7 +1119,6 @@ def test_update_organisation_settings(
|
||||
_expected_redirect=url_for(
|
||||
'main.organisation_settings',
|
||||
org_id=organisation_one['id'],
|
||||
_external=True,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -1151,7 +1146,6 @@ def test_update_organisation_sector_sends_service_id_data_to_api_client(
|
||||
_expected_redirect=url_for(
|
||||
'main.organisation_settings',
|
||||
org_id=organisation_one['id'],
|
||||
_external=True,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -1272,7 +1266,6 @@ def test_update_organisation_domains(
|
||||
_expected_redirect=url_for(
|
||||
'main.organisation_settings',
|
||||
org_id=organisation_one['id'],
|
||||
_external=True,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -1329,7 +1322,6 @@ def test_update_organisation_name(
|
||||
_expected_redirect=url_for(
|
||||
'.organisation_settings',
|
||||
org_id=fake_uuid,
|
||||
_external=True,
|
||||
)
|
||||
)
|
||||
mock_update_organisation.assert_called_once_with(
|
||||
@@ -1425,7 +1417,6 @@ def test_post_edit_organisation_go_live_notes_updates_go_live_notes(
|
||||
_expected_redirect=url_for(
|
||||
'.organisation_settings',
|
||||
org_id=organisation_one['id'],
|
||||
_external=True,
|
||||
),
|
||||
)
|
||||
mock_update_organisation.assert_called_once_with(
|
||||
@@ -1481,7 +1472,6 @@ def test_update_organisation_notes(
|
||||
_expected_redirect=url_for(
|
||||
'main.organisation_settings',
|
||||
org_id=organisation_one['id'],
|
||||
_external=True,
|
||||
),
|
||||
)
|
||||
mock_update_organisation.assert_called_with(
|
||||
@@ -1525,7 +1515,6 @@ def test_update_organisation_notes_doesnt_call_api_when_notes_dont_change(
|
||||
_expected_redirect=url_for(
|
||||
'main.organisation_settings',
|
||||
org_id=organisation_one['id'],
|
||||
_external=True,
|
||||
),
|
||||
)
|
||||
assert not mock_update_organisation.called
|
||||
@@ -1604,7 +1593,6 @@ def test_update_organisation_billing_details(
|
||||
_expected_redirect=url_for(
|
||||
'main.organisation_settings',
|
||||
org_id=organisation_one['id'],
|
||||
_external=True,
|
||||
)
|
||||
)
|
||||
mock_update_organisation.assert_called_with(
|
||||
|
||||
Reference in New Issue
Block a user