Skip to content

Migrate Native Auth test email provider to Mail.tm, Fixes AB#3720943 - #3215

Closed
Disha Janardhan (djanardhan98) wants to merge 10 commits into
devfrom
djanardhan/mail-tm-native-auth-e2e
Closed

Migrate Native Auth test email provider to Mail.tm, Fixes AB#3720943#3215
Disha Janardhan (djanardhan98) wants to merge 10 commits into
devfrom
djanardhan/mail-tm-native-auth-e2e

Conversation

@djanardhan98

@djanardhan98 Disha Janardhan (djanardhan98) commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replace the Native Auth 1secmail inbox integration with authenticated Mail.tm mailboxes.
  • Pass the Mail.tm password through the existing Gradle BuildConfig/BuildValues pattern without committing credentials.
  • Add checkpoint-aware OTP polling, resend handling, MIME-aware OTP extraction, and bounded retries.
  • Force HTTP/1.1 for compatibility with the existing OkHttp client and Mail.tm.
  • Remove obsolete 1secmail response models and add regression coverage for the Mail.tm transport and inbox behavior.

Motivation

Native Auth end-to-end tests need both dynamically created signup inboxes and an authenticated persistent inbox for SSPR. Mail.tm supports both workflows, while the previous unauthenticated 1secmail integration cannot support the persistent SSPR mailbox used by the re-enabled tests.

Validation

  • ./gradlew.bat :testutils:clean :testutils:assembleDebug :testutils:testDebugUnitTest --no-daemon: passed locally.
  • MSAL dev with this Common working tree, ./gradlew.bat :msal:compileLocalDebugUnitTestKotlin --no-daemon: passed locally.
  • Downstream MSAL SSPRTest: 7 tests executed locally with 0 failures and 1 intentional skip.

Pipeline configuration

  • The MSAL consumer-validation task passes the secured Azure DevOps variable EMAIL_PROVIDER_PASSWORD from the pipeline's linked variable groups to Common as -PemailProviderPassword=$(EMAIL_PROVIDER_PASSWORD); Common exposes it through generated BuildConfig and BuildValues without committing the secret.

Related work

Merge sequencing

This PR is the expand step of a cross-repository migration: it temporarily retains generateRandomEmailAddressLocally() so both dev branches remain buildable. After AzureAD/microsoft-authentication-library-for-android#2553 migrates callers to createRandomEmailAddress() or generateRandomUnregisteredEmailAddress() and merges, the compatibility method will be removed in a Common follow-up.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@djanardhan98
Disha Janardhan (djanardhan98) force-pushed the djanardhan/mail-tm-native-auth-e2e branch from 90a68a7 to da8d585 Compare August 12, 2026 23:19
Mail.tm resets HTTP/2 streams used by the legacy OkHttp client. Restrict the test transport to HTTP/1.1 and cover the protocol configuration with a regression test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@djanardhan98 Disha Janardhan (djanardhan98) changed the title Djanardhan/mail tm native auth e2e Migrate Native Auth test email provider to Mail.tm, Fixes AB#3720943 Aug 13, 2026
@github-actions

Copy link
Copy Markdown

✅ Work item link check complete. Description contains link AB#3720943 to an Azure Boards work item.

@djanardhan98 Disha Janardhan (djanardhan98) changed the title Migrate Native Auth test email provider to Mail.tm, Fixes AB#3720943 Migrate Native Auth test email provider to Mail.tm Aug 13, 2026
@github-actions github-actions Bot changed the title Migrate Native Auth test email provider to Mail.tm Migrate Native Auth test email provider to Mail.tm, Fixes AB#3720943 Aug 13, 2026
Model Mail.tm response fields as nullable at the JSON boundary, skip incomplete entries, and add regression coverage. Add the PR changelog entry.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error: Your billing is not configured or you have Copilot licenses from multiple standalone organizations or enterprises. To use premium requests, select a billing entity via the GitHub site, under Settings > Copilot > Features.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Suppressed comments (2)

testutils/src/main/java/com/microsoft/identity/internal/testutils/nativeauth/api/TemporaryEmailService.kt:95

  • Authentication performs a Mail.tm network request before the bounded retry loop. A transient /token failure therefore fails the E2E flow immediately, even though equivalent transient /messages and /sources failures are retried; this is especially relevant to the linked SSPR tests, which no longer wrap the flow in their previous outer retry. Move token acquisition into the retry policy (while still failing immediately for blank credentials/permanent auth errors).
        val token = state.token ?: authenticate(emailAddress).also { state.token = it }

testutils/src/main/java/com/microsoft/identity/internal/testutils/nativeauth/api/TemporaryEmailService.kt:180

  • This treats a MIME text part as already decoded, but /sources/{id} returns raw message source and valid text parts may use Content-Transfer-Encoding: base64 or quoted-printable. In those cases the OTP is not present as literal digits and polling times out. Parse the selected MIME part's headers and decode its transfer encoding before applying the OTP regex; add encoded-part regression cases.
        val textPart = TEXT_PART_REGEX.find(body)
        if (textPart != null) {
            body = textPart.groupValues[1]
        }
        return FALLBACK_OTP_REGEX.find(body)?.groupValues?.get(1)

Co-authored-by: djanardhan98 <307255345+djanardhan98@users.noreply.github.com>
Preserve zero-argument construction for downstream MSAL consumers while sourcing the Mail.tm password from BuildValues. Add regression coverage for the compatibility API.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep downstream consumers buildable while MSAL migrates to the explicit Mail.tm address APIs. Add regression coverage for authenticated inbox creation through the compatibility bridge.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@djanardhan98

Copy link
Copy Markdown
Contributor Author

Copilot resolve the merge conflicts in this pull request

…ive-auth-e2e

Co-authored-by: djanardhan98 <307255345+djanardhan98@users.noreply.github.com>

Copilot AI commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Copilot resolve the merge conflicts in this pull request

Resolved the merge conflicts by merging dev in 0fb87ec.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

Suppressed comments (1)

testutils/src/main/java/com/microsoft/identity/internal/testutils/nativeauth/api/TemporaryEmailService.kt:208

  • [^\r\n]* treats every line after Content-Type as another header. Because that repetition is greedy, a text part containing a blank paragraph (for example, the OTP in the first paragraph followed by \r\n\r\nThanks) is parsed from the last blank line, so the OTP is discarded and polling eventually fails. Restrict the repeated lines to actual MIME headers/folded continuations, and add a regression case with a multi-paragraph text part.
            "Content-Type:\\s*text/(?:plain|html)[^\\r\\n]*(?:\\r?\\n[^\\r\\n]*)*\\r?\\n\\r?\\n(.*?)(?=\\r?\\n--|$)",

Supply the secured email provider password when validating the Common branch against MSAL dev.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants