MailSlurp logo

blog

Choose an MFA Testing Tool for Your Authentication Flow

Choose an MFA testing setup for email, SMS and TOTP challenges, then verify enrollment, later login and recovery with your existing test runner.

An MFA testing tool must supply the factor your application actually requests. An email inbox receives a delivered code; a phone number receives a text; a TOTP authenticator generates a code from an enrolled secret. Choosing the right mechanism lets the test continue through the challenge instead of bypassing it.

The practical difficulty is coordinating that second step with the browser or API session. Parallel tests need separate users and factor state, and the code must still be usable when it reaches the application.

MailSlurp provides API-controlled inboxes, receiving numbers and virtual TOTP devices. Use them with your existing runner to obtain the challenge response, submit it in the same account journey, and check the protected application state.

Match the tool to the factor

MFA requires independent factor categories, such as a password and possession of an enrolled authenticator. A username is an identifier, and two knowledge questions do not create two independent factors. The MFA explanation and test plan covers that distinction.

Application challenge Test resource Required capability
Code or verification link in email Private receiving inbox Find the message for the current account and request, then read its intended code or link.
Code delivered by SMS Assigned receiving phone number Receive the current text, validate its context and return the code to the application.
Authenticator-app code Virtual TOTP device Pair with the user's real enrollment secret and request a fresh code with matching parameters.

Use the email OTP guide for message retrieval, the SMS OTP guide for phone-based challenges, and the TOTP walkthrough for authenticator enrollment and login. Keep the application's chosen security policy separate from the automation mechanism used to test it.

Check the capabilities that affect a real test

Start with one existing signup or login scenario. A useful evaluation answers these questions with an actual test:

  • Can each concurrent worker identify its own account, inbox or factor without using another worker's message?
  • Can the wait exclude messages issued before the current request, use an explicit timeout, and expose a useful error when delivery fails?
  • Can extraction reject a missing or ambiguous code and preserve leading zeros?
  • Can a TOTP device pair with the actual enrollment URI or secret, including the provider's code parameters?
  • Can the test inspect the final account identity and clean up only the resources it created?

These checks are more useful than comparing a list of supported frameworks alone. A tool can be callable from a runner while the example still reads stale mail or stops before verifying login.

Exercise an Auth0 authenticator flow

Configure the factor and challenge policy for your Auth0 test environment using Auth0's MFA documentation. Keep dedicated test users separate from customer accounts.

Start a new user's enrollment through your application. Capture the manual secret or enrollment URI from that flow and pair a MailSlurp virtual device with it. Submit the generated code to finish setup, then sign out and begin a new login. Assert that the second-factor challenge blocks protected access until its current code succeeds.

The Selenium Auth0 example follows enrollment and subsequent sign-in. The Playwright Auth0 example demonstrates enrollment. Use the examples that match the journey you want to prove rather than treating enrollment success as evidence about every later login.

Include step-up and recovery paths

An application may ask an already signed-in user to verify again before changing a sensitive setting. Test that operation from the expected initial session, check that it remains blocked while the challenge is incomplete, then complete the factor and verify the exact change.

Recovery and factor replacement need separate scenarios. Use controlled recovery fixtures, verify required identity checks, and confirm what happens to the previous factor. A successful normal login does not cover a recovery path.

Make failures useful to the team

Record whether the failure happened during enrollment, message delivery, code extraction, challenge submission or final account access. Keep device and message references in restricted diagnostics. Enrollment secrets, usable OTPs and recovery codes should stay out of shared reports and browser recordings.

Clean up the owned MailSlurp resources and the application user separately. If a scenario intentionally keeps a returning user, retain its paired device deliberately and reset only the state the next test requires. The TOTP API guide shows device setup and code requests; the complete OTP test plan covers expiry, resends and single-use behavior for delivered codes.