How would you test an authorization-code flow with PKCE?
Answer
Verify exact registered redirect handling, unpredictable state and nonce where applicable, one-time short-lived authorization codes, and a valid verifier for the original challenge. Test missing, wrong, replayed and intercepted codes; issuer and audience confusion; canceled consent; refresh-token rotation; logout and session mix-up across tabs. Confirm secrets and tokens never appear in URLs, logs or browser storage outside the design.
Strong answer includes
- covers state, nonce, PKCE verifier and replay resistance
- tests issuer, audience and redirect validation
- checks token storage, rotation and leakage
Practical example
A test intercepts the authorization code from a network log and replays it in a second browser session after the legitimate exchange already happened; a correctly implemented flow rejects the replayed code because it was already consumed, while a buggy implementation that reuses codes issues a second valid token pair to an attacker.