Authentication Testing

MFA and 2FA Test Cases That Prove the Challenge Belongs to the Right User and Session

60 practical cases for challenge binding, OTP/TOTP, replay prevention, trusted devices, recovery and step-up access.

2026-07-28 Approximately 16 min read

Accepting a correct verification code does not prove that multi-factor authentication works.

A complete MFA or two-factor authentication test must verify that:

  • the application requires the additional factor at every intended entry point
  • the challenge belongs to the intended identity, session and protected operation
  • the user cannot reach the protected state after primary credentials alone
  • valid proof is accepted only within its permitted window
  • expired, malformed, replayed and cross-user proof is rejected
  • resend and concurrent challenges follow one explicit validity policy
  • successful proof is consumed and cannot elevate another session
  • trusted-device state expires and can be revoked
  • recovery and factor replacement do not create a weaker authentication path
  • step-up verification elevates only the intended session or sensitive action

This guide contains 60 practical MFA and 2FA test cases covering trigger rules, enrollment, OTP and TOTP, push approval, backup codes, remembered browsers, recovery, factor replacement and session elevation.

This guide starts after primary credentials are evaluated. Use the Login Page Test Cases guide for the first-stage credential, identity and redirect flow.

MFA testing flow showing challenge issuance, factor verification, one-time consumption and session elevation
MFA testing flow showing challenge issuance, factor verification, one-time consumption and session elevation

The Minimum MFA Smoke Test

When release time is limited, begin with these ten cases.

Minimum Mfa Smoke Test
IDTestWhat it proves
MFA-01Complete the required MFA flow with an enrolled active accountThe primary supported journey reaches the protected state.
MFA-03Open a protected route after primary credentials but before the second factorThe pre-MFA session is not treated as fully authenticated.
MFA-05Complete the challenge in a different browser sessionThe challenge is bound to the intended authentication transaction.
MFA-13Finish enrollment with the first valid factor proofA factor is not active until its possession is verified.
MFA-25Submit a valid current OTP or TOTPThe expected factor proof is accepted.
MFA-30Submit an expired proofTime-limited proof is rejected.
MFA-33Reuse a proof after successful verificationSuccessful proof is one-time and replay-resistant according to policy.
MFA-34Use User A's code during User B's challengeProof is bound to the intended account.
MFA-50Change a security-sensitive account setting after trusting a browserRemembered-device state can be revoked.
MFA-58Complete step-up verification for one sensitive actionOnly the intended session or operation receives elevated access.

The smoke set verifies the transaction boundary. It does not replace provider integration tests, protocol conformance, penetration testing or full session-management coverage.

Define the MFA Acceptance Contract First

The phrase “MFA succeeded” is too vague to produce reliable tests. Define the contract before writing cases.

Define Mfa Acceptance Contract
Contract elementQuestion to answer
Entry pointWhich login methods, devices, recovery paths and sensitive actions require MFA?
Primary stateWhat may the user access after the first factor but before the next factor?
Challenge identityWhich user account owns the challenge?
Challenge transactionWhich browser session, device, tenant or protected operation owns it?
FactorWhich enrolled authenticator is being verified?
ValidityWhen does the proof start and stop being acceptable?
CompetitionWhat happens after resend, a second tab or a newly issued challenge?
AttemptsWhich retry, cooldown and notification rules apply?
ConsumptionWhen is the proof permanently marked used?
Session elevationWhat authenticated level, action or resource becomes available after success?
Trusted deviceHow is remembered-browser state created, expired and revoked?
RecoveryHow can a lost factor be replaced without lowering assurance?
EvidenceWhich browser, API, provider, identity and session observations prove the outcome?

Example MFA acceptance contract

Define Mfa Acceptance Contract
Input stateExpected browser resultExpected system result
Valid password + enrolled TOTPTOTP challenge is shownPre-MFA session exists but protected access is not granted
Valid current TOTP for the same challengeUser reaches the permitted destinationProof is consumed and the intended session is elevated
Expired TOTPChallenge remains unresolved with a recoverable errorNo protected session elevation
Valid code issued to another accountGeneric rejectionNo cross-account authentication
Resend requestedA new delivery state is shownOld/new challenge validity follows the documented policy
Trusted browser still within policyMFA may be skipped only where policy permitsRemembered-device evidence is valid for this account and device
Sensitive action requires step-upVerification is requested before executionOnly that session or action receives elevated authority

