QA Interview Hub · Knowledge base · Quizzes · Українська

QA Fundamentals › Situational questions

Testing a login form

A login form is tested by risk, not by a list: clarify the context (2FA, SSO), then go through layers from access to usability. The key points are the same response, including timing, for an unknown account and a wrong password, protection against guessing (429 with Retry-After) that cannot lock someone else's account, and a session with HttpOnly, Secure and SameSite cookies whose token is invalidated at logout.

QA Fundamentals · Situational questions

You are asked to test a login form. Start with a valid password or with the risks?

"How would you test a login form?" sounds like the simplest interview question, and that is why it reveals the level. A newcomer lists: a correct password, a wrong one, empty fields. This is not wrong, but such an answer resembles a list, not an approach, and it lacks what is really dangerous in a login: password guessing, leaking information about accounts, and a session that survives sign-out. This lesson is about the structure of the answer: where to start, what to prioritise and which traps separate a strong answer from a template one.

How it works and why. A login form is the entrance to all of a user's data, so the value of testing it is determined by risk, not by the number of cases. The structure of a strong answer is this: clarify the context (email or phone, is there 2FA, SSO), name what is at risk, go through the layers from the most important to the least and say what you automate. The layers: access (who got in and who did not), brute-force protection, session, fields, usability and accessibility. Priority is determined by impact: a defect that lets a stranger in or keeps the owner out matters more than a shifted label.

Two subtle points set an experienced answer apart. First: the error message and the response time must not reveal whether such an account exists. If for a non-existent email the message is different, the response is faster, or "Forgot password" says "no such user", an attacker goes through addresses and collects a customer base. Second: locking after several attempts protects against guessing, but if it is per account with no limits, anyone can lock somebody else's account, so the block and the delay are thought through together, not "there is a block, so all is well".

An error message: what it reveals

Bad

"Wrong password" / "User not found"

Different texts hint at which addresses are registered. The same goes for different response times.

Better

"Wrong email or password"

One text, one response code and a similar time for any failed attempt. An attacker sees no difference.

Figure 1. The same failed attempt: a response that reveals accounts and one that does not.

Example: from a list to an answer with structure. The typical answer:

I will enter a valid login and password, then wrong ones, then empty fields.
I will check that an error message appears.

It starts with valid data and does not touch the risks. The strong version:

0. Clarify: email or phone, is there 2FA or SSO, "remember me", what is at risk.
1. Access (P1): valid sign-in; wrong password; non-existent email.
   The response and the time in the last two cases are identical.
2. Brute force (P1): after N failed attempts a block, a delay or CAPTCHA.
   On the API: 429 and Retry-After. A block per account and per IP; does
   the block let an attacker lock out somebody else's account.
3. Session (P1): cookie HttpOnly, Secure, SameSite; after logout the old
   token gives 401; lifetime; parallel sessions.
4. Fields (P2): empty, spaces, email case, very long values,
   Unicode, SQL injection and XSS strings; the password is not in the URL or logs.
5. UX and accessibility (P2): Enter, Tab, label, show password, password manager.
6. Automation: items 1-3 as API tests in CI; items 4-5 manually and exploratory.

What changed here. The clarification at the start shows that the approach depends on the context: with 2FA or SSO the set of cases is different. Each layer has a priority, so if time is short it is clear what to keep. The first three items are the most valuable and automate best at the API level: there is no dependence on the markup, and 429, Retry-After and 401 after logout are verified stably. The talk about fields and usability is important but secondary. The ending "what I automate" shows that this is not a one-off manual check.

Extra details worth having ready. The session cookie with the flags HttpOnly (not accessible from JavaScript), Secure (only over HTTPS) and SameSite (limits cross-site requests). The response 401 for wrong credentials and 429 with Retry-After for exceeding the rate. Spaces at the start and end of a password must not be silently trimmed, and email case is usually normalised, while password case is not. After a successful sign-in the session identifier is renewed so as not to inherit the one that existed before sign-in.

Limits and alternatives. Not all items can realistically be checked manually: the lock behaviour is better checked with API tests with a controlled number of attempts, and timings need repeated measurements, because one response proves nothing. A full security test (guessing, session fixation) goes beyond functional testing, and here it is acceptable to say: I check the basics, and a deep check is done by security specialists. If the login goes through third-party providers (Google, SSO), scenarios of a cancelled sign-in, revoked access and mismatched account data are added. Finally, in an interview it is important not to read out everything: name the structure, go deeper into two or three items and ask what interests the interviewer more.

Common mistakes.

  • Starting with valid data and ending with empty fields: the risks stay outside the conversation.
  • Different messages for "wrong password" and "no such user": enumerating addresses becomes trivial.
  • Checking the lock and not asking whether it can be used to lock somebody else's account.
  • Checking that logout leads to the sign-in page and not checking that the old token no longer works.
  • Taking a single response as "proof" that there is no leak through timing.

Check yourself

After logout the user presses "Back" in the browser and sees their profile. Is it a bug, and what else do you check?

Answer

It may be a cached page in the browser rather than an active session, so you need to tell them apart: after logout repeat a request with the old token or cookie, and if the server returns data, the session was not invalidated and it is a serious bug. Also check the caching headers for protected pages and that the next request from the Back button redirects to sign-in.

A form locks the account for 15 minutes after 5 failed attempts. What security question is worth asking?

Answer

Whether this lets an attacker deliberately lock other people's accounts by entering 5 wrong passwords, and whether there is protection per IP and a delay that grows gradually. Also whether the behaviour is the same for non-existent accounts, otherwise the lock hints at which emails are registered.

In an interview. Junior: I would check sign-in with valid data, a wrong password, a non-existent email, empty fields and spaces, the error message, that the password is hidden and that the session ends after sign-out. Middle/Senior: First I clarify the context, the risk and whether there is 2FA or SSO, then I go by priority: access (the same response for failed attempts, without revealing accounts), brute-force protection (429, Retry-After, whether the block can lock somebody else's account), session (a cookie with HttpOnly, Secure, SameSite, token invalidation after logout). Then fields, UX and accessibility. I automate the first three at the API level and check the rest manually and exploratively.

More articles in this chapter