-
Notifications
You must be signed in to change notification settings - Fork 86
Release 2.74.2 #6965
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
Draft
JadeCara
wants to merge
4
commits into
release-2.74.1
Choose a base branch
from
release-2.74.2
base: release-2.74.1
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Release 2.74.2 #6965
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -53,10 +53,14 @@ | |
| MessagingServiceType, | ||
| RequestReceiptBodyParams, | ||
| RequestReviewDenyBodyParams, | ||
| SubjectIdentityVerificationBodyParams, | ||
| ) | ||
| from fides.api.schemas.policy import ActionType, CurrentStep, PolicyResponse | ||
| from fides.api.schemas.privacy_request import PrivacyRequestSource, PrivacyRequestStatus | ||
| from fides.api.schemas.privacy_request import ( | ||
| IdentityValue, | ||
| PrivacyRequestResponse, | ||
| PrivacyRequestSource, | ||
| PrivacyRequestStatus, | ||
| ) | ||
| from fides.api.schemas.redis_cache import ( | ||
| CustomPrivacyRequestField, | ||
| Identity, | ||
|
|
@@ -1210,6 +1214,195 @@ def test_get_privacy_requests_with_identity( | |
| assert resp["items"][0]["id"] == succeeded_privacy_request.id | ||
| assert resp["items"][0].get("identity") is None | ||
|
|
||
| @pytest.mark.parametrize( | ||
| "custom_identities,expected_identity_values", | ||
| [ | ||
| # Test case 1: List of integers | ||
| ( | ||
| { | ||
| "regi_id": LabeledIdentity(label="Regi ID", value=[12345678]), | ||
| }, | ||
| { | ||
| "regi_id": {"label": "Regi ID", "value": [12345678]}, | ||
| }, | ||
| ), | ||
| # Test case 2: List of strings | ||
| ( | ||
| { | ||
| "agent_id": LabeledIdentity( | ||
| label="Agent ID", value=["one", "two", "three"] | ||
| ), | ||
| }, | ||
| { | ||
| "agent_id": {"label": "Agent ID", "value": ["one", "two", "three"]}, | ||
| }, | ||
| ), | ||
| # Test case 3: Mixed list | ||
| ( | ||
| { | ||
| "user_id": LabeledIdentity( | ||
| label="User ID", value=[12345678, "one", "two", "three"] | ||
| ), | ||
| }, | ||
| { | ||
| "user_id": { | ||
| "label": "User ID", | ||
| "value": [12345678, "one", "two", "three"], | ||
| }, | ||
| }, | ||
| ), | ||
| # Test case 4: All three cases together | ||
| ( | ||
| { | ||
| "regi_id": LabeledIdentity(label="Regi ID", value=[12345678]), | ||
| "agent_id": LabeledIdentity( | ||
| label="Agent ID", value=["one", "two", "three"] | ||
| ), | ||
| "user_id": LabeledIdentity( | ||
| label="User ID", value=[12345678, "one", "two", "three"] | ||
| ), | ||
| }, | ||
| { | ||
| "regi_id": {"label": "Regi ID", "value": [12345678]}, | ||
| "agent_id": {"label": "Agent ID", "value": ["one", "two", "three"]}, | ||
| "user_id": { | ||
| "label": "User ID", | ||
| "value": [12345678, "one", "two", "three"], | ||
| }, | ||
| }, | ||
| ), | ||
| # Test case 5: Single integer in list | ||
| ( | ||
| { | ||
| "customer_id": LabeledIdentity(label="Customer ID", value=[999]), | ||
| }, | ||
| { | ||
| "customer_id": {"label": "Customer ID", "value": [999]}, | ||
| }, | ||
| ), | ||
| # Test case 6: Empty list | ||
| ( | ||
| { | ||
| "empty_list": LabeledIdentity(label="Empty List", value=[]), | ||
| }, | ||
| { | ||
| "empty_list": {"label": "Empty List", "value": []}, | ||
| }, | ||
| ), | ||
| # Test case 7: String value (not a list) | ||
| ( | ||
| { | ||
| "customer_name": LabeledIdentity( | ||
| label="Customer Name", value="John Doe" | ||
| ), | ||
| }, | ||
| { | ||
| "customer_name": {"label": "Customer Name", "value": "John Doe"}, | ||
| }, | ||
| ), | ||
| # Test case 8: Integer value (not a list) | ||
| ( | ||
| { | ||
| "account_number": LabeledIdentity( | ||
| label="Account Number", value=98765 | ||
| ), | ||
| }, | ||
| { | ||
| "account_number": {"label": "Account Number", "value": 98765}, | ||
| }, | ||
| ), | ||
| # Test case 9: Mixed types - string, int, and list | ||
| ( | ||
| { | ||
| "name": LabeledIdentity(label="Name", value="Jane Smith"), | ||
| "id": LabeledIdentity(label="ID", value=456789), | ||
| "tags": LabeledIdentity(label="Tags", value=["tag1", "tag2"]), | ||
| }, | ||
| { | ||
| "name": {"label": "Name", "value": "Jane Smith"}, | ||
| "id": {"label": "ID", "value": 456789}, | ||
| "tags": {"label": "Tags", "value": ["tag1", "tag2"]}, | ||
| }, | ||
| ), | ||
| ], | ||
| ) | ||
| def test_get_privacy_requests_with_custom_identities( | ||
| self, | ||
| api_client: TestClient, | ||
| url, | ||
| generate_auth_header, | ||
| db, | ||
| policy, | ||
| custom_identities, | ||
| expected_identity_values, | ||
| ): | ||
| """Test that privacy requests with custom identities containing various value types | ||
| can be retrieved and validated correctly. | ||
|
|
||
| This test would have caught the validation error where IdentityValue.value | ||
| was too restrictive and couldn't accept list values like [12345678] or | ||
| ['one', 'two', 'three']. | ||
|
|
||
| The test is parametrized to cover: | ||
| - List values | ||
| - String values | ||
| - Integer values | ||
| - Mixed types (string, int, list) | ||
|
|
||
| Note: LabeledIdentity only accepts MultiValue types (int, str, or list of int/str) | ||
| """ | ||
| # Create a privacy request | ||
| privacy_request = PrivacyRequest.create( | ||
| db=db, | ||
| data={ | ||
| "status": PrivacyRequestStatus.pending, | ||
| "policy_id": policy.id, | ||
| "client_id": policy.client_id, | ||
| }, | ||
| ) | ||
|
|
||
| # Persist identity with custom fields that have various value types | ||
| identity_dict = {"email": "[email protected]", **custom_identities} | ||
| privacy_request.persist_identity(db=db, identity=Identity(**identity_dict)) | ||
|
|
||
| auth_header = generate_auth_header(scopes=[PRIVACY_REQUEST_READ]) | ||
| response = api_client.get( | ||
| url + f"?include_identities=true", headers=auth_header | ||
| ) | ||
| assert response.status_code == 200 | ||
| resp = response.json() | ||
|
|
||
| # Verify the response validates correctly | ||
| assert len(resp["items"]) == 1 | ||
| assert resp["items"][0]["id"] == privacy_request.id | ||
|
|
||
| # Verify the identity field is present and contains the list values | ||
| identity = resp["items"][0]["identity"] | ||
| assert identity is not None | ||
|
|
||
| # Verify standard identity field | ||
| assert identity["email"] == { | ||
| "label": "Email", | ||
| "value": "[email protected]", | ||
| } | ||
|
|
||
| # Verify custom identity fields with various value types | ||
| for field_name, expected_value in expected_identity_values.items(): | ||
| assert identity[field_name] == expected_value | ||
|
|
||
| validated_response = PrivacyRequestResponse(**resp["items"][0]) | ||
| assert validated_response.identity is not None | ||
|
|
||
| # Verify each custom identity field can be accessed and has the correct value | ||
| for field_name, expected_value in expected_identity_values.items(): | ||
| assert field_name in validated_response.identity | ||
| identity_value = validated_response.identity[field_name] | ||
| assert isinstance(identity_value, IdentityValue) | ||
| assert identity_value.value == expected_value["value"] | ||
| assert identity_value.label == expected_value["label"] | ||
|
|
||
| privacy_request.delete(db) | ||
|
|
||
| def test_get_privacy_requests_with_custom_fields( | ||
| self, | ||
| api_client: TestClient, | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.