Skip to content

Commit 35fdd33

Browse files
authored
Merge pull request #258 from nih-sparc/fix-failing-test
Fix failing test
2 parents 84b6ce1 + 2b60ec8 commit 35fdd33

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

app/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1699,7 +1699,7 @@ def hubspot_webhook():
16991699

17001700
base64_hashed_signature = base64.b64encode(hashed_signature).decode('utf-8')
17011701

1702-
# Validate the signature
1702+
# Validate the signature if we are not running a test
17031703
if not hmac.compare_digest(base64_hashed_signature, signature_header):
17041704
logging.error(f'Signature is invalid')
17051705
return jsonify({"error": "Signature is invalid"}), 401

tests/test_api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ def test_hubspot_webhook(client):
185185
# The timestamp must be a Unix epoch time within 5 minutes (300 seconds) of the current time when the webhook request is received.
186186
valid_timestamp = int(time.time())
187187
# 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}'
190190

191191
# Generate the HMAC SHA256 signature
192192
signature = hmac.new(
@@ -200,7 +200,7 @@ def test_hubspot_webhook(client):
200200
# Send a mock POST request
201201
response = client.post(
202202
endpoint,
203-
json=mock_body,
203+
data=raw_json,
204204
headers={
205205
"Content-Type": "application/json",
206206
"X-HubSpot-Signature-Version": "v3",

0 commit comments

Comments
 (0)