Model MFA as a Challenge Lifecycle

MFA challenge lifecycle from primary authentication through challenge issuance, validation, consumption and protected session elevation
MFA challenge lifecycle from primary authentication through challenge issuance, validation, consumption and protected session elevation

MFA is a stateful transaction. Model its transitions before selecting test data.

  1. Primary authentication evaluated
  2. MFA required
  3. Challenge issued
  4. Challenge delivered or presented
  5. Proof submitted
  6. Proof validated
  7. Challenge consumed
  8. Intended session or action elevated
  9. Protected state reached

Alternative outcomes

  • Challenge denied
  • Challenge expired
  • Challenge superseded
  • Challenge rate-limited
  • Factor unavailable
  • Recovery required
  • Factor replacement pending

Prohibited transitions

Prohibited MFA transitions
StateMust not transition to
Primary credentials onlyFully authenticated
Expired or consumed proofSession elevated
Proof for User AUser B authenticated
Successful step-up for Action AUnrelated Action B authorised

MFA Trigger and Pre-Challenge State Test Cases

Mfa Trigger Pre Challenge
IDScenarioExpected resultEvidence
MFA-01Complete the required MFA flow with an enrolled active accountThe user reaches the intended protected state only after all required factors passRedirect chain, identity, challenge and session state
MFA-02Submit invalid primary credentialsNo MFA challenge is issued and no pre-authenticated transaction is createdRequest count, challenge store and browser state
MFA-03Open a protected route after valid primary credentials but before MFAAccess is denied or redirected to the unresolved challengeProtected-route response and session level
MFA-04Start primary authentication as User A and attempt to finish as User BThe second stage remains bound to User A or the transaction is invalidatedChallenge owner and final identity
MFA-05Open the challenge in another browser context or sessionThe proof cannot complete an unrelated transaction unless the product explicitly supports a safe cross-device flowSession IDs and verification result
MFA-06Submit primary credentials repeatedly while the first challenge is pendingChallenge creation follows a deterministic duplicate policyChallenge count and active challenge state
MFA-07Refresh, use Back, or reopen the pending challenge URLThe page restores or rejects the pending state according to policy without granting accessHistory, URL and protected-route result
MFA-08Use each supported authentication entry point: local login, federated login, mobile web, deep link or APIMFA is enforced consistently wherever policy requires itEntry-point matrix and final session level

OWASP recommends reviewing every authentication method and checking that the second stage cannot be skipped through force-browsing or direct API requests.

Enrollment and Factor Binding Test Cases

Mfa Enrollment Factor Binding
IDScenarioExpected resultEvidence
MFA-09Start enrollment from an authenticated accountEnrollment requires the configured reauthentication or step-up conditionSession age, reauthentication prompt and API result
MFA-10Scan the QR code or enter the displayed secretThe authenticator is provisioned for the intended account and issuerProvisioning data and generated proof
MFA-11Enroll two accounts or factorsEach receives a distinct factor record and secret or credentialFactor identifiers and verification output
MFA-12Leave enrollment before verifying the first proofThe unverified factor does not become activeAccount factor list and next login
MFA-13Submit the first valid proof during enrollmentThe factor becomes active only after possession is confirmedEnrollment response and factor status
MFA-14Cancel enrollment or fail the confirmation stepExisting factors remain unchanged and partial setup is cleaned up or expiresOld factor login and pending record
MFA-15Add a second factor to an account that already has MFABoth factors follow the documented selection, fallback and recovery policyFactor list and challenge choices
MFA-16Remove or replace a factorThe change requires appropriate reauthentication, affects only the intended factor and generates the configured notificationFactor status, audit event and notification

Challenge Issuance and Delivery Test Cases

