react to aspnet/hosting#1005 (#353)

This commit is contained in:
Andrew Stanton-Nurse 2017-04-06 15:19:40 -07:00 committed by GitHub
parent c420addfca
commit b019d30426
10 changed files with 90 additions and 73 deletions

View File

@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15 # Visual Studio 15
VisualStudioVersion = 15.0.26228.10 VisualStudioVersion = 15.0.26405.2
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{04B1EDB6-E967-4D25-89B9-E6F8304038CD}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{04B1EDB6-E967-4D25-89B9-E6F8304038CD}"
EndProject EndProject
@ -30,34 +30,78 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{7E80C58E
build\repo.props = build\repo.props build\repo.props = build\repo.props
EndProjectSection EndProjectSection
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FunctionalTests", "test\FunctionalTests\FunctionalTests.csproj", "{A2F7598B-85E1-4F53-B307-55F2A21D39A2}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IISIntegration.FunctionalTests", "test\IISIntegration.FunctionalTests\IISIntegration.FunctionalTests.csproj", "{4E3E1F5C-CD52-4CC0-A35F-D1FA1685D2FA}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E4E2BDC4-A9C6-4AE9-B429-032EC83EDE64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E4E2BDC4-A9C6-4AE9-B429-032EC83EDE64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E4E2BDC4-A9C6-4AE9-B429-032EC83EDE64}.Debug|Any CPU.Build.0 = Debug|Any CPU {E4E2BDC4-A9C6-4AE9-B429-032EC83EDE64}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E4E2BDC4-A9C6-4AE9-B429-032EC83EDE64}.Debug|x64.ActiveCfg = Debug|Any CPU
{E4E2BDC4-A9C6-4AE9-B429-032EC83EDE64}.Debug|x64.Build.0 = Debug|Any CPU
{E4E2BDC4-A9C6-4AE9-B429-032EC83EDE64}.Debug|x86.ActiveCfg = Debug|Any CPU
{E4E2BDC4-A9C6-4AE9-B429-032EC83EDE64}.Debug|x86.Build.0 = Debug|Any CPU
{E4E2BDC4-A9C6-4AE9-B429-032EC83EDE64}.Release|Any CPU.ActiveCfg = Release|Any CPU {E4E2BDC4-A9C6-4AE9-B429-032EC83EDE64}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E4E2BDC4-A9C6-4AE9-B429-032EC83EDE64}.Release|Any CPU.Build.0 = Release|Any CPU {E4E2BDC4-A9C6-4AE9-B429-032EC83EDE64}.Release|Any CPU.Build.0 = Release|Any CPU
{E4E2BDC4-A9C6-4AE9-B429-032EC83EDE64}.Release|x64.ActiveCfg = Release|Any CPU
{E4E2BDC4-A9C6-4AE9-B429-032EC83EDE64}.Release|x64.Build.0 = Release|Any CPU
{E4E2BDC4-A9C6-4AE9-B429-032EC83EDE64}.Release|x86.ActiveCfg = Release|Any CPU
{E4E2BDC4-A9C6-4AE9-B429-032EC83EDE64}.Release|x86.Build.0 = Release|Any CPU
{8B3446E8-E6A8-4591-AA63-A95837C6E97C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8B3446E8-E6A8-4591-AA63-A95837C6E97C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8B3446E8-E6A8-4591-AA63-A95837C6E97C}.Debug|Any CPU.Build.0 = Debug|Any CPU {8B3446E8-E6A8-4591-AA63-A95837C6E97C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8B3446E8-E6A8-4591-AA63-A95837C6E97C}.Debug|x64.ActiveCfg = Debug|Any CPU
{8B3446E8-E6A8-4591-AA63-A95837C6E97C}.Debug|x64.Build.0 = Debug|Any CPU
{8B3446E8-E6A8-4591-AA63-A95837C6E97C}.Debug|x86.ActiveCfg = Debug|Any CPU
{8B3446E8-E6A8-4591-AA63-A95837C6E97C}.Debug|x86.Build.0 = Debug|Any CPU
{8B3446E8-E6A8-4591-AA63-A95837C6E97C}.Release|Any CPU.ActiveCfg = Release|Any CPU {8B3446E8-E6A8-4591-AA63-A95837C6E97C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8B3446E8-E6A8-4591-AA63-A95837C6E97C}.Release|Any CPU.Build.0 = Release|Any CPU {8B3446E8-E6A8-4591-AA63-A95837C6E97C}.Release|Any CPU.Build.0 = Release|Any CPU
{8B3446E8-E6A8-4591-AA63-A95837C6E97C}.Release|x64.ActiveCfg = Release|Any CPU
{8B3446E8-E6A8-4591-AA63-A95837C6E97C}.Release|x64.Build.0 = Release|Any CPU
{8B3446E8-E6A8-4591-AA63-A95837C6E97C}.Release|x86.ActiveCfg = Release|Any CPU
{8B3446E8-E6A8-4591-AA63-A95837C6E97C}.Release|x86.Build.0 = Release|Any CPU
{4106DB10-E09F-480E-9CE6-B39235512EE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4106DB10-E09F-480E-9CE6-B39235512EE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4106DB10-E09F-480E-9CE6-B39235512EE6}.Debug|Any CPU.Build.0 = Debug|Any CPU {4106DB10-E09F-480E-9CE6-B39235512EE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4106DB10-E09F-480E-9CE6-B39235512EE6}.Debug|x64.ActiveCfg = Debug|Any CPU
{4106DB10-E09F-480E-9CE6-B39235512EE6}.Debug|x64.Build.0 = Debug|Any CPU
{4106DB10-E09F-480E-9CE6-B39235512EE6}.Debug|x86.ActiveCfg = Debug|Any CPU
{4106DB10-E09F-480E-9CE6-B39235512EE6}.Debug|x86.Build.0 = Debug|Any CPU
{4106DB10-E09F-480E-9CE6-B39235512EE6}.Release|Any CPU.ActiveCfg = Release|Any CPU {4106DB10-E09F-480E-9CE6-B39235512EE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4106DB10-E09F-480E-9CE6-B39235512EE6}.Release|Any CPU.Build.0 = Release|Any CPU {4106DB10-E09F-480E-9CE6-B39235512EE6}.Release|Any CPU.Build.0 = Release|Any CPU
{4106DB10-E09F-480E-9CE6-B39235512EE6}.Release|x64.ActiveCfg = Release|Any CPU
{4106DB10-E09F-480E-9CE6-B39235512EE6}.Release|x64.Build.0 = Release|Any CPU
{4106DB10-E09F-480E-9CE6-B39235512EE6}.Release|x86.ActiveCfg = Release|Any CPU
{4106DB10-E09F-480E-9CE6-B39235512EE6}.Release|x86.Build.0 = Release|Any CPU
{F54715C3-88D8-49E3-A291-C13570FE81FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F54715C3-88D8-49E3-A291-C13570FE81FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F54715C3-88D8-49E3-A291-C13570FE81FC}.Debug|Any CPU.Build.0 = Debug|Any CPU {F54715C3-88D8-49E3-A291-C13570FE81FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F54715C3-88D8-49E3-A291-C13570FE81FC}.Debug|x64.ActiveCfg = Debug|Any CPU
{F54715C3-88D8-49E3-A291-C13570FE81FC}.Debug|x64.Build.0 = Debug|Any CPU
{F54715C3-88D8-49E3-A291-C13570FE81FC}.Debug|x86.ActiveCfg = Debug|Any CPU
{F54715C3-88D8-49E3-A291-C13570FE81FC}.Debug|x86.Build.0 = Debug|Any CPU
{F54715C3-88D8-49E3-A291-C13570FE81FC}.Release|Any CPU.ActiveCfg = Release|Any CPU {F54715C3-88D8-49E3-A291-C13570FE81FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F54715C3-88D8-49E3-A291-C13570FE81FC}.Release|Any CPU.Build.0 = Release|Any CPU {F54715C3-88D8-49E3-A291-C13570FE81FC}.Release|Any CPU.Build.0 = Release|Any CPU
{A2F7598B-85E1-4F53-B307-55F2A21D39A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F54715C3-88D8-49E3-A291-C13570FE81FC}.Release|x64.ActiveCfg = Release|Any CPU
{A2F7598B-85E1-4F53-B307-55F2A21D39A2}.Debug|Any CPU.Build.0 = Debug|Any CPU {F54715C3-88D8-49E3-A291-C13570FE81FC}.Release|x64.Build.0 = Release|Any CPU
{A2F7598B-85E1-4F53-B307-55F2A21D39A2}.Release|Any CPU.ActiveCfg = Release|Any CPU {F54715C3-88D8-49E3-A291-C13570FE81FC}.Release|x86.ActiveCfg = Release|Any CPU
{A2F7598B-85E1-4F53-B307-55F2A21D39A2}.Release|Any CPU.Build.0 = Release|Any CPU {F54715C3-88D8-49E3-A291-C13570FE81FC}.Release|x86.Build.0 = Release|Any CPU
{4E3E1F5C-CD52-4CC0-A35F-D1FA1685D2FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4E3E1F5C-CD52-4CC0-A35F-D1FA1685D2FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E3E1F5C-CD52-4CC0-A35F-D1FA1685D2FA}.Debug|x64.ActiveCfg = Debug|Any CPU
{4E3E1F5C-CD52-4CC0-A35F-D1FA1685D2FA}.Debug|x64.Build.0 = Debug|Any CPU
{4E3E1F5C-CD52-4CC0-A35F-D1FA1685D2FA}.Debug|x86.ActiveCfg = Debug|Any CPU
{4E3E1F5C-CD52-4CC0-A35F-D1FA1685D2FA}.Debug|x86.Build.0 = Debug|Any CPU
{4E3E1F5C-CD52-4CC0-A35F-D1FA1685D2FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4E3E1F5C-CD52-4CC0-A35F-D1FA1685D2FA}.Release|Any CPU.Build.0 = Release|Any CPU
{4E3E1F5C-CD52-4CC0-A35F-D1FA1685D2FA}.Release|x64.ActiveCfg = Release|Any CPU
{4E3E1F5C-CD52-4CC0-A35F-D1FA1685D2FA}.Release|x64.Build.0 = Release|Any CPU
{4E3E1F5C-CD52-4CC0-A35F-D1FA1685D2FA}.Release|x86.ActiveCfg = Release|Any CPU
{4E3E1F5C-CD52-4CC0-A35F-D1FA1685D2FA}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -67,6 +111,6 @@ Global
{8B3446E8-E6A8-4591-AA63-A95837C6E97C} = {04B1EDB6-E967-4D25-89B9-E6F8304038CD} {8B3446E8-E6A8-4591-AA63-A95837C6E97C} = {04B1EDB6-E967-4D25-89B9-E6F8304038CD}
{4106DB10-E09F-480E-9CE6-B39235512EE6} = {EF30B533-D715-421A-92B7-92FEF460AC9C} {4106DB10-E09F-480E-9CE6-B39235512EE6} = {EF30B533-D715-421A-92B7-92FEF460AC9C}
{F54715C3-88D8-49E3-A291-C13570FE81FC} = {EF30B533-D715-421A-92B7-92FEF460AC9C} {F54715C3-88D8-49E3-A291-C13570FE81FC} = {EF30B533-D715-421A-92B7-92FEF460AC9C}
{A2F7598B-85E1-4F53-B307-55F2A21D39A2} = {EF30B533-D715-421A-92B7-92FEF460AC9C} {4E3E1F5C-CD52-4CC0-A35F-D1FA1685D2FA} = {EF30B533-D715-421A-92B7-92FEF460AC9C}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View File

