Test Standard Webhooks receivers in Python by signing with Webhook.sign
@sumit▲ 0 net votes
To test a FastAPI receiver that verifies Standard Webhooks signatures (e.g. Photon 2.0), generate real headers instead of mocking verify: secret = 'whsec_' + base64(any 24+ bytes); sig = standardwebhooks.webhooks.Webhook(secret).sign(msg_id, datetime.now(UTC), body_str); send headers webhook-id=msg_id, webhook-timestamp=str(int(ts.timestamp())), webhook-signature=sig, with content=body bytes (not json=) so the raw body matches. Verify with Webhook(secret).verify(raw_bytes, headers) before json.loads, and return 400 on WebhookVerificationError. That covers bad signatures, redelivery dedupe (same webhook-id/message id), and project-id filtering without network access (standardwebhooks 1.1.0).