From c702104421d5a162c34683df7eaa9c7757022b9e Mon Sep 17 00:00:00 2001 From: jimmoffet Date: Mon, 12 Sep 2022 17:38:53 -0700 Subject: [PATCH] fix redis mocking for test runner --- .github/workflows/checks.yml | 49 +++-- app/config.py | 1 + app/static/images/email-template/us-flag.png | Bin 0 -> 18033 bytes .../service_settings/test_service_settings.py | 203 +++++++++--------- tests/app/main/views/test_register.py | 3 +- 5 files changed, 129 insertions(+), 127 deletions(-) create mode 100644 app/static/images/email-template/us-flag.png diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 87ac3c240..94ff75ac4 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -10,9 +10,8 @@ env: FLASK_APP: application.py FLASK_ENV: development WERKZEUG_DEBUG_PIN: off - REDIS_URL: redis://adminredis:6379/0 - DEV_REDIS_URL: redis://adminredis:6379/0 - REDIS_ENABLED: False + REDIS_URL: "redis://you-forgot-to-mock-a-redis-call-to" + REDIS_ENABLED: True ANTIVIRUS_ENABLED: 0 NODE_VERSION: 16.15.1 ADMIN_CLIENT_ID: notify-admin @@ -30,28 +29,28 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/setup-project - - name: Run style checks - run: flake8 . - - name: Check imports alphabetized - run: isort --check-only ./app ./tests - - name: Run js tests - run: npm test - - name: Run py tests - run: pytest -n4 --maxfail=10 + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup-project + - name: Run style checks + run: flake8 . + - name: Check imports alphabetized + run: isort --check-only ./app ./tests + - name: Run js tests + run: npm test + - name: Run py tests + run: pytest -n4 --maxfail=10 dependency-audits: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/setup-project - - uses: trailofbits/gh-action-pip-audit@v1.0.0 - with: - inputs: requirements.txt requirements_for_test.txt - ignore-vulns: PYSEC-2022-237 - - name: Run npm audit - run: make npm-audit + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup-project + - uses: trailofbits/gh-action-pip-audit@v1.0.0 + with: + inputs: requirements.txt requirements_for_test.txt + ignore-vulns: PYSEC-2022-237 + - name: Run npm audit + run: make npm-audit static-scan: runs-on: ubuntu-latest @@ -75,12 +74,12 @@ jobs: - name: Run OWASP Baseline Scan uses: zaproxy/action-baseline@v0.7.0 with: - docker_name: 'owasp/zap2docker-weekly' - target: 'http://localhost:6012' + docker_name: "owasp/zap2docker-weekly" + target: "http://localhost:6012" fail_action: true allow_issue_writing: false - rules_file_name: 'zap.conf' - cmd_options: '-I' + rules_file_name: "zap.conf" + cmd_options: "-I" a11y-scan: runs-on: ubuntu-latest diff --git a/app/config.py b/app/config.py index c2b14ca84..f3f034c85 100644 --- a/app/config.py +++ b/app/config.py @@ -141,6 +141,7 @@ class Test(Development): PRECOMPILED_ORIGINALS_BACKUP_LETTERS = 'test-letters-precompiled-originals-backup' NOTIFY_ENVIRONMENT = 'test' API_HOST_NAME = 'http://you-forgot-to-mock-an-api-call-to' + REDIS_URL = 'redis://you-forgot-to-mock-a-redis-call-to' TEMPLATE_PREVIEW_API_HOST = 'http://localhost:9999' ANTIVIRUS_API_HOST = 'https://test-antivirus' ANTIVIRUS_API_KEY = 'test-antivirus-secret' diff --git a/app/static/images/email-template/us-flag.png b/app/static/images/email-template/us-flag.png new file mode 100644 index 0000000000000000000000000000000000000000..c22f819d00e805943c549142c4dc1c1a60ed20ca GIT binary patch literal 18033 zcmdse2UJwqw(X%&F@lJSWEBJz0YP$BP(YF-0Rcf!5fKo{83RcK6qK9{fMfy5QAtXa zoC^t(p~zK)s`~q!LYnTrx9{`4*W>^38H1v%I{Tcx*IsL`x#rsXTv3wQx0`l11VQ`c zWTjOhXd8ID4cfT_{BdJoe+>TYx-YA31wnh-;a?IA&)I_zv|HIkO6tm$I~LX!R(CA! zAC;4mI(q+s#ch*&w;;&AJ4(%1U2XiZ7zVX?LEhW_rM!jep`AxnFZjA2e8GD9*slGT zy^p=_I;8T6^5Vs9bYEh^?q8jHsJKuw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wy(|ni!#Q=T* zNeTS8gX{#SqCdWc-~)b8Z2Bp18Z?q;V*d#ed*!#IQKxRp#NESYzUyOlI zLCvzkS6|uo|InFTcM{3pz?}X&r&Qs!5XZSFm?+Z^uN=xfjjZ)1c6?!8{1Q^KKbU+! z?$ZL>uGnbfbgVKwFm@+m<}&y_puX_W-&mYz=Kt9wk)0|-p7fXJk-EeGnZf}1^3S_X ze0CY~-Ijq{-V(>HhBikFe)&ehix|O03oJicQ0X}Mk0j6{3XNW2EQ^8fAxZhKeW(on z^50m(0Qv5}JF&kTw*&g0|M!ta?l>{a=ZX{rB{?w9u@jFI6u+(=K`8T=)VJ|$N`PTN zi~g`4I4|ZY0sDgcaRc!BU)b_86= z-ui36_geh`2$h&+r1WL*kFnzZ{sl4j|F0MBlyeVRxTD-kYbar' in normalize_spaces(page.select('.user-list-item')[1].text) -@pytest.mark.parametrize('sms_sender, expected_link_text, partial_href', [ +@ pytest.mark.parametrize('sms_sender, expected_link_text, partial_href', [ ( create_sms_sender(is_default=False), 'Delete', @@ -3199,7 +3200,7 @@ def test_confirm_delete_sms_sender( assert page.select_one('.banner-dangerous form')['method'] == 'post' -@pytest.mark.parametrize('sms_sender, expected_link_text', [ +@ pytest.mark.parametrize('sms_sender, expected_link_text', [ (create_sms_sender(is_default=False, inbound_number_id='1234'), None), (create_sms_sender(is_default=True), None), (create_sms_sender(is_default=False), 'Delete'), @@ -3250,7 +3251,7 @@ def test_delete_sms_sender( mock_delete.assert_called_once_with(service_id=SERVICE_ONE_ID, sms_sender_id=fake_uuid) -@pytest.mark.parametrize('sms_sender, hide_textbox', [ +@ pytest.mark.parametrize('sms_sender, hide_textbox', [ (create_sms_sender(is_default=False, inbound_number_id='1234'), True), (create_sms_sender(is_default=True), False), ]) @@ -3324,7 +3325,7 @@ def test_service_set_letter_branding_platform_admin_only( ) -@pytest.mark.parametrize('letter_branding, expected_selected, expected_items', [ +@ pytest.mark.parametrize('letter_branding, expected_selected, expected_items', [ # expected order: currently selected, then default, then rest alphabetically (None, '__NONE__', ( ('__NONE__', 'None'), @@ -3345,7 +3346,7 @@ def test_service_set_letter_branding_platform_admin_only( (str(UUID(int=1)), 'Land Registry'), )), ]) -@pytest.mark.parametrize('endpoint, extra_args', ( +@ pytest.mark.parametrize('endpoint, extra_args', ( ( 'main.service_set_letter_branding', {'service_id': SERVICE_ONE_ID}, @@ -3396,11 +3397,11 @@ def test_service_set_letter_branding_prepopulates( assert page.select('input[type=radio]')[index]['value'] == expected_value -@pytest.mark.parametrize('selected_letter_branding, expected_post_data', [ +@ pytest.mark.parametrize('selected_letter_branding, expected_post_data', [ (str(UUID(int=1)), str(UUID(int=1))), ('__NONE__', None), ]) -@pytest.mark.parametrize('endpoint, extra_args, expected_redirect', ( +@ pytest.mark.parametrize('endpoint, extra_args, expected_redirect', ( ( 'main.service_set_letter_branding', {'service_id': SERVICE_ONE_ID}, @@ -3437,7 +3438,7 @@ def test_service_set_letter_branding_redirects_to_preview_page_when_form_submitt ) -@pytest.mark.parametrize('endpoint, extra_args', ( +@ pytest.mark.parametrize('endpoint, extra_args', ( ( 'main.service_preview_letter_branding', {'service_id': SERVICE_ONE_ID}, @@ -3466,11 +3467,11 @@ def test_service_preview_letter_branding_shows_preview_letter( assert page.find('iframe')['src'] == url_for('main.letter_template', branding_style='hm-government') -@pytest.mark.parametrize('selected_letter_branding, expected_post_data', [ +@ pytest.mark.parametrize('selected_letter_branding, expected_post_data', [ (str(UUID(int=1)), str(UUID(int=1))), ('__NONE__', None), ]) -@pytest.mark.parametrize('endpoint, extra_args, expected_redirect', ( +@ pytest.mark.parametrize('endpoint, extra_args, expected_redirect', ( ( 'main.service_preview_letter_branding', {'service_id': SERVICE_ONE_ID}, @@ -3531,7 +3532,7 @@ def test_service_preview_letter_branding_saves( raise Exception -@pytest.mark.parametrize('current_branding, expected_values, expected_labels', [ +@ pytest.mark.parametrize('current_branding, expected_values, expected_labels', [ (None, [ '__NONE__', '1', '2', '3', '4', '5', ], [ @@ -3543,7 +3544,7 @@ def test_service_preview_letter_branding_saves( 'org 5', 'GOV.UK', 'org 1', 'org 2', 'org 3', 'org 4', ]), ]) -@pytest.mark.parametrize('endpoint, extra_args', ( +@ pytest.mark.parametrize('endpoint, extra_args', ( ( 'main.service_set_email_branding', {'service_id': SERVICE_ONE_ID}, @@ -3603,7 +3604,7 @@ def test_should_show_branding_styles( app.service_api_client.get_service.assert_called_once_with(service_one['id']) -@pytest.mark.parametrize('endpoint, extra_args, expected_redirect', ( +@ pytest.mark.parametrize('endpoint, extra_args, expected_redirect', ( ( 'main.service_set_email_branding', {'service_id': SERVICE_ONE_ID}, @@ -3645,7 +3646,7 @@ def test_should_send_branding_and_organisations_to_preview( mock_get_all_email_branding.assert_called_once_with() -@pytest.mark.parametrize('endpoint, extra_args', ( +@ pytest.mark.parametrize('endpoint, extra_args', ( ( 'main.service_preview_email_branding', {'service_id': SERVICE_ONE_ID}, @@ -3679,12 +3680,12 @@ def test_should_preview_email_branding( assert iframeQString['branding_style'] == ['1'] -@pytest.mark.parametrize('posted_value, submitted_value', ( +@ pytest.mark.parametrize('posted_value, submitted_value', ( ('1', '1'), ('__NONE__', None), pytest.param('None', None, marks=pytest.mark.xfail(raises=AssertionError)), )) -@pytest.mark.parametrize('endpoint, extra_args, expected_redirect', ( +@ pytest.mark.parametrize('endpoint, extra_args, expected_redirect', ( ( 'main.service_preview_email_branding', {'service_id': SERVICE_ONE_ID}, @@ -3745,8 +3746,8 @@ def test_should_set_branding_and_organisations( raise Exception -@pytest.mark.parametrize('method', ['get', 'post']) -@pytest.mark.parametrize('endpoint', [ +@ pytest.mark.parametrize('method', ['get', 'post']) +@ pytest.mark.parametrize('endpoint', [ 'main.set_free_sms_allowance', 'main.set_message_limit', 'main.set_rate_limit', @@ -3779,8 +3780,8 @@ def test_should_show_page_to_set_sms_allowance( mock_get_free_sms_fragment_limit.assert_called_once_with(SERVICE_ONE_ID) -@freeze_time("2017-04-01 11:09:00.061258") -@pytest.mark.parametrize('given_allowance, expected_api_argument', [ +@ freeze_time("2017-04-01 11:09:00.061258") +@ pytest.mark.parametrize('given_allowance, expected_api_argument', [ ('0', 0), ('1', 1), ('250000', 250000), @@ -3848,11 +3849,11 @@ def test_should_show_page_to_set_rate_limit( ) -@pytest.mark.parametrize('endpoint, field_name', ( +@ pytest.mark.parametrize('endpoint, field_name', ( ('main.set_message_limit', 'message_limit'), ('main.set_rate_limit', 'rate_limit'), )) -@pytest.mark.parametrize('new_limit, expected_api_argument', [ +@ pytest.mark.parametrize('new_limit, expected_api_argument', [ ('1', 1), ('250000', 250000), pytest.param('foo', 'foo', marks=pytest.mark.xfail), @@ -3906,7 +3907,7 @@ def test_unknown_channel_404s( ) -@pytest.mark.parametrize(( +@ pytest.mark.parametrize(( 'channel,' 'expected_first_para,' 'expected_legend,' @@ -4003,7 +4004,7 @@ def test_switch_service_channels_on_and_off( assert mocked_fn.call_args[0][0] == service_one['id'] -@pytest.mark.parametrize('channel', ( +@ pytest.mark.parametrize('channel', ( 'email', 'sms', 'letter', )) def test_broadcast_service_cant_post_to_set_other_channels_endpoint( @@ -4029,7 +4030,7 @@ def test_broadcast_service_cant_post_to_set_other_channels_endpoint( ) -@pytest.mark.parametrize('permission, permissions, expected_checked', [ +@ pytest.mark.parametrize('permission, permissions, expected_checked', [ ('international_sms', ['international_sms'], 'True'), ('international_letters', ['international_letters'], 'True'), ('international_sms', [''], 'False'), @@ -4056,11 +4057,11 @@ def test_show_international_sms_and_letters_as_radio_button( assert checked_radios[0]['value'] == expected_checked -@pytest.mark.parametrize('permission', ( +@ pytest.mark.parametrize('permission', ( 'international_sms', 'international_letters', )) -@pytest.mark.parametrize('post_value, permission_expected_in_api_call', [ +@ pytest.mark.parametrize('post_value, permission_expected_in_api_call', [ ('True', True), ('False', False), ]) @@ -4090,7 +4091,7 @@ def test_switch_service_enable_international_sms_and_letters( assert mocked_fn.call_args[0][0] == service_one['id'] -@pytest.mark.parametrize('user, is_trial_service', ( +@ pytest.mark.parametrize('user, is_trial_service', ( [create_platform_admin_user(), True], [create_platform_admin_user(), False], [create_active_user_with_permissions(), True], @@ -4133,7 +4134,7 @@ def test_archive_service_after_confirm( assert call(f"user-{sample_uuid()}") in redis_delete_mock.call_args_list -@pytest.mark.parametrize('user, is_trial_service', ( +@ pytest.mark.parametrize('user, is_trial_service', ( [create_platform_admin_user(), True], [create_platform_admin_user(), False], [create_active_user_with_permissions(), True], @@ -4198,7 +4199,7 @@ def test_cant_archive_inactive_service( assert 'Delete service' not in {a.text for a in page.find_all('a', class_='button')} -@pytest.mark.parametrize('user', ( +@ pytest.mark.parametrize('user', ( create_platform_admin_user(), pytest.param(create_active_user_with_permissions(), marks=pytest.mark.xfail), )) @@ -4224,7 +4225,7 @@ def test_suspend_service_after_confirm( mock_event.assert_called_once_with(service_id=SERVICE_ONE_ID, suspended_by_id=user['id']) -@pytest.mark.parametrize('user', ( +@ pytest.mark.parametrize('user', ( create_platform_admin_user(), pytest.param(create_active_user_with_permissions(), marks=pytest.mark.xfail), )) @@ -4268,7 +4269,7 @@ def test_cant_suspend_inactive_service( assert 'Suspend service' not in {a.text for a in page.find_all('a', class_='button')} -@pytest.mark.parametrize('user', ( +@ pytest.mark.parametrize('user', ( create_platform_admin_user(), pytest.param(create_active_user_with_permissions(), marks=pytest.mark.xfail), )) @@ -4296,7 +4297,7 @@ def test_resume_service_after_confirm( assert mock_event.called_once_with(service_id=SERVICE_ONE_ID, resumed_by_id=user['id']) -@pytest.mark.parametrize('user', ( +@ pytest.mark.parametrize('user', ( create_platform_admin_user(), pytest.param(create_active_user_with_permissions(), marks=pytest.mark.xfail), )) @@ -4338,7 +4339,7 @@ def test_cant_resume_active_service( assert 'Resume service' not in {a.text for a in page.find_all('a', class_='button')} -@pytest.mark.parametrize('contact_details_type, contact_details_value', [ +@ pytest.mark.parametrize('contact_details_type, contact_details_value', [ ('url', 'http://example.com/'), ('email_address', 'me@example.com'), ('phone_number', '0207 123 4567'), @@ -4358,7 +4359,7 @@ def test_send_files_by_email_contact_details_prefills_the_form_with_the_existing assert page.find('input', {'id': contact_details_type}).get('value') == contact_details_value -@pytest.mark.parametrize('contact_details_type, old_value, new_value', [ +@ pytest.mark.parametrize('contact_details_type, old_value, new_value', [ ('url', 'http://example.com/', 'http://new-link.com/'), ('email_address', 'old@example.com', 'new@example.com'), ('phone_number', '0207 12345', '0207 56789'), @@ -4416,7 +4417,7 @@ def test_send_files_by_email_contact_details_uses_the_selected_field_when_multip mock_update_service.assert_called_once_with(SERVICE_ONE_ID, contact_link='http://www.new-url.com') -@pytest.mark.parametrize( +@ pytest.mark.parametrize( 'contact_link, subheader, button_selected', [ ('contact.me@gsa.gov', 'Change contact details for the file download page', True), @@ -4455,7 +4456,7 @@ def test_send_files_by_email_contact_details_displays_error_message_when_no_radi assert normalize_spaces(page.h1.text) == "Send files by email" -@pytest.mark.parametrize('contact_details_type, invalid_value, error', [ +@ pytest.mark.parametrize('contact_details_type, invalid_value, error', [ ('url', 'invalid.com/', 'Must be a valid URL'), ('email_address', 'me@co', 'Enter a valid email address'), ('phone_number', 'abcde', 'Must be a valid phone number'), @@ -4484,7 +4485,7 @@ def test_send_files_by_email_contact_details_does_not_update_invalid_contact_det assert normalize_spaces(page.h1.text) == "Send files by email" -@pytest.mark.parametrize('endpoint, permissions, expected_p', [ +@ pytest.mark.parametrize('endpoint, permissions, expected_p', [ ( 'main.service_set_inbound_sms', ['sms'], @@ -4569,7 +4570,7 @@ def test_set_inbound_sms_when_inbound_number_is_not_set( ) -@pytest.mark.parametrize('user, expected_paragraphs', [ +@ pytest.mark.parametrize('user, expected_paragraphs', [ (create_active_user_with_permissions(), [ 'Your service can receive text messages sent to 07700900123.', 'You can still send text messages from a sender name if you ' @@ -4627,7 +4628,7 @@ def test_show_sms_prefixing_setting_page( assert radios[1]['checked'] -@pytest.mark.parametrize('post_value', [ +@ pytest.mark.parametrize('post_value', [ True, False, ]) @@ -4727,7 +4728,7 @@ def test_update_service_organisation_does_not_update_if_same_value( assert mock_update_service_organisation.called is False -@pytest.mark.parametrize('single_branding_option, expected_href', [ +@ pytest.mark.parametrize('single_branding_option, expected_href', [ (True, f'/services/{SERVICE_ONE_ID}/service-settings/email-branding/something-else'), (False, f'/services/{SERVICE_ONE_ID}/service-settings/email-branding'), ]) @@ -5066,7 +5067,7 @@ def test_service_set_broadcast_channel_has_no_radio_selected_for_non_broadcast_s assert len(page.select('input[checked]')) == 0 -@pytest.mark.parametrize( +@ pytest.mark.parametrize( 'service_mode,broadcast_channel,allowed_broadcast_provider,expected_text,expected_value', [ ( @@ -5119,7 +5120,7 @@ def test_service_set_broadcast_channel_has_radio_selected_for_broadcast_service( assert selected_label.text.strip() == expected_text -@pytest.mark.parametrize( +@ pytest.mark.parametrize( 'channel,expected_redirect_endpoint,extra_args', [ ( @@ -5172,7 +5173,7 @@ def test_service_set_broadcast_channel_redirects( ) -@pytest.mark.parametrize( +@ pytest.mark.parametrize( 'service_mode,broadcast_channel,allowed_broadcast_provider,expected_selected', [ ( @@ -5228,7 +5229,7 @@ def test_service_set_broadcast_network_has_radio_selected( ] == expected_selected -@pytest.mark.parametrize( +@ pytest.mark.parametrize( 'broadcast_channel, data, expected_result', ( ('severe', {'all_networks': True}, 'live-severe-all'), @@ -5265,14 +5266,14 @@ def test_service_set_broadcast_network( ) -@pytest.mark.parametrize( +@ pytest.mark.parametrize( 'data', ( {}, {'all_networks': ''}, # Missing choice of MNO ), ) -@pytest.mark.parametrize('broadcast_channel', ['government', 'severe', 'test', 'operator']) +@ pytest.mark.parametrize('broadcast_channel', ['government', 'severe', 'test', 'operator']) def test_service_set_broadcast_network_makes_you_choose( client_request, platform_admin_user, @@ -5293,7 +5294,7 @@ def test_service_set_broadcast_network_makes_you_choose( ) == 'Error: Select a mobile network' -@pytest.mark.parametrize( +@ pytest.mark.parametrize( 'value, expected_paragraphs', [ ('training-test-all', [ @@ -5375,7 +5376,7 @@ def test_service_confirm_broadcast_account_type_confirmation_page( ] == expected_paragraphs + ['All team member permissions will be removed.'] -@pytest.mark.parametrize( +@ pytest.mark.parametrize( 'value,service_mode,broadcast_channel,allowed_broadcast_provider', [ ("training-test-all", "training", "test", "all"), @@ -5425,7 +5426,7 @@ def test_service_confirm_broadcast_account_type_posts_data_to_api_and_redirects( ) -@pytest.mark.parametrize('account_type', ( +@ pytest.mark.parametrize('account_type', ( 'foo-test-ee', 'live-foo-all', 'live-government-foo' diff --git a/tests/app/main/views/test_register.py b/tests/app/main/views/test_register.py index 7c4bd4c78..d9c523b3c 100644 --- a/tests/app/main/views/test_register.py +++ b/tests/app/main/views/test_register.py @@ -131,11 +131,12 @@ def test_should_return_200_when_email_is_not_gov_uk( @pytest.mark.parametrize('email_address', ( 'notfound@example.gsa.gov', - pytest.param('example@lsquo.net', marks=pytest.mark.xfail(raises=AssertionError)), + 'example@lsquo.net', pytest.param('example@ellipsis.com', marks=pytest.mark.xfail(raises=AssertionError)), )) def test_should_add_user_details_to_session( client_request, + mocker, mock_send_verify_code, mock_register_user, mock_get_user_by_email_not_found,