Mfa Challenge Delivery
IDScenarioExpected resultEvidence
MFA-17Issue an email, SMS, voice or push challengeThe challenge is sent to the enrolled destination for the intended accountMasked destination, provider event and challenge owner
MFA-18Inspect the challenge screen and delivery messageSensitive contact details are masked and no factor secret is exposedRendered UI and response payload
MFA-19Trigger one authentication requestOne intended challenge transaction is created without duplicate messagesChallenge and provider message counts
MFA-20Request resend while the first proof is pendingThe UI and backend apply the documented resend cooldown and challenge policyCountdown, response and active challenge list
MFA-21Submit the old and new proofs after resendOnly the proof or proofs permitted by the explicit policy are acceptedBoth verification responses and challenge state
MFA-22Delay provider delivery until near or beyond expiryLate proof is accepted or rejected according to challenge validity, not delivery timestamp aloneIssue time, delivery time and verification result
MFA-23Simulate provider failure, blocked email, unavailable phone or push errorThe user receives a recoverable state without premature access or endless spinnerProvider error, UI message and session level
MFA-24Generate repeated resend and failed-verification requestsRate limits and cooldowns apply; generating a new proof does not silently reset the failed-attempt policyAttempt counters, provider events and responses

OTP and TOTP Verification Test Cases

Otp Totp Test Cases
IDScenarioExpected resultEvidence
MFA-25Submit the valid current OTP or TOTPThe intended challenge is satisfied and the proof is consumedVerification response, challenge state and session level
MFA-26Submit an incorrect code of the expected formatVerification fails without elevating the sessionError and protected-route result
MFA-27Submit a code with wrong length, characters or separatorsInput is rejected consistently by browser and server rulesUI validation and direct API response
MFA-28Submit a valid code beginning with zeroThe value is treated as a string and retains leading zeroesSubmitted payload and verification result
MFA-29Submit an empty proof or whitespaceThe challenge remains unresolved and the required error is accessibleField state and absence of elevation
MFA-30Submit a proof after its validity windowThe proof is rejected and cannot elevate the sessionIssue time, server time and response
MFA-31Submit a TOTP at the current/previous time-step boundaryAcceptance follows the configured clock-skew windowControlled clock, step number and response
MFA-32Submit a proof from a future or out-of-policy time stepThe proof is rejected outside the configured drift policyControlled clock and verification result
MFA-33Reuse a proof after successful verificationThe duplicate proof is rejected and cannot elevate another transactionSecond response, challenge consumption and session state
MFA-34Use User A's valid proof for User B's challengeVerification fails because the proof is bound to the intended accountChallenge owner and final identity
MFA-35Use a valid proof in another tab, browser session or protected operationVerification fails unless the product explicitly binds and permits that transactionChallenge/session IDs and target operation
MFA-36Submit the same proof concurrently from two requestsAt most one transaction succeeds; consumption is atomicParallel responses and final challenge state

The validity window must be an explicit system policy. RFC 6238 recommends a 30-second TOTP step as a security/usability balance and requires a verifier not to accept a successfully used OTP again. NIST also requires one-time acceptance during the validity period and rate limiting for short authentication secrets.

Push Approval and Transaction-Binding Test Cases

Push Transaction Binding
IDScenarioExpected resultEvidence
MFA-37Approve the correct current push promptThe intended challenge succeeds and the intended session or action is elevatedPush event, challenge ID and protected result
MFA-38Deny the push promptThe transaction remains unauthenticated and the browser receives the correct denial statePush decision and browser result
MFA-39Ignore the prompt until timeoutThe challenge expires without silent approval or indefinite pending stateTimeout event and session level
MFA-40Approve a stale prompt after a newer challenge existsThe stale prompt is rejected or handled according to one explicit challenge policyPrompt IDs and verification result
MFA-41Generate repeated push promptsNotification count and frequency are limited to reduce accidental approval and abuseProvider events, cooldown and responses
MFA-42Verify a push or number-matching prompt for a sensitive transactionDisplayed account, amount, destination or number matches the operation being authorisedPrompt details and final operation record

Backup Code and Trusted-Device Test Cases

Backup Code Trusted Device
IDScenarioExpected resultEvidence
MFA-43Use one valid unused backup codeThe intended account is authenticated and that code becomes consumedCode status and final identity
MFA-44Reuse the consumed backup codeVerification is rejectedSecond response and code status
MFA-45Generate a replacement set of backup codesOld unused codes are invalidated if that is the documented policyOld/new code verification and generation event
MFA-46Consume the final backup codeThe product shows the configured exhausted-code warning or recovery route without exposing codesRemaining count and UI state
MFA-47Choose to trust or remember the browser after successful MFARemembered-device state is created only after completed MFA and for the intended accountCookie/storage attributes and next login
MFA-48Sign in from a new browser profile or deviceMFA is required when trusted-device evidence is absentSeparate context and challenge trigger
MFA-49Use the remembered browser after its validity periodMFA is required again according to policyControlled time and challenge trigger
MFA-50Change password, replace factor, revoke devices, report compromise or perform another configured security eventTrusted-device state is revoked where policy requires itOld trust token and next authentication

