Skip to content

Mark regional SNI mTLS PoP test inconclusive on AAD test-slice Bearer downgrade - #6084

Merged
Neha Bhargava (neha-bhargava) merged 2 commits into
mainfrom
nebharg/skip-mtls-pop-regional-test-slice-issue
Jun 22, 2026
Merged

Neha Bhargava (neha-bhargava) merged 2 commits into
mainfrom
nebharg/skip-mtls-pop-regional-test-slice-issue

Conversation

@neha-bhargava

Copy link
Copy Markdown
Contributor

Problem

Sni_Gets_Pop_Token_Successfully_TestAsync is failing on the pipeline with:

MsalClientException: You asked for token type mtls_pop, but receive Bearer.

Investigation

Reproduced locally. The test targets the AAD westus3 test slice (westus3.mtlsauth.microsoft.com). MSAL is correctly:

  • routing to the regional mtlsauth endpoint,
  • sending token_type=mtls_pop in the body,
  • presenting the SNI cert (cert load + lab/KeyVault calls succeed).

AAD is responding with token_type=Bearer. The companion test Sni_Gets_Pop_Token_WithGlobalEndpoint_TestAsync (global mtlsauth.microsoft.com) still passes, isolating the issue to the westus3 test slice, not MSAL.

Test Endpoint Result
Sni_Gets_Pop_Token_Successfully_TestAsync westus3.mtlsauth.microsoft.com ❌ AAD returns Bearer
Sni_Gets_Pop_Token_WithGlobalEndpoint_TestAsync mtlsauth.microsoft.com ✅ Passes

Fix

Catch MsalClientException with ErrorCode == TokenTypeMismatch in the regional test only and call Assert.Inconclusive with a clear message. The global-endpoint test is unchanged and continues to exercise the MSAL mTLS PoP path end-to-end. Same pattern used in #6033 for transient infrastructure issues.

A TODO is left in the catch block so the workaround is removed once the AAD test slice is fixed.

Validation (local)

Total tests: 2
     Passed: 1   (Sni_Gets_Pop_Token_WithGlobalEndpoint_TestAsync)
    Skipped: 1   (Sni_Gets_Pop_Token_Successfully_TestAsync)

Follow-up

Escalate westus3.mtlsauth.microsoft.com returning Bearer for token_type=mtls_pop with AAD test-slice owners and revert once fixed.

… downgrade

The Sni_Gets_Pop_Token_Successfully_TestAsync test runs against the AAD
westus3 test-slice mtlsauth endpoint, which is currently returning
token_type=Bearer instead of mtls_pop. This is a server-side issue on
the test slice, not a MSAL regression: the global mtlsauth endpoint
(covered by Sni_Gets_Pop_Token_WithGlobalEndpoint_TestAsync) continues
to honor mtls_pop and that test still passes.

Catch MsalClientException with ErrorCode=TokenTypeMismatch and fail
the test with Assert.Inconclusive so the pipeline is not blocked while
the test slice is investigated. Same pattern used in PR #6033.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@neha-bhargava
Neha Bhargava (neha-bhargava) requested a review from a team as a code owner June 22, 2026 20:47
Copilot AI review requested due to automatic review settings June 22, 2026 20:47

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

Adjusts the regional SNI mTLS PoP integration test to treat an upstream AAD westus3 test-slice “Bearer downgrade” as an infrastructure problem (inconclusive) rather than a product regression, while keeping the global-endpoint E2E coverage intact.

Changes:

  • Wraps the regional AcquireTokenForClient(...).WithMtlsProofOfPossession() call in a try/catch and marks the test Inconclusive when MsalError.TokenTypeMismatch is observed.
  • Adds a targeted TODO and an explicit inconclusive message to aid future re-enablement once the westus3 slice is fixed.

Five tests in ClientCredentialsMtlsPopTests were failing in the PR
pipeline with the same MsalError.TokenTypeMismatch (AAD westus3
test-slice mtlsauth endpoint downgrades token_type=mtls_pop to Bearer).

Refactor the previous inline catch into a reusable
ExecuteOrInconclusiveOnTokenTypeMismatchAsync helper and apply it to the
first PoP-acquisition call in each affected test:
  - Sni_Gets_Pop_Token_Successfully_TestAsync
  - Sni_AssertionFlow_Uses_JwtPop_And_Succeeds_TestAsync
  - Sni_AssertionFlow_Uses_JwtPop_And_Acquires_Bearer_Token_TestAsync
  - Sni_Gets_Pop_Token_WithCertificateOptionsAsync (covers both
    WithSendCertificateOverMtls_True / _False)
  - Sni_AssertionFlow_GlobalEndpoint_Uses_JwtPop_And_Succeeds_TestAsync
    (first leg uses westus3 + PoP)

Each catch converts MsalClientException with ErrorCode=TokenTypeMismatch
into Assert.Inconclusive, so the tests will auto-recover (PASS) once the
AAD test slice honors token_type=mtls_pop again. The global-endpoint PoP
test and the Bearer-over-mTLS test are unchanged and continue to pass.

Local verification:
  Total tests: 8
       Passed: 2 (Sni_Gets_Pop_Token_WithGlobalEndpoint_TestAsync,
                  Sni_Over_Mtls_Gets_Bearer_Token_Successfully_TestAsync)
      Skipped: 6 (the 5 affected + the one already wrapped)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@neha-bhargava
Neha Bhargava (neha-bhargava) merged commit 1360db1 into main Jun 22, 2026
15 checks passed
@neha-bhargava
Neha Bhargava (neha-bhargava) deleted the nebharg/skip-mtls-pop-regional-test-slice-issue branch June 22, 2026 22:26
@neha-bhargava Neha Bhargava (neha-bhargava) added this to the 4.85.1 milestone Jun 23, 2026
Neha Bhargava (neha-bhargava) added a commit to AzureAD/microsoft-identity-web that referenced this pull request Jun 23, 2026
…rer (#3892)

The E2E test AcquireTokenWithMtlsPop_WithBindingCertificate_ReturnsMtlsPopToken
fails consistently in the PR pipeline with:

  MsalClientException: You asked for token type mtls_pop, but receive Bearer.

Root cause is server-side: the AAD westus3 test-slice mtlsauth endpoint
is downgrading token_type=mtls_pop responses to Bearer. MSAL is
correctly routing to westus3.mtlsauth.microsoft.com, sending
token_type=mtls_pop, and presenting the SNI cert. The matching MSAL.NET
test against the global mtlsauth.microsoft.com endpoint continues to
pass, isolating the issue to the test slice — not a Microsoft.Identity.Web
or MSAL regression.

Skip the test via [Fact(Skip = "...")] (the repo's established pattern
for known-broken external-dependency tests) until the AAD test slice
honors token_type=mtls_pop again.

Tracking: #3891
Related: AzureAD/microsoft-authentication-library-for-dotnet#6084

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.

4 participants