Skip to content

Add test coverage for multi-tenant auth methods and fix regex pattern bug#309

Merged
MattB-msft merged 3 commits intousers/mbarbour/supportMultiTenantMultiInstanceAgentIdfrom
copilot/sub-pr-307
Feb 5, 2026
Merged

Add test coverage for multi-tenant auth methods and fix regex pattern bug#309
MattB-msft merged 3 commits intousers/mbarbour/supportMultiTenantMultiInstanceAgentIdfrom
copilot/sub-pr-307

Conversation

Copy link
Contributor

Copilot AI commented Feb 5, 2026

Adds comprehensive test coverage for _resolve_authority and _resolve_tenant_id methods in MsalAuth, which are critical for multi-tenant authentication but were previously untested.

Changes

  • Test coverage for _resolve_tenant_id: Validates tenant ID resolution logic across scenarios including "common" tenant handling, parameter overrides, and missing configuration error cases
  • Test coverage for _resolve_authority: Validates regex-based tenant replacement in authority URLs, including /common and GUID replacements, path preservation, and trailing slash handling
  • Regex bug fix: Corrected pattern from r"/\/(?:common|<GUID>)(?=\/|$)/" to r"/(?:common|<GUID>)(?=/|$)" - the extra forward slashes prevented pattern matching entirely

Example

The regex now correctly replaces tenant identifiers:

# Before (bug): No replacement occurred
authority = "https://login.microsoftonline.com/common"
# Result: "https://login.microsoftonline.com/common"

# After (fixed): Correct replacement
authority = "https://login.microsoftonline.com/common"
# Result: "https://login.microsoftonline.com/12345678-1234-1234-1234-123456789abc"

Added 14 test cases covering tenant resolution scenarios for both methods.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits February 5, 2026 18:32
…enant_id methods; fix regex bug

Co-authored-by: MattB-msft <10568244+MattB-msft@users.noreply.github.com>
…comment

Co-authored-by: MattB-msft <10568244+MattB-msft@users.noreply.github.com>
Copilot AI changed the title [WIP] Update to address review feedback on multi-tenant MsalAuth Add test coverage for multi-tenant auth methods and fix regex pattern bug Feb 5, 2026
Copilot AI requested a review from MattB-msft February 5, 2026 18:34
@MattB-msft MattB-msft marked this pull request as ready for review February 5, 2026 18:37
@MattB-msft MattB-msft requested a review from a team as a code owner February 5, 2026 18:37
@MattB-msft MattB-msft merged commit 8aca851 into users/mbarbour/supportMultiTenantMultiInstanceAgentId Feb 5, 2026
2 checks passed
@MattB-msft MattB-msft deleted the copilot/sub-pr-307 branch February 5, 2026 18:38
MattB-msft added a commit that referenced this pull request Feb 5, 2026
…dd JWT decoding functionality with adaptive card integration (#307)

* Enhance MsalAuth for multi-tenant support, update MSAL version, and add JWT decoding functionality with adaptive card integration

* Update test_samples/agentic-test/src/agent.py

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

* Refactor: Improve regex formatting and comment clarity in MsalAuth class

* Add test coverage for multi-tenant auth methods and fix regex pattern bug (#309)

* Initial plan

* Add comprehensive test coverage for _resolve_authority and _resolve_tenant_id methods; fix regex bug

Co-authored-by: MattB-msft <10568244+MattB-msft@users.noreply.github.com>

* Address code review feedback: improve test naming and add clarifying comment

Co-authored-by: MattB-msft <10568244+MattB-msft@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: MattB-msft <10568244+MattB-msft@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: MattB-msft <10568244+MattB-msft@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.

2 participants