@ -1,26 +1,23 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// 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.IO;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.IntegrationTesting; using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.AspNetCore.Server.IntegrationTesting.xunit;
using Microsoft.AspNetCore.Testing.xunit; using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System;
using System.IO;
using System.Threading.Tasks;
using Xunit; using Xunit;
using Xunit.Abstractions; using Xunit.Abstractions;
using Xunit.Sdk; using Xunit.Sdk;
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{ {
public class HelloWorldTests public class HelloWorldTests : LoggedTest
{ {
private readonly ITestOutputHelper _output; public HelloWorldTests(ITestOutputHelper output) : base(output)
public HelloWorldTests(ITestOutputHelper output)
{ {
_output = output;
} }
[ConditionalTheory] [ConditionalTheory]
@ -58,13 +55,11 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
public async Task HelloWorld(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, ApplicationType applicationType) public async Task HelloWorld(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, ApplicationType applicationType)
{ {
var loggerFactory = new LoggerFactory() var testName = $"HelloWorld_{serverType}_{runtimeFlavor}_{architecture}";
.AddXunit(_output) using (StartLog(out var loggerFactory, testName))
.AddDebug();
var logger = loggerFactory.CreateLogger($"HelloWorld:{serverType}:{runtimeFlavor}:{architecture}");
using (logger.BeginScope("HelloWorldTest"))
{ {
var logger = loggerFactory.CreateLogger("HelloWorldTest");
var deploymentParameters = new DeploymentParameters(Helpers.GetTestSitesPath(), serverType, runtimeFlavor, architecture) var deploymentParameters = new DeploymentParameters(Helpers.GetTestSitesPath(), serverType, runtimeFlavor, architecture)
{ {
EnvironmentName = "HelloWorld", // Will pick the Start class named 'StartupHelloWorld', EnvironmentName = "HelloWorld", // Will pick the Start class named 'StartupHelloWorld',
@ -77,17 +72,12 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory)) using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory))
{ {
var deploymentResult = await deployer.DeployAsync(); var deploymentResult = await deployer.DeployAsync();
var httpClientHandler = new HttpClientHandler(); deploymentResult.HttpClient.Timeout = TimeSpan.FromSeconds(5);
var httpClient = new HttpClient(httpClientHandler)
{
BaseAddress = new Uri(deploymentResult.ApplicationBaseUri),
Timeout = TimeSpan.FromSeconds(5),
};
// Request to base address and check if various parts of the body are rendered & measure the cold startup time. // Request to base address and check if various parts of the body are rendered & measure the cold startup time.
var response = await RetryHelper.RetryRequest(() => var response = await RetryHelper.RetryRequest(() =>
{ {
return httpClient.GetAsync(string.Empty); return deploymentResult.HttpClient.GetAsync(string.Empty);
}, logger, deploymentResult.HostShutdownToken, retryCount: 30); }, logger, deploymentResult.HostShutdownToken, retryCount: 30);
var responseText = await response.Content.ReadAsStringAsync(); var responseText = await response.Content.ReadAsStringAsync();
@ -95,11 +85,11 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{ {
Assert.Equal("Hello World", responseText); Assert.Equal("Hello World", responseText);
response = await httpClient.GetAsync("/Path%3F%3F?query"); response = await deploymentResult.HttpClient.GetAsync("/Path%3F%3F?query");
responseText = await response.Content.ReadAsStringAsync(); responseText = await response.Content.ReadAsStringAsync();
Assert.Equal("/Path??", responseText); Assert.Equal("/Path??", responseText);
response = await httpClient.GetAsync("/Query%3FPath?query?"); response = await deploymentResult.HttpClient.GetAsync("/Query%3FPath?query?");
responseText = await response.Content.ReadAsStringAsync(); responseText = await response.Content.ReadAsStringAsync();
Assert.Equal("?query?", responseText); Assert.Equal("?query?", responseText);
} }

View File

@ -12,19 +12,17 @@ using Microsoft.Extensions.Logging;
using Xunit; using Xunit;
using Xunit.Abstractions; using Xunit.Abstractions;
using Xunit.Sdk; using Xunit.Sdk;
using Microsoft.AspNetCore.Server.IntegrationTesting.xunit;
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{ {
// IIS Express preregisteres 44300-44399 ports with SSL bindings. // IIS Express preregisteres 44300-44399 ports with SSL bindings.
// So these tests always have to use ports in this range, and we can't rely on OS-allocated ports without a whole lot of ceremony around // So these tests always have to use ports in this range, and we can't rely on OS-allocated ports without a whole lot of ceremony around
// creating self-signed certificates and registering SSL bindings with HTTP.sys // creating self-signed certificates and registering SSL bindings with HTTP.sys
public class HttpsTest public class HttpsTest : LoggedTest
{ {
private readonly ITestOutputHelper _output; public HttpsTest(ITestOutputHelper output) : base(output)
public HttpsTest(ITestOutputHelper output)
{ {
_output = output;
} }
[ConditionalTheory] [ConditionalTheory]
@ -49,13 +47,11 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
public async Task HttpsHelloWorld(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl, ApplicationType applicationType) public async Task HttpsHelloWorld(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl, ApplicationType applicationType)
{ {
var loggerFactory = new LoggerFactory() var testName = $"HttpsHelloWorld_{serverType}_{runtimeFlavor}_{architecture}";
.AddConsole() using (StartLog(out var loggerFactory, testName))
.AddDebug();
var logger = loggerFactory.CreateLogger($"HttpsHelloWorld:{serverType}:{runtimeFlavor}:{architecture}");
using (logger.BeginScope("HttpsHelloWorldTest"))
{ {
var logger = loggerFactory.CreateLogger("HttpsHelloWorldTest");
var deploymentParameters = new DeploymentParameters(Helpers.GetTestSitesPath(), serverType, runtimeFlavor, architecture) var deploymentParameters = new DeploymentParameters(Helpers.GetTestSitesPath(), serverType, runtimeFlavor, architecture)
{ {
ApplicationBaseUriHint = applicationBaseUrl, ApplicationBaseUriHint = applicationBaseUrl,
@ -71,11 +67,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
var deploymentResult = await deployer.DeployAsync(); var deploymentResult = await deployer.DeployAsync();
var handler = new HttpClientHandler(); var handler = new HttpClientHandler();
handler.ServerCertificateCustomValidationCallback = (a, b, c, d) => true; handler.ServerCertificateCustomValidationCallback = (a, b, c, d) => true;
var httpClient = new HttpClient(handler) var httpClient = deploymentResult.CreateHttpClient(handler);
{ httpClient.Timeout = TimeSpan.FromSeconds(5);
BaseAddress = new Uri(deploymentResult.ApplicationBaseUri),
Timeout = TimeSpan.FromSeconds(5),
};
// Request to base address and check if various parts of the body are rendered & measure the cold startup time. // Request to base address and check if various parts of the body are rendered & measure the cold startup time.
var response = await RetryHelper.RetryRequest(() => var response = await RetryHelper.RetryRequest(() =>
@ -138,13 +131,11 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
public async Task HttpsHelloWorldCerts(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl, ApplicationType applicationType, bool sendClientCert) public async Task HttpsHelloWorldCerts(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl, ApplicationType applicationType, bool sendClientCert)
{ {
var loggerFactory = new LoggerFactory() var testName = $"HttpsHelloWorldCerts_{serverType}_{runtimeFlavor}_{architecture}";
.AddXunit(_output) using (StartLog(out var loggerFactory, testName))
.AddDebug();
var logger = loggerFactory.CreateLogger($"HttpsHelloWorldCerts:{serverType}:{runtimeFlavor}:{architecture}");
using (logger.BeginScope("HttpsHelloWorldTest"))
{ {
var logger = loggerFactory.CreateLogger("HttpsHelloWorldTest");
var deploymentParameters = new DeploymentParameters(Helpers.GetTestSitesPath(), serverType, runtimeFlavor, architecture) var deploymentParameters = new DeploymentParameters(Helpers.GetTestSitesPath(), serverType, runtimeFlavor, architecture)
{ {
ApplicationBaseUriHint = applicationBaseUrl, ApplicationBaseUriHint = applicationBaseUrl,
@ -167,7 +158,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
Assert.NotNull(clientCert); Assert.NotNull(clientCert);
handler.ClientCertificates.Add(clientCert); handler.ClientCertificates.Add(clientCert);
} }
var httpClient = new HttpClient(handler) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) }; var httpClient = deploymentResult.CreateHttpClient(handler);
// Request to base address and check if various parts of the body are rendered & measure the cold startup time. // Request to base address and check if various parts of the body are rendered & measure the cold startup time.
var response = await RetryHelper.RetryRequest(() => var response = await RetryHelper.RetryRequest(() =>

View File

@ -13,16 +13,14 @@ using Microsoft.Extensions.Logging;
using Xunit; using Xunit;
using Xunit.Sdk; using Xunit.Sdk;
using Xunit.Abstractions; using Xunit.Abstractions;
using Microsoft.AspNetCore.Server.IntegrationTesting.xunit;
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{ {
public class NtlmAuthenticationTests public class NtlmAuthenticationTests : LoggedTest
{ {
private readonly ITestOutputHelper _output; public NtlmAuthenticationTests(ITestOutputHelper output) : base(output)
public NtlmAuthenticationTests(ITestOutputHelper output)
{ {
_output = output;
} }
[ConditionalTheory] [ConditionalTheory]
@ -47,13 +45,11 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
public async Task NtlmAuthentication(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, ApplicationType applicationType) public async Task NtlmAuthentication(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, ApplicationType applicationType)
{ {
var loggerFactory = new LoggerFactory() var testName = $"NtlmAuthentication_{serverType}_{runtimeFlavor}_{architecture}";
.AddXunit(_output) using (StartLog(out var loggerFactory, testName))
.AddDebug();
var logger = loggerFactory.CreateLogger($"NtlmAuthentication:{serverType}:{runtimeFlavor}:{architecture}");
using (logger.BeginScope("NtlmAuthenticationTest"))
{ {
var logger = loggerFactory.CreateLogger("NtlmAuthenticationTest");
var windowsRid = architecture == RuntimeArchitecture.x64 var windowsRid = architecture == RuntimeArchitecture.x64
? "win7-x64" ? "win7-x64"
: "win7-x86"; : "win7-x86";
@ -73,12 +69,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory)) using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory))
{ {
var deploymentResult = await deployer.DeployAsync(); var deploymentResult = await deployer.DeployAsync();
var httpClientHandler = new HttpClientHandler(); var httpClient = deploymentResult.HttpClient;
var httpClient = new HttpClient(httpClientHandler) httpClient.Timeout = TimeSpan.FromSeconds(5);
{
BaseAddress = new Uri(deploymentResult.ApplicationBaseUri),
Timeout = TimeSpan.FromSeconds(5),
};
// Request to base address and check if various parts of the body are rendered & measure the cold startup time. // Request to base address and check if various parts of the body are rendered & measure the cold startup time.
var response = await RetryHelper.RetryRequest(() => var response = await RetryHelper.RetryRequest(() =>
@ -114,8 +106,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
responseText = await response.Content.ReadAsStringAsync(); responseText = await response.Content.ReadAsStringAsync();
Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode); Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode);
httpClientHandler = new HttpClientHandler() { UseDefaultCredentials = true }; var httpClientHandler = new HttpClientHandler() { UseDefaultCredentials = true };
httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) }; httpClient = deploymentResult.CreateHttpClient(httpClientHandler);
response = await httpClient.GetAsync("/Anonymous"); response = await httpClient.GetAsync("/Anonymous");
responseText = await response.Content.ReadAsStringAsync(); responseText = await response.Content.ReadAsStringAsync();