End-to-End Testing for SMS OTP: Validate Every Stage
An operational guide to testing SMS OTP sending, receipt, and verification as separate stages, with reproducible cases and application-defined criteria.

Sending an SMS Is Not the Same as Authentication
An end-to-end test should distinguish at least three events: the application requests that a code be sent, the SMS may reach the device, and the application verifies the code entered. These stages are related, but a successful response to a send request does not, by itself, prove that the user received the message or completed authentication.
This distinction helps locate failures without prematurely attributing them to the SMS route. If the request was accepted but the user cannot complete the flow, you still need to determine whether the message arrived, whether the code was still valid, and whether verification accepted the correct value.
- Transport: the application requests the message and records the available response.
- Receipt: when the environment allows, observe whether the message appears on the test phone.
- Authentication: the user or test client enters the code, and the server confirms or rejects the verification.

Model the Flow and Its States Before Testing
Represent the journey with separately observable states: request received, code issued, send requested, transport result available, code expired, and verification accepted or rejected. Not all providers or integrations expose the same events; adapt the model to the responses and logs your system actually provides.
Define the transition the application expects in each case. For example, an accepted request may be followed by a later transport result, while authentication is completed only after the server verifies the code entered. Keeping these states distinct prevents a test from marking a user as authenticated just because sending was initiated.
- Identify the event that starts each stage and the response that is recorded.
- Note which system produces each piece of evidence: the application, messaging provider, test device, or authentication service.
- Explicitly define possible outcomes and how uncertain states are represented.

Prepare a Controlled and Authorized Environment
Run tests in an environment separate from production whenever possible. Use test numbers authorized and controlled by your team, along with synthetic codes generated by the test application. Do not send test messages to people who have not authorized them, and do not reuse real user data to construct test cases.
Before each run, document the relevant configuration so the test can be repeated: application version, integration used, authorized test destination, and conditions defined by the team. Available technical documentation describes simulation tools for certain diagnostic flows, but that does not mean an equivalent simulation exists for every SMS-MT OTP flow. Check the specific capabilities of your environment.
- Keep credentials, configuration, and test data separate from those used in production.
- Use authorized test destinations under your control and confirm that the test will not affect real users.
- Do not assume that a simulator for one stage or message type covers the entire OTP flow.
Cover the Normal Case and the Flow’s Boundaries
Start with the expected journey: request a code, check the available events, enter the value in the verifier, and confirm that the application completes authentication only after successful verification. Then test the boundaries relevant to your product policy.
No universal values for expiration, latency, resends, or maximum attempts are established here. Set these values according to your application’s policy and requirements, then verify the implemented behavior without presenting them as general industry thresholds.
- Incorrect code: confirm that verification rejects it and authentication is not completed.
- Expired code: check the result against the duration configured by the application.
- Resend: test the configured rule and confirm which codes remain valid or become invalid.
- Concurrent attempts: check how the application handles simultaneous requests or verification attempts.
- Uncertain transport result: verify that the interface does not present it as confirmed receipt.
Correlate Evidence Without Exposing the Code
To investigate a test run, you need to link the stages to the evidence available in each system. Design correlation identifiers that let you follow the request across the application, integration, and verifier, in line with the actual capabilities of those components.
Do not include the OTP in plain text in logs, screenshots, or test reports. Keep only the data needed to diagnose the case, and limit retention in accordance with applicable internal rules. The specific secure logging format depends on the architecture; do not assume that one provider generates the same fields as another.
- Record the result and source of each stage without confusing it with evidence of later stages.
- Use test identifiers and avoid including personal numbers or real codes in shared reports.
- Restrict access to and retention of diagnostic data to what is necessary for analysis.
Interpret API Responses and DLRs with Care
An API response may confirm that a request was accepted or processed by a component; its meaning depends on the integration. A DLR is a delivery status report available through the messaging chain, but it should not automatically be presented as independent proof that the user saw or received the message in the sense required to complete authentication.
The documentation for each integration determines what each response means and what evidence it provides. Even when a delivery status is available, OTP verification remains a separate stage: only the authentication service can confirm whether the submitted code was accepted according to the application’s policy.
- Document the meaning of responses according to the API and provider used.
- Distinguish a status reported by the messaging chain from direct observation on a test device.
- Do not use a DLR or send response as a substitute for the authentication result.
Define Acceptance Criteria for Each Stage
A verifiable criterion describes what should happen, what evidence confirms it, and what falls outside its scope. This lets a test pass for request processing without claiming that the SMS arrived, or confirm receipt observed on a device without declaring that the user was authenticated.
Time limits, expiration, and resend rules should come from the policy defined by your application. Record them as test parameters and confirm that they match the configuration being evaluated; do not present them as general transport guarantees.
- Request: the system returns the expected result for the request, according to the documented integration.
- Transport: interpret the recorded status within the scope and uncertainty of its source.
- Receipt: if it needs to be tested, observe it on an authorized test device.
- Verification: the configured valid code produces the expected result, and invalid cases do not authenticate.
- Timing: take limits from the application’s policy and check them in the relevant environment.
Repeat Tests When the Flow Changes
Run a controlled regression test when the message template, integration, provider, or configuration affecting the flow changes. Use the same documented cases and conditions to compare results, without assuming that a previous run guarantees future behavior.
Keep tests on authorized destinations and avoid generating test traffic to real users. If a result depends on an undocumented capability—for example, a specific simulation or the meaning of a particular DLR—consult the integration documentation before making it an acceptance criterion.
- Maintain a versioned, reproducible test-case matrix.
- Review transport and authentication results separately.
- Stop or adjust tests if they could affect users, data, or production traffic.
Frequently asked questions
Does an SMS accepted by the API confirm that the user received the OTP?
No. It confirms only the outcome documented by the API for that request. Receipt and authentication verification are separate stages.
Does a DLR prove that authentication was completed successfully?
No. A DLR is evidence of status within the messaging chain. Authentication requires the relevant service to verify the code entered.
What expiration time or latency should I use as a criterion?
No universal value is established here. Define limits according to your application’s policy and configuration, and test them in the relevant environment.
Can OTP be tested without sending real SMS messages?
It depends on the integration and type of flow. The existence of simulation for a specific diagnostic flow does not mean it covers SMS-MT OTP; check the applicable technical documentation.
Sources consulted
- Flujo de OTP por SMS-MT y distinción entre envío, recepción y verificaciónGoogle Standard Payments
- Guía NIST de identidad digitalNIST
- Guía OWASP de autenticaciónOWASP