Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing privacy request received message #5518

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ The types of changes are:
- Fixed extra delete icon on Domains page [#5513](https://github.com/ethyca/fides/pull/5513)
- Fixed incorrect display names on some D&D resources [#5498](https://github.com/ethyca/fides/pull/5498)
- Fixed position of "Integration" button on system detail page [#5497](https://github.com/ethyca/fides/pull/5497)
- Fixing issue where "privacy request received" emails would not be sent if the request had custom identities [#5518](https://github.com/ethyca/fides/pull/5518)

### Changed
- Allow hiding systems via a `hidden` parameter and add two flags on the `/system` api endpoint; `show_hidden` and `dnd_relevant`, to display only systems with integrations [#5484](https://github.com/ethyca/fides/pull/5484)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def _send_privacy_request_receipt_message_to_user(
body_params=RequestReceiptBodyParams(request_types=request_types),
).model_dump(mode="json"),
"service_type": service_type,
"to_identity": to_identity.model_dump(mode="json"),
"to_identity": to_identity.labeled_dict(),
"property_id": property_id,
},
)
Expand Down
77 changes: 77 additions & 0 deletions tests/ops/api/v1/endpoints/test_privacy_request_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -5557,6 +5557,83 @@ def test_verify_identity_admin_approval_needed(
queue = call_args["queue"]
assert queue == MESSAGING_QUEUE_NAME

@mock.patch(
"fides.api.service.privacy_request.request_runner_service.run_privacy_request.delay"
)
@mock.patch(
"fides.api.api.v1.endpoints.privacy_request_endpoints.dispatch_message_task.apply_async"
)
def test_verify_identity_with_custom_identity_admin_approval_needed(
self,
mock_dispatch_message,
mock_run_privacy_request,
require_manual_request_approval,
db,
api_client,
url,
privacy_request,
privacy_request_receipt_notification_enabled,
):
privacy_request.status = PrivacyRequestStatus.identity_unverified
privacy_request.save(db)
privacy_request.cache_identity_verification_code(self.code)

# add a custom identity to the request to verify it can be
# passed successfully to the dispatch_message_task
privacy_request.persist_identity(
db=db,
identity=Identity(
custom_id=LabeledIdentity(label="Custom ID", value="123"),
),
)

request_body = {"code": self.code}
resp = api_client.post(url, headers={}, json=request_body)
assert resp.status_code == 200

resp = resp.json()
assert resp["status"] == "pending"
assert resp["identity_verified_at"] is not None

db.refresh(privacy_request)
assert privacy_request.status == PrivacyRequestStatus.pending
assert privacy_request.identity_verified_at is not None

approved_audit_log: AuditLog = AuditLog.filter(
db=db,
conditions=(
(AuditLog.privacy_request_id == privacy_request.id)
& (AuditLog.action == AuditLogAction.approved)
),
).first()

assert approved_audit_log is None
assert not mock_run_privacy_request.called

assert mock_dispatch_message.called

call_args = mock_dispatch_message.call_args[1]
task_kwargs = call_args["kwargs"]
assert (
task_kwargs["to_identity"]
== Identity(
phone_number="+12345678910",
email="test@example.com",
custom_id=LabeledIdentity(label="Custom ID", value="123"),
).labeled_dict()
)
assert task_kwargs["service_type"] == MessagingServiceType.mailgun.value

message_meta = task_kwargs["message_meta"]
assert (
message_meta["action_type"] == MessagingActionType.PRIVACY_REQUEST_RECEIPT
)
assert message_meta["body_params"] == RequestReceiptBodyParams(
request_types={ActionType.access.value}
).model_dump(mode="json")
queue = call_args["queue"]
assert queue == MESSAGING_QUEUE_NAME


class TestCreatePrivacyRequestEmailVerificationRequired:
@pytest.fixture(scope="function")
Expand Down
Loading