Back to API Practice

Security/Auth path · Step 1

Login API Testing Practice

Edit a fake Login API request, inspect realistic auth responses, then write what you would test and compare your answer with structured API QA checklist coverage.

POST/api/auth/login
Auth PublicSuccess 200 OK
Rules
  • Generic errors, rate limits, and account states

Interactive sandbox

Try the request, inspect the response

Edit the request body, choose auth conditions, send a simulated POST /api/auth/login request, and inspect the fake API response. No real data is sent.

1. EDIT REQUEST

Build the login request

POST/api/auth/login
application/json

Test case presets

Choose a case, inspect the fake response, then write what you would test.

Happy path

2 Cases

Validation / contract

6 Cases

Credential / account states

5 Cases

2. INSPECT RESPONSE

Fake API result

Send a simulated request to see the HTTP status, JSON response, QA note, and the risks this case should make you mention in your answer.

3. WRITE TEST IDEAS

Test Ideas Notebook

List contract checks, valid email/username login, missing fields, wrong password, unknown users, account states, MFA, token/session behavior, security, rate limiting, observability, and reliability.

Use Markdown lists to organize your test ideas.

Ready to evaluate: include happy path, negative cases, auth, data, errors, and observability.

Resources / Test Checklist

Rules
  • Generic errors, rate limits, and account states
Endpoints
  • POST /api/auth/login
Headers
  • Review request headers in the API Reference.
Scenarios
  • Happy path
  • Negative cases
  • Data rules
  • Security/API risks
  • UX/performance

4. COMPARE ANSWER

API ReferenceEndpoint, request fields, responses, and business rulesExpand

API reference

Login endpoint

Use this reference while you experiment in the sandbox and write test ideas.

Endpoint

POST/api/auth/login

Identifiers

Email/password or username/password if username login is supported

Request body

{
  "email": "qa.user@example.com",
  "password": "Password123!",
  "rememberMe": false
}

Authentication

No bearer token required

Success response

200 OK

Success response body

{
  "accessToken": "eyJhbGciOi...",
  "refreshToken": "rt_fake_refresh_token",
  "tokenType": "Bearer",
  "expiresIn": 900,
  "user": {
    "id": "usr_123",
    "email": "qa.user@example.com",
    "role": "user",
    "status": "active"
  }
}

Business rules

  • email or username is required
  • password is required
  • invalid credentials return a generic safe error
  • unknown users return the same error as wrong password
  • locked, disabled, and unverified users follow product policy
  • MFA-enabled users receive a challenge before full tokens
  • rate limiting protects repeated attempts
  • rememberMe changes session lifetime only according to requirements
  • passwords and tokens are never logged or exposed
  • successful and failed authentication events are logged safely

API interview guide

What this Login API practice covers

This scenario trains API test design for authentication endpoints where credential validation, account states, token creation, and safe error handling all matter.

Key risks covered

  • - Valid email or username login with the expected token response.
  • - Missing identifiers, missing passwords, malformed emails, wrong passwords, and unknown users.
  • - Locked, disabled, unverified, deleted, and MFA-required account states.
  • - Generic errors that prevent user enumeration and brute-force clues.
  • - Rate limiting, secure token/session behavior, password exposure checks, and auth telemetry.

Example interview prompt

How would you test a Login API that accepts email or username plus password and returns access and refresh tokens?

Common mistakes

  • - Only testing valid login and wrong password.
  • - Forgetting locked, disabled, unverified, and MFA-enabled users.
  • - Not checking token response schema, safe errors, logging, or rate limiting.