Skip to content

Conversation

@ksaaf
Copy link
Contributor

@ksaaf ksaaf commented Mar 10, 2025

This PR fixes throwing exception when service config region is set to null for Mtls.

Fixes #5181

Changes proposed in this request

  • Replaced string.IsNullOrEmpty with null in AcquireTokenForClientParameterBuilder.cs for Azure region check when the authority is AAD.

Testing

  • Updates existing unit tests to cover another case for this case when service config region is set to null and fixes existing tests.

Performance impact

N/A

Documentation

  • All relevant documentation is updated.

@ksaaf ksaaf requested a review from a team as a code owner March 10, 2025 23:19
@gladjohn
Copy link
Contributor

gladjohn commented Mar 10, 2025

not sure if this is the correct fix. The issue is not in MTLS code path but in the the Azure Region API code path. After your fix trying running the test MsalForceRegionIsSet_WithRegionIsSet_WithRegionWins with " "

Copy link
Contributor

@gladjohn gladjohn left a comment

Choose a reason for hiding this comment

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

may not fix all region cases

@ksaaf
Copy link
Contributor Author

ksaaf commented Mar 10, 2025

not sure if this is the correct fix. The issue is not in MTLS code path in the the Azure Region API code path. After your fix trying running the test MsalForceRegionIsSet_WithRegionIsSet_WithRegionWins with " "

@gladjohn - I ran the tests as original and with your suggestion under debugger putting a breakpoint on the line I fixed. It didn't even hit the breakpoint.

Do you have a different test in mind? Can you run tests against this PR branch and check? Thanks.

@ksaaf
Copy link
Contributor Author

ksaaf commented Mar 10, 2025

may not fix all region cases

I am not sure if we I am following you. The fix is simple and adds test cases for string.empty scenario as well as for the new whitespace. And the test passes in all three cases. What am I missing here?

Also, do you have a change in mind as you requested a change here?

@gladjohn
Copy link
Contributor

I ran the tests as original and with your suggestion under debugger putting a breakpoint on the line I fixed. It didn't even hit the breakpoint.

And what is the outcome of the test?

@gladjohn
Copy link
Contributor

do you have a change in mind as you requested a change here?

The correct fix should happen here

@gladjohn gladjohn requested a review from sruke March 11, 2025 00:15
Copy link
Member

@bgavrilMS bgavrilMS left a comment

Choose a reason for hiding this comment

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

I believe the test MtlsPopWithoutRegionAsync is misleading. It should not set an env variable. Regional opt-in is done via API.

@ksaaf
Copy link
Contributor Author

ksaaf commented Mar 11, 2025

MsalForceRegionIsSet_WithRegionIsSet_WithRegionWins

It passed.

@ksaaf
Copy link
Contributor Author

ksaaf commented Mar 11, 2025

I believe the test MtlsPopWithoutRegionAsync is misleading. It should not set an env variable. Regional opt-in is done via API.

Correct, see my response here as well.

@ksaaf ksaaf closed this Mar 11, 2025
@ksaaf
Copy link
Contributor Author

ksaaf commented Mar 11, 2025

do you have a change in mind as you requested a change here?

The correct fix should happen here

This is a different issue. Please see my response here.

@ksaaf ksaaf requested a review from gladjohn March 11, 2025 18:29
@ksaaf ksaaf changed the title For Mtls, throw exception when service config region is set to whites… For Mtls, throw exception when service config region is set to null. Mar 11, 2025
@ksaaf ksaaf reopened this Mar 11, 2025
@gladjohn
Copy link
Contributor

do you have a change in mind as you requested a change here?

The correct fix should happen here

This is a different issue. Please see my response here.

@ksaaf the actual issue is not in the AcquireTokenForClient API or flows, The issue you are describing stems from WithAzureRegion API. I am happy to discuss this with you and go over the actual problem.

As @bgavrilMS, mentioned there could be other bugs that are present in the Region flow that has been exposed by this test. So this needs a little more investigation.

@ksaaf
Copy link
Contributor Author

ksaaf commented Mar 11, 2025

do you have a change in mind as you requested a change here?

The correct fix should happen here

This is a different issue. Please see my response here.

@ksaaf the actual issue is not in the AcquireTokenForClient API or flows, The issue you are describing stems from WithAzureRegion API. I am happy to discuss this with you and go over the actual problem.

As @bgavrilMS, mentioned there could be other bugs that are present in the Region flow that has been exposed by this test. So this needs a little more investigation.

Yes, let's discuss; happy to learn the context as I am new to the codebase.

Copy link
Contributor

@gladjohn gladjohn left a comment

Choose a reason for hiding this comment

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

looks good.

@gladjohn gladjohn dismissed their stale review March 12, 2025 15:50

two approvals granted

@gladjohn gladjohn self-requested a review March 12, 2025 15:50
@ksaaf ksaaf merged commit e5e4cd2 into main Mar 12, 2025
7 checks passed
@ksaaf ksaaf deleted the ksaaf/issue-5181 branch March 12, 2025 19:59
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.

[Bug] `WithMtlsProofOfPossession()' if the region in the config is null.

6 participants