-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable MSA Passthrough for WAM (#37567)
- Loading branch information
1 parent
16190d1
commit 1525950
Showing
8 changed files
with
121 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...e.Identity.BrokeredAuthentication/tests/InteractiveBrowserCredentialBrokerOptionsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Reflection; | ||
using Microsoft.Identity.Client; | ||
using NUnit.Framework; | ||
|
||
namespace Azure.Identity.BrokeredAuthentication.Tests | ||
{ | ||
public class InteractiveBrowserCredentialBrokerOptionsTests | ||
{ | ||
[Test] | ||
public void RespectsMsaPassthrough( | ||
[Values(true, false, null)] bool? enableMsaPassthrough) | ||
{ | ||
IntPtr parentWindowHandle = new(1234); | ||
IMsalPublicClientInitializerOptions credentialOptions; | ||
if (enableMsaPassthrough.HasValue) | ||
{ | ||
credentialOptions = new InteractiveBrowserCredentialBrokerOptions(parentWindowHandle) { IsMsaPassthroughEnabled = enableMsaPassthrough.Value } as IMsalPublicClientInitializerOptions; | ||
} | ||
else | ||
{ | ||
credentialOptions = new InteractiveBrowserCredentialBrokerOptions(parentWindowHandle) as IMsalPublicClientInitializerOptions; | ||
} | ||
PublicClientApplicationBuilder builder = PublicClientApplicationBuilder | ||
.Create(Guid.NewGuid().ToString()); | ||
|
||
credentialOptions.BeforeBuildClient(builder); | ||
|
||
(BrokerOptions Options, Func<object> Parent) = GetBrokerOptions(builder); | ||
Assert.AreEqual(enableMsaPassthrough ?? false, Options?.MsaPassthrough); | ||
Assert.AreEqual(parentWindowHandle, Parent()); | ||
} | ||
|
||
private static (BrokerOptions Options, Func<object> Parent) GetBrokerOptions(PublicClientApplicationBuilder builder) | ||
{ | ||
var config = builder | ||
.GetType() | ||
.BaseType.GetProperty("Config", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(builder); | ||
Console.WriteLine(config); | ||
|
||
var options = config.GetType().GetProperty("BrokerOptions").GetValue(config); | ||
Console.WriteLine(options); | ||
var parent = config.GetType().GetProperty("ParentActivityOrWindowFunc").GetValue(config); | ||
|
||
return (options as BrokerOptions, parent as Func<object>); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters