This repository has been archived by the owner on Nov 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return persisted identities in
get_request_status
view (#860)
- Loading branch information
Sean Preston
authored
Jul 13, 2022
1 parent
f54e07f
commit 7929220
Showing
6 changed files
with
52 additions
and
29 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
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 |
---|---|---|
|
@@ -640,7 +640,7 @@ def test_get_privacy_requests_with_identity( | |
assert resp["items"][0]["id"] == succeeded_privacy_request.id | ||
assert ( | ||
resp["items"][0]["identity"] | ||
== succeeded_privacy_request.get_cached_identity_data() | ||
== succeeded_privacy_request.get_persisted_identity() | ||
) | ||
|
||
assert resp["items"][0]["policy"]["key"] == privacy_request.policy.key | ||
|
@@ -710,22 +710,25 @@ def test_filter_privacy_requests_by_internal_id( | |
api_client, | ||
url, | ||
generate_auth_header, | ||
privacy_request, | ||
policy, | ||
): | ||
data = [ | ||
{ | ||
"requested_at": "2021-08-30T16:09:37.359Z", | ||
"policy_key": policy.key, | ||
"identity": {"email": "[email protected]"}, | ||
"id": "test_internal_id_1", | ||
} | ||
] | ||
resp = api_client.post(url, json=data) | ||
assert resp.status_code == 200 | ||
response_data = resp.json()["succeeded"] | ||
assert len(response_data) == 1 | ||
privacy_request = PrivacyRequest.get(db=db, object_id=response_data[0]["id"]) | ||
auth_header = generate_auth_header(scopes=[PRIVACY_REQUEST_READ]) | ||
new_request_id = "test_internal_id_1" | ||
response = api_client.get( | ||
url + f"?request_id={new_request_id}", headers=auth_header | ||
) | ||
assert response.status_code == status.HTTP_200_OK | ||
resp = response.json() | ||
assert len(resp["items"]) == 0 | ||
|
||
privacy_request.id = new_request_id | ||
privacy_request.save(db) | ||
|
||
response = api_client.get( | ||
url + f"?request_id={new_request_id}", headers=auth_header | ||
url + f"?request_id={privacy_request.id}", | ||
headers=auth_header, | ||
) | ||
assert response.status_code == status.HTTP_200_OK | ||
resp = response.json() | ||
|
@@ -1080,8 +1083,13 @@ def test_get_privacy_requests_csv_format( | |
privacy_request.status = PrivacyRequestStatus.approved | ||
privacy_request.reviewed_by = user.id | ||
privacy_request.reviewed_at = reviewed_at | ||
TEST_EMAIL = "[email protected]" | ||
TEST_PHONE = "+1 234 567 8910" | ||
privacy_request.cache_identity( | ||
{"email": "[email protected]", "phone_number": "111-111-1111"} | ||
{ | ||
"email": TEST_EMAIL, | ||
"phone_number": TEST_PHONE, | ||
} | ||
) | ||
privacy_request.save(db) | ||
|
||
|
@@ -1102,8 +1110,8 @@ def test_get_privacy_requests_csv_format( | |
first_row = next(csv_file) | ||
assert parse(first_row["Time received"], ignoretz=True) == created_at | ||
assert ast.literal_eval(first_row["Subject identity"]) == { | ||
"email": "[email protected]", | ||
"phone_number": "111-111-1111", | ||
"email": TEST_EMAIL, | ||
"phone_number": TEST_PHONE, | ||
} | ||
assert first_row["Policy key"] == "example_access_request_policy" | ||
assert first_row["Request status"] == "approved" | ||
|
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 |
---|---|---|
|
@@ -32,6 +32,7 @@ | |
) | ||
from fidesops.models.privacy_request import PrivacyRequest, PrivacyRequestStatus | ||
from fidesops.models.storage import ResponseFormat, StorageConfig | ||
from fidesops.schemas.redis_cache import PrivacyRequestIdentity | ||
from fidesops.schemas.storage.storage import ( | ||
FileNaming, | ||
StorageDetails, | ||
|
@@ -772,10 +773,18 @@ def _create_privacy_request_for_policy( | |
microsecond=393185, | ||
tzinfo=timezone.utc, | ||
) | ||
return PrivacyRequest.create( | ||
pr = PrivacyRequest.create( | ||
db=db, | ||
data=data, | ||
) | ||
pr.persist_identity( | ||
db=db, | ||
identity=PrivacyRequestIdentity( | ||
email="[email protected]", | ||
phone_number="+1 234 567 8910", | ||
), | ||
) | ||
return pr | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
|
@@ -839,7 +848,12 @@ def succeeded_privacy_request(cache, db: Session, policy: Policy) -> PrivacyRequ | |
"client_id": policy.client_id, | ||
}, | ||
) | ||
pr.cache_identity({"email": "[email protected]"}) | ||
identity_kwargs = {"email": "[email protected]"} | ||
pr.cache_identity(identity_kwargs) | ||
pr.persist_identity( | ||
db=db, | ||
identity=PrivacyRequestIdentity(**identity_kwargs), | ||
) | ||
yield pr | ||
pr.delete(db) | ||
|
||
|