MailSlurp logo

What Is MFA? How to Test Multi-Factor Authentication

Understand authentication factors, then test enrollment, second-factor challenges, protected access and recovery with real email, SMS or authenticator codes.

Multi-factor authentication (MFA) requires more than one independent kind of evidence before granting access. A password followed by an authenticator code is a common example. A username and password together are still one factor: the username identifies the account, while the password is the secret.

For a tester, the important question is whether the application enforces those factors throughout the journey. A working code field is not enough if the account is already accessible before the code is accepted.

Manual MFA checks often pause while someone reads an email, text or authenticator app. MailSlurp gives tests private email inboxes, receiving phone numbers and virtual TOTP authenticators, so your browser or API test can obtain the real challenge response and continue to an account-specific assertion.

What counts as an authentication factor?

Factors are commonly grouped into knowledge, possession and inherence:

Factor Example What the test must establish
Something the user knows Password or PIN Correct credentials reach the expected challenge; incorrect credentials do not grant access.
Something the user has Authenticator, security key or controlled receiving device The correct enrolled factor is required for that account and operation.
Something the user is A biometric checked by the relevant device The application's supported device verification and fallback policies are enforced.

Two passwords or two security questions do not become two independent factors merely because they appear on separate screens. An email code used as the entire login method is a passwordless flow; evaluate its factor design separately from a password-plus-second-factor flow.

Follow one account through the MFA challenge

Take a test user who has enrolled an authenticator. Begin in a fresh browser context without a saved session. Submit the user's password and check that the application displays the second-factor challenge. At this point, opening a protected account page or calling its protected API should still be rejected or redirected according to the application contract.

Now request a current code from the paired authenticator, submit it through the application, and confirm that the protected page shows the expected user. A generic success notification can appear before the session is ready, so check the account result itself.

Keep the same pattern when the second step is delivered by email or SMS:

  • For an email OTP, receive the message for the current account and request, extract its code, and finish the challenge.
  • For an SMS OTP, use the test user's assigned number and check the intended sender and current message.
  • For TOTP authentication, pair with the enrollment secret and request a time-based code. There is no incoming message to wait for.

A test that bypasses the challenge with a pre-created session can still be useful for another feature. Keep at least one separate test that exercises the complete MFA journey so bypassing authentication does not become the only coverage.

Check enrollment, sign-in and recovery separately

Enrollment establishes a factor; a later login uses it. Test both. For an authenticator, capture the secret from the user's actual enrollment, submit a valid setup code, sign out, and complete a new login using the same pairing. Follow the provider's timing and replay rules if the two challenges occur in the same TOTP period.

Then exercise the paths that change the factor: replacement, removal, recovery and sensitive account changes. Verify the application's required reauthentication and the state of the old factor afterward. Recovery should follow the product's intended policy, not silently inherit an authenticated session from a previous test.

Useful negative cases include an invalid code, an expired challenge, a consumed code, a challenge issued to another account and too many failed attempts. Keep each scenario isolated so a lockout or consumed token does not contaminate a later test. Use the application's documented policy to choose expected outcomes; the OTP testing guide explains received-code scenarios.

Test conditional challenges deliberately

Risk-based rules may ask for a second factor only for certain sessions, locations or operations. Those signals influence when a challenge appears; they do not automatically become independent authentication factors.

If the application has a remembered-device feature, maintain two explicit tests: an unfamiliar session that must challenge, and a remembered session that follows the configured policy. Record the test-user state and policy setting. An old cookie should not make the first scenario appear to pass.

Is 2FA different from MFA?

Two-factor authentication uses exactly two independent factors. MFA includes two or more. For either label, test which factors the application actually requires and whether access stays blocked until they are satisfied.

A passing MFA test verifies the scenarios it exercises, rather than guaranteeing the application's overall security. Keep broader security review alongside functional tests. Retain useful failure details such as the user reference, challenge step and response status, while excluding usable codes, enrollment secrets and recovery credentials from shared logs.