Notes
Password logins
Every login form needs these cases. A valid login lands the right user on the right page. A wrong password and an unknown email give the same generic message, so attackers cannot discover which emails have accounts. Email case, spaces and unusual characters. Empty and very long input. Pasting into the password field. Rate limiting or lockout after repeated failures. Logout that really ends the session. And redirecting back to the page you came from.
- valid login → right user, page
- wrong password / unknown email → SAME generic message
- email case, spaces, Unicode
- empty fields, very long input
- show/hide password, paste
- lockout or rate limit after repeated failures
- logout really ends session
- redirect back after login
ShopRung, checked
We checked ShopRung's login API. Wrong password and unknown email both return four oh one with the same message, email or password is wrong. Good. Alice's email in capitals logs in, so emails are not case sensitive. A short password at signup gets four hundred, password must be eight to sixty four characters. But eight failed logins in a row all returned four oh one, with no lockout or slow down. In a real product, that gap would be worth raising.
wrong password 401 "Email or password is wrong" unknown email 401 "Email or password is wrong" → same message: good ALICE@shoprung.test → 200 (email not case sensitive) signup "short" → 400 "Password must be 8 to 64 ..." 8 failed logins in a row: 401 × 8, no lockout
MFA and codes
Multi factor authentication adds a second step: a code from an authenticator app, a text message or an email. Test expired codes, reused codes and wrong codes. To automate app codes, give the test account a known test secret and generate the current code in the test with a TOTP library. For text and email codes, use test inboxes or the provider's test API, never personal phones. Also test recovery codes and remember this device.
- codes by app (TOTP), SMS or email; expired, reused, wrong
- automating TOTP: generate the code from a TEST secret
- SMS/email: test inboxes or APIs, never real phones
- recovery codes, "remember this device"
- never: disable MFA in prod to make tests pass
Passkeys
Passkeys use public key cryptography through a web standard called WebAuthn. At registration, the authenticator, such as a phone, a laptop or a security key, creates a key pair just for that site, and the server stores only the public key. At sign in, the server sends a random challenge, and the device signs it after a fingerprint, face or PIN check. There is nothing to type and nothing to phish, because the key only works on the real domain.
- register: the authenticator makes a key pair for THIS site; server stores the public key
- sign in: server sends a challenge; device signs it after fingerprint, face or PIN
- nothing secret to type or phish; bound to the domain
- standard: WebAuthn (FIDO2)
Virtual authenticator
An automated test cannot press a fingerprint reader. Browsers support a virtual authenticator instead. In Playwright with Chromium, open a Chrome DevTools protocol session, enable WebAuthn, and add a virtual authenticator: CTAP two, an internal platform authenticator like a laptop's, able to store passkeys, with user verification that succeeds. Selenium offers the same idea through its virtual authenticator API.
const cdp = await page.context()
.newCDPSession(page);
await cdp.send("WebAuthn.enable");
const r = await cdp.send(
"WebAuthn.addVirtualAuthenticator",
{ options: {
protocol: "ctap2",
transport: "internal",
hasResidentKey: true,
hasUserVerification: true,
isUserVerified: true } }); Run for real
ShopRung has no passkeys, so we built a tiny demo page on localhost and tested it. Clicking create passkey registered a credential, and the virtual authenticator showed one stored passkey for localhost. Signing in worked. Then we switched user verification off, as if the fingerprint check failed, and the sign in attempt failed with a not allowed error. All in one test, passing in one second.
click "Create passkey"
→ "registered public-key"
WebAuthn.getCredentials
→ 1 credential, resident,
rpId "localhost"
click "Sign in with passkey"
→ "signed in public-key"
setUserVerified(false), retry
→ "error NotAllowedError"
1 passed (1.0s) Passkey cases
Passkey test ideas. Register, sign in and sign out. Verification failing or the user cancelling, which should give a clear message, not a frozen page. Several passkeys on one account, and removing one. Fallbacks to a password or account recovery. A subdomain or wrong domain, where the passkey must not work. An account with no passkey. And signing in on a laptop with a phone by scanning a QR code, which is best tested manually on real devices.
- register, sign in, sign out verification fails or is cancelled → clear message
- several passkeys per account; remove one fallback: password, recovery
- wrong domain / subdomain
- account with no passkey
- cross-device: phone QR flow (manual)
Third-party sign-in
Sign in with Google or a company's single sign on is common. Do not automate the real provider's login page: it has bot detection and CAPTCHAs, changes without notice, and its terms often forbid it. Instead, use test accounts in a test tenant, a mock identity provider, or tokens obtained through an API and loaded as storage state, as in the fixtures episode. Then test your own callback handling directly.
- do not automate the real provider's page (bot checks, CAPTCHAs, flaky, terms)
- instead: test accounts in a test tenant, or mock the identity provider
- or get tokens via the API and load storageState
- test the callback page itself
Common mistakes
Login testing mistakes. Testing only the happy path. Personal phones for text message codes. Automating real Google or Microsoft login pages. Turning multi factor off in every test environment, so it is never tested at all. Passwords in code, logs or screenshots. And never testing rate limits or lockouts, the gap we just saw on ShopRung.
- only testing the happy path
- real personal phones for SMS codes
- automating real Google/ Microsoft login pages
- MFA turned off in test envs forever (untested)
- passwords in code or logs
- no lockout/rate-limit tests
Say it like this
In the interview: I use a virtual authenticator, through the WebAuthn domain of the Chrome DevTools protocol in Playwright, or Selenium's virtual authenticator support. I test registration, sign in, failed or cancelled verification, multiple and removed passkeys, password and recovery fallbacks, and that passkeys only work on the right domain. Cross device QR flows I check manually on real phones.
- "With a virtual authenticator: CDP WebAuthn in Playwright or Selenium's virtual
- authenticator. I test
- registration, sign-in, failed
- or cancelled verification, multiple and removed passkeys, fallback and recovery, and the domain binding. Cross-device
- QR flows I check manually."