-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
111 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
ProvidedIdentity, | ||
) | ||
from fides.api.schemas.messaging.messaging import MessagingServiceType | ||
from fides.api.schemas.privacy_request import PrivacyRequestSource | ||
from fides.common.api.scope_registry import CONNECTION_READ, CONSENT_READ | ||
from fides.common.api.v1.urn_registry import ( | ||
CONSENT_REQUEST, | ||
|
@@ -367,6 +368,32 @@ def test_consent_request_email_and_phone_default_to_email( | |
).first() | ||
assert provided_identity is not None | ||
|
||
@pytest.mark.usefixtures( | ||
"messaging_config", | ||
"subject_identity_verification_required", | ||
) | ||
@patch("fides.api.service._verification.dispatch_message") | ||
def test_consent_request_with_source( | ||
self, | ||
mock_dispatch_message, | ||
db, | ||
api_client, | ||
url, | ||
): | ||
data = { | ||
"identity": {"email": "[email protected]"}, | ||
"source": PrivacyRequestSource.privacy_center, | ||
} | ||
response = api_client.post(url, json=data) | ||
assert response.status_code == 200 | ||
assert mock_dispatch_message.called | ||
|
||
consent_request_id = response.json()["consent_request_id"] | ||
consent_request = ConsentRequest.get_by_key_or_id( | ||
db=db, data={"id": consent_request_id} | ||
) | ||
assert consent_request.source == PrivacyRequestSource.privacy_center | ||
|
||
@pytest.mark.usefixtures( | ||
"messaging_config", | ||
"sovrn_email_connection_config", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,7 @@ | |
generate_request_task_callback_jwe, | ||
) | ||
from fides.api.oauth.jwt import generate_jwe | ||
from fides.api.oauth.roles import APPROVER, VIEWER | ||
from fides.api.oauth.roles import APPROVER, OWNER, VIEWER | ||
from fides.api.schemas.dataset import DryRunDatasetResponse | ||
from fides.api.schemas.masking.masking_secrets import SecretType | ||
from fides.api.schemas.messaging.messaging import ( | ||
|
@@ -53,6 +53,7 @@ | |
SubjectIdentityVerificationBodyParams, | ||
) | ||
from fides.api.schemas.policy import ActionType, PolicyResponse | ||
from fides.api.schemas.privacy_request import PrivacyRequestSource | ||
from fides.api.schemas.redis_cache import Identity, LabeledIdentity | ||
from fides.api.task.graph_runners import access_runner | ||
from fides.api.tasks import MESSAGING_QUEUE_NAME | ||
|
@@ -95,6 +96,7 @@ | |
V1_URL_PREFIX, | ||
) | ||
from fides.config import CONFIG | ||
from tests.conftest import generate_auth_header_for_user, generate_role_header_for_user | ||
|
||
page_size = Params().size | ||
|
||
|
@@ -6114,6 +6116,54 @@ def test_create_privacy_request( | |
assert len(response_data) == 1 | ||
assert run_access_request_mock.called | ||
|
||
@pytest.mark.parametrize( | ||
"source, expected_submitted_by", | ||
[ | ||
(PrivacyRequestSource.request_manager, lambda user: user.client.user_id), | ||
(PrivacyRequestSource.privacy_center, lambda _: None), | ||
(None, lambda _: None), | ||
], | ||
) | ||
@mock.patch( | ||
"fides.api.service.privacy_request.request_runner_service.run_privacy_request.delay" | ||
) | ||
def test_request_manager_privacy_request_stores_submitted_by( | ||
self, | ||
run_access_request_mock, | ||
db, | ||
url, | ||
api_client, | ||
owner_user, | ||
policy, | ||
source, | ||
expected_submitted_by, | ||
): | ||
auth_header = generate_role_header_for_user( | ||
owner_user, roles=owner_user.permissions.roles | ||
) | ||
data = [ | ||
{ | ||
"policy_key": policy.key, | ||
"identity": {"email": "[email protected]"}, | ||
"source": source, | ||
} | ||
] | ||
resp = api_client.post( | ||
url, | ||
headers=auth_header, | ||
json=data, | ||
) | ||
assert resp.status_code == 200 | ||
|
||
response_data = resp.json()["succeeded"] | ||
assert len(response_data) == 1 | ||
|
||
pr = PrivacyRequest.get(db=db, object_id=response_data[0]["id"]) | ||
assert pr.submitted_by == expected_submitted_by(owner_user) | ||
|
||
pr.delete(db=db) | ||
assert run_access_request_mock.called | ||
|
||
@pytest.mark.usefixtures("verification_config") | ||
@mock.patch( | ||
"fides.api.service.privacy_request.request_runner_service.run_privacy_request.delay" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters