Add windows auth tests for inproc (#1385)

This commit is contained in:
Justin Kotalik 2018-09-17 11:57:46 -07:00 committed by GitHub
parent e477f47ba8
commit 2cd6ad6d50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 18 deletions

View File

@ -293,7 +293,8 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
ConfigureModuleAndBinding(config.Root, contentRoot, port); ConfigureModuleAndBinding(config.Root, contentRoot, port);
if (!DeploymentParameters.PublishApplicationBeforeDeployment) var webConfigPath = Path.Combine(contentRoot, "web.config");
if (!DeploymentParameters.PublishApplicationBeforeDeployment && !File.Exists(webConfigPath))
{ {
// The elements normally in the web.config are in the applicationhost.config for unpublished apps. // The elements normally in the web.config are in the applicationhost.config for unpublished apps.
AddAspNetCoreElement(config.Root); AddAspNetCoreElement(config.Root);

View File

@ -66,7 +66,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
response = await deploymentResult.HttpClient.GetAsync("/Auth"); response = await deploymentResult.HttpClient.GetAsync("/Auth");
responseText = await response.Content.ReadAsStringAsync(); responseText = await response.Content.ReadAsStringAsync();
Assert.True("backcompat;Windows".Equals(responseText) || "latest;null".Equals(responseText), "Auth"); Assert.True("null".Equals(responseText), "Auth");
Assert.Equal( Assert.Equal(
$"ContentRootPath {deploymentResult.ContentRoot}" + Environment.NewLine + $"ContentRootPath {deploymentResult.ContentRoot}" + Environment.NewLine +

View File

@ -26,7 +26,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
=> TestMatrix.ForServers(DeployerSelector.ServerType) => TestMatrix.ForServers(DeployerSelector.ServerType)
.WithTfms(Tfm.NetCoreApp22, Tfm.Net461) .WithTfms(Tfm.NetCoreApp22, Tfm.Net461)
.WithAllApplicationTypes() .WithAllApplicationTypes()
.WithAllAncmVersions(); .WithAllAncmVersions()
.WithAllHostingModels();
[ConditionalTheory] [ConditionalTheory]
[MemberData(nameof(TestVariants))] [MemberData(nameof(TestVariants))]
@ -41,7 +42,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
var response = await deploymentResult.HttpClient.GetAsync("/Auth"); var response = await deploymentResult.HttpClient.GetAsync("/Auth");
var responseText = await response.Content.ReadAsStringAsync(); var responseText = await response.Content.ReadAsStringAsync();
Assert.True("backcompat;Windows".Equals(responseText) || "latest;Windows".Equals(responseText), "Auth"); Assert.Equal("Windows", responseText);
} }
} }
} }

View File

@ -36,20 +36,6 @@ namespace TestSite
public Task BodyLimit(HttpContext ctx) => ctx.Response.WriteAsync(ctx.Features.Get<IHttpMaxRequestBodySizeFeature>()?.MaxRequestBodySize?.ToString() ?? "null"); public Task BodyLimit(HttpContext ctx) => ctx.Response.WriteAsync(ctx.Features.Get<IHttpMaxRequestBodySizeFeature>()?.MaxRequestBodySize?.ToString() ?? "null");
public async Task Auth(HttpContext ctx)
{
var iisAuth = Environment.GetEnvironmentVariable("ASPNETCORE_IIS_HTTPAUTH");
var authProvider = ctx.RequestServices.GetService<IAuthenticationSchemeProvider>();
var authScheme = (await authProvider.GetAllSchemesAsync()).SingleOrDefault();
if (string.IsNullOrEmpty(iisAuth))
{
await ctx.Response.WriteAsync("backcompat;" + (authScheme?.Name ?? "null"));
}
else
{
await ctx.Response.WriteAsync("latest;" + (authScheme?.Name ?? "null"));
}
}
public Task HelloWorld(HttpContext ctx) => ctx.Response.WriteAsync("Hello World"); public Task HelloWorld(HttpContext ctx) => ctx.Response.WriteAsync("Hello World");

View File

@ -2,7 +2,9 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@ -33,5 +35,13 @@ namespace TestSite
await ctx.Response.WriteAsync("Hello World"); await ctx.Response.WriteAsync("Hello World");
} }
public async Task Auth(HttpContext ctx)
{
var authProvider = ctx.RequestServices.GetService<IAuthenticationSchemeProvider>();
var authScheme = (await authProvider.GetAllSchemesAsync()).SingleOrDefault();
await ctx.Response.WriteAsync(authScheme?.Name ?? "null");
}
} }
} }