Recovery and Factor-Replacement Test Cases

Mfa Recovery Factor Replacement
IDScenarioExpected resultEvidence
MFA-51Start recovery after losing the enrolled deviceRecovery begins without treating the active browser session as sufficient proof by itselfRecovery entry, session level and required evidence
MFA-52Complete the approved identity-recovery pathOnly the intended account can regain factor-management accessIdentity evidence, recovery decision and audit event
MFA-53Attempt to replace MFA using a weaker alternative such as generic security questions aloneThe weak fallback is rejected or augmented according to policyRecovery response and factor status
MFA-54Replace a factor while another enrolled factor remains availableThe user reauthenticates with an existing approved factor before replacementReauthentication and change response
MFA-55Complete factor replacement and try the old factorThe old factor is invalid, the new factor works, and the account receives the configured notificationBoth verification results and notification
MFA-56Perform an administrator-assisted MFA resetPending challenges and relevant remembered-device/session state are revoked according to policy and the action is auditedAdmin event, factor list, sessions and next login

OWASP treats MFA recovery and factor replacement as high-risk flows. Recovery should not become an easier bypass, and changing a factor should require suitable reauthentication rather than relying only on an active session.

Step-Up Authentication and Session-Elevation Test Cases

Step Up Session Elevation
IDScenarioExpected resultEvidence
MFA-57Open a sensitive action that requires recent or stronger authenticationThe action is paused and the configured step-up challenge appearsAction state and challenge context
MFA-58Complete step-up verification for the sensitive actionOnly the intended session, tenant and operation receive the configured elevationSession assurance, operation result and audit event
MFA-59Wait until the step-up assurance window expiresThe sensitive action requires verification again while the base session follows its own policyControlled time and assurance state
MFA-60Cancel or fail step-up verificationThe protected action remains blocked and the base session is preserved or terminated exactly as documentedAction result, base session and error state

The Most Important MFA Failure Patterns

MFA failure patterns including bypass, cross-user code, replay, multiple active challenges, stale trusted device and weak recovery
MFA failure patterns including bypass, cross-user code, replay, multiple active challenges, stale trusted device and weak recovery

The second step is visible but not enforced

A browser may show an MFA screen while a direct protected URL, API endpoint, alternative login flow or backend route accepts the pre-MFA session. Verify enforcement at the resource boundary, not only the visible navigation.

A code for User A verifies User B

This is a challenge-binding failure. Record the account and challenge identifiers before submission and assert the final identity after verification.

Resend creates several valid challenges

Multiple simultaneously valid proofs enlarge the attack and race-condition surface. Define whether resend supersedes the old challenge or whether a bounded set remains valid, then test both orders.

The proof is accepted twice

A one-time proof must be consumed atomically. Parallel or repeated submissions should not elevate two sessions or operations.

The session is elevated before verification

Primary credentials may create a restricted transaction, but protected routes and privileged APIs must still recognise that MFA is unresolved.

A trusted-device cookie survives a security change

Remembered-browser state can become a durable bypass after password changes, factor replacement, device revocation or suspected compromise unless explicit invalidation rules exist.

Recovery is weaker than the factor it replaces

A simple email link, generic security question or support shortcut can nullify stronger MFA. Test recovery as an authentication flow, not as an account-settings convenience.

Step-up verification elevates the wrong action or session

Successful verification for one transfer, tenant, browser tab or admin operation must not authorise unrelated actions.

Choose the Right MFA Test Environment

The correct automation method depends on what the test needs to prove. Do not use one bypass for every case.

Mfa Test Environment
Environment patternUse it to proveDo not claim
Real provider and real deviceEnd-to-end delivery, device prompts, carrier/provider delay, platform behaviourDeterministic CI stability for every regression test
Provider sandbox or controlled test inbox/numberDelivery integration, message parsing and known failure modesProduction carrier or spam-filter behaviour
Seeded TOTP factor in a test accountDeterministic current, boundary, drift and replay casesSecure production secret storage or device compromise resistance
Explicit test-only authenticator adapterApplication state transitions and negative outcomes without external latencyThat the real provider integration works
Prepared post-MFA browser stateUnrelated authenticated workflows where MFA is setup onlyThat the MFA journey itself still works
Manual checkpoint or device-assisted runHardware keys, biometric prompts or approvals that cannot be safely simulatedFully unattended coverage

Do not build a hidden MFA bypass. Use explicit test-only providers, isolated fixtures or prepared states that cannot exist in production. A query parameter, magic header, hard-coded account or undocumented endpoint that skips MFA is a security defect, not a testing strategy.

What Each Testing Layer Can Prove

Mfa Testing Layers
LayerWhat it can verifyWhat it cannot prove alone
Browser testTrigger rules, challenge UI, resend, accessible errors, redirects, trusted-device behaviour and protected navigationSecret generation, provider delivery internals or complete server enforcement
Authentication API testChallenge ownership, proof validation, expiry, replay, attempts and structured errorsReal browser cookies, accessibility or external delivery
Provider integration testSMS, email, push or identity-provider request/response behaviourThe application applies the result to the correct user session
Identity/factor store testEnrollment status, factor replacement, backup-code state and revocationCorrect end-user presentation
Session/authorisation testPre-MFA restrictions, assurance level, step-up scope and protected resourcesFactor delivery and user recovery experience
Accessibility evaluationLabels, focus, error association, timers, copy/paste and keyboard completionCryptographic or server-side controls
Security reviewBypass paths, cross-user binding, brute force, replay and recovery weaknessesEveryday reliability and usability
Load/resilience testProvider queues, rate limits, challenge storage and concurrent verificationCorrectness of one user's visible journey

Automating MFA and 2FA Test Cases

Separate the reusable browser journey from the factor source and expected security state.

  1. Open {{AUTH_ENTRY_URL}}
  2. Complete primary authentication as {{USER}}
  3. Assert {{MFA_REQUIRED}}
  4. Assert {{PRE_MFA_ACCESS}}
  5. Capture {{CHALLENGE_ID}}
  6. Acquire proof from {{FACTOR_SOURCE}}
  7. Submit {{FACTOR_PROOF}}
  8. Assert {{MFA_RESULT}}
  9. Assert {{CHALLENGE_STATE}}
  10. Assert {{SESSION_ASSURANCE}}
  11. Assert {{PROTECTED_RESULT}}

Positive dataset

{
  "name": "current_totp_elevates_only_intended_session",
  "user": "[email protected]",
  "factor": "totp",
  "challengeContext": {
    "tenant": "test-workspace",
    "operation": "login"
  },
  "proof": {
    "source": "seeded-totp",
    "timeOffsetSeconds": 0
  },
  "expected": {
    "mfaResult": "accepted",
    "challengeState": "consumed",
    "sessionAssurance": "mfa-complete",
    "protectedRouteAccessible": true
  }
}

Replay dataset

{
  "name": "consumed_totp_cannot_elevate_second_session",
  "user": "[email protected]",
  "factor": "totp",
  "proof": {
    "source": "previously-consumed-proof"
  },
  "expected": {
    "mfaResult": "rejected",
    "secondSessionElevated": false,
    "protectedRouteAccessible": false
  }
}

Cross-user binding dataset

{
  "name": "user_a_code_rejected_for_user_b_challenge",
  "challengeUser": "[email protected]",
  "proofOwner": "[email protected]",
  "expected": {
    "mfaResult": "rejected",
    "authenticatedIdentity": null,
    "challengeState": "pending-or-failed"
  }
}

Use scenario names that state the business and security condition. Avoid names such as mfa_test_3, otp_negative_7 or 2fa_case.

What Browser Automation Should Not Claim

  • TOTP or OTP secrets are generated with sufficient entropy and stored securely
  • the SMS carrier, email provider or push infrastructure is secure against every attack
  • hardware-backed private keys cannot be extracted
  • biometric false-accept and false-reject rates meet platform requirements
  • WebAuthn attestation and authenticator conformance are correct
  • all MFA bypass paths are absent across the complete architecture
  • rate limiting remains effective under distributed production-scale attacks
  • support agents follow identity-recovery procedures correctly
  • trusted-device tokens cannot be forged
  • all phishing and social-engineering attacks are prevented

