Skip to main content

Testing Guide

This project includes PowerShell test scripts that exercise the production-like Worker deployment. Most tests assume these environment variables are set:

Run tests in this order after a fresh deploy.

1. End-to-end test

This verifies:
  • health check
  • schema check
  • tenant creation
  • API key creation
  • unauthorized request failure
  • endpoint creation
  • event creation
  • idempotency behavior

2. Idempotency

Expected:
  • first request succeeds
  • same request reuses the original event
  • same key with different payload fails with 409

3. SSRF protection

Expected:
  • localhost/private/metadata URLs rejected
  • URLs with embedded credentials rejected
  • non-HTTP protocols rejected

4. Endpoint health

Use a real endpoint ID returned from endpoint creation.

5. Metrics summary

Expected fields:
  • deliveries by status
  • attempts by status code
  • DLQ count
  • retry count
  • endpoint counts
  • queue age approximation

6. Current usage

Expected fields:
  • events
  • deliveries
  • billable attempts
  • retry attempts
  • payload storage estimate
  • endpoint count

7. Usage limits


8. Safety limits


9. Event rate limit

Default config:
Expected:

10. Endpoint create rate limit

Default config:
Expected:

11. Event deliveries

Use a real event ID from an event creation response.

12. Delivery attempts

Use a real delivery ID from an event creation response.

13. Delivery replay


14. DLQ list

If all endpoints are healthy, an empty DLQ is expected.

15. Secret rotation overlap

Expected:
  • new signing secret returned
  • previous secret expiry returned
  • overlap days returned
  • previous signing secret active flag true

16. Retention cleanup dry-run

Expected:
  • does not delete rows
  • reports what would be deleted

17. Retention cleanup apply

Only run this after dry-run looks safe.

Common test mistakes

Using placeholders

This will fail:
Use a real ID from test output.

Using admin key as tenant key

This will fail:
Admin keys and tenant API keys are different.

Forgetting required SQL migrations

Some phases require new tables or columns. If you see:
then Phase 8 SQL was not applied.

Not redeploying after changing Worker vars/secrets

After changing wrangler.jsonc or Worker secrets:

Clean test environment recommendation

Because tests create endpoints and events, dev databases can get noisy. Recommended cleanup approach:
  1. Use short retention values in dev.
  2. Run retention dry-run.
  3. Run retention apply.
  4. Avoid using production tenant IDs during aggressive test loops.