QA testing JWT-based authentication is more than checking if a user can sign in. It’s about verifying the entire trust chain that keeps APIs secure. JSON Web Tokens (JWT) carry claims about identity and permissions. If these claims are wrong, forged, or expired, the system breaks.
Start with token generation. Ensure the server signs tokens with a strong algorithm, usually HS256 or RS256. Validate that the payload contains only expected claims. Check issued-at (iat), expiration (exp), and not-before (nbf) fields. Manipulate them in tests to confirm the server rejects invalid times.
Next, target signature verification. Use a tampered token with a correct header and payload but a wrong signature. The API must deny it. If the system lets it through, the signature check is broken. Test across microservices to confirm consistent verification.
Test token storage and transport. JWTs should never appear in URLs. They belong in secure HTTP-only cookies or Authorization headers using the Bearer scheme. In automated QA, simulate XSS and CSRF attacks. The goal is to see if tokens can be stolen or reused.
Run expiry tests. Try requests with expired tokens and with tokens near expiration. Check refresh logic. If refresh generates a token without re-authentication when policy requires it, report it.