Browser automation remains valuable because it can prove the user-visible and session-visible transaction: the correct challenge appeared, the selected proof produced the expected decision, and only the intended protected state became available.

MFA Testing Checklist

  • every intended authentication entry point enforces MFA consistently
  • primary credentials alone do not create fully protected access
  • the challenge is bound to the intended user, session, factor and operation
  • enrollment is inactive until the first proof confirms possession
  • partial or cancelled enrollment does not leave a usable factor
  • delivery destinations are correct and masked
  • resend and concurrent challenge rules are explicit and tested
  • new proof generation does not silently reset failed-attempt policy
  • valid OTP and TOTP values are accepted within the configured window
  • leading zeroes and exact formatting are preserved
  • expired, out-of-window, malformed and incorrect proofs are rejected
  • successful proof is consumed and cannot be replayed
  • cross-user and cross-session proof is rejected
  • parallel submissions cannot create two successful consumptions
  • push deny, timeout, stale prompt and notification-spam cases are covered
  • transaction details or number matching correspond to the intended action
  • backup codes are single-use and old sets follow the regeneration policy
  • trusted-device state is account-specific, expires and can be revoked
  • recovery is not weaker than the MFA control it replaces
  • factor replacement requires suitable reauthentication and creates an audit event
  • the old factor stops working after replacement
  • administrator reset follows explicit revocation and notification rules
  • step-up success elevates only the intended session, tenant or operation
  • failed or cancelled step-up leaves the protected action blocked
  • browser, API, provider, identity and session evidence are used where appropriate
  • test fixtures are isolated from production and do not create a hidden bypass

Final acceptance criterion. Do not accept: “The correct OTP opened the dashboard.” Accept: “The intended factor satisfied the intended challenge once, invalid and cross-context proof remained outside the protected state, and only the intended session or action received elevated access.”

Frequently Asked Questions

What are the most important MFA test cases?

Verify consistent triggering, pre-MFA access restrictions, account and session binding, valid proof, expiry, replay rejection, cross-user rejection, recovery strength, trusted-device revocation and correct session elevation.

What is the difference between MFA and 2FA testing?

2FA uses exactly two different factors. MFA is the broader category and may use two or more factors. One page can cover both search intents when the tested lifecycle and expected evidence are the same.

How should OTP expiry and replay be tested?

Control issue time and server time, test the configured boundary and drift window, consume one valid proof, then repeat it in the same and another transaction. The duplicate must not elevate access.

Can MFA testing be automated?

Yes. TOTP can be generated from a test secret, email/SMS can use controlled providers, and challenge APIs can expose test fixtures. Real-device or manual runs are still needed for some push, biometric and hardware-backed paths.

Should automated tests bypass MFA?

Unrelated authenticated tests may reuse prepared post-MFA state. Tests of MFA itself must exercise the real application decision. Never create a hidden production-capable bypass to make automation easier.

Does this guide completely test passkeys and hardware keys?

No. It covers their place in the MFA lifecycle and browser-visible outcomes, but complete WebAuthn, authenticator and hardware conformance requires dedicated protocol and device testing.

Automate the Repeatable MFA Journey

Reusable MFA browser flow with datasets for valid, expired, replayed, cross-user and step-up verification cases
Reusable MFA browser flow with datasets for valid, expired, replayed, cross-user and step-up verification cases

WrightTest lets teams record the browser part of an MFA flow, replace fixed accounts and proofs with named datasets, run scenarios independently, and inspect screenshots, step results, errors and Playwright traces.

  1. Which user started the transaction
  2. Which challenge appeared
  3. Which factor proof was supplied
  4. Whether the proof was accepted or rejected
  5. Whether the challenge was consumed
  6. Which session or action was elevated
  7. Where a failed journey stopped

The browser checks can be exported to Playwright .spec.ts files when they need to move into an existing repository or CI pipeline.

Use controlled factor sources, provider sandboxes or explicit manual checkpoints for the parts that a browser cannot safely reproduce. Combine browser results with API, provider, factor-store, session and security evidence for the complete MFA contract.

Continue with Authentication Testing

MFA is one part of the complete authentication lifecycle. Use the Authentication Testing guide to plan coverage across primary login, additional factors, session management and logout.