← ClaudeAtlas

mfa-flow-test-authorlisted

Use when multi-factor login needs automated tests or a new second factor is being added: deterministic TOTP and HOTP codes, SMS or email OTP, WebAuthn passkeys via the Chrome virtual authenticator, recovery codes, enrollment and step-up challenges.
testland/qa · ★ 13 · Testing & QA · score 83
Install: claude install-skill testland/qa
# mfa-flow-test-author ## Overview This skill is the per-flow test recipe for multi-factor authentication. It covers the six second-factor mechanisms most commonly found in production systems. Neighbour skills handle the first-factor and session layers: `oauth-flow-test-author` covers the primary OAuth/OIDC token flow; `session-management-test-author` covers the post-authentication session lifecycle. ## Shared setup All test patterns below require a known, fixed second-factor secret in the test environment. Never use production secrets in tests. Provision per-run secrets using the relevant library and store them in the test fixture. ```python # Common imports used across patterns in this skill import base64, hashlib, hmac, struct, time import pyotp # pyauth.github.io/pyotp ``` ## Step 1 - TOTP (RFC 6238) Per [RFC 6238 §4.2][rfc6238], TOTP = HOTP(K, T) where T = floor((t - T0) / X), T0 = Unix epoch 0 and X = time step (default 30s). TOTP is testable because it is deterministic: a fixed secret + fixed `for_time` always yields the same code. Generate the expected code with `pyotp.TOTP.at(for_time)` ([pyotp][pyotp]) and compare it against what the server accepts. Interoperability test vectors are in [RFC 6238 Appendix B][rfc6238-b]: ASCII secret `12345678901234567890` at Unix time 59 produces `94287082` with SHA-1. ```python import pyotp def make_totp_fixture(digits=6, interval=30): """Return a base32 secret and the matching pyotp.TOTP instance.""" secr