-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding privacy_request_id placeholder (#911)
- Loading branch information
Showing
7 changed files
with
93 additions
and
24 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
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 |
---|---|---|
|
@@ -636,6 +636,10 @@ def test_generate_query( | |
CollectionAddress(saas_config.fides_key, "payment_methods") | ||
] | ||
|
||
data_management = combined_traversal.traversal_node_dict[ | ||
CollectionAddress(saas_config.fides_key, "data_management") | ||
] | ||
|
||
# static path with single query param | ||
config = SaaSQueryConfig(member, endpoints, {}) | ||
prepared_request: SaaSRequestParams = config.generate_query( | ||
|
@@ -700,6 +704,14 @@ def test_generate_query( | |
"query": "[email protected]", | ||
} | ||
|
||
# using privacy_request_id placeholder | ||
config = SaaSQueryConfig(data_management, endpoints, {}, None, privacy_request) | ||
prepared_request = config.generate_query( | ||
{"email": ["[email protected]"]}, policy | ||
) | ||
assert prepared_request.method == HTTPMethod.GET.value | ||
assert prepared_request.path == f"/v1/privacy_request/{privacy_request.id}" | ||
|
||
def test_generate_update_stmt( | ||
self, | ||
erasure_policy_string_rewrite, | ||
|
@@ -714,6 +726,10 @@ def test_generate_update_stmt( | |
CollectionAddress(saas_config.fides_key, "member") | ||
] | ||
|
||
data_management = combined_traversal.traversal_node_dict[ | ||
CollectionAddress(saas_config.fides_key, "data_management") | ||
] | ||
|
||
config = SaaSQueryConfig(member, endpoints, {}, update_request) | ||
row = { | ||
"id": "123", | ||
|
@@ -730,10 +746,18 @@ def test_generate_update_stmt( | |
assert prepared_request.path == "/3.0/lists/abc/members/123" | ||
assert prepared_request.headers == {"Content-Type": "application/json"} | ||
assert prepared_request.query_params == {} | ||
assert ( | ||
prepared_request.body | ||
== '{\n "merge_fields": {"FNAME": "MASKED", "LNAME": "MASKED"}\n}\n' | ||
assert json.loads(prepared_request.body) == { | ||
"merge_fields": {"FNAME": "MASKED", "LNAME": "MASKED"} | ||
} | ||
|
||
# using privacy_request_id placeholder | ||
config = SaaSQueryConfig(data_management, endpoints, {}, None, privacy_request) | ||
prepared_request = config.generate_update_stmt( | ||
row, erasure_policy_string_rewrite, privacy_request | ||
) | ||
assert prepared_request.method == HTTPMethod.POST.value | ||
assert prepared_request.path == "/v1/privacy_request/" | ||
assert json.loads(prepared_request.body) == {"unique_id": privacy_request.id} | ||
|
||
def test_generate_update_stmt_custom_http_method( | ||
self, | ||
|
@@ -768,10 +792,9 @@ def test_generate_update_stmt_custom_http_method( | |
assert prepared_request.path == "/3.0/lists/abc/members/123" | ||
assert prepared_request.headers == {"Content-Type": "application/json"} | ||
assert prepared_request.query_params == {} | ||
assert ( | ||
prepared_request.body | ||
== '{\n "merge_fields": {"FNAME": "MASKED", "LNAME": "MASKED"}\n}\n' | ||
) | ||
assert json.loads(prepared_request.body) == { | ||
"merge_fields": {"FNAME": "MASKED", "LNAME": "MASKED"} | ||
} | ||
|
||
def test_generate_update_stmt_with_request_body( | ||
self, | ||
|
@@ -847,7 +870,7 @@ def test_generate_update_stmt_with_request_body( | |
assert prepared_request.path == "/2.0/payment_methods" | ||
assert prepared_request.headers == {"Content-Type": "application/json"} | ||
assert prepared_request.query_params == {} | ||
assert prepared_request.body == '{\n "customer_name": "MASKED"\n}\n' | ||
assert json.loads(prepared_request.body) == {"customer_name": "MASKED"} | ||
|
||
def test_generate_update_stmt_with_url_encoded_body( | ||
self, | ||
|