-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test cases
- Loading branch information
Showing
7 changed files
with
93 additions
and
70 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
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 |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
using Azure.Core.TestFramework; | ||
using Azure.Identity.Tests.Mock; | ||
using Microsoft.Identity.Client; | ||
|
||
using NUnit.Framework; | ||
|
||
namespace Azure.Identity.Tests | ||
|
@@ -186,7 +187,7 @@ public async Task LoginHint([Values(null, "[email protected]")] string loginHint | |
{ | ||
var mockMsalClient = new MockMsalPublicClient | ||
{ | ||
InteractiveAuthFactory = (_, _, prompt, hintArg, _, _, _) => | ||
InteractiveAuthFactory = (_, _, prompt, hintArg, _, _, _, _) => | ||
{ | ||
Assert.AreEqual(loginHint == null ? Prompt.SelectAccount : Prompt.NoPrompt, prompt); | ||
Assert.AreEqual(loginHint, hintArg); | ||
|
@@ -305,5 +306,59 @@ public async Task InvokesBeforeBuildClientOnExtendedOptions() | |
|
||
Assert.True(beforeBuildClientInvoked); | ||
} | ||
|
||
[Test] | ||
public async Task BrowserCustomizedOptionsHtmlMessage([Values(null, "<p> Login Successfully.</p>")] string htmlMessageSuccess, [Values(null, "<p> An error occured: {0}. Details {1}</p>")] string htmlMessageError) | ||
{ | ||
var mockMsalClient = new MockMsalPublicClient | ||
{ | ||
InteractiveAuthFactory = (_, _, _, _, _, _, browserOptions, _) => | ||
{ | ||
Assert.AreEqual(false, browserOptions.UseEmbeddedWebView); | ||
Assert.AreEqual(htmlMessageSuccess, browserOptions.HtmlMessageSuccess); | ||
Assert.AreEqual(htmlMessageError, browserOptions.HtmlMessageError); | ||
return AuthenticationResultFactory.Create(Guid.NewGuid().ToString(), expiresOn: DateTimeOffset.UtcNow.AddMinutes(5)); | ||
} | ||
}; | ||
var options = new InteractiveBrowserCredentialOptions() | ||
{ | ||
BrowserCustomizedOptions = new BrowserCustomizationOptions() | ||
{ | ||
UseEmbeddedWebView = false, | ||
HtmlMessageSuccess = htmlMessageSuccess, | ||
HtmlMessageError = htmlMessageError | ||
} | ||
}; | ||
|
||
var credential = InstrumentClient(new InteractiveBrowserCredential(default, "", options, default, mockMsalClient)); | ||
|
||
await credential.GetTokenAsync(new TokenRequestContext(MockScopes.Default)); | ||
} | ||
|
||
[Test] | ||
public async Task BrowserCustomizedUseEmbeddedWebView([Values(null, true, false)] bool useEmbeddedWebView, [Values(null, "<p> An error occured: {0}. Details {1}</p>")] string htmlMessageError) | ||
{ | ||
var mockMsalClient = new MockMsalPublicClient | ||
{ | ||
InteractiveAuthFactory = (_, _, _, _, _, _, browserOptions, _) => | ||
{ | ||
Assert.AreEqual(useEmbeddedWebView, browserOptions.UseEmbeddedWebView); | ||
Assert.AreEqual(htmlMessageError, browserOptions.HtmlMessageError); | ||
return AuthenticationResultFactory.Create(Guid.NewGuid().ToString(), expiresOn: DateTimeOffset.UtcNow.AddMinutes(5)); | ||
} | ||
}; | ||
var options = new InteractiveBrowserCredentialOptions() | ||
{ | ||
BrowserCustomizedOptions = new BrowserCustomizationOptions() | ||
{ | ||
UseEmbeddedWebView = useEmbeddedWebView, | ||
HtmlMessageError = htmlMessageError | ||
} | ||
}; | ||
|
||
var credential = InstrumentClient(new InteractiveBrowserCredential(default, "", options, default, mockMsalClient)); | ||
|
||
await credential.GetTokenAsync(new TokenRequestContext(MockScopes.Default)); | ||
} | ||
} | ||
} |
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