EveryRole

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.

The test cases for a login page that every list has are the right password and the wrong one. The ones that find bugs come after: logging in right after a wrong try, where the person lands, what a signed-in person gets at the login page, and what Back shows after logging out. We ran the whole list on our practice app. The password check was fine. Four other things were not.

Here is the list, then what the app really answered.

A login testing checklist

CaseWhat to doWhat must come out
Good loginThe test account’s email and passwordSigned in, on the page that was asked for
EmptyPress “Log in” with nothing typedThe form stays, and says which field is missing
Wrong formatnot an email as the emailA message at the email field
Wrong passwordThe right email, a wrong passwordA refusal that doesn’t say which of the two was wrong. The form is still there, the email kept
Unknown emailAn address with no accountExactly the same answer as the wrong password
Right after wrongA wrong password, then the right oneSigned in, on the page that was asked for
Other caseEditor@Example.com for editor@example.comYour decision. Usually: the same person
A pasted spaceThe email with a space after itSigned in, or a message that says why not
Already signed inOpen the login page while signed inSent on into the app
Back after log outLog out, press BackThe login page. Not the private page from the browser’s memory
A changed destinationChange the address the login returns toStays on your site

Eleven rows. The first five are the list everyone has. The rest is this post.

Negative test cases for a login page: the refusal

Start with the wrong password, because it sets up the rest.

The practice app's login page after a wrong password: the heading "Log in", a red message "Wrong email or password", and a link "Try again". There is no form on the page.
The practice app’s answer to a wrong password. The message is right. The page is a dead end.

Two things to read in that answer.

The message. “Wrong email or password” doesn’t say which. That is right: a login page that says “no account with this email” tells a stranger which addresses are registered. We compared the app’s answer to a wrong password with its answer to an unknown email, and the two pages are identical, status and all. Write that comparison into your case. The words can match while the status code or the response time gives it away.

The page. The form is gone. The email is gone. The person has to press “Try again” and type everything a second time, for one mistyped character in a password they couldn’t see. It is the same dead end we found in the empty form post, and it is the thing to look for on your own login page: after a refusal, is the form still there, with the email in it?

Right after wrong, and where you land

This is the case that separates a login test from a password test.

We started signed out and asked for the new item form. The app sent us to log in and remembered where we were going. Then we typed a wrong password, and then the right one.

One wrong password, and the app forgets where we were going.

Signed in, and on the list. The form we had asked for was forgotten. Logging in on the first try lands on the form, as it should. So the destination is kept through a good login and lost through one wrong password: the “Try again” link drops it.

No error anywhere. The login “works”. A person who followed a link from an email, mistyped once, and landed on a page that has nothing to do with the link will just think the link was wrong. Wrong then right is the least tested state of any form, and on a login form it has this extra way to fail.

Small differences in the email

Two rows that depend on a decision, so make the decision.

Our practice app refuses Editor@Example.com when the account is editor@example.com: “Wrong email or password”. A phone that capitalises the first letter is enough. A pasted space is kinder: the browser’s email field drops it before sending, so it logs in. Sent past the browser, the server refuses it, and a plain text email field would send the space on.

Whether case should matter is yours to choose. Whatever you choose, the sign-up form and the login form have to agree, or people register one way and can’t log in the other. That pair is a case in the sign-up list too.

Already signed in, and Back after log out

Already signed in. Open the login page in a tab where you are signed in. Our practice app shows the form again, as if nobody were there. In an app where logging in a second time makes a second session, or where the form logs you in as someone else while the other tab still shows the first account, it is the start of a confusing bug report.

Back after log out. Log out on a private page, then press the browser’s Back button. You must not see the private page again. Browsers keep pages in memory, and a page served without the right cache headers comes back with all its data, on a shared computer, for the next person. Our practice app has no log out, so we can’t show this one on it. It does send Cache-Control: no-store on every page, which is the header this case checks for.

A changed destination

The login page carried the address to return to in its own address: /login?next=/items/new. Anything in an address can be changed by whoever sends the link.

We tried two changes. With next=https://example.com/ the app ignored it and went to the list. Good. With next=//example.com/ the app sent the browser there, to another site, straight after a successful login. That is an open redirect, and it is the kind a quick check misses, because the first attempt is refused.

We are leaving the finding in this post because it is the honest result of running the last row.

What we didn’t cover

Many wrong passwords in a row. Decide what should happen (a pause, a lock, an email) and try it. Our practice app has no limit at all, which is a finding of its own. And second factors, which deserve their own list. The reset link has one already: forgot password test cases.

How EveryRole runs a login form

To EveryRole a login page is a form stop. Its main cases there are Good input, Wrong format (the email field states a format), Empty, and Wrong then right once the form has refused something. You approve each first result, and every later run compares with it, so a refusal message that changes, or a good login that starts landing somewhere else, comes back as “Result changed”.

It also signs in as each kind of user you gave a test login for at the start of their journeys, on every run, so a login that stops working shows up at the start of a run.

The four findings above are still ours, though. On this form the browser stops the empty and the wrong-format case before the server sees them, and no case sends a wrong password, so the dead-end refusal page is never reached. Today its Wrong then right loads the form again before the good input, so it doesn’t follow “Try again” and wouldn’t see the lost destination. And it doesn’t edit addresses, so the changed destination is a test for you.

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