EveryRole

Password reset test cases: the email, the link, the reuse

Password reset test cases for a forgot password flow: the request, the email, a link that works once and then expires, and an old password that stops working.

Password reset test cases, for any forgot password flow, are about one object: the link in the email. It has to work once. It has to stop working after that, and after a set time, and when a newer link exists. And when it has done its job, the old password must be dead. The lists we read test the form that asks for the link and stop when the email arrives. The bugs are in what the link still does afterwards.

Here is the list, in the order the link lives.

The life of a reset link. Asked for: the page answers the same for any address. Sent: one email with a link to the live site. Used once: a new password is set and the old one stops working. From there on the link must be dead: refused when used a second time, when it is past its time, and after a newer link was asked for.
Three things the link must do, and three ways it must be dead. An honest note: our practice app has no password reset, so this post’s pictures are drawn, not photographed.
CaseWhat to doWhat must come out
A real accountThe test account’s addressA message that a link was sent if the account exists. One email
No accountAn address nobody registeredThe same message, word for word. No email
EmptyPress the button with nothing typedThe form stays and says the address is missing
Wrong formatnot an emailA message at the field
Asked twiceThe same address, two requestsTwo emails. Decide which link works: we say only the latest
Asked ten timesTen requests in a minuteA limit, said in words. Not ten emails in someone’s inbox
From the login pagePress “Forgot password?” after a wrong passwordThe request page opens, with the address carried over if you decided it should be

The second row is the one to look at twice.

The reset page asked about an address with no account, drawn two ways. The first answers "No account with this email address." The second answers "If this address has an account, a reset link is on its way."
The first answer lets anyone find out who has an account. The second gives nothing away.

Compare the two answers the way a script would: the words, the status code, and roughly how long each took. If any of the three differs between a real account and nobody, the page is telling strangers who your users are. It is the same check as “wrong password” against “unknown email” on the login page.

2. The email

  • It arrives, in a time you chose and wrote down.
  • Its link points at the live site. Read the link’s address. A reset link to a staging host is a leftover we look for, and it is found only by opening a real email.
  • It contains no password. Not the old one, not a new one. Only a link.
  • It says what to do if you didn’t ask. Someone else may have typed your address.

For a test to read that email it needs an inbox of its own. We wrote that up separately in how to test email verification.

This is the part to spend the time on.

CaseWhat to doWhat must come out
The link, onceOpen it, set a new passwordThe password is changed, and the app says so
The link, twiceOpen the same link againRefused, in the app’s own words, with a way to ask for a new link
Back and send againAfter setting the password, press Back and send the form againRefused. The password is not changed a second time
An older linkAsk twice, use the first email’s linkRefused, if you decided only the latest works
A changed linkChange the last characters of the link’s addressRefused the same way as a used link. No server error
Reset link expiryUse a link after its lifetimeRefused, with a way to ask again
Another accountWith two test accounts, open A’s link and change any account id or address in the form or the link to B’sOnly A’s password changes. B’s still works

On expiry. Pick the lifetime, write the number into the test case, and test both sides of it: just before, it works, and just after, it doesn’t. That is a boundary like any other. Waiting an hour in a test is not practical, so ask for one of two things: a setting that shortens the lifetime on staging, or a way to make a link that is already old. If neither exists, keep one link overnight and try it in the morning. A slow test is still a test.

On the link’s address. The secret is in the address, so the page it opens must not hand that address to anyone else. If the reset page loads scripts or images from other sites (analytics, a chat widget), open the browser’s network panel and check that none of those requests carries the full link, in a Referer header or anywhere else. A Referrer-Policy of no-referrer on that page closes the usual leak.

On reset token reuse. “Twice” is ordinary use. Some mail programs and link scanners open links before the person does, and people double-click. So the second opening must not be a crash, and it must not let anyone set a password again.

4. After the new password

The link has done its job. Four things should now be true, and the first is the one a password reset exists for.

  1. The old password no longer works. Log out, try the old one, expect the login’s usual refusal. It is easy to forget, because nothing on screen reminds you to try it.
  2. The new password works, on the login page, typed by hand.
  3. Other sessions are signed out, if that is what you decided. Stay logged in on a second browser, reset the password in the first, then reload the second. Someone resets a password because they fear another person has it. That other person should not stay logged in.
  4. The account’s owner is told. A short “your password was changed” email, for the case where the owner didn’t do it.

And the new password itself follows the same rules as at sign-up: the minimum length, the confirmation that must match, and whether the old password may be chosen again. Whatever the sign-up form refuses, this form must refuse too. The two are written at different times, and nothing makes them agree.

The forgot password test cases to run first

If you are short of time, run these four by hand, in this order:

  1. Ask for a link with an address that has no account. Read the answer.
  2. Ask with the test account, open the link, set a new password.
  3. Open the same link again.
  4. Log in with the old password.

Three of the four have a wrong answer that is a real security problem: telling strangers who has an account, a link that works for ever, or an old password that still opens the door.

Where EveryRole stands on this

We’ll be plain about what it covers. The page that asks for the link is a form, so it gets a form’s main cases: good input, empty, wrong format, and wrong then right once the form has refused something.

The link’s life is part of a longer test: EveryRole signs up a brand-new account through an inbox of its own and walks it through log in, log out and a password reset. That test is off until you turn it on, because it makes a real account each time. With it on, one stop asks for the reset email, opens its link, sets a new password and logs in with it. An extra case, off until you choose it, then tries the old password and opens the same link a second time.

It doesn’t test an older link, the link’s lifetime, another account’s link, a limit on requests, other sessions, or whether the page answers the same for an address with no account. Each of those needs a decision from you first (the lifetime, which link wins, what happens to other sessions), so today they are yours to run by hand or to script.

Keep reading

Sign-up, login and passwords

How to test email verification, from inbox to app

How to test email verification end to end. The test has to read the real email, so give it an inbox of its own, a new address per run, and five things to check.

6 min read

Sign-up, login and passwords

Test cases for a login page, beyond the password

Test cases for a login page beyond right and wrong passwords: right after wrong, where you land, already signed in, Back after log out, with real answers.

6 min read