Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update test #1173

Merged
merged 1 commit into from
May 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 8 additions & 32 deletions tests/Microsoft.Identity.Web.Test/WebAppExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -422,47 +422,23 @@ public void AddMicrosoftIdentityWebApp_AddsInMemoryTokenCaches()
Assert.Contains(services, s => s.ServiceType == typeof(IMsalTokenCacheProvider));
}

[Fact]
[Theory]
[InlineData("tRue", "azureactivedirectory")]
[InlineData("true", "azureactivedirectory")]
[InlineData("tRue", AppServicesAuthenticationInformation.AppServicesAuthAzureActiveDirectory)]
[InlineData("true", AppServicesAuthenticationInformation.AppServicesAuthAzureActiveDirectory)]
// Regression for https://github.com/AzureAD/microsoft-identity-web/issues/1163
public void AddMicrosoftIdentityWebApp_CaseInsensitive_AppServices()
{
try
{
// Arrange
Environment.SetEnvironmentVariable(
AppServicesAuthenticationInformation.AppServicesAuthEnabledEnvironmentVariable, "tRue");

Environment.SetEnvironmentVariable(
AppServicesAuthenticationInformation.AppServicesAuthIdentityProviderEnvironmentVariable,
"azureactivedirectory"); // used to be uppercase

var services = new ServiceCollection();

// Act
services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApp(_configureMsOptions);

// Assert
Assert.Contains(services, s => s.ServiceType == typeof(AppServicesAuthenticationHandler));
}
finally
{
ResetAppServiceEnv();
}
}

[Fact]
public void AddMicrosoftIdentityWebApp_AppServices()
public void AppServices_EnvironmentTest(string appServicesEnvEnabledValue, string idpEnvValue)
{
try
{
// Arrange
Environment.SetEnvironmentVariable(
AppServicesAuthenticationInformation.AppServicesAuthEnabledEnvironmentVariable, "true");
AppServicesAuthenticationInformation.AppServicesAuthEnabledEnvironmentVariable, appServicesEnvEnabledValue);

Environment.SetEnvironmentVariable(
AppServicesAuthenticationInformation.AppServicesAuthIdentityProviderEnvironmentVariable,
AppServicesAuthenticationInformation.AppServicesAuthAzureActiveDirectory);
idpEnvValue);

var services = new ServiceCollection();

Expand Down