From 8489fb9e613d85488cee1d2f6e679115b1848382 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Mon, 15 Jul 2024 08:07:18 -0700 Subject: [PATCH 01/15] update flake8-pytest-style-plugin --- poetry.lock | 10 +- pyproject.toml | 2 +- .../views/accounts/test_choose_accounts.py | 2 +- .../test_service_setting_permissions.py | 2 +- .../service_settings/test_service_settings.py | 2 +- tests/app/main/views/test_accept_invite.py | 6 +- tests/app/main/views/test_dashboard.py | 2 +- tests/app/main/views/test_two_factor.py | 2 +- tests/app/models/test_template_list.py | 2 +- tests/app/s3_client/test_s3_logo_client.py | 4 +- tests/app/test_cloudfoundry_config.py | 2 +- tests/app/utils/test_csv.py | 2 +- tests/conftest.py | 402 +++++++++--------- tests/end_to_end/conftest.py | 6 +- .../clients/redis/test_redis_client.py | 8 +- .../clients/redis/test_request_cache.py | 4 +- tests/notifications_utils/conftest.py | 6 +- 17 files changed, 232 insertions(+), 232 deletions(-) diff --git a/poetry.lock b/poetry.lock index 71e030da0..710ea3526 100644 --- a/poetry.lock +++ b/poetry.lock @@ -817,13 +817,13 @@ pycodestyle = "*" [[package]] name = "flake8-pytest-style" -version = "1.7.2" +version = "2.0.0" description = "A flake8 plugin checking common style issues or inconsistencies with pytest-based tests." optional = false -python-versions = ">=3.7.2,<4.0.0" +python-versions = "<4.0.0,>=3.8.1" files = [ - {file = "flake8_pytest_style-1.7.2-py3-none-any.whl", hash = "sha256:f5d2aa3219163a052dd92226589d45fab8ea027a3269922f0c4029f548ea5cd1"}, - {file = "flake8_pytest_style-1.7.2.tar.gz", hash = "sha256:b924197c99b951315949920b0e5547f34900b1844348432e67a44ab191582109"}, + {file = "flake8_pytest_style-2.0.0-py3-none-any.whl", hash = "sha256:abcb9f56f277954014b749e5a0937fae215be01a21852e9d05e7600c3de6aae5"}, + {file = "flake8_pytest_style-2.0.0.tar.gz", hash = "sha256:919c328cacd4bc4f873ea61ab4db0d8f2c32e0db09a3c73ab46b1de497556464"}, ] [package.dependencies] @@ -3112,4 +3112,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.12.2" -content-hash = "78cfb6ff10239c4ad8e34c059e01c9ee7603d591c43cb06dd0a1acf8fa51f510" +content-hash = "df3fd7d58fb974e467ccac5e6504d0085327770f947ea099ba49e1987b01ad89" diff --git a/pyproject.toml b/pyproject.toml index 06e8ffe35..26ecf2224 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,7 +80,7 @@ freezegun = "^1.5.1" flake8 = "^7.1.0" flake8-bugbear = "^24.1.17" flake8-print = "^5.0.0" -flake8-pytest-style = "^1.7.2" +flake8-pytest-style = "^2.0.0" isort = "^5.13.2" jinja2-cli = {version = "==0.8.2", extras = ["yaml"]} moto = "*" diff --git a/tests/app/main/views/accounts/test_choose_accounts.py b/tests/app/main/views/accounts/test_choose_accounts.py index 1ead9dd0d..77e06d6ca 100644 --- a/tests/app/main/views/accounts/test_choose_accounts.py +++ b/tests/app/main/views/accounts/test_choose_accounts.py @@ -67,7 +67,7 @@ SAMPLE_DATA = { } -@pytest.fixture() +@pytest.fixture def mock_get_orgs_and_services(mocker): return mocker.patch( "app.user_api_client.get_organizations_and_services_for_user", diff --git a/tests/app/main/views/service_settings/test_service_setting_permissions.py b/tests/app/main/views/service_settings/test_service_setting_permissions.py index 16240d716..b7c945902 100644 --- a/tests/app/main/views/service_settings/test_service_setting_permissions.py +++ b/tests/app/main/views/service_settings/test_service_setting_permissions.py @@ -7,7 +7,7 @@ from app.main.views.service_settings import PLATFORM_ADMIN_SERVICE_PERMISSIONS from tests.conftest import normalize_spaces -@pytest.fixture() +@pytest.fixture def get_service_settings_page( client_request, platform_admin_user, diff --git a/tests/app/main/views/service_settings/test_service_settings.py b/tests/app/main/views/service_settings/test_service_settings.py index 599491e08..a9895ef99 100644 --- a/tests/app/main/views/service_settings/test_service_settings.py +++ b/tests/app/main/views/service_settings/test_service_settings.py @@ -33,7 +33,7 @@ from tests.conftest import ( FAKE_TEMPLATE_ID = uuid4() -@pytest.fixture() +@pytest.fixture def _mock_get_service_settings_page_common( mock_get_inbound_number_for_service, mock_get_free_sms_fragment_limit, diff --git a/tests/app/main/views/test_accept_invite.py b/tests/app/main/views/test_accept_invite.py index 1fc355abb..01dab9876 100644 --- a/tests/app/main/views/test_accept_invite.py +++ b/tests/app/main/views/test_accept_invite.py @@ -100,19 +100,19 @@ MOCK_JOBS = { } -@pytest.fixture() +@pytest.fixture def _mock_no_users_for_service(mocker): mocker.patch("app.models.user.Users.client_method", return_value=[]) -@pytest.fixture() +@pytest.fixture def mock_get_existing_user_by_email(mocker, api_user_active): return mocker.patch( "app.user_api_client.get_user_by_email", return_value=api_user_active ) -@pytest.fixture() +@pytest.fixture def mock_check_invite_token(mocker, sample_invite): return mocker.patch("app.invite_api_client.check_token", return_value=sample_invite) diff --git a/tests/app/main/views/test_dashboard.py b/tests/app/main/views/test_dashboard.py index 475d7514e..d2e543f6a 100644 --- a/tests/app/main/views/test_dashboard.py +++ b/tests/app/main/views/test_dashboard.py @@ -1882,7 +1882,7 @@ def test_service_dashboard_shows_batched_jobs( assert len(rows) == 1 -@pytest.fixture() +@pytest.fixture def app_with_socketio(): app = Flask("app") create_app(app) diff --git a/tests/app/main/views/test_two_factor.py b/tests/app/main/views/test_two_factor.py index d1f38d1ab..27e1ce33f 100644 --- a/tests/app/main/views/test_two_factor.py +++ b/tests/app/main/views/test_two_factor.py @@ -9,7 +9,7 @@ from tests.conftest import ( ) -@pytest.fixture() +@pytest.fixture def mock_email_validated_recently(mocker): return mocker.patch( "app.main.views.two_factor.email_needs_revalidating", return_value=False diff --git a/tests/app/models/test_template_list.py b/tests/app/models/test_template_list.py index 1a620809d..874d4fc9b 100644 --- a/tests/app/models/test_template_list.py +++ b/tests/app/models/test_template_list.py @@ -12,7 +12,7 @@ VIS_PARENT_FOLDER_ID = "bbbb222b-2b22-2b22-222b-b222b22b2222" INV_CHILD_2_FOLDER_ID = "fafe723f-1d39-4a10-865f-e551e03d8886" -@pytest.fixture() +@pytest.fixture def _mock_get_hierarchy_of_folders( mock_get_template_folders, active_user_with_permissions ): diff --git a/tests/app/s3_client/test_s3_logo_client.py b/tests/app/s3_client/test_s3_logo_client.py index 92ce34c37..dc6e419e2 100644 --- a/tests/app/s3_client/test_s3_logo_client.py +++ b/tests/app/s3_client/test_s3_logo_client.py @@ -19,14 +19,14 @@ svg_filename = "test.svg" upload_id = "test_uuid" -@pytest.fixture() +@pytest.fixture def upload_filename(fake_uuid): return EMAIL_LOGO_LOCATION_STRUCTURE.format( temp=TEMP_TAG.format(user_id=fake_uuid), unique_id=upload_id, filename=filename ) -@pytest.fixture() +@pytest.fixture def bucket_credentials(notify_admin): return notify_admin.config["LOGO_UPLOAD_BUCKET"] diff --git a/tests/app/test_cloudfoundry_config.py b/tests/app/test_cloudfoundry_config.py index 6eea0dd95..433f2c73e 100644 --- a/tests/app/test_cloudfoundry_config.py +++ b/tests/app/test_cloudfoundry_config.py @@ -13,7 +13,7 @@ bucket_credentials = { } -@pytest.fixture() +@pytest.fixture def vcap_services(): return { "aws-elasticache-redis": [{"credentials": {"uri": "redis://xxx:6379"}}], diff --git a/tests/app/utils/test_csv.py b/tests/app/utils/test_csv.py index a7e77055b..d603fcd0e 100644 --- a/tests/app/utils/test_csv.py +++ b/tests/app/utils/test_csv.py @@ -71,7 +71,7 @@ def _get_notifications_csv( return _get -@pytest.fixture() +@pytest.fixture def get_notifications_csv_mock( mocker, api_user_active, diff --git a/tests/conftest.py b/tests/conftest.py index 592ec9403..de1ff28a3 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -53,17 +53,17 @@ def notify_admin(): return app -@pytest.fixture() +@pytest.fixture def service_one(api_user_active): return service_json(SERVICE_ONE_ID, "service one", [api_user_active["id"]]) -@pytest.fixture() +@pytest.fixture def service_two(api_user_active): return service_json(SERVICE_TWO_ID, "service two", [api_user_active["id"]]) -@pytest.fixture() +@pytest.fixture def multiple_reply_to_email_addresses(mocker): def _get(service_id): return [ @@ -99,7 +99,7 @@ def multiple_reply_to_email_addresses(mocker): ) -@pytest.fixture() +@pytest.fixture def no_reply_to_email_addresses(mocker): def _get(service_id): return [] @@ -109,7 +109,7 @@ def no_reply_to_email_addresses(mocker): ) -@pytest.fixture() +@pytest.fixture def single_reply_to_email_address(mocker): def _get(service_id): return [ @@ -128,7 +128,7 @@ def single_reply_to_email_address(mocker): ) -@pytest.fixture() +@pytest.fixture def get_default_reply_to_email_address(mocker): def _get(service_id, reply_to_email_id): return { @@ -145,7 +145,7 @@ def get_default_reply_to_email_address(mocker): ) -@pytest.fixture() +@pytest.fixture def get_non_default_reply_to_email_address(mocker): def _get(service_id, reply_to_email_id): return { @@ -162,7 +162,7 @@ def get_non_default_reply_to_email_address(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_add_reply_to_email_address(mocker): def _add_reply_to(service_id, email_address, is_default=False): return @@ -172,7 +172,7 @@ def mock_add_reply_to_email_address(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_update_reply_to_email_address(mocker): def _update_reply_to( service_id, reply_to_email_id, email_address=None, active=None, is_default=False @@ -185,7 +185,7 @@ def mock_update_reply_to_email_address(mocker): ) -@pytest.fixture() +@pytest.fixture def multiple_sms_senders(mocker): def _get(service_id): return [ @@ -221,7 +221,7 @@ def multiple_sms_senders(mocker): return mocker.patch("app.service_api_client.get_sms_senders", side_effect=_get) -@pytest.fixture() +@pytest.fixture def multiple_sms_senders_with_diff_default(mocker): def _get(service_id): return [ @@ -257,7 +257,7 @@ def multiple_sms_senders_with_diff_default(mocker): return mocker.patch("app.service_api_client.get_sms_senders", side_effect=_get) -@pytest.fixture() +@pytest.fixture def multiple_sms_senders_no_inbound(mocker): def _get(service_id): return [ @@ -284,7 +284,7 @@ def multiple_sms_senders_no_inbound(mocker): return mocker.patch("app.service_api_client.get_sms_senders", side_effect=_get) -@pytest.fixture() +@pytest.fixture def no_sms_senders(mocker): def _get(service_id): return [] @@ -292,7 +292,7 @@ def no_sms_senders(mocker): return mocker.patch("app.service_api_client.get_sms_senders", side_effect=_get) -@pytest.fixture() +@pytest.fixture def single_sms_sender(mocker): def _get(service_id): return [ @@ -310,7 +310,7 @@ def single_sms_sender(mocker): return mocker.patch("app.service_api_client.get_sms_senders", side_effect=_get) -@pytest.fixture() +@pytest.fixture def get_default_sms_sender(mocker): def _get(service_id, sms_sender_id): return { @@ -326,7 +326,7 @@ def get_default_sms_sender(mocker): return mocker.patch("app.service_api_client.get_sms_sender", side_effect=_get) -@pytest.fixture() +@pytest.fixture def get_non_default_sms_sender(mocker): def _get(service_id, sms_sender_id): return { @@ -342,7 +342,7 @@ def get_non_default_sms_sender(mocker): return mocker.patch("app.service_api_client.get_sms_sender", side_effect=_get) -@pytest.fixture() +@pytest.fixture def mock_add_sms_sender(mocker): def _add_sms_sender( service_id, sms_sender, is_default=False, inbound_number_id=None @@ -354,7 +354,7 @@ def mock_add_sms_sender(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_update_sms_sender(mocker): def _update_sms_sender( service_id, sms_sender_id, sms_sender=None, active=None, is_default=False @@ -366,7 +366,7 @@ def mock_update_sms_sender(mocker): ) -@pytest.fixture() +@pytest.fixture def multiple_available_inbound_numbers(mocker): def _get(): return { @@ -406,7 +406,7 @@ def multiple_available_inbound_numbers(mocker): ) -@pytest.fixture() +@pytest.fixture def no_available_inbound_numbers(mocker): def _get(): return {"data": []} @@ -416,12 +416,12 @@ def no_available_inbound_numbers(mocker): ) -@pytest.fixture() +@pytest.fixture def fake_uuid(): return sample_uuid() -@pytest.fixture() +@pytest.fixture def mock_get_service(mocker, api_user_active): def _get(service_id): service = service_json( @@ -432,7 +432,7 @@ def mock_get_service(mocker, api_user_active): return mocker.patch("app.service_api_client.get_service", side_effect=_get) -@pytest.fixture() +@pytest.fixture def mock_get_service_statistics(mocker, api_user_active): def _get(service_id, limit_days=None): return { @@ -445,7 +445,7 @@ def mock_get_service_statistics(mocker, api_user_active): ) -@pytest.fixture() +@pytest.fixture def mock_get_detailed_services(mocker, fake_uuid): service_one = service_json( id_=SERVICE_ONE_ID, @@ -476,7 +476,7 @@ def mock_get_detailed_services(mocker, fake_uuid): return mocker.patch("app.service_api_client.get_services", return_value=services) -@pytest.fixture() +@pytest.fixture def mock_get_live_service(mocker, api_user_active): def _get(service_id): service = service_json( @@ -487,7 +487,7 @@ def mock_get_live_service(mocker, api_user_active): return mocker.patch("app.service_api_client.get_service", side_effect=_get) -@pytest.fixture() +@pytest.fixture def mock_create_service(mocker): def _create( service_name, @@ -510,7 +510,7 @@ def mock_create_service(mocker): return mocker.patch("app.service_api_client.create_service", side_effect=_create) -@pytest.fixture() +@pytest.fixture def mock_update_service(mocker): def _update(service_id, **kwargs): service = service_json( @@ -538,7 +538,7 @@ def mock_update_service(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_update_service_raise_httperror_duplicate_name(mocker): def _update(service_id, **kwargs): json_mock = Mock( @@ -563,7 +563,7 @@ TEMPLATE_ONE_ID = "b22d7d94-2197-4a7d-a8e7-fd5f9770bf48" USER_ONE_ID = "7b395b52-c6c1-469c-9d61-54166461c1ab" -@pytest.fixture() +@pytest.fixture def mock_get_services(mocker, active_user_with_permissions): def _get_services(params_dict=None): service_one = service_json( @@ -589,7 +589,7 @@ def mock_get_services(mocker, active_user_with_permissions): ) -@pytest.fixture() +@pytest.fixture def mock_get_services_with_no_services(mocker): def _get_services(params_dict=None): return {"data": []} @@ -599,7 +599,7 @@ def mock_get_services_with_no_services(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_get_services_with_one_service(mocker, api_user_active): def _get_services(params_dict=None): return { @@ -620,7 +620,7 @@ def mock_get_services_with_one_service(mocker, api_user_active): ) -@pytest.fixture() +@pytest.fixture def mock_get_service_template(mocker): def _get(service_id, template_id, version=None): template = template_json( @@ -637,7 +637,7 @@ def mock_get_service_template(mocker): return mocker.patch("app.service_api_client.get_service_template", side_effect=_get) -@pytest.fixture() +@pytest.fixture def mock_get_service_template_with_priority(mocker): def _get(service_id, template_id, version=None): template = template_json( @@ -655,7 +655,7 @@ def mock_get_service_template_with_priority(mocker): return mocker.patch("app.service_api_client.get_service_template", side_effect=_get) -@pytest.fixture() +@pytest.fixture def mock_get_deleted_template(mocker): def _get(service_id, template_id, version=None): template = template_json( @@ -673,7 +673,7 @@ def mock_get_deleted_template(mocker): return mocker.patch("app.service_api_client.get_service_template", side_effect=_get) -@pytest.fixture() +@pytest.fixture def mock_get_template_version(mocker, api_user_active): def _get(service_id, template_id, version): template_version = template_version_json( @@ -684,7 +684,7 @@ def mock_get_template_version(mocker, api_user_active): return mocker.patch("app.service_api_client.get_service_template", side_effect=_get) -@pytest.fixture() +@pytest.fixture def mock_get_template_versions(mocker, api_user_active): def _get(service_id, template_id): template_version = template_version_json( @@ -697,7 +697,7 @@ def mock_get_template_versions(mocker, api_user_active): ) -@pytest.fixture() +@pytest.fixture def mock_get_service_template_with_placeholders(mocker): def _get(service_id, template_id, version=None): template = template_json( @@ -712,7 +712,7 @@ def mock_get_service_template_with_placeholders(mocker): return mocker.patch("app.service_api_client.get_service_template", side_effect=_get) -@pytest.fixture() +@pytest.fixture def mock_get_empty_service_template_with_optional_placeholder(mocker): def _get(service_id, template_id, version=None): template = template_json( @@ -726,7 +726,7 @@ def mock_get_empty_service_template_with_optional_placeholder(mocker): return mocker.patch("app.service_api_client.get_service_template", side_effect=_get) -@pytest.fixture() +@pytest.fixture def mock_get_service_template_with_multiple_placeholders(mocker): def _get(service_id, template_id, version=None): template = template_json( @@ -741,7 +741,7 @@ def mock_get_service_template_with_multiple_placeholders(mocker): return mocker.patch("app.service_api_client.get_service_template", side_effect=_get) -@pytest.fixture() +@pytest.fixture def mock_get_service_template_with_placeholders_same_as_recipient(mocker): def _get(service_id, template_id, version=None): template = template_json( @@ -756,7 +756,7 @@ def mock_get_service_template_with_placeholders_same_as_recipient(mocker): return mocker.patch("app.service_api_client.get_service_template", side_effect=_get) -@pytest.fixture() +@pytest.fixture def mock_get_service_email_template(mocker): def _get(service_id, template_id, version=None): template = template_json( @@ -773,7 +773,7 @@ def mock_get_service_email_template(mocker): return mocker.patch("app.service_api_client.get_service_template", side_effect=_get) -@pytest.fixture() +@pytest.fixture def mock_get_service_email_template_without_placeholders(mocker): def _get(service_id, template_id, version=None): template = template_json( @@ -790,7 +790,7 @@ def mock_get_service_email_template_without_placeholders(mocker): return mocker.patch("app.service_api_client.get_service_template", side_effect=_get) -@pytest.fixture() +@pytest.fixture def mock_create_service_template(mocker, fake_uuid): def _create( name, @@ -811,7 +811,7 @@ def mock_create_service_template(mocker, fake_uuid): ) -@pytest.fixture() +@pytest.fixture def mock_update_service_template(mocker): def _update(id_, name, type_, content, service, subject=None, process_type=None): template = template_json( @@ -824,7 +824,7 @@ def mock_update_service_template(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_create_service_template_content_too_big(mocker): def _create( name, @@ -861,7 +861,7 @@ def mock_create_service_template_content_too_big(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_update_service_template_400_content_too_big(mocker): def _update(id_, name, type_, content, service, subject=None, process_type=None): json_mock = Mock( @@ -925,7 +925,7 @@ def _template(template_type, name, parent=None, template_id=None): } -@pytest.fixture() +@pytest.fixture def mock_get_service_templates(mocker): def _create(service_id): return create_service_templates(service_id) @@ -935,7 +935,7 @@ def mock_get_service_templates(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_get_more_service_templates_than_can_fit_onscreen(mocker): def _create(service_id): return create_service_templates(service_id, number_of_templates=20) @@ -945,7 +945,7 @@ def mock_get_more_service_templates_than_can_fit_onscreen(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_get_service_templates_when_no_templates_exist(mocker): def _create(service_id): return {"data": []} @@ -955,7 +955,7 @@ def mock_get_service_templates_when_no_templates_exist(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_get_service_templates_with_only_one_template(mocker): def _get(service_id): return { @@ -975,7 +975,7 @@ def mock_get_service_templates_with_only_one_template(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_delete_service_template(mocker): def _delete(service_id, template_id): template = template_json( @@ -992,12 +992,12 @@ def mock_delete_service_template(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_redact_template(mocker): return mocker.patch("app.service_api_client.redact_service_template") -@pytest.fixture() +@pytest.fixture def mock_update_service_template_sender(mocker): def _update(service_id, template_id, reply_to): return @@ -1007,12 +1007,12 @@ def mock_update_service_template_sender(mocker): ) -@pytest.fixture() +@pytest.fixture def api_user_pending(fake_uuid): return create_user(id=fake_uuid, state="pending") -@pytest.fixture() +@pytest.fixture def platform_admin_user(fake_uuid): return create_platform_admin_user( permissions={ @@ -1029,7 +1029,7 @@ def platform_admin_user(fake_uuid): ) -@pytest.fixture() +@pytest.fixture def platform_admin_user_no_service_permissions(): """ this fixture is for situations where we want to test that platform admin can access @@ -1038,17 +1038,17 @@ def platform_admin_user_no_service_permissions(): return create_platform_admin_user() -@pytest.fixture() +@pytest.fixture def api_user_active(): return create_api_user_active() -@pytest.fixture() +@pytest.fixture def api_user_active_email_auth(fake_uuid): return create_user(id=fake_uuid, auth_type="email_auth") -@pytest.fixture() +@pytest.fixture def active_user_with_permissions_no_mobile(fake_uuid): return create_service_one_admin( id=fake_uuid, @@ -1056,7 +1056,7 @@ def active_user_with_permissions_no_mobile(fake_uuid): ) -@pytest.fixture() +@pytest.fixture def api_nongov_user_active(fake_uuid): return create_service_one_admin( id=fake_uuid, @@ -1064,17 +1064,17 @@ def api_nongov_user_active(fake_uuid): ) -@pytest.fixture() +@pytest.fixture def active_user_with_permissions(fake_uuid): return create_active_user_with_permissions() -@pytest.fixture() +@pytest.fixture def active_user_empty_permissions(fake_uuid): return create_active_user_empty_permissions() -@pytest.fixture() +@pytest.fixture def active_user_with_permission_to_two_services(fake_uuid): permissions = [ "send_texts", @@ -1097,7 +1097,7 @@ def active_user_with_permission_to_two_services(fake_uuid): ) -@pytest.fixture() +@pytest.fixture def active_user_with_permission_to_other_service( active_user_with_permission_to_two_services, ): @@ -1110,22 +1110,22 @@ def active_user_with_permission_to_other_service( return active_user_with_permission_to_two_services -@pytest.fixture() +@pytest.fixture def active_caseworking_user(): return create_active_caseworking_user() -@pytest.fixture() +@pytest.fixture def active_user_view_permissions(): return create_active_user_view_permissions() -@pytest.fixture() +@pytest.fixture def active_user_no_settings_permission(): return create_active_user_no_settings_permission() -@pytest.fixture() +@pytest.fixture def api_user_locked(fake_uuid): return create_user( id=fake_uuid, @@ -1134,7 +1134,7 @@ def api_user_locked(fake_uuid): ) -@pytest.fixture() +@pytest.fixture def api_user_request_password_reset(fake_uuid): return create_user( id=fake_uuid, @@ -1142,7 +1142,7 @@ def api_user_request_password_reset(fake_uuid): ) -@pytest.fixture() +@pytest.fixture def api_user_changed_password(fake_uuid): return create_user( id=fake_uuid, @@ -1151,12 +1151,12 @@ def api_user_changed_password(fake_uuid): ) -@pytest.fixture() +@pytest.fixture def mock_send_change_email_verification(mocker): return mocker.patch("app.user_api_client.send_change_email_verification") -@pytest.fixture() +@pytest.fixture def mock_register_user(mocker, api_user_pending): def _register(name, email_address, mobile_number, password, auth_type): api_user_pending["name"] = name @@ -1169,7 +1169,7 @@ def mock_register_user(mocker, api_user_pending): return mocker.patch("app.user_api_client.register_user", side_effect=_register) -@pytest.fixture() +@pytest.fixture def mock_get_non_govuser(mocker, api_user_active): api_user_active["email_address"] = "someuser@example.com" @@ -1180,7 +1180,7 @@ def mock_get_non_govuser(mocker, api_user_active): return mocker.patch("app.user_api_client.get_user", side_effect=_get_user) -@pytest.fixture() +@pytest.fixture def mock_get_user(mocker, api_user_active): def _get_user(id_): api_user_active["id"] = id_ @@ -1189,7 +1189,7 @@ def mock_get_user(mocker, api_user_active): return mocker.patch("app.user_api_client.get_user", side_effect=_get_user) -@pytest.fixture() +@pytest.fixture def mock_get_locked_user(mocker, api_user_locked): def _get_user(id_): api_user_locked["id"] = id_ @@ -1198,12 +1198,12 @@ def mock_get_locked_user(mocker, api_user_locked): return mocker.patch("app.user_api_client.get_user", side_effect=_get_user) -@pytest.fixture() +@pytest.fixture def mock_get_user_pending(mocker, api_user_pending): return mocker.patch("app.user_api_client.get_user", return_value=api_user_pending) -@pytest.fixture() +@pytest.fixture def mock_get_user_by_email(mocker, api_user_active): def _get_user(email_address): api_user_active["email_address"] = email_address @@ -1212,7 +1212,7 @@ def mock_get_user_by_email(mocker, api_user_active): return mocker.patch("app.user_api_client.get_user_by_email", side_effect=_get_user) -@pytest.fixture() +@pytest.fixture def mock_dont_get_user_by_email(mocker): def _get_user(email_address): return None @@ -1222,7 +1222,7 @@ def mock_dont_get_user_by_email(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_get_user_by_email_request_password_reset( mocker, api_user_request_password_reset ): @@ -1232,28 +1232,28 @@ def mock_get_user_by_email_request_password_reset( ) -@pytest.fixture() +@pytest.fixture def mock_get_user_by_email_user_changed_password(mocker, api_user_changed_password): return mocker.patch( "app.user_api_client.get_user_by_email", return_value=api_user_changed_password ) -@pytest.fixture() +@pytest.fixture def mock_get_user_by_email_locked(mocker, api_user_locked): return mocker.patch( "app.user_api_client.get_user_by_email", return_value=api_user_locked ) -@pytest.fixture() +@pytest.fixture def mock_get_user_by_email_pending(mocker, api_user_pending): return mocker.patch( "app.user_api_client.get_user_by_email", return_value=api_user_pending ) -@pytest.fixture() +@pytest.fixture def mock_get_user_by_email_not_found(mocker, api_user_active): def _get_user(email): json_mock = Mock(return_value={"message": "Not found", "result": "error"}) @@ -1264,7 +1264,7 @@ def mock_get_user_by_email_not_found(mocker, api_user_active): return mocker.patch("app.user_api_client.get_user_by_email", side_effect=_get_user) -@pytest.fixture() +@pytest.fixture def mock_verify_password(mocker): def _verify_password(user, password): return True @@ -1274,7 +1274,7 @@ def mock_verify_password(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_update_user_password(mocker, api_user_active): def _update(user_id, password): api_user_active["id"] = user_id @@ -1283,7 +1283,7 @@ def mock_update_user_password(mocker, api_user_active): return mocker.patch("app.user_api_client.update_password", side_effect=_update) -@pytest.fixture() +@pytest.fixture def mock_update_user_attribute(mocker, api_user_active): def _update(user_id, **kwargs): api_user_active["id"] = user_id @@ -1294,7 +1294,7 @@ def mock_update_user_attribute(mocker, api_user_active): ) -@pytest.fixture() +@pytest.fixture def mock_activate_user(mocker, api_user_active): def _activate(user_id): api_user_active["id"] = user_id @@ -1303,14 +1303,14 @@ def mock_activate_user(mocker, api_user_active): return mocker.patch("app.user_api_client.activate_user", side_effect=_activate) -@pytest.fixture() +@pytest.fixture def mock_email_is_not_already_in_use(mocker): return mocker.patch( "app.user_api_client.get_user_by_email_or_none", return_value=None ) -@pytest.fixture() +@pytest.fixture def mock_revoke_api_key(mocker): def _revoke(service_id, key_id): return {} @@ -1318,7 +1318,7 @@ def mock_revoke_api_key(mocker): return mocker.patch("app.api_key_api_client.revoke_api_key", side_effect=_revoke) -@pytest.fixture() +@pytest.fixture def mock_get_api_keys(mocker, fake_uuid): def _get_keys(service_id, key_id=None): keys = { @@ -1339,7 +1339,7 @@ def mock_get_api_keys(mocker, fake_uuid): return mocker.patch("app.api_key_api_client.get_api_keys", side_effect=_get_keys) -@pytest.fixture() +@pytest.fixture def mock_get_no_api_keys(mocker): def _get_keys(service_id): keys = {"apiKeys": []} @@ -1348,7 +1348,7 @@ def mock_get_no_api_keys(mocker): return mocker.patch("app.api_key_api_client.get_api_keys", side_effect=_get_keys) -@pytest.fixture() +@pytest.fixture def mock_login(mocker, mock_get_user, mock_update_user_attribute, mock_events): def _verify_code(user_id, code, code_type): return True, "" @@ -1362,17 +1362,17 @@ def mock_login(mocker, mock_get_user, mock_update_user_attribute, mock_events): ) -@pytest.fixture() +@pytest.fixture def mock_send_verify_code(mocker): return mocker.patch("app.user_api_client.send_verify_code") -@pytest.fixture() +@pytest.fixture def mock_send_verify_email(mocker): return mocker.patch("app.user_api_client.send_verify_email") -@pytest.fixture() +@pytest.fixture def mock_check_verify_code(mocker): def _verify(user_id, code, code_type): return True, "" @@ -1380,7 +1380,7 @@ def mock_check_verify_code(mocker): return mocker.patch("app.user_api_client.check_verify_code", side_effect=_verify) -@pytest.fixture() +@pytest.fixture def mock_check_verify_code_code_not_found(mocker): def _verify(user_id, code, code_type): return False, "Code not found" @@ -1388,7 +1388,7 @@ def mock_check_verify_code_code_not_found(mocker): return mocker.patch("app.user_api_client.check_verify_code", side_effect=_verify) -@pytest.fixture() +@pytest.fixture def mock_check_verify_code_code_expired(mocker): def _verify(user_id, code, code_type): return False, "Code has expired" @@ -1396,7 +1396,7 @@ def mock_check_verify_code_code_expired(mocker): return mocker.patch("app.user_api_client.check_verify_code", side_effect=_verify) -@pytest.fixture() +@pytest.fixture def mock_create_job(mocker, api_user_active): def _create( job_id, @@ -1416,7 +1416,7 @@ def mock_create_job(mocker, api_user_active): return mocker.patch("app.job_api_client.create_job", side_effect=_create) -@pytest.fixture() +@pytest.fixture def mock_get_job(mocker, api_user_active): def _get_job(service_id, job_id): return {"data": job_json(service_id, api_user_active, job_id=job_id)} @@ -1424,7 +1424,7 @@ def mock_get_job(mocker, api_user_active): return mocker.patch("app.job_api_client.get_job", side_effect=_get_job) -@pytest.fixture() +@pytest.fixture def mock_get_job_doesnt_exist(mocker): def _get_job(service_id, job_id): raise HTTPError(response=Mock(status_code=404, json={}), message={}) @@ -1432,7 +1432,7 @@ def mock_get_job_doesnt_exist(mocker): return mocker.patch("app.job_api_client.get_job", side_effect=_get_job) -@pytest.fixture() +@pytest.fixture def mock_get_scheduled_job(mocker, api_user_active): def _get_job(service_id, job_id): return { @@ -1448,7 +1448,7 @@ def mock_get_scheduled_job(mocker, api_user_active): return mocker.patch("app.job_api_client.get_job", side_effect=_get_job) -@pytest.fixture() +@pytest.fixture def mock_get_cancelled_job(mocker, api_user_active): def _get_job(service_id, job_id): return { @@ -1464,7 +1464,7 @@ def mock_get_cancelled_job(mocker, api_user_active): return mocker.patch("app.job_api_client.get_job", side_effect=_get_job) -@pytest.fixture() +@pytest.fixture def mock_get_job_in_progress(mocker, api_user_active): def _get_job(service_id, job_id): return { @@ -1481,7 +1481,7 @@ def mock_get_job_in_progress(mocker, api_user_active): return mocker.patch("app.job_api_client.get_job", side_effect=_get_job) -@pytest.fixture() +@pytest.fixture def mock_get_job_with_sending_limits_exceeded(mocker, api_user_active): def _get_job(service_id, job_id): return { @@ -1498,17 +1498,17 @@ def mock_get_job_with_sending_limits_exceeded(mocker, api_user_active): return mocker.patch("app.job_api_client.get_job", side_effect=_get_job) -@pytest.fixture() +@pytest.fixture def mock_has_jobs(mocker): return mocker.patch("app.job_api_client.has_jobs", return_value=True) -@pytest.fixture() +@pytest.fixture def mock_has_no_jobs(mocker): return mocker.patch("app.job_api_client.has_jobs", return_value=False) -@pytest.fixture() +@pytest.fixture def mock_get_jobs(mocker, api_user_active, fake_uuid): def _get_jobs(service_id, limit_days=None, statuses=None, page=1): if statuses is None: @@ -1564,7 +1564,7 @@ def mock_get_jobs(mocker, api_user_active, fake_uuid): return mocker.patch("app.job_api_client.get_jobs", side_effect=_get_jobs) -@pytest.fixture() +@pytest.fixture def mock_get_scheduled_job_stats(mocker, api_user_active): return mocker.patch( "app.job_api_client.get_scheduled_job_stats", @@ -1576,7 +1576,7 @@ def mock_get_scheduled_job_stats(mocker, api_user_active): ) -@pytest.fixture() +@pytest.fixture def mock_get_uploads(mocker, api_user_active): def _get_uploads(service_id, limit_days=None, statuses=None, page=1): uploads = [ @@ -1608,7 +1608,7 @@ def mock_get_uploads(mocker, api_user_active): ) -@pytest.fixture() +@pytest.fixture def _mock_get_no_uploads(mocker, api_user_active): mocker.patch( "app.models.job.PaginatedUploads.client_method", @@ -1618,7 +1618,7 @@ def _mock_get_no_uploads(mocker, api_user_active): ) -@pytest.fixture() +@pytest.fixture def mock_get_no_jobs(mocker, api_user_active): return mocker.patch( "app.models.job.PaginatedJobs.client_method", @@ -1629,7 +1629,7 @@ def mock_get_no_jobs(mocker, api_user_active): ) -@pytest.fixture() +@pytest.fixture def mock_get_notifications( mocker, api_user_active, @@ -1680,7 +1680,7 @@ def mock_get_notifications( ) -@pytest.fixture() +@pytest.fixture def mock_get_notifications_with_previous_next(mocker): def _get_notifications( service_id, @@ -1705,7 +1705,7 @@ def mock_get_notifications_with_previous_next(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_get_notifications_with_no_notifications(mocker): def _get_notifications( service_id, @@ -1728,7 +1728,7 @@ def mock_get_notifications_with_no_notifications(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_get_inbound_sms(mocker): def _get_inbound_sms(service_id, user_number=None, page=1): return inbound_sms_json() @@ -1739,7 +1739,7 @@ def mock_get_inbound_sms(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_get_inbound_sms_by_id_with_no_messages(mocker): def _get_inbound_sms_by_id(service_id, notification_id): raise HTTPError(response=Mock(status_code=404)) @@ -1750,7 +1750,7 @@ def mock_get_inbound_sms_by_id_with_no_messages(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_get_most_recent_inbound_sms(mocker): def _get_most_recent_inbound_sms(service_id, user_number=None, page=1): return inbound_sms_json() @@ -1761,7 +1761,7 @@ def mock_get_most_recent_inbound_sms(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_get_most_recent_inbound_sms_with_no_messages(mocker): def _get_most_recent_inbound_sms(service_id, user_number=None, page=1): return {"has_next": False, "data": []} @@ -1772,7 +1772,7 @@ def mock_get_most_recent_inbound_sms_with_no_messages(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_get_inbound_sms_summary(mocker): def _get_inbound_sms_summary( service_id, @@ -1785,7 +1785,7 @@ def mock_get_inbound_sms_summary(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_get_inbound_sms_summary_with_no_messages(mocker): def _get_inbound_sms_summary( service_id, @@ -1798,7 +1798,7 @@ def mock_get_inbound_sms_summary_with_no_messages(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_get_inbound_number_for_service(mocker): return mocker.patch( "app.inbound_number_client.get_inbound_sms_number_for_service", @@ -1806,7 +1806,7 @@ def mock_get_inbound_number_for_service(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_no_inbound_number_for_service(mocker): return mocker.patch( "app.inbound_number_client.get_inbound_sms_number_for_service", @@ -1814,7 +1814,7 @@ def mock_no_inbound_number_for_service(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_has_permissions(mocker): def _has_permission(*permissions, restrict_admin_usage=False, allow_org_user=False): return True @@ -1824,7 +1824,7 @@ def mock_has_permissions(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_get_users_by_service(mocker): def _get_users_for_service(service_id): return [ @@ -1843,7 +1843,7 @@ def mock_get_users_by_service(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_s3_download(mocker): def _download(service_id, upload_id): return """ @@ -1855,7 +1855,7 @@ def mock_s3_download(mocker): return mocker.patch("app.main.views.send.s3download", side_effect=_download) -@pytest.fixture() +@pytest.fixture def sample_invite(mocker, service_one): id_ = USER_ONE_ID from_user = service_one["users"][0] @@ -1879,7 +1879,7 @@ def sample_invite(mocker, service_one): ) -@pytest.fixture() +@pytest.fixture def encoded_invite_data(): """ This mimics what API does when it encodes invite data in @@ -1898,7 +1898,7 @@ def encoded_invite_data(): return invite_data.decode("utf8") -@pytest.fixture() +@pytest.fixture def expired_invite(service_one): id_ = USER_ONE_ID from_user = service_one["users"][0] @@ -1922,7 +1922,7 @@ def expired_invite(service_one): ) -@pytest.fixture() +@pytest.fixture def mock_create_invite(mocker, sample_invite): def _create_invite( from_user, service_id, email_address, permissions, folder_permissions @@ -1940,7 +1940,7 @@ def mock_create_invite(mocker, sample_invite): ) -@pytest.fixture() +@pytest.fixture def mock_get_invites_for_service(mocker, service_one, sample_invite): def _get_invites(service_id): data = [] @@ -1955,7 +1955,7 @@ def mock_get_invites_for_service(mocker, service_one, sample_invite): ) -@pytest.fixture() +@pytest.fixture def mock_get_invites_without_manage_permission(mocker, service_one, sample_invite): def _get_invites(service_id): return [ @@ -1977,7 +1977,7 @@ def mock_get_invites_without_manage_permission(mocker, service_one, sample_invit ) -@pytest.fixture() +@pytest.fixture def mock_accept_invite(mocker, sample_invite): def _accept(service_id, invite_id): return sample_invite @@ -1985,7 +1985,7 @@ def mock_accept_invite(mocker, sample_invite): return mocker.patch("app.invite_api_client.accept_invite", side_effect=_accept) -@pytest.fixture() +@pytest.fixture def mock_add_user_to_service(mocker, service_one, api_user_active): def _add_user(service_id, user_id, permissions, folder_permissions): return @@ -1995,19 +1995,19 @@ def mock_add_user_to_service(mocker, service_one, api_user_active): ) -@pytest.fixture() +@pytest.fixture def mock_set_user_permissions(mocker): return mocker.patch("app.user_api_client.set_user_permissions", return_value=None) -@pytest.fixture() +@pytest.fixture def mock_remove_user_from_service(mocker): return mocker.patch( "app.service_api_client.remove_user_from_service", return_value=None ) -@pytest.fixture() +@pytest.fixture def mock_get_template_statistics(mocker, service_one, fake_uuid): template = template_json( service_one["id"], @@ -2033,7 +2033,7 @@ def mock_get_template_statistics(mocker, service_one, fake_uuid): ) -@pytest.fixture() +@pytest.fixture def mock_get_monthly_template_usage(mocker, service_one, fake_uuid): def _stats(service_id, year): return [ @@ -2053,7 +2053,7 @@ def mock_get_monthly_template_usage(mocker, service_one, fake_uuid): ) -@pytest.fixture() +@pytest.fixture def mock_get_monthly_notification_stats(mocker, service_one, fake_uuid): def _stats(service_id, year): return { @@ -2076,7 +2076,7 @@ def mock_get_monthly_notification_stats(mocker, service_one, fake_uuid): ) -@pytest.fixture() +@pytest.fixture def mock_get_annual_usage_for_service(mocker, service_one, fake_uuid): def _get_usage(service_id, year=None): return [ @@ -2111,7 +2111,7 @@ def mock_get_annual_usage_for_service(mocker, service_one, fake_uuid): ) -@pytest.fixture() +@pytest.fixture def mock_get_monthly_usage_for_service(mocker): def _get_usage(service_id, year): return [ @@ -2162,7 +2162,7 @@ def mock_get_monthly_usage_for_service(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_get_annual_usage_for_service_in_future(mocker, service_one, fake_uuid): def _get_usage(service_id, year=None): return [ @@ -2189,7 +2189,7 @@ def mock_get_annual_usage_for_service_in_future(mocker, service_one, fake_uuid): ) -@pytest.fixture() +@pytest.fixture def mock_get_monthly_usage_for_service_in_future(mocker): def _get_usage(service_id, year): return [] @@ -2199,7 +2199,7 @@ def mock_get_monthly_usage_for_service_in_future(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_events(mocker): def _create_event(event_type, event_data): return {"some": "data"} @@ -2207,12 +2207,12 @@ def mock_events(mocker): return mocker.patch("app.events_api_client.create_event", side_effect=_create_event) -@pytest.fixture() +@pytest.fixture def mock_send_already_registered_email(mocker): return mocker.patch("app.user_api_client.send_already_registered_email") -@pytest.fixture() +@pytest.fixture def mock_get_guest_list(mocker): def _get_guest_list(service_id): return { @@ -2225,17 +2225,17 @@ def mock_get_guest_list(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_update_guest_list(mocker): return mocker.patch("app.service_api_client.update_guest_list") -@pytest.fixture() +@pytest.fixture def mock_reset_failed_login_count(mocker): return mocker.patch("app.user_api_client.reset_failed_login_count") -@pytest.fixture() +@pytest.fixture def mock_get_notification(mocker): def _get_notification( service_id, @@ -2266,7 +2266,7 @@ def mock_get_notification(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_send_notification(mocker, fake_uuid): def _send_notification( service_id, *, template_id, recipient, personalisation, sender_id @@ -2278,7 +2278,7 @@ def mock_send_notification(mocker, fake_uuid): ) -@pytest.fixture() +@pytest.fixture def client(notify_admin): """ Do not use this fixture directly – use `client_request` instead @@ -2288,7 +2288,7 @@ def client(notify_admin): yield client -@pytest.fixture() +@pytest.fixture def logged_in_client( client, active_user_with_permissions, mocker, service_one, mock_login ): @@ -2299,7 +2299,7 @@ def logged_in_client( return client -@pytest.fixture() +@pytest.fixture def _os_environ(): """ clear os.environ, and restore it after the test runs @@ -2312,7 +2312,7 @@ def _os_environ(): os.environ[k] = v -@pytest.fixture() # noqa (C901 too complex) +@pytest.fixture # noqa (C901 too complex) def client_request(logged_in_client, mocker, service_one): # noqa (C901 too complex) def _get(mocker): return {"count": 0} @@ -2505,7 +2505,7 @@ def normalize_spaces(input): return normalize_spaces(" ".join(item.text for item in input)) -@pytest.fixture() +@pytest.fixture def mock_get_service_data_retention(mocker): data = { "id": str(sample_uuid()), @@ -2521,17 +2521,17 @@ def mock_get_service_data_retention(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_create_service_data_retention(mocker): return mocker.patch("app.service_api_client.create_service_data_retention") -@pytest.fixture() +@pytest.fixture def mock_update_service_data_retention(mocker): return mocker.patch("app.service_api_client.update_service_data_retention") -@pytest.fixture() +@pytest.fixture def mock_get_free_sms_fragment_limit(mocker): sample_limit = 250000 return mocker.patch( @@ -2540,7 +2540,7 @@ def mock_get_free_sms_fragment_limit(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_create_or_update_free_sms_fragment_limit(mocker): sample_limit = 250000 return mocker.patch( @@ -2571,7 +2571,7 @@ def set_config_values(app, dict): app.config[key] = old_values[key] -@pytest.fixture() +@pytest.fixture def valid_token(notify_admin, fake_uuid): return generate_token( json.dumps({"user_id": fake_uuid, "secret_code": "my secret"}), @@ -2580,7 +2580,7 @@ def valid_token(notify_admin, fake_uuid): ) -@pytest.fixture() +@pytest.fixture def mock_get_valid_service_inbound_api(mocker): def _get(service_id, inbound_api_id): return { @@ -2597,7 +2597,7 @@ def mock_get_valid_service_inbound_api(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_get_valid_service_callback_api(mocker): def _get(service_id, callback_api_id): return { @@ -2614,7 +2614,7 @@ def mock_get_valid_service_callback_api(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_get_empty_service_inbound_api(mocker): return mocker.patch( "app.service_api_client.get_service_inbound_api", @@ -2622,7 +2622,7 @@ def mock_get_empty_service_inbound_api(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_get_empty_service_callback_api(mocker): return mocker.patch( "app.service_api_client.get_service_callback_api", @@ -2630,7 +2630,7 @@ def mock_get_empty_service_callback_api(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_create_service_inbound_api(mocker): def _create_service_inbound_api(service_id, url, bearer_token, user_id): return @@ -2641,7 +2641,7 @@ def mock_create_service_inbound_api(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_update_service_inbound_api(mocker): def _update_service_inbound_api( service_id, url, bearer_token, user_id, inbound_api_id @@ -2654,7 +2654,7 @@ def mock_update_service_inbound_api(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_create_service_callback_api(mocker): def _create_service_callback_api(service_id, url, bearer_token, user_id): return @@ -2665,7 +2665,7 @@ def mock_create_service_callback_api(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_update_service_callback_api(mocker): def _update_service_callback_api( service_id, url, bearer_token, user_id, callback_api_id @@ -2678,14 +2678,14 @@ def mock_update_service_callback_api(mocker): ) -@pytest.fixture() +@pytest.fixture def organization_one(api_user_active): return organization_json( ORGANISATION_ID, "organization one", [api_user_active["id"]] ) -@pytest.fixture() +@pytest.fixture def mock_get_organizations(mocker): def _get_organizations(): return [ @@ -2705,7 +2705,7 @@ def mock_get_organizations(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_get_organizations_with_unusual_domains(mocker): def _get_organizations(): return [ @@ -2726,7 +2726,7 @@ def mock_get_organizations_with_unusual_domains(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_get_organization(mocker): def _get_organization(org_id): return organization_json( @@ -2743,7 +2743,7 @@ def mock_get_organization(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_get_organization_by_domain(mocker): def _get_organization_by_domain(domain): return organization_json(ORGANISATION_ID) @@ -2754,7 +2754,7 @@ def mock_get_organization_by_domain(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_get_no_organization_by_domain(mocker): return mocker.patch( "app.organizations_client.get_organization_by_domain", @@ -2762,7 +2762,7 @@ def mock_get_no_organization_by_domain(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_get_service_organization( mocker, mock_get_organization, @@ -2774,7 +2774,7 @@ def mock_get_service_organization( ) -@pytest.fixture() +@pytest.fixture def mock_update_service_organization(mocker): def _update_service_organization(service_id, org_id): return @@ -2805,7 +2805,7 @@ def _get_organization_services(organization_id): ] -@pytest.fixture() +@pytest.fixture def mock_get_organization_services(mocker, api_user_active): return mocker.patch( "app.organizations_client.get_organization_services", @@ -2813,7 +2813,7 @@ def mock_get_organization_services(mocker, api_user_active): ) -@pytest.fixture() +@pytest.fixture def mock_get_users_for_organization(mocker): def _get_users_for_organization(org_id): return [ @@ -2827,7 +2827,7 @@ def mock_get_users_for_organization(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_get_invited_users_for_organization(mocker, sample_org_invite): def _get_invited_invited_users_for_organization(org_id): return [sample_org_invite] @@ -2838,7 +2838,7 @@ def mock_get_invited_users_for_organization(mocker, sample_org_invite): ) -@pytest.fixture() +@pytest.fixture def sample_org_invite(mocker, organization_one): id_ = str(UUID(bytes=b"sample_org_invit", version=4)) invited_by = organization_one["users"][0] @@ -2852,7 +2852,7 @@ def sample_org_invite(mocker, organization_one): ) -@pytest.fixture() +@pytest.fixture def mock_get_invites_for_organization(mocker, sample_org_invite): def _get_org_invites(org_id): data = [] @@ -2868,7 +2868,7 @@ def mock_get_invites_for_organization(mocker, sample_org_invite): ) -@pytest.fixture() +@pytest.fixture def mock_check_org_invite_token(mocker, sample_org_invite): def _check_org_token(token): return sample_org_invite @@ -2878,7 +2878,7 @@ def mock_check_org_invite_token(mocker, sample_org_invite): ) -@pytest.fixture() +@pytest.fixture def mock_check_org_cancelled_invite_token(mocker, sample_org_invite): def _check_org_token(token): sample_org_invite["status"] = "cancelled" @@ -2889,7 +2889,7 @@ def mock_check_org_cancelled_invite_token(mocker, sample_org_invite): ) -@pytest.fixture() +@pytest.fixture def mock_check_org_accepted_invite_token(mocker, sample_org_invite): sample_org_invite["status"] = "accepted" @@ -2901,7 +2901,7 @@ def mock_check_org_accepted_invite_token(mocker, sample_org_invite): ) -@pytest.fixture() +@pytest.fixture def mock_accept_org_invite(mocker, sample_org_invite): def _accept(organization_id, invite_id): return sample_org_invite @@ -2909,7 +2909,7 @@ def mock_accept_org_invite(mocker, sample_org_invite): return mocker.patch("app.org_invite_api_client.accept_invite", side_effect=_accept) -@pytest.fixture() +@pytest.fixture def mock_add_user_to_organization(mocker, organization_one, api_user_active): def _add_user(organization_id, user_id): return api_user_active @@ -2919,7 +2919,7 @@ def mock_add_user_to_organization(mocker, organization_one, api_user_active): ) -@pytest.fixture() +@pytest.fixture def mock_update_organization(mocker): def _update_org(org, **kwargs): return @@ -2929,7 +2929,7 @@ def mock_update_organization(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_get_organizations_and_services_for_user( mocker, organization_one, api_user_active ): @@ -2942,7 +2942,7 @@ def mock_get_organizations_and_services_for_user( ) -@pytest.fixture() +@pytest.fixture def mock_get_non_empty_organizations_and_services_for_user( mocker, organization_one, api_user_active ): @@ -2989,7 +2989,7 @@ def mock_get_non_empty_organizations_and_services_for_user( ) -@pytest.fixture() +@pytest.fixture def mock_get_just_services_for_user(mocker, organization_one, api_user_active): def _make_services(name, trial_mode=False): return [ @@ -3014,7 +3014,7 @@ def mock_get_just_services_for_user(mocker, organization_one, api_user_active): ) -@pytest.fixture() +@pytest.fixture def mock_get_empty_organizations_and_one_service_for_user( mocker, organization_one, api_user_active ): @@ -3036,7 +3036,7 @@ def mock_get_empty_organizations_and_one_service_for_user( ) -@pytest.fixture() +@pytest.fixture def mock_create_event(mocker): """ This should be used whenever your code is calling `flask_login.login_user` @@ -3053,19 +3053,19 @@ def url_for_endpoint_with_token(endpoint, token, next=None): return url_for(endpoint, token=token, next=next) -@pytest.fixture() +@pytest.fixture def mock_get_template_folders(mocker): return mocker.patch( "app.template_folder_api_client.get_template_folders", return_value=[] ) -@pytest.fixture() +@pytest.fixture def mock_move_to_template_folder(mocker): return mocker.patch("app.template_folder_api_client.move_to_folder") -@pytest.fixture() +@pytest.fixture def mock_create_template_folder(mocker): return mocker.patch( "app.template_folder_api_client.create_template_folder", @@ -3073,7 +3073,7 @@ def mock_create_template_folder(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_get_service_and_organization_counts(mocker): return mocker.patch( "app.status_api_client.get_count_of_live_services_and_organizations", @@ -3084,7 +3084,7 @@ def mock_get_service_and_organization_counts(mocker): ) -@pytest.fixture() +@pytest.fixture def mock_get_service_history(mocker): return mocker.patch( "app.service_api_client.get_service_history", @@ -3497,7 +3497,7 @@ def create_template( ) -@pytest.fixture() +@pytest.fixture def mock_get_invited_user_by_id(mocker, sample_invite): def _get(invited_user_id): return sample_invite @@ -3508,7 +3508,7 @@ def mock_get_invited_user_by_id(mocker, sample_invite): ) -@pytest.fixture() +@pytest.fixture def mock_get_invited_org_user_by_id(mocker, sample_org_invite): def _get(invited_org_user_id): return sample_org_invite @@ -3519,19 +3519,19 @@ def mock_get_invited_org_user_by_id(mocker, sample_org_invite): ) -@pytest.fixture() +@pytest.fixture def fake_markdown_file(): input = "#Test" return input -@pytest.fixture() +@pytest.fixture def fake_jinja_template(): input = "{% if True %}True{% endif %}" return input -@pytest.fixture() +@pytest.fixture def fake_soup_template(): input = "

Test

" return input diff --git a/tests/end_to_end/conftest.py b/tests/end_to_end/conftest.py index 30ca363f5..64e48a8fd 100644 --- a/tests/end_to_end/conftest.py +++ b/tests/end_to_end/conftest.py @@ -68,7 +68,7 @@ def login_for_end_to_end_testing(browser): context.storage_state(path=auth_state_path) -@pytest.fixture() +@pytest.fixture def end_to_end_authenticated_context(browser): # Create and load a previously authenticated context for Playwright E2E # tests. @@ -82,13 +82,13 @@ def end_to_end_authenticated_context(browser): return context -@pytest.fixture() +@pytest.fixture def end_to_end_context(browser): context = browser.new_context() return context -@pytest.fixture() +@pytest.fixture def authenticated_page(end_to_end_context): # Open a new page and go to the site. page = end_to_end_context.new_page() diff --git a/tests/notifications_utils/clients/redis/test_redis_client.py b/tests/notifications_utils/clients/redis/test_redis_client.py index ac228849d..909f7685f 100644 --- a/tests/notifications_utils/clients/redis/test_redis_client.py +++ b/tests/notifications_utils/clients/redis/test_redis_client.py @@ -8,17 +8,17 @@ from freezegun import freeze_time from notifications_utils.clients.redis.redis_client import RedisClient, prepare_value -@pytest.fixture() +@pytest.fixture def mocked_redis_pipeline(): return Mock() -@pytest.fixture() +@pytest.fixture def delete_mock(): return Mock(return_value=4) -@pytest.fixture() +@pytest.fixture def mocked_redis_client(app, mocked_redis_pipeline, delete_mock, mocker): app.config["REDIS_ENABLED"] = True @@ -46,7 +46,7 @@ def mocked_redis_client(app, mocked_redis_pipeline, delete_mock, mocker): return redis_client -@pytest.fixture() +@pytest.fixture def failing_redis_client(mocked_redis_client, delete_mock): # nota bene: using KeyError because flake8 thinks Exception # and BaseException are too broad diff --git a/tests/notifications_utils/clients/redis/test_request_cache.py b/tests/notifications_utils/clients/redis/test_request_cache.py index 472d9398b..cab88a827 100644 --- a/tests/notifications_utils/clients/redis/test_request_cache.py +++ b/tests/notifications_utils/clients/redis/test_request_cache.py @@ -4,7 +4,7 @@ from notifications_utils.clients.redis import RequestCache from notifications_utils.clients.redis.redis_client import RedisClient -@pytest.fixture() +@pytest.fixture def mocked_redis_client(app): app.config["REDIS_ENABLED"] = True redis_client = RedisClient() @@ -12,7 +12,7 @@ def mocked_redis_client(app): return redis_client -@pytest.fixture() +@pytest.fixture def cache(mocked_redis_client): return RequestCache(mocked_redis_client) diff --git a/tests/notifications_utils/conftest.py b/tests/notifications_utils/conftest.py index 0b8f3bce8..7150b1486 100644 --- a/tests/notifications_utils/conftest.py +++ b/tests/notifications_utils/conftest.py @@ -9,7 +9,7 @@ class FakeService: id = "1234" -@pytest.fixture() +@pytest.fixture def app(): flask_app = Flask(__name__) ctx = flask_app.app_context() @@ -20,7 +20,7 @@ def app(): ctx.pop() -@pytest.fixture() +@pytest.fixture def celery_app(mocker): app = Flask(__name__) app.config["CELERY"] = {"broker_url": "foo"} @@ -39,7 +39,7 @@ def sample_service(): return FakeService() -@pytest.fixture() +@pytest.fixture def rmock(): with requests_mock.mock() as rmock: yield rmock From 361b936857f9dbebf57a4ebc63c5c652f644fbf0 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Tue, 16 Jul 2024 11:32:08 -0400 Subject: [PATCH 02/15] Update Python dependencies - 7/16/24 This changeset updates several Python dependencies that were being picked up by Dependabot. Signed-off-by: Carlo Costino --- poetry.lock | 114 +++++++++++++++++++++++-------------------------- pyproject.toml | 10 ++--- 2 files changed, 59 insertions(+), 65 deletions(-) diff --git a/poetry.lock b/poetry.lock index 71e030da0..b96f87d44 100644 --- a/poetry.lock +++ b/poetry.lock @@ -182,17 +182,17 @@ files = [ [[package]] name = "boto3" -version = "1.34.143" +version = "1.34.144" description = "The AWS SDK for Python" optional = false python-versions = ">=3.8" files = [ - {file = "boto3-1.34.143-py3-none-any.whl", hash = "sha256:0d16832f23e6bd3ae94e35ea8e625529850bfad9baccd426de96ad8f445d8e03"}, - {file = "boto3-1.34.143.tar.gz", hash = "sha256:b590ce80c65149194def43ebf0ea1cf0533945502507837389a8d22e3ecbcf05"}, + {file = "boto3-1.34.144-py3-none-any.whl", hash = "sha256:b8433d481d50b68a0162c0379c0dd4aabfc3d1ad901800beb5b87815997511c1"}, + {file = "boto3-1.34.144.tar.gz", hash = "sha256:2f3e88b10b8fcc5f6100a9d74cd28230edc9d4fa226d99dd40a3ab38ac213673"}, ] [package.dependencies] -botocore = ">=1.34.143,<1.35.0" +botocore = ">=1.34.144,<1.35.0" jmespath = ">=0.7.1,<2.0.0" s3transfer = ">=0.10.0,<0.11.0" @@ -201,13 +201,13 @@ crt = ["botocore[crt] (>=1.21.0,<2.0a0)"] [[package]] name = "botocore" -version = "1.34.143" +version = "1.34.144" description = "Low-level, data-driven core of boto 3." optional = false python-versions = ">=3.8" files = [ - {file = "botocore-1.34.143-py3-none-any.whl", hash = "sha256:094aea179e8aaa1bc957ad49cc27d93b189dd3a1f3075d8b0ca7c445a2a88430"}, - {file = "botocore-1.34.143.tar.gz", hash = "sha256:059f032ec05733a836e04e869c5a15534420102f93116f3bc9a5b759b0651caf"}, + {file = "botocore-1.34.144-py3-none-any.whl", hash = "sha256:a2cf26e1bf10d5917a2285e50257bc44e94a1d16574f282f3274f7a5d8d1f08b"}, + {file = "botocore-1.34.144.tar.gz", hash = "sha256:4215db28d25309d59c99507f1f77df9089e5bebbad35f6e19c7c44ec5383a3e8"}, ] [package.dependencies] @@ -241,13 +241,13 @@ redis = ["redis (>=2.10.5)"] [[package]] name = "cachetools" -version = "5.3.3" +version = "5.4.0" description = "Extensible memoizing collections and decorators" optional = false python-versions = ">=3.7" files = [ - {file = "cachetools-5.3.3-py3-none-any.whl", hash = "sha256:0abad1021d3f8325b2fc1d2e9c8b9c9d57b04c3932657a72465447332c24d945"}, - {file = "cachetools-5.3.3.tar.gz", hash = "sha256:ba29e2dfa0b8b556606f097407ed1aa62080ee108ab0dc5ec9d6a723a007d105"}, + {file = "cachetools-5.4.0-py3-none-any.whl", hash = "sha256:3ae3b49a3d5e28a77a0be2b37dbcb89005058959cb2323858c2657c4a8cab474"}, + {file = "cachetools-5.4.0.tar.gz", hash = "sha256:b8adc2e7c07f105ced7bc56dbb6dfbe7c4a00acce20e2227b3f355be89bc6827"}, ] [[package]] @@ -713,13 +713,13 @@ dev = ["black", "build", "commitizen", "isort", "pip-tools", "pre-commit", "twin [[package]] name = "exceptiongroup" -version = "1.2.1" +version = "1.2.2" description = "Backport of PEP 654 (exception groups)" optional = false python-versions = ">=3.7" files = [ - {file = "exceptiongroup-1.2.1-py3-none-any.whl", hash = "sha256:5258b9ed329c5bbdd31a309f53cbfb0b155341807f6ff7606a1e801a891b29ad"}, - {file = "exceptiongroup-1.2.1.tar.gz", hash = "sha256:a4785e48b045528f5bfe627b6ad554ff32def154f42372786903b7abcfe1aa16"}, + {file = "exceptiongroup-1.2.2-py3-none-any.whl", hash = "sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b"}, + {file = "exceptiongroup-1.2.2.tar.gz", hash = "sha256:47c2edf7c6738fafb49fd34290706d1a1a2f4d1c6df275526b62cbb4aa5393cc"}, ] [package.extras] @@ -1681,7 +1681,6 @@ files = [ {file = "msgpack-1.0.8-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:5fbb160554e319f7b22ecf530a80a3ff496d38e8e07ae763b9e82fadfe96f273"}, {file = "msgpack-1.0.8-cp39-cp39-win32.whl", hash = "sha256:f9af38a89b6a5c04b7d18c492c8ccf2aee7048aff1ce8437c4683bb5a1df893d"}, {file = "msgpack-1.0.8-cp39-cp39-win_amd64.whl", hash = "sha256:ed59dd52075f8fc91da6053b12e8c89e37aa043f8986efd89e61fae69dc1b011"}, - {file = "msgpack-1.0.8-py3-none-any.whl", hash = "sha256:24f727df1e20b9876fa6e95f840a2a2651e34c0ad147676356f4bf5fbb0206ca"}, {file = "msgpack-1.0.8.tar.gz", hash = "sha256:95c02b0e27e706e48d0e5426d1710ca78e0f0628d6e89d5b5a5b91a5f12274f3"}, ] @@ -1838,13 +1837,13 @@ dev = ["black", "mypy", "pytest"] [[package]] name = "packageurl-python" -version = "0.15.3" +version = "0.15.4" description = "A purl aka. Package URL parser and builder" optional = false python-versions = ">=3.7" files = [ - {file = "packageurl_python-0.15.3-py3-none-any.whl", hash = "sha256:96624702032239e70e61b950e14460a5b5f87ac21fc68f119414047b94f0de27"}, - {file = "packageurl_python-0.15.3.tar.gz", hash = "sha256:82e1150f1fc228e25e7b3be1c641ef96b6a0811526c0b4e4f7882a181e862607"}, + {file = "packageurl_python-0.15.4-py3-none-any.whl", hash = "sha256:4c015634c97f634ff88c9e3916361e4442ef22bd9bf702090a78b427c274e397"}, + {file = "packageurl_python-0.15.4.tar.gz", hash = "sha256:9ea4215e2bcd7d2369d0b7857abba7def81f3fa217d7903fc72661c946c75e0f"}, ] [package.extras] @@ -2791,52 +2790,47 @@ crt = ["botocore[crt] (>=1.33.2,<2.0a.0)"] [[package]] name = "shapely" -version = "2.0.4" +version = "2.0.5" description = "Manipulation and analysis of geometric objects" optional = false python-versions = ">=3.7" files = [ - {file = "shapely-2.0.4-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:011b77153906030b795791f2fdfa2d68f1a8d7e40bce78b029782ade3afe4f2f"}, - {file = "shapely-2.0.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:9831816a5d34d5170aa9ed32a64982c3d6f4332e7ecfe62dc97767e163cb0b17"}, - {file = "shapely-2.0.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:5c4849916f71dc44e19ed370421518c0d86cf73b26e8656192fcfcda08218fbd"}, - {file = "shapely-2.0.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:841f93a0e31e4c64d62ea570d81c35de0f6cea224568b2430d832967536308e6"}, - {file = "shapely-2.0.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d2b4431f522b277c79c34b65da128029a9955e4481462cbf7ebec23aab61fc58"}, - {file = "shapely-2.0.4-cp310-cp310-win32.whl", hash = "sha256:92a41d936f7d6743f343be265ace93b7c57f5b231e21b9605716f5a47c2879e7"}, - {file = "shapely-2.0.4-cp310-cp310-win_amd64.whl", hash = "sha256:30982f79f21bb0ff7d7d4a4e531e3fcaa39b778584c2ce81a147f95be1cd58c9"}, - {file = "shapely-2.0.4-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:de0205cb21ad5ddaef607cda9a3191eadd1e7a62a756ea3a356369675230ac35"}, - {file = "shapely-2.0.4-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:7d56ce3e2a6a556b59a288771cf9d091470116867e578bebced8bfc4147fbfd7"}, - {file = "shapely-2.0.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:58b0ecc505bbe49a99551eea3f2e8a9b3b24b3edd2a4de1ac0dc17bc75c9ec07"}, - {file = "shapely-2.0.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:790a168a808bd00ee42786b8ba883307c0e3684ebb292e0e20009588c426da47"}, - {file = "shapely-2.0.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4310b5494271e18580d61022c0857eb85d30510d88606fa3b8314790df7f367d"}, - {file = "shapely-2.0.4-cp311-cp311-win32.whl", hash = "sha256:63f3a80daf4f867bd80f5c97fbe03314348ac1b3b70fb1c0ad255a69e3749879"}, - {file = "shapely-2.0.4-cp311-cp311-win_amd64.whl", hash = "sha256:c52ed79f683f721b69a10fb9e3d940a468203f5054927215586c5d49a072de8d"}, - {file = "shapely-2.0.4-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:5bbd974193e2cc274312da16b189b38f5f128410f3377721cadb76b1e8ca5328"}, - {file = "shapely-2.0.4-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:41388321a73ba1a84edd90d86ecc8bfed55e6a1e51882eafb019f45895ec0f65"}, - {file = "shapely-2.0.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:0776c92d584f72f1e584d2e43cfc5542c2f3dd19d53f70df0900fda643f4bae6"}, - {file = "shapely-2.0.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c75c98380b1ede1cae9a252c6dc247e6279403fae38c77060a5e6186c95073ac"}, - {file = "shapely-2.0.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c3e700abf4a37b7b8b90532fa6ed5c38a9bfc777098bc9fbae5ec8e618ac8f30"}, - {file = "shapely-2.0.4-cp312-cp312-win32.whl", hash = "sha256:4f2ab0faf8188b9f99e6a273b24b97662194160cc8ca17cf9d1fb6f18d7fb93f"}, - {file = "shapely-2.0.4-cp312-cp312-win_amd64.whl", hash = "sha256:03152442d311a5e85ac73b39680dd64a9892fa42bb08fd83b3bab4fe6999bfa0"}, - {file = "shapely-2.0.4-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:994c244e004bc3cfbea96257b883c90a86e8cbd76e069718eb4c6b222a56f78b"}, - {file = "shapely-2.0.4-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:05ffd6491e9e8958b742b0e2e7c346635033d0a5f1a0ea083547fcc854e5d5cf"}, - {file = "shapely-2.0.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2fbdc1140a7d08faa748256438291394967aa54b40009f54e8d9825e75ef6113"}, - {file = "shapely-2.0.4-cp37-cp37m-win32.whl", hash = "sha256:5af4cd0d8cf2912bd95f33586600cac9c4b7c5053a036422b97cfe4728d2eb53"}, - {file = "shapely-2.0.4-cp37-cp37m-win_amd64.whl", hash = "sha256:464157509ce4efa5ff285c646a38b49f8c5ef8d4b340f722685b09bb033c5ccf"}, - {file = "shapely-2.0.4-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:489c19152ec1f0e5c5e525356bcbf7e532f311bff630c9b6bc2db6f04da6a8b9"}, - {file = "shapely-2.0.4-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:b79bbd648664aa6f44ef018474ff958b6b296fed5c2d42db60078de3cffbc8aa"}, - {file = "shapely-2.0.4-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:674d7baf0015a6037d5758496d550fc1946f34bfc89c1bf247cabdc415d7747e"}, - {file = "shapely-2.0.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6cd4ccecc5ea5abd06deeaab52fcdba372f649728050c6143cc405ee0c166679"}, - {file = "shapely-2.0.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fb5cdcbbe3080181498931b52a91a21a781a35dcb859da741c0345c6402bf00c"}, - {file = "shapely-2.0.4-cp38-cp38-win32.whl", hash = "sha256:55a38dcd1cee2f298d8c2ebc60fc7d39f3b4535684a1e9e2f39a80ae88b0cea7"}, - {file = "shapely-2.0.4-cp38-cp38-win_amd64.whl", hash = "sha256:ec555c9d0db12d7fd777ba3f8b75044c73e576c720a851667432fabb7057da6c"}, - {file = "shapely-2.0.4-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:3f9103abd1678cb1b5f7e8e1af565a652e036844166c91ec031eeb25c5ca8af0"}, - {file = "shapely-2.0.4-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:263bcf0c24d7a57c80991e64ab57cba7a3906e31d2e21b455f493d4aab534aaa"}, - {file = "shapely-2.0.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:ddf4a9bfaac643e62702ed662afc36f6abed2a88a21270e891038f9a19bc08fc"}, - {file = "shapely-2.0.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:485246fcdb93336105c29a5cfbff8a226949db37b7473c89caa26c9bae52a242"}, - {file = "shapely-2.0.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8de4578e838a9409b5b134a18ee820730e507b2d21700c14b71a2b0757396acc"}, - {file = "shapely-2.0.4-cp39-cp39-win32.whl", hash = "sha256:9dab4c98acfb5fb85f5a20548b5c0abe9b163ad3525ee28822ffecb5c40e724c"}, - {file = "shapely-2.0.4-cp39-cp39-win_amd64.whl", hash = "sha256:31c19a668b5a1eadab82ff070b5a260478ac6ddad3a5b62295095174a8d26398"}, - {file = "shapely-2.0.4.tar.gz", hash = "sha256:5dc736127fac70009b8d309a0eeb74f3e08979e530cf7017f2f507ef62e6cfb8"}, + {file = "shapely-2.0.5-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:89d34787c44f77a7d37d55ae821f3a784fa33592b9d217a45053a93ade899375"}, + {file = "shapely-2.0.5-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:798090b426142df2c5258779c1d8d5734ec6942f778dab6c6c30cfe7f3bf64ff"}, + {file = "shapely-2.0.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:45211276900c4790d6bfc6105cbf1030742da67594ea4161a9ce6812a6721e68"}, + {file = "shapely-2.0.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2e119444bc27ca33e786772b81760f2028d930ac55dafe9bc50ef538b794a8e1"}, + {file = "shapely-2.0.5-cp310-cp310-win32.whl", hash = "sha256:9a4492a2b2ccbeaebf181e7310d2dfff4fdd505aef59d6cb0f217607cb042fb3"}, + {file = "shapely-2.0.5-cp310-cp310-win_amd64.whl", hash = "sha256:1e5cb5ee72f1bc7ace737c9ecd30dc174a5295fae412972d3879bac2e82c8fae"}, + {file = "shapely-2.0.5-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:5bbfb048a74cf273db9091ff3155d373020852805a37dfc846ab71dde4be93ec"}, + {file = "shapely-2.0.5-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:93be600cbe2fbaa86c8eb70656369f2f7104cd231f0d6585c7d0aa555d6878b8"}, + {file = "shapely-2.0.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0f8e71bb9a46814019f6644c4e2560a09d44b80100e46e371578f35eaaa9da1c"}, + {file = "shapely-2.0.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d5251c28a29012e92de01d2e84f11637eb1d48184ee8f22e2df6c8c578d26760"}, + {file = "shapely-2.0.5-cp311-cp311-win32.whl", hash = "sha256:35110e80070d664781ec7955c7de557456b25727a0257b354830abb759bf8311"}, + {file = "shapely-2.0.5-cp311-cp311-win_amd64.whl", hash = "sha256:6c6b78c0007a34ce7144f98b7418800e0a6a5d9a762f2244b00ea560525290c9"}, + {file = "shapely-2.0.5-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:03bd7b5fa5deb44795cc0a503999d10ae9d8a22df54ae8d4a4cd2e8a93466195"}, + {file = "shapely-2.0.5-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:2ff9521991ed9e201c2e923da014e766c1aa04771bc93e6fe97c27dcf0d40ace"}, + {file = "shapely-2.0.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1b65365cfbf657604e50d15161ffcc68de5cdb22a601bbf7823540ab4918a98d"}, + {file = "shapely-2.0.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:21f64e647a025b61b19585d2247137b3a38a35314ea68c66aaf507a1c03ef6fe"}, + {file = "shapely-2.0.5-cp312-cp312-win32.whl", hash = "sha256:3ac7dc1350700c139c956b03d9c3df49a5b34aaf91d024d1510a09717ea39199"}, + {file = "shapely-2.0.5-cp312-cp312-win_amd64.whl", hash = "sha256:30e8737983c9d954cd17feb49eb169f02f1da49e24e5171122cf2c2b62d65c95"}, + {file = "shapely-2.0.5-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:ff7731fea5face9ec08a861ed351734a79475631b7540ceb0b66fb9732a5f529"}, + {file = "shapely-2.0.5-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ff9e520af0c5a578e174bca3c18713cd47a6c6a15b6cf1f50ac17dc8bb8db6a2"}, + {file = "shapely-2.0.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:49b299b91557b04acb75e9732645428470825061f871a2edc36b9417d66c1fc5"}, + {file = "shapely-2.0.5-cp37-cp37m-win32.whl", hash = "sha256:b5870633f8e684bf6d1ae4df527ddcb6f3895f7b12bced5c13266ac04f47d231"}, + {file = "shapely-2.0.5-cp37-cp37m-win_amd64.whl", hash = "sha256:401cb794c5067598f50518e5a997e270cd7642c4992645479b915c503866abed"}, + {file = "shapely-2.0.5-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:e91ee179af539100eb520281ba5394919067c6b51824e6ab132ad4b3b3e76dd0"}, + {file = "shapely-2.0.5-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:8af6f7260f809c0862741ad08b1b89cb60c130ae30efab62320bbf4ee9cc71fa"}, + {file = "shapely-2.0.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f5456dd522800306ba3faef77c5ba847ec30a0bd73ab087a25e0acdd4db2514f"}, + {file = "shapely-2.0.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b714a840402cde66fd7b663bb08cacb7211fa4412ea2a209688f671e0d0631fd"}, + {file = "shapely-2.0.5-cp38-cp38-win32.whl", hash = "sha256:7e8cf5c252fac1ea51b3162be2ec3faddedc82c256a1160fc0e8ddbec81b06d2"}, + {file = "shapely-2.0.5-cp38-cp38-win_amd64.whl", hash = "sha256:4461509afdb15051e73ab178fae79974387f39c47ab635a7330d7fee02c68a3f"}, + {file = "shapely-2.0.5-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:7545a39c55cad1562be302d74c74586f79e07b592df8ada56b79a209731c0219"}, + {file = "shapely-2.0.5-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:4c83a36f12ec8dee2066946d98d4d841ab6512a6ed7eb742e026a64854019b5f"}, + {file = "shapely-2.0.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:89e640c2cd37378480caf2eeda9a51be64201f01f786d127e78eaeff091ec897"}, + {file = "shapely-2.0.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:06efe39beafde3a18a21dde169d32f315c57da962826a6d7d22630025200c5e6"}, + {file = "shapely-2.0.5-cp39-cp39-win32.whl", hash = "sha256:8203a8b2d44dcb366becbc8c3d553670320e4acf0616c39e218c9561dd738d92"}, + {file = "shapely-2.0.5-cp39-cp39-win_amd64.whl", hash = "sha256:7fed9dbfbcfec2682d9a047b9699db8dcc890dfca857ecba872c42185fc9e64e"}, + {file = "shapely-2.0.5.tar.gz", hash = "sha256:bff2366bc786bfa6cb353d6b47d0443c570c32776612e527ee47b6df63fcfe32"}, ] [package.dependencies] @@ -3112,4 +3106,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.12.2" -content-hash = "78cfb6ff10239c4ad8e34c059e01c9ee7603d591c43cb06dd0a1acf8fa51f510" +content-hash = "5e401543af85348b3df85fb128689c492ed4eedd18d705eca209738e7e82d2b9" diff --git a/pyproject.toml b/pyproject.toml index 06e8ffe35..596f06ac7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ python = "^3.12.2" ago = "~=0.0.95" beautifulsoup4 = "^4.12.3" blinker = "~=1.8" -exceptiongroup = "==1.2.1" +exceptiongroup = "==1.2.2" flask = "~=3.0" flask-basicauth = "~=0.2" flask-login = "^0.6" @@ -39,9 +39,9 @@ wtforms = "~=3.1" markdown = "^3.5.2" async-timeout = "^4.0.3" bleach = "^6.1.0" -boto3 = "^1.34.143" -botocore = "^1.34.143" -cachetools = "^5.3.3" +boto3 = "^1.34.144" +botocore = "^1.34.144" +cachetools = "^5.4.0" cffi = "^1.16.0" cryptography = "^42.0.8" flask-redis = "^0.4.0" @@ -56,7 +56,7 @@ python-json-logger = "^2.0.7" redis = "^5.0.7" regex = "^2024.5.15" s3transfer = "^0.10.2" -shapely = "^2.0.4" +shapely = "^2.0.5" smartypants = "^2.0.1" certifi = "^2024.7.4" charset-normalizer = "^3.3.2" From 3922593e55c56012a681fe4f7ea7c1c73ec955b2 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 16 Jul 2024 10:10:23 -0700 Subject: [PATCH 03/15] another tweak for session management --- app/notify_client/__init__.py | 4 ++++ poetry.lock | 1 + 2 files changed, 5 insertions(+) diff --git a/app/notify_client/__init__.py b/app/notify_client/__init__.py index 3bbb35733..cedecb3ae 100644 --- a/app/notify_client/__init__.py +++ b/app/notify_client/__init__.py @@ -67,6 +67,10 @@ class NotifyAdminAPIClient(BaseAPIClient): or "/email-code" in arg ): still_signing_in = True + + # This seems to be a weird edge case that happens intermittently with invites + if str(arg) == "()": + still_signing_in = True # TODO: Update this once E2E tests are managed by a feature flag or some other main config option. if os.getenv("NOTIFY_E2E_TEST_EMAIL"): # allow end-to-end tests to skip check diff --git a/poetry.lock b/poetry.lock index b96f87d44..879c2a436 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1681,6 +1681,7 @@ files = [ {file = "msgpack-1.0.8-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:5fbb160554e319f7b22ecf530a80a3ff496d38e8e07ae763b9e82fadfe96f273"}, {file = "msgpack-1.0.8-cp39-cp39-win32.whl", hash = "sha256:f9af38a89b6a5c04b7d18c492c8ccf2aee7048aff1ce8437c4683bb5a1df893d"}, {file = "msgpack-1.0.8-cp39-cp39-win_amd64.whl", hash = "sha256:ed59dd52075f8fc91da6053b12e8c89e37aa043f8986efd89e61fae69dc1b011"}, + {file = "msgpack-1.0.8-py3-none-any.whl", hash = "sha256:24f727df1e20b9876fa6e95f840a2a2651e34c0ad147676356f4bf5fbb0206ca"}, {file = "msgpack-1.0.8.tar.gz", hash = "sha256:95c02b0e27e706e48d0e5426d1710ca78e0f0628d6e89d5b5a5b91a5f12274f3"}, ] From f6975724a813f617649f1ef6cee3645f86749d23 Mon Sep 17 00:00:00 2001 From: John Skiles Skinner Date: Tue, 16 Jul 2024 13:55:29 -0700 Subject: [PATCH 04/15] Specify working version, sadly the oldest version --- terraform/bootstrap/main.tf | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/terraform/bootstrap/main.tf b/terraform/bootstrap/main.tf index 241cd1ed6..562410e27 100644 --- a/terraform/bootstrap/main.tf +++ b/terraform/bootstrap/main.tf @@ -4,7 +4,7 @@ locals { } module "s3" { - source = "github.com/18f/terraform-cloudgov//s3" + source = "github.com/18f/terraform-cloudgov//s3?ref=v0.1.0" cf_api_url = local.cf_api_url cf_user = var.cf_user @@ -18,7 +18,3 @@ resource "cloudfoundry_service_key" "bucket_creds" { name = "${local.s3_service_name}-access" service_instance = module.s3.bucket_id } - -output "bucket_credentials" { - value = cloudfoundry_service_key.bucket_creds.credentials -} From b34d3c8aa22d0e8962659885c3000d67e3aa606b Mon Sep 17 00:00:00 2001 From: John Skiles Skinner Date: Tue, 16 Jul 2024 14:23:21 -0700 Subject: [PATCH 05/15] Expunge boilerplate instructions, link to updated ones in API repo --- terraform/README.md | 131 +------------------------------------------- 1 file changed, 1 insertion(+), 130 deletions(-) diff --git a/terraform/README.md b/terraform/README.md index 7390e3947..74f181514 100644 --- a/terraform/README.md +++ b/terraform/README.md @@ -1,132 +1,3 @@ # Terraform -This directory holds the terraform modules for maintaining your complete persistent infrastructure. - -Prerequisite: install the `jq` JSON processor: `brew install jq` - -## Initial setup - -1. Manually run the bootstrap module following instructions under `Terraform State Credentials` -1. Setup CI/CD Pipeline to run Terraform - 1. Copy bootstrap credentials to your CI/CD secrets using the instructions in the base README - 1. Create a cloud.gov SpaceDeployer by following the instructions under `SpaceDeployers` - 1. Copy SpaceDeployer credentials to your CI/CD secrets using the instructions in the base README -1. Manually Running Terraform - 1. Follow instructions under `Set up a new environment` to create your infrastructure - -## Terraform State Credentials - -The bootstrap module is used to create an s3 bucket for later terraform runs to store their state in. - -### Bootstrapping the state storage s3 buckets for the first time - -1. `cd bootstrap` -1. Run `terraform init` -1. Run `./run.sh plan` to verify that the changes are what you expect -1. Run `./run.sh apply` to set up the bucket and retrieve credentials -1. Follow instructions under `Use bootstrap credentials` -1. Ensure that `import.sh` includes a line and correct IDs for any resources created -1. Run `./teardown_creds.sh` to remove the space deployer account used to create the s3 bucket - -Notes: -- The `run.sh` commands will move your `cf target` to the `notify-management` space, so make sure to re-target afterwards. -- If you have trouble with `./run.sh plan`, try getting on the GSA VPN. It may be necessary to connect to the cloud.gov API. - -### To make changes to the bootstrap module - -*This should not be necessary in most cases* - -1. Run `terraform init` -1. If you don't have terraform state locally: - 1. run `./import.sh` - 1. optionally run `./run.sh apply` to include the existing outputs in the state file -1. Make your changes -1. Continue from step 2 of the boostrapping instructions - -### Use bootstrap credentials - -1. Run `./run.sh show` if you need to retrieve the credentials -1. Add the following to `~/.aws/credentials` - ``` - [notify-terraform-backend] - aws_access_key_id = - aws_secret_access_key = - ``` -1. Copy `bucket` from `bucket_credentials` output to the backend block of `staging/providers.tf` and `production/providers.tf` - -## SpaceDeployers - -A [SpaceDeployer](https://cloud.gov/docs/services/cloud-gov-service-account/) account is required to run terraform or -deploy the application from the CI/CD pipeline. Create a new account by running: - -`./create_service_account.sh -s -u ` - -## Set up a new environment manually - -The below steps rely on you first configuring access to the Terraform state in s3 as described in [Terraform State Credentials](#terraform-state-credentials). - -1. `cd` to the environment you are working in - -1. Set up a SpaceDeployer - ```bash - # create a space deployer service instance that can log in with just a username and password - # the value of < SPACE_NAME > should be `staging` or `prod` depending on where you are working - # the value for < ACCOUNT_NAME > can be anything, although we recommend - # something that communicates the purpose of the deployer - # for example: circleci-deployer for the credentials CircleCI uses to - # deploy the application or -terraform for credentials to run terraform manually - ./create_service_account.sh -s -u > secrets.auto.tfvars - ``` - - The script will output the `username` (as `cf_user`) and `password` (as `cf_password`) for your ``. Read more in the [cloud.gov service account documentation](https://cloud.gov/docs/services/cloud-gov-service-account/). - - The easiest way to use this script is to redirect the output directly to the `secrets.auto.tfvars` file it needs to be used in - -1. Run terraform from your new environment directory with - ```bash - terraform init - terraform plan - ``` - - If the `terraform init` command fails, you may need to run `terraform init -upgrade` to make sure new module versions are picked up. - -1. Apply changes with `terraform apply`. - -1. Remove the space deployer service instance if it doesn't need to be used again, such as when manually running terraform once. - ```bash - # and have the same values as used above. - ./destroy_service_account.sh -s -u - ``` - -## Structure - -Each environment has its own module, which relies on a shared module for everything except the providers code and environment specific variables and settings. - -``` -- bootstrap/ - |- main.tf - |- providers.tf - |- variables.tf - |- run.sh - |- teardown_creds.sh - |- import.sh -- / - |- main.tf - |- providers.tf - |- secrets.auto.tfvars - |- variables.tf -``` - -In the environment-specific modules: -- `providers.tf` lists the required providers -- `main.tf` calls the shared Terraform code, but this is also a place where you can add any other services, resources, etc, which you would like to set up for that environment -- `variables.tf` lists the variables that will be needed, either to pass through to the child module or for use in this module -- `secrets.auto.tfvars` is a file which contains the information about the service-key and other secrets that should not be shared - -In the bootstrap module: -- `providers.tf` lists the required providers -- `main.tf` sets up s3 bucket to be shared across all environments. It lives in `prod` to communicate that it should not be deleted -- `variables.tf` lists the variables that will be needed. Most values are hard-coded in this module -- `run.sh` Helper script to set up a space deployer and run terraform. The terraform action (`show`/`plan`/`apply`/`destroy`) is passed as an argument -- `teardown_creds.sh` Helper script to remove the space deployer setup as part of `run.sh` -- `import.sh` Helper script to create a new local state file in case terraform changes are needed +The instructions for how to use the Terraform in this repo are the same [as those in the API repo](https://github.com/GSA/notifications-api/tree/main/terraform#terraform). From cb46bb1e240a890649517c4d25f2c4ee0817aaac Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Wed, 17 Jul 2024 12:59:13 -0700 Subject: [PATCH 06/15] add debug for compliance #46 --- app/notify_client/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/notify_client/__init__.py b/app/notify_client/__init__.py index cedecb3ae..30cfe218e 100644 --- a/app/notify_client/__init__.py +++ b/app/notify_client/__init__.py @@ -1,6 +1,6 @@ import os -from flask import abort, has_request_context, request +from flask import abort, current_app, has_request_context, request from flask_login import current_user from notifications_python_client import __version__ from notifications_python_client.base import BaseAPIClient @@ -79,6 +79,7 @@ class NotifyAdminAPIClient(BaseAPIClient): # we are not full signed in yet pass elif not current_user or not current_user.is_active: + current_app.logger.error(f"Unauthorized URL #notify-compliance-46 {args}") abort(403) def post(self, *args, **kwargs): From 39ee6b677fa3c91309b3c866ddb28a0288e003e5 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Wed, 17 Jul 2024 13:35:51 -0700 Subject: [PATCH 07/15] fix /verify/code --- app/notify_client/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/notify_client/__init__.py b/app/notify_client/__init__.py index 30cfe218e..f78573090 100644 --- a/app/notify_client/__init__.py +++ b/app/notify_client/__init__.py @@ -65,6 +65,7 @@ class NotifyAdminAPIClient(BaseAPIClient): or "user/email" in arg or "/activate" in arg or "/email-code" in arg + or "/verify/code" in arg ): still_signing_in = True From 5800f9289e352850bc7a64057baf7241ec50d6dd Mon Sep 17 00:00:00 2001 From: John Skiles Skinner Date: Wed, 17 Jul 2024 14:54:37 -0700 Subject: [PATCH 08/15] Delete outdated Redis instance from Sandbox Terraform config --- terraform/sandbox/main.tf | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/terraform/sandbox/main.tf b/terraform/sandbox/main.tf index b831b44d6..54c97bdde 100644 --- a/terraform/sandbox/main.tf +++ b/terraform/sandbox/main.tf @@ -6,16 +6,6 @@ locals { recursive_delete = true } -module "redis" { # default v6.2; delete after v7.0 resource is bound - source = "github.com/18f/terraform-cloudgov//redis?ref=v0.7.1" - - cf_org_name = local.cf_org_name - cf_space_name = local.cf_space_name - name = "${local.app_name}-redis-${local.env}" - recursive_delete = local.recursive_delete - redis_plan_name = "redis-dev" -} - module "redis-v70" { source = "github.com/GSA-TTS/terraform-cloudgov//redis?ref=v1.0.0" From 58dc83d9fd5a8369220b0cc8ab2e4732ef5d5584 Mon Sep 17 00:00:00 2001 From: John Skiles Skinner Date: Wed, 17 Jul 2024 16:35:58 -0700 Subject: [PATCH 09/15] Upgrade terraform-cloudgov version and args in Bootstrap module --- terraform/bootstrap/main.tf | 12 ++++-------- terraform/bootstrap/providers.tf | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/terraform/bootstrap/main.tf b/terraform/bootstrap/main.tf index 562410e27..3693cb0f4 100644 --- a/terraform/bootstrap/main.tf +++ b/terraform/bootstrap/main.tf @@ -1,17 +1,13 @@ locals { - cf_api_url = "https://api.fr.cloud.gov" s3_service_name = "notify-terraform-state" } module "s3" { - source = "github.com/18f/terraform-cloudgov//s3?ref=v0.1.0" + source = "github.com/GSA-TTS/terraform-cloudgov//s3?ref=v1.0.0" - cf_api_url = local.cf_api_url - cf_user = var.cf_user - cf_password = var.cf_password - cf_org_name = "gsa-tts-benefits-studio" - cf_space_name = "notify-management" - s3_service_name = local.s3_service_name + cf_org_name = "gsa-tts-benefits-studio" + cf_space_name = "notify-management" + name = local.s3_service_name } resource "cloudfoundry_service_key" "bucket_creds" { diff --git a/terraform/bootstrap/providers.tf b/terraform/bootstrap/providers.tf index cce97ee8f..7b9ce5c7f 100644 --- a/terraform/bootstrap/providers.tf +++ b/terraform/bootstrap/providers.tf @@ -9,7 +9,7 @@ terraform { } provider "cloudfoundry" { - api_url = local.cf_api_url + api_url = "https://api.fr.cloud.gov" user = var.cf_user password = var.cf_password app_logs_max = 30 From c41cb94a5d4218a8a07ee49f7af10702a73cc74a Mon Sep 17 00:00:00 2001 From: John Skiles Skinner Date: Wed, 17 Jul 2024 16:47:30 -0700 Subject: [PATCH 10/15] Add prevent_destroy to env modules --- terraform/demo/main.tf | 7 +++++++ terraform/production/main.tf | 7 +++++++ terraform/sandbox/main.tf | 7 +++++++ terraform/staging/main.tf | 1 - 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/terraform/demo/main.tf b/terraform/demo/main.tf index 5a38faf17..0b5143d8e 100644 --- a/terraform/demo/main.tf +++ b/terraform/demo/main.tf @@ -6,6 +6,13 @@ locals { recursive_delete = false } +resource "null_resource" "prevent_destroy" { + + lifecycle { + prevent_destroy = true # never destroy demo + } +} + module "redis-v70" { source = "github.com/GSA-TTS/terraform-cloudgov//redis?ref=v1.0.0" diff --git a/terraform/production/main.tf b/terraform/production/main.tf index 433770a55..cb02b9caa 100644 --- a/terraform/production/main.tf +++ b/terraform/production/main.tf @@ -6,6 +6,13 @@ locals { recursive_delete = false } +resource "null_resource" "prevent_destroy" { + + lifecycle { + prevent_destroy = true # never destroy production + } +} + module "redis-v70" { source = "github.com/GSA-TTS/terraform-cloudgov//redis?ref=v1.0.0" diff --git a/terraform/sandbox/main.tf b/terraform/sandbox/main.tf index 54c97bdde..87c95f79f 100644 --- a/terraform/sandbox/main.tf +++ b/terraform/sandbox/main.tf @@ -6,6 +6,13 @@ locals { recursive_delete = true } +resource "null_resource" "prevent_destroy" { + + lifecycle { + prevent_destroy = false # destroying sandbox is allowed + } +} + module "redis-v70" { source = "github.com/GSA-TTS/terraform-cloudgov//redis?ref=v1.0.0" diff --git a/terraform/staging/main.tf b/terraform/staging/main.tf index 338d440e4..1798feda9 100644 --- a/terraform/staging/main.tf +++ b/terraform/staging/main.tf @@ -13,7 +13,6 @@ resource "null_resource" "prevent_destroy" { } } - module "redis-v70" { source = "github.com/GSA-TTS/terraform-cloudgov//redis?ref=v1.0.0" From 24bbf5fa9c010666b9236dbc302cc0cfa8659d41 Mon Sep 17 00:00:00 2001 From: John Skiles Skinner Date: Wed, 17 Jul 2024 16:52:51 -0700 Subject: [PATCH 11/15] Upgrade terraform-cloudgov in 4 env modules, remove recursive_delete --- terraform/demo/main.tf | 4 +--- terraform/production/main.tf | 4 +--- terraform/sandbox/main.tf | 4 +--- terraform/staging/main.tf | 4 +--- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/terraform/demo/main.tf b/terraform/demo/main.tf index 0b5143d8e..f32e2d897 100644 --- a/terraform/demo/main.tf +++ b/terraform/demo/main.tf @@ -3,7 +3,6 @@ locals { cf_space_name = "notify-demo" env = "demo" app_name = "notify-admin" - recursive_delete = false } resource "null_resource" "prevent_destroy" { @@ -28,11 +27,10 @@ module "redis-v70" { } module "logo_upload_bucket" { - source = "github.com/18f/terraform-cloudgov//s3?ref=v0.7.1" + source = "github.com/GSA-TTS/terraform-cloudgov//s3?ref=v1.0.0" cf_org_name = local.cf_org_name cf_space_name = local.cf_space_name - recursive_delete = local.recursive_delete name = "${local.app_name}-logo-upload-bucket-${local.env}" } diff --git a/terraform/production/main.tf b/terraform/production/main.tf index cb02b9caa..19d5c8fbd 100644 --- a/terraform/production/main.tf +++ b/terraform/production/main.tf @@ -3,7 +3,6 @@ locals { cf_space_name = "notify-production" env = "production" app_name = "notify-admin" - recursive_delete = false } resource "null_resource" "prevent_destroy" { @@ -28,11 +27,10 @@ module "redis-v70" { } module "logo_upload_bucket" { - source = "github.com/18f/terraform-cloudgov//s3?ref=v0.7.1" + source = "github.com/GSA-TTS/terraform-cloudgov//s3?ref=v1.0.0" cf_org_name = local.cf_org_name cf_space_name = local.cf_space_name - recursive_delete = local.recursive_delete name = "${local.app_name}-logo-upload-bucket-${local.env}" } diff --git a/terraform/sandbox/main.tf b/terraform/sandbox/main.tf index 87c95f79f..074a978d1 100644 --- a/terraform/sandbox/main.tf +++ b/terraform/sandbox/main.tf @@ -3,7 +3,6 @@ locals { cf_space_name = "notify-sandbox" env = "sandbox" app_name = "notify-admin" - recursive_delete = true } resource "null_resource" "prevent_destroy" { @@ -28,11 +27,10 @@ module "redis-v70" { } module "logo_upload_bucket" { - source = "github.com/18f/terraform-cloudgov//s3?ref=v0.7.1" + source = "github.com/GSA-TTS/terraform-cloudgov//s3?ref=v1.0.0" cf_org_name = local.cf_org_name cf_space_name = local.cf_space_name - recursive_delete = local.recursive_delete name = "${local.app_name}-logo-upload-bucket-${local.env}" } diff --git a/terraform/staging/main.tf b/terraform/staging/main.tf index 1798feda9..63c4d8ad1 100644 --- a/terraform/staging/main.tf +++ b/terraform/staging/main.tf @@ -3,7 +3,6 @@ locals { cf_space_name = "notify-staging" env = "staging" app_name = "notify-admin" - recursive_delete = true } resource "null_resource" "prevent_destroy" { @@ -28,11 +27,10 @@ module "redis-v70" { } module "logo_upload_bucket" { - source = "github.com/18f/terraform-cloudgov//s3?ref=v0.7.1" + source = "github.com/GSA-TTS/terraform-cloudgov//s3?ref=v1.0.0" cf_org_name = local.cf_org_name cf_space_name = local.cf_space_name - recursive_delete = local.recursive_delete name = "${local.app_name}-logo-upload-bucket-${local.env}" } From 43818a6df483ea94c9517ce9d45ba5872748137e Mon Sep 17 00:00:00 2001 From: John Skiles Skinner Date: Wed, 17 Jul 2024 17:00:21 -0700 Subject: [PATCH 12/15] Add a note about an upgrade I don't feel good about making just now --- terraform/production/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/production/main.tf b/terraform/production/main.tf index 19d5c8fbd..710b32b15 100644 --- a/terraform/production/main.tf +++ b/terraform/production/main.tf @@ -59,7 +59,7 @@ module "api_network_route" { # https://cloud.gov/docs/services/external-domain-service/#how-to-create-an-instance-of-this-service ########################################################################### module "domain" { - source = "github.com/18f/terraform-cloudgov//domain?ref=v0.7.1" + source = "github.com/18f/terraform-cloudgov//domain?ref=v0.7.1" # TODO: upgrade this cf_org_name = local.cf_org_name cf_space_name = local.cf_space_name From aef7ff487ed56bffa9eb7d25b312e3413fc2503b Mon Sep 17 00:00:00 2001 From: John Skiles Skinner Date: Wed, 17 Jul 2024 17:02:56 -0700 Subject: [PATCH 13/15] Add prevent_destory in Bootstrap module --- terraform/bootstrap/main.tf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/terraform/bootstrap/main.tf b/terraform/bootstrap/main.tf index 3693cb0f4..a518530f1 100644 --- a/terraform/bootstrap/main.tf +++ b/terraform/bootstrap/main.tf @@ -13,4 +13,8 @@ module "s3" { resource "cloudfoundry_service_key" "bucket_creds" { name = "${local.s3_service_name}-access" service_instance = module.s3.bucket_id + + lifecycle { + prevent_destroy = true + } } From b8a62852a6f7d46003558ba48b505a5ca49c1549 Mon Sep 17 00:00:00 2001 From: John Skiles Skinner Date: Wed, 17 Jul 2024 17:35:17 -0700 Subject: [PATCH 14/15] Terraform fmt --- terraform/demo/main.tf | 14 +++++++------- terraform/production/main.tf | 14 +++++++------- terraform/sandbox/main.tf | 14 +++++++------- terraform/staging/main.tf | 14 +++++++------- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/terraform/demo/main.tf b/terraform/demo/main.tf index f32e2d897..4223e29e4 100644 --- a/terraform/demo/main.tf +++ b/terraform/demo/main.tf @@ -1,8 +1,8 @@ locals { - cf_org_name = "gsa-tts-benefits-studio" - cf_space_name = "notify-demo" - env = "demo" - app_name = "notify-admin" + cf_org_name = "gsa-tts-benefits-studio" + cf_space_name = "notify-demo" + env = "demo" + app_name = "notify-admin" } resource "null_resource" "prevent_destroy" { @@ -29,9 +29,9 @@ module "redis-v70" { module "logo_upload_bucket" { source = "github.com/GSA-TTS/terraform-cloudgov//s3?ref=v1.0.0" - cf_org_name = local.cf_org_name - cf_space_name = local.cf_space_name - name = "${local.app_name}-logo-upload-bucket-${local.env}" + cf_org_name = local.cf_org_name + cf_space_name = local.cf_space_name + name = "${local.app_name}-logo-upload-bucket-${local.env}" } # ########################################################################## diff --git a/terraform/production/main.tf b/terraform/production/main.tf index 710b32b15..771558ce2 100644 --- a/terraform/production/main.tf +++ b/terraform/production/main.tf @@ -1,8 +1,8 @@ locals { - cf_org_name = "gsa-tts-benefits-studio" - cf_space_name = "notify-production" - env = "production" - app_name = "notify-admin" + cf_org_name = "gsa-tts-benefits-studio" + cf_space_name = "notify-production" + env = "production" + app_name = "notify-admin" } resource "null_resource" "prevent_destroy" { @@ -29,9 +29,9 @@ module "redis-v70" { module "logo_upload_bucket" { source = "github.com/GSA-TTS/terraform-cloudgov//s3?ref=v1.0.0" - cf_org_name = local.cf_org_name - cf_space_name = local.cf_space_name - name = "${local.app_name}-logo-upload-bucket-${local.env}" + cf_org_name = local.cf_org_name + cf_space_name = local.cf_space_name + name = "${local.app_name}-logo-upload-bucket-${local.env}" } # ########################################################################## diff --git a/terraform/sandbox/main.tf b/terraform/sandbox/main.tf index 074a978d1..ad0748199 100644 --- a/terraform/sandbox/main.tf +++ b/terraform/sandbox/main.tf @@ -1,8 +1,8 @@ locals { - cf_org_name = "gsa-tts-benefits-studio" - cf_space_name = "notify-sandbox" - env = "sandbox" - app_name = "notify-admin" + cf_org_name = "gsa-tts-benefits-studio" + cf_space_name = "notify-sandbox" + env = "sandbox" + app_name = "notify-admin" } resource "null_resource" "prevent_destroy" { @@ -29,9 +29,9 @@ module "redis-v70" { module "logo_upload_bucket" { source = "github.com/GSA-TTS/terraform-cloudgov//s3?ref=v1.0.0" - cf_org_name = local.cf_org_name - cf_space_name = local.cf_space_name - name = "${local.app_name}-logo-upload-bucket-${local.env}" + cf_org_name = local.cf_org_name + cf_space_name = local.cf_space_name + name = "${local.app_name}-logo-upload-bucket-${local.env}" } # ########################################################################## diff --git a/terraform/staging/main.tf b/terraform/staging/main.tf index 63c4d8ad1..99ef28590 100644 --- a/terraform/staging/main.tf +++ b/terraform/staging/main.tf @@ -1,8 +1,8 @@ locals { - cf_org_name = "gsa-tts-benefits-studio" - cf_space_name = "notify-staging" - env = "staging" - app_name = "notify-admin" + cf_org_name = "gsa-tts-benefits-studio" + cf_space_name = "notify-staging" + env = "staging" + app_name = "notify-admin" } resource "null_resource" "prevent_destroy" { @@ -29,9 +29,9 @@ module "redis-v70" { module "logo_upload_bucket" { source = "github.com/GSA-TTS/terraform-cloudgov//s3?ref=v1.0.0" - cf_org_name = local.cf_org_name - cf_space_name = local.cf_space_name - name = "${local.app_name}-logo-upload-bucket-${local.env}" + cf_org_name = local.cf_org_name + cf_space_name = local.cf_space_name + name = "${local.app_name}-logo-upload-bucket-${local.env}" } # ########################################################################## From 3567a0651a704a8d405a2bda2cabc664d4c1d2f1 Mon Sep 17 00:00:00 2001 From: John Skiles Skinner Date: Thu, 18 Jul 2024 15:56:27 -0700 Subject: [PATCH 15/15] Upgrade terraform-cloudgov, remove recursive_delete in dev module --- terraform/development/main.tf | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/terraform/development/main.tf b/terraform/development/main.tf index 767256c3f..939b5a3fb 100644 --- a/terraform/development/main.tf +++ b/terraform/development/main.tf @@ -11,12 +11,11 @@ data "cloudfoundry_space" "dev" { } module "logo_upload_bucket" { - source = "github.com/18f/terraform-cloudgov//s3?ref=v0.7.1" + source = "github.com/GSA-TTS/terraform-cloudgov//s3?ref=v1.0.0" - cf_org_name = local.cf_org_name - cf_space_name = local.cf_space_name - recursive_delete = local.recursive_delete - name = "${var.username}-logo-upload-bucket" + cf_org_name = local.cf_org_name + cf_space_name = local.cf_space_name + name = "${var.username}-logo-upload-bucket" } resource "cloudfoundry_service_key" "logo_key" { name = local.key_name