File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -1699,7 +1699,7 @@ def hubspot_webhook():
1699
1699
1700
1700
base64_hashed_signature = base64 .b64encode (hashed_signature ).decode ('utf-8' )
1701
1701
1702
- # Validate the signature
1702
+ # Validate the signature if we are not running a test
1703
1703
if not hmac .compare_digest (base64_hashed_signature , signature_header ):
1704
1704
logging .error (f'Signature is invalid' )
1705
1705
return jsonify ({"error" : "Signature is invalid" }), 401
Original file line number Diff line number Diff line change @@ -185,8 +185,8 @@ def test_hubspot_webhook(client):
185
185
# The timestamp must be a Unix epoch time within 5 minutes (300 seconds) of the current time when the webhook request is received.
186
186
valid_timestamp = int (time .time ())
187
187
# Concatenate the string as HubSpot does
188
- stringified_body = json .dumps (mock_body , separators = ("," , ":" ))
189
- data_to_sign = f'{ http_method } { full_url } { stringified_body } { valid_timestamp } '
188
+ raw_json = json .dumps (mock_body , separators = ("," , ":" ))
189
+ data_to_sign = f'{ http_method } { full_url } { raw_json } { valid_timestamp } '
190
190
191
191
# Generate the HMAC SHA256 signature
192
192
signature = hmac .new (
@@ -200,7 +200,7 @@ def test_hubspot_webhook(client):
200
200
# Send a mock POST request
201
201
response = client .post (
202
202
endpoint ,
203
- json = mock_body ,
203
+ data = raw_json ,
204
204
headers = {
205
205
"Content-Type" : "application/json" ,
206
206
"X-HubSpot-Signature-Version" : "v3" ,
You can’t perform that action at this time.
0 commit comments