PTHMINT-96: Webhook validation for payloads with Unicode characters #42
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.
This pull request improves the handling of unicode characters in webhook validation and enhances the test coverage to ensure correct behavior with non-ASCII payloads. The main changes are grouped into improvements in unicode support and expanded test coverage.
Unicode handling improvements:
json.dumpscall insrc/multisafepay/util/webhook.pyto useensure_ascii=False, allowing unicode characters to be preserved in the compact JSON used for HMAC signature calculation.Test coverage enhancements:
test_validate_with_unicode_characters, to verify that webhook validation works correctly when the payload contains unicode characters. This test ensures the signature is generated and validated as expected with non-ASCII data.base64,hashlib,hmac,time) intests/multisafepay/unit/util/test_unit_webhook.pyto support the new unicode validation test.- Update Webhook.validate to use ensure_ascii=False during JSON reconstruction.