\n

ShazaMail

Test Password Reset Emails Without Leaking Recovery Links

Password-reset tests handle sensitive links. Their job is to prove the recovery path works without exposing tokens or allowing one test to reset another account.

Product documentation last reviewed: 2026-11-18

Abstract cybersecurity imagery representing protected account recovery

Use a dedicated test user and inbox

Create a disposable test identity for each isolated run, or use a deterministic test account protected from concurrent jobs. Route its reset message to a dedicated inbox and verify the recipient before reading the link. Never use a real employee's or customer's mailbox in automated recovery tests. This separation reduces accidental account lockouts and prevents a parallel test from consuming the wrong recovery email.

Treat reset links as secrets

A password-reset URL usually contains a one-time token or another bearer credential. Do not print the full URL, store it in a screenshot, attach the message to an unrestricted CI artifact, or paste it into an issue. Read the link in memory, validate the expected host, and follow it only in the isolated test browser context. Avoid sending reset tokens to third-party URL preview services.

Assert the complete recovery journey

Check that the request produces a reset message, that the link belongs to the expected test application, and that the application accepts it only once within its intended validity period. Submit a new password, confirm the success state, then verify the old password no longer works and the new password does. Include negative tests for expired, malformed, or reused links without exposing token values in test output.

Prevent cross-run contamination

Use unique resource IDs, clear test state between runs, and ensure cleanup does not delete shared fixtures. A failed reset test should report safe metadata such as run ID, elapsed time, and status code. Keep the inbox retention period long enough for debugging but short enough for the test policy. Disposable mailboxes are useful test infrastructure, not a secure place to store long-lived recovery secrets.