This project is a Java + Maven + JUnit test that validates an email OTP signup flow end to end using MailSlurp (MailSoup).
It demonstrates a common system-test pattern:
- Create an isolated inbox.
- Trigger signup in the system under test.
- Wait for a matching email by subject.
- Extract the OTP code from email content.
- Submit the code to confirm signup.
- Login and verify success.
The implementation is designed for broad runtime compatibility:
- Java source/target:
1.8(runs on Java 8+) - Works on modern JVMs (for example Java 17/21/25) when Maven and network access are available.
Primary test file:
src/test/java/com/mailslurp/examples/EmailOtpMatchFlowTest.java
The test uses:
- MailSlurp Java client
17.1.0for inbox creation/cleanup. - Direct HTTP calls for the signup/confirm/login sample endpoints and matching/extraction endpoints.
The README flow is intentionally kept in sync with this canonical test implementation.
MailSlurp API endpoints:
POST /inboxesPOST /waitForMatchingEmailsPOST /emails/{emailId}/contentMatch
Sample application endpoints under test:
POST /test-endpoints/sign-upPOST /test-endpoints/confirmPOST /test-endpoints/login
MailSlurp API docs:
createInbox:https://docs.mailslurp.com/api/#operation/createInboxwaitForMatchingEmails:https://docs.mailslurp.com/api/#operation/waitForMatchingEmailsgetEmailContentMatch:https://docs.mailslurp.com/api/#operation/getEmailContentMatch
Sample endpoint behavior and expected responses:
../http-accelq-email-otp-test/test-application.md
Makefile includes ../.env and supports these variables:
MAILSLURP_API_KEY(or fallbackAPI_KEY)MAILSLURP_BASE_URL(default:https://api.mailslurp.com)TEST_ENDPOINTS_BASE_URL(default: same asMAILSLURP_BASE_URL)TEST_PASSWORD(default:TestPass123!)WAIT_TIMEOUT_MS(default:120000)SUBJECT_MATCH(default:Please confirm your email address)
make testMAILSLURP_API_KEY=your_api_key_here mvn -q -Dtest=EmailOtpMatchFlowTest testThe test uses POST /waitForMatchingEmails with:
inboxId: the created inbox UUIDcount=1timeout=120000(configurable)unreadOnly=true- match condition:
field=SUBJECTshould=CONTAINvalue=Please confirm your email address
This pattern avoids arbitrary sleep/retry loops and waits for the specific expected message.
The test calls POST /emails/{emailId}/contentMatch with regex:
Your confirmation code is "(\w+)"\.
Then it reads capture group 1 from matches[1], and posts that value to:
POST /test-endpoints/confirm
After confirmation it validates login via:
POST /test-endpoints/loginexpectingLogin successful.