Skip to content

Use tenant-specific authority instead of organizations in certain tests#909

Open
Avery-Dunn wants to merge 3 commits intodevfrom
avdunn/fix-test-flakiness
Open

Use tenant-specific authority instead of organizations in certain tests#909
Avery-Dunn wants to merge 3 commits intodevfrom
avdunn/fix-test-flakiness

Conversation

@Avery-Dunn
Copy link
Copy Markdown
Contributor

Two OBO integration tests (test_acquire_token_obo and
test_cca_obo_should_bypass_regional_endpoint_therefore_still_work) intermittently fail with: ``AADSTS53003: Access has been blocked by Conditional Access policies. The access policy does not allow token issuance.`

These were the only automated ROPC tests using the multi-tenant /organizations authority. With /organizations, AAD must perform home-realm discovery to route the request to the correct tenant, and this additional routing context can cause risk-based Conditional Access policies to intermittently block the sign-in — particularly in CI environments with shared IPs and high sign-in frequency.

This PR switches both tests to use the tenant-specific user.authority, matching the pattern used by every other passing ROPC test. The OBO flow itself is unaffected — only the authority used to obtain the initial user assertion changes.

Copilot AI review requested due to automatic review settings May 8, 2026 15:40
@Avery-Dunn Avery-Dunn requested a review from a team as a code owner May 8, 2026 15:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR reduces flakiness in MSAL Python’s end-to-end OBO integration tests by avoiding the multi-tenant /organizations authority during the initial ROPC step, instead using the tenant-specific authority associated with the lab user (user.authority).

Changes:

  • Updated test_acquire_token_obo to use user.authority (tenant-specific) for the PCA ROPC token acquisition step.
  • Updated test_cca_obo_should_bypass_regional_endpoint_therefore_still_work to use user.authority (tenant-specific) for the PCA ROPC token acquisition step.
  • Removed an outdated comment referencing a Java test using the /organizations authority.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings May 8, 2026 16:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 3 out of 3 changed files in this pull request and generated 5 comments.

Comment thread tests/lab_config.py
Comment on lines 94 to +98
WEB_APP_CLIENT = "App-WebAPP-Config"
B2C_CLIENT = "MSAL-App-B2C-JSON"
CIAM_CLIENT = "MSAL-App-CIAM-JSON"
ARLINGTON_CLIENT = "MSAL-App-Arlington-JSON"
OBO_CLIENT_SECRET = "IdentityDivisionDotNetOBOServiceSecret"
Comment thread tests/test_e2e.py
Comment on lines +914 to +918
"authority": user.authority,
"client_id": s2s_app.app_id,
"username": user.upn,
"password": password,
"scope": ["api://%s/access_as_user" % web_api_app.app_id],
"scope": [web_api_app.defaultscopes],
Comment thread tests/test_e2e.py
Comment on lines 923 to +926
"client_id": web_api_app.app_id,
"client_secret": get_secret(web_api_app.client_secret, vault="msal_team"),
"scope": ["https://graph.microsoft.com/.default"],
"client_secret": get_secret(
AppSecrets.OBO_CLIENT_SECRET, vault="msal_team"),
"scope": ["User.Read"],
Comment thread tests/test_e2e.py
Comment on lines +1247 to +1251
"authority": user.authority,
"client_id": s2s_app.app_id,
"username": user.upn,
"password": password,
"scope": ["api://%s/access_as_user" % web_api_app.app_id],
"scope": [web_api_app.defaultscopes],
Comment thread tests/test_e2e.py
Comment on lines 1256 to +1259
"client_id": web_api_app.app_id,
"client_secret": get_secret(web_api_app.client_secret, vault="msal_team"),
"scope": ["https://graph.microsoft.com/.default"],
"client_secret": get_secret(
AppSecrets.OBO_CLIENT_SECRET, vault="msal_team"),
"scope": ["User.Read"],
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