From a421903c77310456ec87e694e3b71947b340f035 Mon Sep 17 00:00:00 2001 From: Cameron Lamb Date: Thu, 28 Sep 2023 17:34:03 +0100 Subject: [PATCH] Update PII settings --- .../workflows/dependabot-requirements.yaml | 2 +- pii-secret-exclude.txt | 34 +++++++++---------- pyproject.toml | 2 +- scripts/truncate_anonymise.py.cli | 2 +- src/e2e_tests/conftest.py | 6 ++-- src/feedback/test/test_utils.py | 16 +++++---- src/peoplefinder/backports.py | 2 +- .../legacy_migration/migrate_legacy.py | 4 +-- ..._alter_person_fluent_languages_and_more.py | 2 +- src/peoplefinder/models.py | 2 +- src/peoplefinder/services/person.py | 2 +- .../test/services/test_profile.py | 4 +-- .../test/views/test_delete_profile_views.py | 6 ++-- .../test/views/test_profile_views.py | 6 ++-- src/peoplefinder/test/views/test_search.py | 2 +- src/peoplefinder/test/views/test_team.py | 8 ++--- 16 files changed, 52 insertions(+), 48 deletions(-) diff --git a/.github/workflows/dependabot-requirements.yaml b/.github/workflows/dependabot-requirements.yaml index 934340f74..9e629d5b9 100644 --- a/.github/workflows/dependabot-requirements.yaml +++ b/.github/workflows/dependabot-requirements.yaml @@ -29,7 +29,7 @@ jobs: continue-on-error: true run: | git config user.name 'GitHub Actions' - git config user.email github-actions@github.com + git config user.email github-actions@github.com # /PS-IGNORE git add . git commit -m "Automated update of requirements.txt" git push diff --git a/pii-secret-exclude.txt b/pii-secret-exclude.txt index 43f1e5cfd..94267ec47 100644 --- a/pii-secret-exclude.txt +++ b/pii-secret-exclude.txt @@ -1,25 +1,25 @@ .env.ci .env.example .pre-commit-config.yaml -Procfile -README.md -config/stop-words.txt -config/synonyms.txt -core/templates/404.html -core/test/test_views.py +docs/features/search.excalidraw import_wordpress/test/wordpress_test.xml +Makefile package-lock.json -peoplefinder/test/conftest.py -peoplefinder/test/services/test_audit_log.py +poetry.lock +Procfile +README.md requirements.txt -requirements/base.txt -requirements/dev.txt -requirements/prod.txt runtime.txt setup/init.sql -user/management/commands/create_test_users.py -user/migrations/0001_initial.py -user/migrations/0002_auto_20210216_0650.py -user/migrations/0004_historicaluser.py -user/test/factories.py -user/test/test_user.py +src/config/stop-words.txt +src/config/synonyms.txt +src/core/templates/404.html +src/core/test/test_views.py +src/peoplefinder/test/conftest.py +src/peoplefinder/test/services/test_audit_log.py +src/user/management/commands/create_test_users.py +src/user/migrations/0001_initial.py +src/user/migrations/0002_auto_20210216_0650.py +src/user/migrations/0004_historicaluser.py +src/user/test/factories.py +src/user/test/test_user.py diff --git a/pyproject.toml b/pyproject.toml index cd97702cd..ecb61ca30 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ name = "digital-workspace-v2" version = "1.0.0" description = "" -authors = ["Live Services "] +authors = ["Live Services "] # /PS-IGNORE license = "MIT" readme = "README.md" diff --git a/scripts/truncate_anonymise.py.cli b/scripts/truncate_anonymise.py.cli index 9fb9f6b0d..523f669a1 100644 --- a/scripts/truncate_anonymise.py.cli +++ b/scripts/truncate_anonymise.py.cli @@ -64,7 +64,7 @@ for person in Person.objects.all().reverse(): f"{person.first_name.lower()}.{person.last_name.lower()}@{email_parts[1]}" ) person.user.username = ( - f"{person.first_name.lower()}.{person.last_name.lower()}-123456@id.trade.gov.uk" + f"{person.first_name.lower()}.{person.last_name.lower()}-123456@id.trade.gov.uk" # /PS-IGNORE ) person.user.email = person.email if person.user.sso_contact_email is not None: diff --git a/src/e2e_tests/conftest.py b/src/e2e_tests/conftest.py index bce23972a..e1f0f3748 100644 --- a/src/e2e_tests/conftest.py +++ b/src/e2e_tests/conftest.py @@ -118,7 +118,7 @@ def recreate_db_between_tests(django_db_blocker): @pytest.fixture def superuser(django_db_blocker, django_user_model, page): - email = "super.user@example.com" + email = "super.user@example.com" # /PS-IGNORE user, _ = django_user_model.objects.get_or_create( username="testsuperuser", @@ -142,10 +142,10 @@ def superuser(django_db_blocker, django_user_model, page): @pytest.fixture def user(django_db_blocker, django_user_model): user, _ = django_user_model.objects.get_or_create( - username="john.smith-1234abcd@digital.trade.gov.uk", + username="john.smith-1234abcd@digital.trade.gov.uk", # /PS-IGNORE first_name="John", last_name="Smith", - email="john.smith@digital.trade.gov.uk", + email="john.smith@digital.trade.gov.uk", # /PS-IGNORE legacy_sso_user_id="1234abcd-1234-abcd-1234-abcd1234abcd", ) user.set_password("password") diff --git a/src/feedback/test/test_utils.py b/src/feedback/test/test_utils.py index f63f44c71..0178137d7 100644 --- a/src/feedback/test/test_utils.py +++ b/src/feedback/test/test_utils.py @@ -1,5 +1,6 @@ -import pytest from unittest.mock import call + +import pytest from django.test import override_settings from django_feedback_govuk.models import BaseFeedback @@ -56,7 +57,7 @@ def test_send_feedback_notification_with_no_email_recipients(): @override_settings( GOVUK_NOTIFY_API_KEY="this-is-my-really-long-api-key-because-gov-uk-notify-expects-it-to-be-long-when-you-create-a-service", - FEEDBACK_NOTIFICATION_EMAIL_RECIPIENTS=["test@email.com"], + FEEDBACK_NOTIFICATION_EMAIL_RECIPIENTS=["test@email.com"], # /PS-IGNORE FEEDBACK_NOTIFICATION_EMAIL_TEMPLATE_ID="test-template-id", WAGTAILADMIN_BASE_URL="https://test.example.com/", ) @@ -67,7 +68,7 @@ def test_send_feedback_notification_with_valid_settings(mocker): ) send_feedback_notification() mock_send_email_notification.assert_called_once_with( - email_address="test@email.com", + email_address="test@email.com", # /PS-IGNORE template_id="test-template-id", personalisation={ "feedback_url": "https://test.example.com/feedback/submitted/" @@ -77,7 +78,10 @@ def test_send_feedback_notification_with_valid_settings(mocker): @override_settings( GOVUK_NOTIFY_API_KEY="this-is-my-really-long-api-key-because-gov-uk-notify-expects-it-to-be-long-when-you-create-a-service", - FEEDBACK_NOTIFICATION_EMAIL_RECIPIENTS=["test1@email.com", "test2@email.com"], + FEEDBACK_NOTIFICATION_EMAIL_RECIPIENTS=[ + "test1@email.com", # /PS-IGNORE + "test2@email.com", # /PS-IGNORE + ], FEEDBACK_NOTIFICATION_EMAIL_TEMPLATE_ID="test-template-id", WAGTAILADMIN_BASE_URL="https://test.example.com/", ) @@ -88,14 +92,14 @@ def test_send_feedback_notification_with_multiple_emails(mocker): ) expected_calls = [ call( - email_address="test1@email.com", + email_address="test1@email.com", # /PS-IGNORE template_id="test-template-id", personalisation={ "feedback_url": "https://test.example.com/feedback/submitted/" }, ), call( - email_address="test2@email.com", + email_address="test2@email.com", # /PS-IGNORE template_id="test-template-id", personalisation={ "feedback_url": "https://test.example.com/feedback/submitted/" diff --git a/src/peoplefinder/backports.py b/src/peoplefinder/backports.py index 818af6c7e..6b5436dbf 100644 --- a/src/peoplefinder/backports.py +++ b/src/peoplefinder/backports.py @@ -5,7 +5,7 @@ # Backport of Django's Postgres specific ArraySubquery expression. # Documentation: https://docs.djangoproject.com/en/dev/ref/contrib/postgres/expressions/#arraysubquery-expressions -# Commit: https://github.com/django/django/commit/a06b977a91f043c509df781670fb4cf35cb437b7 +# Commit: https://github.com/django/django/commit/a06b977a91f043c509df781670fb4cf35cb437b7 /PS-IGNORE # TODO: Remove once Django has released this and we upgrade to that version. class ArraySubquery(Subquery): template = "ARRAY(%(subquery)s)" diff --git a/src/peoplefinder/legacy_migration/migrate_legacy.py b/src/peoplefinder/legacy_migration/migrate_legacy.py index 497597a38..ceed6ceaa 100644 --- a/src/peoplefinder/legacy_migration/migrate_legacy.py +++ b/src/peoplefinder/legacy_migration/migrate_legacy.py @@ -241,11 +241,11 @@ def migrate_person(legacy_person, person): if legacy_person.ditsso_user_id: person.legacy_sso_user_id = legacy_person.ditsso_user_id - # first name + # first name /PS-IGNORE if legacy_person.given_name: person.first_name = legacy_person.given_name - # last name + # last name /PS-IGNORE if legacy_person.surname: person.last_name = legacy_person.surname diff --git a/src/peoplefinder/migrations/0115_alter_person_fluent_languages_and_more.py b/src/peoplefinder/migrations/0115_alter_person_fluent_languages_and_more.py index c3f8f1b57..2a207c7f1 100644 --- a/src/peoplefinder/migrations/0115_alter_person_fluent_languages_and_more.py +++ b/src/peoplefinder/migrations/0115_alter_person_fluent_languages_and_more.py @@ -36,7 +36,7 @@ class Migration(migrations.Migration): name="preferred_first_name", field=models.CharField( blank=True, - help_text="This name appears on your profile. Colleagues can search for you using either of your first names", + help_text="This name appears on your profile. Colleagues can search for you using either of your first names", # /PS-IGNORE max_length=200, null=True, ), diff --git a/src/peoplefinder/models.py b/src/peoplefinder/models.py index 09ac15f39..26566bc28 100644 --- a/src/peoplefinder/models.py +++ b/src/peoplefinder/models.py @@ -550,7 +550,7 @@ class RemoteWorking(models.TextChoices): max_length=200, help_text=( "This name appears on your profile. Colleagues can search for you" - " using either of your first names" + " using either of your first names" # /PS-IGNORE ), null=True, blank=True, diff --git a/src/peoplefinder/services/person.py b/src/peoplefinder/services/person.py index 8ffa15775..4d73ea433 100644 --- a/src/peoplefinder/services/person.py +++ b/src/peoplefinder/services/person.py @@ -195,7 +195,7 @@ def create_user_profile(self, user: User) -> Person: Q(legacy_sso_user_id=user.legacy_sso_user_id), # Next see if we can match on the email. Q(email=user.email), - # Finally try and match on the first and last name. + # Finally try and match on the first and last names /PS-IGNORE. Q(first_name=user.first_name, last_name=user.last_name), ] diff --git a/src/peoplefinder/test/services/test_profile.py b/src/peoplefinder/test/services/test_profile.py index 8942c7dab..67eb6b887 100644 --- a/src/peoplefinder/test/services/test_profile.py +++ b/src/peoplefinder/test/services/test_profile.py @@ -96,7 +96,7 @@ def test_already_has_profile(self, normal_user): { "user": None, "legacy_sso_user_id": "not-a-match", - "email": "not-a-match@example.com", + "email": "not-a-match@example.com", # /PS-IGNORE }, ), ) @@ -120,7 +120,7 @@ def test_no_match(self, normal_user): profile.user = None profile.legacy_sso_user_id = "not-a-match" - profile.email = "not-a-match@example.com" + profile.email = "not-a-match@example.com" # /PS-IGNORE profile.first_name = "no" profile.last_name = "match" profile.save() diff --git a/src/peoplefinder/test/views/test_delete_profile_views.py b/src/peoplefinder/test/views/test_delete_profile_views.py index 6b2d7f486..11fbb2209 100644 --- a/src/peoplefinder/test/views/test_delete_profile_views.py +++ b/src/peoplefinder/test/views/test_delete_profile_views.py @@ -179,10 +179,10 @@ def test_delete_profile_with_no_user(state): other_user = UserFactory( first_name="Other", last_name="User", - email="other.user@example.com", + email="other.user@example.com", # /PS-IGNORE legacy_sso_user_id=None, - username="other.user-11111111@example.com", - sso_contact_email="other.user@example.com", + username="other.user-11111111@example.com", # /PS-IGNORE + sso_contact_email="other.user@example.com", # /PS-IGNORE ) other_user.save() other_person = PersonService().create_user_profile(other_user) diff --git a/src/peoplefinder/test/views/test_profile_views.py b/src/peoplefinder/test/views/test_profile_views.py index 073cf6e51..04bd99089 100644 --- a/src/peoplefinder/test/views/test_profile_views.py +++ b/src/peoplefinder/test/views/test_profile_views.py @@ -424,13 +424,13 @@ def test_profile_edit_contact_view(state): response = state.client.get(view_url) assert response.status_code == 200 - assert state.person.contact_email == "jane.smith@test.com" + assert state.person.contact_email == "jane.smith@test.com" # /PS-IGNORE assert state.person.primary_phone_number is None assert state.person.secondary_phone_number is None form = ContactProfileEditForm( { - "contact_email": "jane.smith123@test.com", + "contact_email": "jane.smith123@test.com", # /PS-IGNORE "primary_phone_number": "01234567890", "secondary_phone_number": "09876543210", }, @@ -445,7 +445,7 @@ def test_profile_edit_contact_view(state): assert response.status_code == 302 assert response.url == view_url - assert state.person.contact_email == "jane.smith123@test.com" + assert state.person.contact_email == "jane.smith123@test.com" # /PS-IGNORE assert state.person.primary_phone_number == "01234567890" assert state.person.secondary_phone_number == "09876543210" diff --git a/src/peoplefinder/test/views/test_search.py b/src/peoplefinder/test/views/test_search.py index e9d9971c6..580cf58d0 100644 --- a/src/peoplefinder/test/views/test_search.py +++ b/src/peoplefinder/test/views/test_search.py @@ -39,7 +39,7 @@ def test_updated_profile(self, another_normal_user): another_normal_user.profile.first_name = "Tim" another_normal_user.profile.preferred_first_name = "Tim" - another_normal_user.profile.email = "tim.smith@example.com" + another_normal_user.profile.email = "tim.smith@example.com" # /PS-IGNORE another_normal_user.profile.save() call_command("update_index") diff --git a/src/peoplefinder/test/views/test_team.py b/src/peoplefinder/test/views/test_team.py index b527c0d16..3c9113026 100644 --- a/src/peoplefinder/test/views/test_team.py +++ b/src/peoplefinder/test/views/test_team.py @@ -21,18 +21,18 @@ def test_order_team_leaders(self, team_admin_user, software_team): red_leader = UserFactory( first_name="Red", last_name="Leader", - email="red.leader@example.com", + email="red.leader@example.com", # /PS-IGNORE legacy_sso_user_id=None, username="red-leader", - sso_contact_email="red.leader@example.com", + sso_contact_email="red.leader@example.com", # /PS-IGNORE ) gold_leader = UserFactory( first_name="Gold", last_name="Leader", - email="gold.leader@example.com", + email="gold.leader@example.com", # /PS-IGNORE legacy_sso_user_id=None, username="gold-leader", - sso_contact_email="gold.leader@example.com", + sso_contact_email="gold.leader@example.com", # /PS-IGNORE ) call_command("create_user_profiles")