Last active
January 19, 2022 19:34
-
-
Save raphaelfruneaux/a878a2b6ad3d8d98ef98dd71ab1fa3b8 to your computer and use it in GitHub Desktop.
Revisions
-
raphaelfruneaux revised this gist
Jun 21, 2021 . 1 changed file with 1 addition and 1 deletion.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 charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,7 @@ def clean_sensitive_data_from_request(response): content = response["content"] if isinstance(content, str): content = json.loads(content) updated = False for field in SENSITIVE_FIELDS: -
raphaelfruneaux created this gist
Jun 21, 2021 .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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ import json import pytest REPLACEMENT_VALUE = "fake" SENSITIVE_FIELDS = ( "client-id", "client-secret", "access_token", "Authorization", ) def clean_sensitive_data_from_request(response): content = response["content"] if isinstance(content, str): content = json.loads(response["content"]) updated = False for field in SENSITIVE_FIELDS: if field in content: content[field] = REPLACEMENT_VALUE updated = True if updated: response["content"] = json.dumps(content) return response @pytest.fixture(scope="module") def vcr_config(): return { "filter_headers": [("authorization", REPLACEMENT_VALUE)], "filter_query_parameters": [("access_token", REPLACEMENT_VALUE)], "before_record_response": clean_sensitive_data_from_request, }