Merge branch 'merge/release/2.2-to-master'

This commit is contained in:
Pavel Krymets 2018-10-16 14:15:55 -07:00
commit 0fa48ea997
25 changed files with 290 additions and 70 deletions

View File

@ -12,11 +12,11 @@
"commandName": "Executable", "commandName": "Executable",
"executablePath": "$(IISExpressPath)", "executablePath": "$(IISExpressPath)",
"commandLineArgs": "$(IISExpressArguments)", "commandLineArgs": "$(IISExpressArguments)",
"nativeDebugging": true,
"environmentVariables": { "environmentVariables": {
"IIS_SITE_PATH": "$(MSBuildThisFileDirectory)", "IIS_SITE_PATH": "$(MSBuildThisFileDirectory)",
"ANCM_PATH": "$(TargetDir)\\$(AncmPath)", "ANCM_PATH": "$(AspNetCoreModuleV1ShimDll)",
"ANCMV2_PATH": "$(TargetDir)\\$(AncmV2Path)", "ANCMV2_PATH": "$(AspNetCoreModuleV2ShimDll)",
"ANCM_OUTOFPROCESS_HANDLER": "$(AspNetCoreModuleV2OutOfProcessHandlerDll)",
"LAUNCHER_ARGS": "$(TargetPath)", "LAUNCHER_ARGS": "$(TargetPath)",
"ASPNETCORE_ENVIRONMENT": "Development", "ASPNETCORE_ENVIRONMENT": "Development",
"LAUNCHER_PATH": "$(DotNetPath)", "LAUNCHER_PATH": "$(DotNetPath)",
@ -29,8 +29,9 @@
"commandLineArgs": "$(IISArguments)", "commandLineArgs": "$(IISArguments)",
"environmentVariables": { "environmentVariables": {
"IIS_SITE_PATH": "$(MSBuildThisFileDirectory)", "IIS_SITE_PATH": "$(MSBuildThisFileDirectory)",
"ANCM_PATH": "$(AncmPath)", "ANCM_PATH": "$(AspNetCoreModuleV1ShimDll)",
"ANCMV2_PATH": "$(AncmV2Path)", "ANCMV2_PATH": "$(AspNetCoreModuleV2ShimDll)",
"ASPNETCORE_MODULE_OUTOFPROCESS_HANDLER": "$(AspNetCoreModuleV2OutOfProcessHandlerDll)",
"LAUNCHER_ARGS": "$(TargetPath)", "LAUNCHER_ARGS": "$(TargetPath)",
"ASPNETCORE_ENVIRONMENT": "Development", "ASPNETCORE_ENVIRONMENT": "Development",
"LAUNCHER_PATH": "$(DotNetPath)", "LAUNCHER_PATH": "$(DotNetPath)",

View File

@ -36,8 +36,6 @@
<IISExpressArguments>/config:"$(IISExpressAppHostConfig)" /systray:false</IISExpressArguments> <IISExpressArguments>/config:"$(IISExpressAppHostConfig)" /systray:false</IISExpressArguments>
<IISArguments>-h "$(IISAppHostConfig)"</IISArguments> <IISArguments>-h "$(IISAppHostConfig)"</IISArguments>
<AncmPath>$(AspNetCoreModuleV1ShimDll)</AncmPath>
<AncmV2Path>$(AspNetCoreModuleV2ShimDll)</AncmV2Path>
<AncmInProcessRHPath>aspnetcorev2_inprocess.dll</AncmInProcessRHPath> <AncmInProcessRHPath>aspnetcorev2_inprocess.dll</AncmInProcessRHPath>
<DotNetPath>$(userprofile)\.dotnet\$(NativePlatform)\dotnet.exe</DotNetPath> <DotNetPath>$(userprofile)\.dotnet\$(NativePlatform)\dotnet.exe</DotNetPath>
</PropertyGroup> </PropertyGroup>

View File

@ -12,11 +12,11 @@
"commandName": "Executable", "commandName": "Executable",
"executablePath": "$(IISExpressPath)", "executablePath": "$(IISExpressPath)",
"commandLineArgs": "$(IISExpressArguments)", "commandLineArgs": "$(IISExpressArguments)",
"nativeDebugging": true,
"environmentVariables": { "environmentVariables": {
"IIS_SITE_PATH": "$(MSBuildThisFileDirectory)", "IIS_SITE_PATH": "$(MSBuildThisFileDirectory)",
"ANCM_PATH": "$(TargetDir)\\$(AncmPath)", "ANCM_PATH": "$(AncmPath)",
"ANCMV2_PATH": "$(TargetDir)\\$(AncmV2Path)", "ANCMV2_PATH": "$(AncmV2Path)",
"ANCM_OUTOFPROCESS_HANDLER": "$(AspNetCoreModuleV2OutOfProcessHandlerDll)",
"LAUNCHER_ARGS": "$(TargetPath)", "LAUNCHER_ARGS": "$(TargetPath)",
"ASPNETCORE_ENVIRONMENT": "Development", "ASPNETCORE_ENVIRONMENT": "Development",
"LAUNCHER_PATH": "$(DotNetPath)", "LAUNCHER_PATH": "$(DotNetPath)",
@ -31,6 +31,7 @@
"IIS_SITE_PATH": "$(MSBuildThisFileDirectory)", "IIS_SITE_PATH": "$(MSBuildThisFileDirectory)",
"ANCM_PATH": "$(AncmPath)", "ANCM_PATH": "$(AncmPath)",
"ANCMV2_PATH": "$(AncmV2Path)", "ANCMV2_PATH": "$(AncmV2Path)",
"ANCM_OUTOFPROCESS_HANDLER": "$(AspNetCoreModuleV2OutOfProcessHandlerDll)",
"LAUNCHER_ARGS": "$(TargetPath)", "LAUNCHER_ARGS": "$(TargetPath)",
"ASPNETCORE_ENVIRONMENT": "Development", "ASPNETCORE_ENVIRONMENT": "Development",
"LAUNCHER_PATH": "$(DotNetPath)", "LAUNCHER_PATH": "$(DotNetPath)",

View File

@ -16,6 +16,7 @@
#include "WebConfigConfigurationSource.h" #include "WebConfigConfigurationSource.h"
#include "ModuleHelpers.h" #include "ModuleHelpers.h"
#include "BaseOutputManager.h" #include "BaseOutputManager.h"
#include "Environment.h"
const PCWSTR HandlerResolver::s_pwzAspnetcoreInProcessRequestHandlerName = L"aspnetcorev2_inprocess.dll"; const PCWSTR HandlerResolver::s_pwzAspnetcoreInProcessRequestHandlerName = L"aspnetcorev2_inprocess.dll";
const PCWSTR HandlerResolver::s_pwzAspnetcoreOutOfProcessRequestHandlerName = L"aspnetcorev2_outofprocess.dll"; const PCWSTR HandlerResolver::s_pwzAspnetcoreOutOfProcessRequestHandlerName = L"aspnetcorev2_outofprocess.dll";
@ -103,12 +104,12 @@ HandlerResolver::LoadRequestHandlerAssembly(const IHttpApplication &pApplication
LOG_INFOF(L"Loading request handler: '%ls'", handlerDllPath.c_str()); LOG_INFOF(L"Loading request handler: '%ls'", handlerDllPath.c_str());
hRequestHandlerDll = LoadLibrary(handlerDllPath.c_str()); hRequestHandlerDll = LoadLibrary(handlerDllPath.c_str());
RETURN_LAST_ERROR_IF_NULL(hRequestHandlerDll);
if (preventUnload) if (preventUnload)
{ {
// Pin module in memory // Pin module in memory
GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_PIN, pstrHandlerDllName, &hRequestHandlerDll); GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_PIN, handlerDllPath.c_str(), &hRequestHandlerDll);
} }
RETURN_LAST_ERROR_IF_NULL(hRequestHandlerDll);
} }
auto pfnAspNetCoreCreateApplication = ModuleHelpers::GetKnownProcAddress<PFN_ASPNETCORE_CREATE_APPLICATION>(hRequestHandlerDll, "CreateApplication"); auto pfnAspNetCoreCreateApplication = ModuleHelpers::GetKnownProcAddress<PFN_ASPNETCORE_CREATE_APPLICATION>(hRequestHandlerDll, "CreateApplication");
@ -150,7 +151,7 @@ HandlerResolver::GetApplicationFactory(const IHttpApplication &pApplication, std
m_loadedApplicationHostingModel = options.QueryHostingModel(); m_loadedApplicationHostingModel = options.QueryHostingModel();
m_loadedApplicationId = pApplication.GetApplicationId(); m_loadedApplicationId = pApplication.GetApplicationId();
RETURN_IF_FAILED(LoadRequestHandlerAssembly(pApplication, options, pApplicationFactory)); RETURN_IF_FAILED(LoadRequestHandlerAssembly(pApplication, options, pApplicationFactory));
return S_OK; return S_OK;
} }
@ -171,6 +172,13 @@ HandlerResolver::FindNativeAssemblyFromGlobalLocation(
{ {
try try
{ {
auto handlerPath = Environment::GetEnvironmentVariableValue(L"ASPNETCORE_MODULE_OUTOFPROCESS_HANDLER");
if (handlerPath.has_value() && std::filesystem::is_regular_file(handlerPath.value()))
{
handlerDllPath = handlerPath.value();
return S_OK;
}
std::wstring modulePath = GlobalVersionUtility::GetModuleName(m_hModule); std::wstring modulePath = GlobalVersionUtility::GetModuleName(m_hModule);
modulePath = GlobalVersionUtility::RemoveFileNameFromFolderPath(modulePath); modulePath = GlobalVersionUtility::RemoveFileNameFromFolderPath(modulePath);

View File

@ -119,12 +119,18 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
key: "hostingModel", key: "hostingModel",
value: DeploymentParameters.HostingModel.ToString()); value: DeploymentParameters.HostingModel.ToString());
if (DeploymentParameters.ApplicationType == ApplicationType.Portable) yield return (element, _) => {
{ var aspNetCore = element
yield return WebConfigHelpers.AddOrModifyAspNetCoreSection( .Descendants("system.webServer")
"processPath", .Single()
DotNetCommands.GetDotNetExecutable(DeploymentParameters.RuntimeArchitecture)); .GetOrAdd("aspNetCore");
}
// Expand path to dotnet because IIS process would not inherit PATH variable
if (aspNetCore.Attribute("processPath")?.Value.StartsWith("dotnet") == true)
{
aspNetCore.SetAttributeValue("processPath", DotNetCommands.GetDotNetExecutable(DeploymentParameters.RuntimeArchitecture));
}
};
yield return WebConfigHelpers.AddOrModifyHandlerSection( yield return WebConfigHelpers.AddOrModifyHandlerSection(
key: "modules", key: "modules",
@ -399,8 +405,10 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
redirectionSection.Attributes["enabled"].Value = false; redirectionSection.Attributes["enabled"].Value = false;
serverManager.CommitChanges(); serverManager.CommitChanges();
if (Directory.Exists(_configPath))
Directory.Delete(_configPath, true); {
Directory.Delete(_configPath, true);
}
}); });
} }
} }

View File

@ -43,14 +43,22 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
public static void SetWindowsAuth(this IISDeploymentParameters parameters, bool enabled = true) public static void SetWindowsAuth(this IISDeploymentParameters parameters, bool enabled = true)
{ {
parameters.EnsureSection("windowsAuthentication", "system.webServer", "security", "windowsAuthentication");
parameters.EnableModule("WindowsAuthenticationModule", "%IIS_BIN%\\authsspi.dll"); parameters.EnableModule("WindowsAuthenticationModule", "%IIS_BIN%\\authsspi.dll");
parameters.AddServerConfigAction( parameters.AddServerConfigAction(
element => element =>
{ {
element.Descendants("windowsAuthentication") var windowsAuthentication = element
.Single() .RequiredElement("system.webServer")
.SetAttributeValue("enabled", enabled); .RequiredElement("security")
.RequiredElement("authentication")
.GetOrAdd("windowsAuthentication");
windowsAuthentication.SetAttributeValue("enabled", enabled);
var providers = windowsAuthentication.GetOrAdd("providers");
providers.GetOrAdd("add", "value", "Negotiate");
providers.GetOrAdd("add", "value", "NTLM");
}); });
} }
@ -59,8 +67,11 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
parameters.AddServerConfigAction( parameters.AddServerConfigAction(
element => element =>
{ {
element.Descendants("anonymousAuthentication") element
.Single() .RequiredElement("system.webServer")
.RequiredElement("security")
.RequiredElement("authentication")
.GetOrAdd("anonymousAuthentication")
.SetAttributeValue("enabled", enabled); .SetAttributeValue("enabled", enabled);
}); });
} }
@ -72,12 +83,33 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
parameters.AddServerConfigAction( parameters.AddServerConfigAction(
element => element =>
{ {
element.Descendants("basicAuthentication") element
.Single() .RequiredElement("system.webServer")
.RequiredElement("security")
.RequiredElement("authentication")
.GetOrAdd("basicAuthentication")
.SetAttributeValue("enabled", enabled); .SetAttributeValue("enabled", enabled);
}); });
} }
public static void EnsureSection(this IISDeploymentParameters parameters, string name, params string[] path)
{
parameters.ServerConfigActionList.Add(
(config, _) => {
var element = config
.RequiredElement("configSections");
foreach (var s in path)
{
element = element.GetOrAdd("sectionGroup", "name", s);
}
element.GetOrAdd("section", "name", "applicationInitialization")
.SetAttributeValue("overrideModeDefault", "Allow");
});
}
public static void EnableLogging(this IISDeploymentParameters deploymentParameters, string path) public static void EnableLogging(this IISDeploymentParameters deploymentParameters, string path)
{ {
deploymentParameters.WebConfigActionList.Add( deploymentParameters.WebConfigActionList.Add(

View File

@ -6,7 +6,6 @@ using System.Net.Http;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities; using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities;
using Microsoft.AspNetCore.Server.IntegrationTesting; using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS; using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
@ -32,7 +31,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
.WithAllAncmVersions() .WithAllAncmVersions()
.WithAllHostingModels(); .WithAllHostingModels();
[ConditionalTheory(Skip = "This test is manual. To run it set ASPNETCORE_MODULE_TEST_USER and ASPNETCORE_MODULE_TEST_PASSWORD environment variables to existing user")] [ConditionalTheory]
[RequiresEnvironmentVariable("ASPNETCORE_MODULE_TEST_USER")]
[RequiresIIS(IISCapability.BasicAuthentication)] [RequiresIIS(IISCapability.BasicAuthentication)]
[MemberData(nameof(TestVariants))] [MemberData(nameof(TestVariants))]
public async Task BasicAuthTest(TestVariant variant) public async Task BasicAuthTest(TestVariant variant)
@ -63,7 +63,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
else else
{ {
// We expect out-of-proc not allowing basic auth // We expect out-of-proc not allowing basic auth
Assert.Equal("Windows:", responseText); Assert.Equal("Windows", responseText);
} }
} }
} }

View File

@ -23,6 +23,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
} }
[ConditionalFact] [ConditionalFact]
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
public async Task IncludesAdditionalErrorPageTextInProcessHandlerLoadFailure() public async Task IncludesAdditionalErrorPageTextInProcessHandlerLoadFailure()
{ {
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true); var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
@ -37,6 +38,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
} }
[ConditionalFact] [ConditionalFact]
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
public async Task IncludesAdditionalErrorPageTextOutOfProcessStartupFailure() public async Task IncludesAdditionalErrorPageTextOutOfProcessStartupFailure()
{ {
var deploymentParameters = _fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess, publish: true); var deploymentParameters = _fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess, publish: true);
@ -51,6 +53,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
} }
[ConditionalFact] [ConditionalFact]
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
public async Task IncludesAdditionalErrorPageTextOutOfProcessHandlerLoadFailure() public async Task IncludesAdditionalErrorPageTextOutOfProcessHandlerLoadFailure()
{ {
var deploymentParameters = _fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess, publish: true); var deploymentParameters = _fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess, publish: true);
@ -69,6 +72,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
} }
[ConditionalFact] [ConditionalFact]
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
public async Task IncludesAdditionalErrorPageTextInProcessStartupFailure() public async Task IncludesAdditionalErrorPageTextInProcessStartupFailure()
{ {
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true); var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);

View File

@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{ {
_fixture = fixture; _fixture = fixture;
} }
public override void Initialize(MethodInfo methodInfo, object[] testMethodArguments, ITestOutputHelper testOutputHelper) public override void Initialize(MethodInfo methodInfo, object[] testMethodArguments, ITestOutputHelper testOutputHelper)
{ {
base.Initialize(methodInfo, testMethodArguments, testOutputHelper); base.Initialize(methodInfo, testMethodArguments, testOutputHelper);

View File

@ -1,6 +1,7 @@
// 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.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
@ -32,18 +33,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
public async Task GlobalVersion_DefaultWorks() public async Task GlobalVersion_DefaultWorks()
{ {
var deploymentParameters = GetGlobalVersionBaseDeploymentParameters(); var deploymentParameters = GetGlobalVersionBaseDeploymentParameters();
deploymentParameters.PublishApplicationBeforeDeployment = false;
deploymentParameters.AddServerConfigAction( deploymentParameters.HandlerSettings["handlerVersion"] = _handlerVersion20;
element =>
{
var handlerVersionElement = new XElement("handlerSetting");
handlerVersionElement.SetAttributeValue("name", "handlerVersion");
handlerVersionElement.SetAttributeValue("value", _handlerVersion20);
element.Descendants("aspNetCore").Single()
.Add(new XElement("handlerSettings", handlerVersionElement));
});
var deploymentResult = await DeployAsync(deploymentParameters); var deploymentResult = await DeployAsync(deploymentParameters);
@ -52,6 +43,35 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
Assert.Equal(_helloWorldResponse, responseText); Assert.Equal(_helloWorldResponse, responseText);
} }
[ConditionalFact]
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
public async Task GlobalVersion_EnvironmentVariableWorks()
{
var temporaryFile = Path.GetTempFileName();
try
{
var deploymentParameters = GetGlobalVersionBaseDeploymentParameters();
CopyShimToOutput(deploymentParameters);
deploymentParameters.PublishApplicationBeforeDeployment = true;
deploymentParameters.EnvironmentVariables["ASPNETCORE_MODULE_OUTOFPROCESS_HANDLER"] = temporaryFile;
var deploymentResult = await DeployAsync(deploymentParameters);
var requestHandlerPath = Path.Combine(GetANCMRequestHandlerPath(deploymentResult, _handlerVersion20), "aspnetcorev2_outofprocess.dll");
File.Delete(temporaryFile);
File.Move(requestHandlerPath, temporaryFile);
var response = await deploymentResult.HttpClient.GetAsync(_helloWorldRequest);
var responseText = await response.Content.ReadAsStringAsync();
Assert.Equal(_helloWorldResponse, responseText);
StopServer();
}
finally
{
File.Delete(temporaryFile);
}
}
[ConditionalTheory] [ConditionalTheory]
[InlineData("2.1.0")] [InlineData("2.1.0")]
[InlineData("2.1.0-preview")] [InlineData("2.1.0-preview")]

View File

@ -0,0 +1,65 @@
// 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.
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.AspNetCore.Testing.xunit;
using Xunit;
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{
public abstract class ServerAbortTests: FixtureLoggedTest
{
private readonly IISTestSiteFixture _fixture;
[Collection(IISTestSiteCollection.Name)]
public class InProc: ServerAbortTests
{
public InProc(IISTestSiteFixture fixture) : base(fixture) { }
}
[Collection(OutOfProcessTestSiteCollection.Name)]
public class OutOfProcess: ServerAbortTests
{
public OutOfProcess(OutOfProcessTestSiteFixture fixture) : base(fixture) { }
}
[Collection(OutOfProcessV1TestSiteCollection.Name)]
public class OutOfProcessV1: ServerAbortTests
{
public OutOfProcessV1(OutOfProcessV1TestSiteFixture fixture) : base(fixture) { }
}
protected ServerAbortTests(IISTestSiteFixture fixture) : base(fixture)
{
_fixture = fixture;
}
[ConditionalFact]
public async Task ClosesConnectionOnServerAbort()
{
try
{
var response = await _fixture.Client.GetAsync("/Abort").DefaultTimeout();
// 502 is expected for outofproc but not for inproc
if (_fixture.DeploymentResult.DeploymentParameters.HostingModel == HostingModel.OutOfProcess)
{
Assert.Equal(HttpStatusCode.BadGateway, response.StatusCode);
// 0x80072f78 ERROR_HTTP_INVALID_SERVER_RESPONSE The server returned an invalid or unrecognized response
Assert.Contains("0x80072f78", await response.Content.ReadAsStringAsync());
}
else
{
Assert.True(false, "Should not reach here");
}
}
catch (HttpRequestException)
{
// Connection reset is expected both for outofproc and inproc
}
}
}
}

View File

@ -57,7 +57,7 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting
if (process.ExitCode != 0) if (process.ExitCode != 0)
{ {
throw new InvalidOperationException($"Exit code {process.ExitCode} when running {fileName} {arguments}. Stdout: {process.StandardOutput.ReadToEnd()}"); throw new InvalidOperationException($"Exit code {process.ExitCode} when running {fileName} {arguments}. Stdout: {process.StandardOutput.ReadToEnd()} Stderr: {process.StandardError.ReadToEnd()}");
} }
} }

View File

@ -146,7 +146,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
public static string InProcessFailedToStop(IISDeploymentResult deploymentResult, string reason) public static string InProcessFailedToStop(IISDeploymentResult deploymentResult, string reason)
{ {
return "Failed to gracefully shutdown application 'MACHINE/WEBROOT/APPHOST/HTTPTESTSITE'."; return "Failed to gracefully shutdown application 'MACHINE/WEBROOT/APPHOST/.*?'.";
} }
public static string InProcessThreadException(IISDeploymentResult deploymentResult, string reason) public static string InProcessThreadException(IISDeploymentResult deploymentResult, string reason)

View File

@ -13,7 +13,6 @@ using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
using Microsoft.AspNetCore.Testing; using Microsoft.AspNetCore.Testing;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Xunit; using Xunit;
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
@ -203,5 +202,12 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
var output = JsonConvert.SerializeObject(depsFileContent); var output = JsonConvert.SerializeObject(depsFileContent);
File.WriteAllText(path, output); File.WriteAllText(path, output);
} }
public static void AllowNoLogs(this IISDeploymentResult deploymentResult)
{
File.AppendAllText(
Path.Combine(deploymentResult.DeploymentParameters.PublishedApplicationRootPath, "aspnetcore-debug.log"),
"Running test allowed log file to be empty." + Environment.NewLine);
}
} }
} }

View File

@ -13,4 +13,17 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{ {
public const string Name = nameof(IISTestSiteCollection); public const string Name = nameof(IISTestSiteCollection);
} }
[CollectionDefinition(Name)]
public class OutOfProcessTestSiteCollection : ICollectionFixture<OutOfProcessTestSiteFixture>
{
public const string Name = nameof(OutOfProcessTestSiteCollection);
}
[CollectionDefinition(Name)]
public class OutOfProcessV1TestSiteCollection : ICollectionFixture<OutOfProcessV1TestSiteFixture>
{
public const string Name = nameof(OutOfProcessV1TestSiteCollection);
}
} }

View File

@ -4,7 +4,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net.Http; using System.Net.Http;
using System.Threading;
using Microsoft.AspNetCore.Server.IntegrationTesting; using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS; using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@ -12,6 +11,33 @@ using Microsoft.Extensions.Logging.Testing;
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{ {
public class OutOfProcessTestSiteFixture : IISTestSiteFixture
{
public OutOfProcessTestSiteFixture() : base(Configure)
{
}
private static void Configure(IISDeploymentParameters deploymentParameters)
{
deploymentParameters.ApplicationPath = Helpers.GetOutOfProcessTestSitesPath();
deploymentParameters.HostingModel = HostingModel.OutOfProcess;
}
}
public class OutOfProcessV1TestSiteFixture : IISTestSiteFixture
{
public OutOfProcessV1TestSiteFixture() : base(Configure)
{
}
private static void Configure(IISDeploymentParameters deploymentParameters)
{
deploymentParameters.ApplicationPath = Helpers.GetOutOfProcessTestSitesPath();
deploymentParameters.HostingModel = HostingModel.OutOfProcess;
deploymentParameters.AncmVersion = AncmVersion.AspNetCoreModule;
}
}
public class IISTestSiteFixture : IDisposable public class IISTestSiteFixture : IDisposable
{ {
private ApplicationDeployer _deployer; private ApplicationDeployer _deployer;

View File

@ -0,0 +1,24 @@
// 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.
using System;
using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.AspNetCore.Testing.xunit;
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method)]
public sealed class RequiresEnvironmentVariableAttribute : Attribute, ITestCondition
{
private readonly string _name;
public RequiresEnvironmentVariableAttribute(string name)
{
_name = name;
}
public bool IsMet => !string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable(_name));
public string SkipReason => $"Environment variable {_name} is required to run this test.";
}
}

View File

@ -31,6 +31,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
private readonly string _dotnetLocation = DotNetCommands.GetDotNetExecutable(RuntimeArchitecture.x64); private readonly string _dotnetLocation = DotNetCommands.GetDotNetExecutable(RuntimeArchitecture.x64);
[ConditionalFact] [ConditionalFact]
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
public async Task ExpandEnvironmentVariableInWebConfig() public async Task ExpandEnvironmentVariableInWebConfig()
{ {
// Point to dotnet installed in user profile. // Point to dotnet installed in user profile.
@ -90,6 +91,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalTheory] [ConditionalTheory]
[InlineData("dotnet")] [InlineData("dotnet")]
[InlineData("dotnet.EXE")] [InlineData("dotnet.EXE")]
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
public async Task StartsWithDotnetOnThePath(string path) public async Task StartsWithDotnetOnThePath(string path)
{ {
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true); var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
@ -120,9 +122,13 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
} }
[ConditionalFact] [ConditionalFact]
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
public async Task StartsWithPortableAndBootstraperExe() public async Task StartsWithPortableAndBootstraperExe()
{ {
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true); var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true);
// We need the right dotnet on the path in IIS
deploymentParameters.EnvironmentVariables["PATH"] = Path.GetDirectoryName(DotNetCommands.GetDotNetExecutable(deploymentParameters.RuntimeArchitecture));
// rest publisher as it doesn't support additional parameters // rest publisher as it doesn't support additional parameters
deploymentParameters.ApplicationPublisher = null; deploymentParameters.ApplicationPublisher = null;
// ReferenceTestTasks is workaround for https://github.com/dotnet/sdk/issues/2482 // ReferenceTestTasks is workaround for https://github.com/dotnet/sdk/issues/2482
@ -302,6 +308,9 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
var result = await deploymentResult.HttpClient.GetAsync("/HelloWorld"); var result = await deploymentResult.HttpClient.GetAsync("/HelloWorld");
Assert.Equal(HttpStatusCode.InternalServerError, result.StatusCode); Assert.Equal(HttpStatusCode.InternalServerError, result.StatusCode);
// Config load errors might not allow us to initialize log file
deploymentResult.AllowNoLogs();
StopServer(); StopServer();
EventLogHelpers.VerifyEventLogEvents(deploymentResult, EventLogHelpers.VerifyEventLogEvents(deploymentResult,

View File

@ -78,13 +78,9 @@ namespace IIS.FunctionalTests
private static void EnablePreload(IISDeploymentParameters baseDeploymentParameters) private static void EnablePreload(IISDeploymentParameters baseDeploymentParameters)
{ {
baseDeploymentParameters.EnsureSection("applicationInitialization", "system.webServer");
baseDeploymentParameters.ServerConfigActionList.Add( baseDeploymentParameters.ServerConfigActionList.Add(
(config, _) => { (config, _) => {
config
.RequiredElement("configSections")
.GetOrAdd("sectionGroup", "name", "system.webServer")
.GetOrAdd("section", "name", "applicationInitialization")
.SetAttributeValue("overrideModeDefault", "Allow");
config config
.RequiredElement("system.applicationHost") .RequiredElement("system.applicationHost")

View File

@ -12,11 +12,11 @@
"commandName": "Executable", "commandName": "Executable",
"executablePath": "$(IISExpressPath)", "executablePath": "$(IISExpressPath)",
"commandLineArgs": "$(IISExpressArguments)", "commandLineArgs": "$(IISExpressArguments)",
"nativeDebugging": true,
"environmentVariables": { "environmentVariables": {
"IIS_SITE_PATH": "$(MSBuildThisFileDirectory)", "IIS_SITE_PATH": "$(MSBuildThisFileDirectory)",
"ANCM_PATH": "$(TargetDir)\\$(AncmPath)", "ANCM_PATH": "$(AspNetCoreModuleV1ShimDll)",
"ANCMV2_PATH": "$(TargetDir)\\$(AncmV2Path)", "ANCMV2_PATH": "$(AspNetCoreModuleV2ShimDll)",
"ANCM_OUTOFPROCESS_HANDLER": "$(AspNetCoreModuleV2OutOfProcessHandlerDll)",
"LAUNCHER_ARGS": "$(TargetPath)", "LAUNCHER_ARGS": "$(TargetPath)",
"ASPNETCORE_ENVIRONMENT": "Development", "ASPNETCORE_ENVIRONMENT": "Development",
"LAUNCHER_PATH": "$(DotNetPath)", "LAUNCHER_PATH": "$(DotNetPath)",
@ -29,8 +29,9 @@
"commandLineArgs": "$(IISArguments)", "commandLineArgs": "$(IISArguments)",
"environmentVariables": { "environmentVariables": {
"IIS_SITE_PATH": "$(MSBuildThisFileDirectory)", "IIS_SITE_PATH": "$(MSBuildThisFileDirectory)",
"ANCM_PATH": "$(AncmPath)", "ANCM_PATH": "$(AspNetCoreModuleV1ShimDll)",
"ANCMV2_PATH": "$(AncmV2Path)", "ANCMV2_PATH": "$(AspNetCoreModuleV2ShimDll)",
"ASPNETCORE_MODULE_OUTOFPROCESS_HANDLER": "$(AspNetCoreModuleV2OutOfProcessHandlerDll)",
"LAUNCHER_ARGS": "$(TargetPath)", "LAUNCHER_ARGS": "$(TargetPath)",
"ASPNETCORE_ENVIRONMENT": "Development", "ASPNETCORE_ENVIRONMENT": "Development",
"LAUNCHER_PATH": "$(DotNetPath)", "LAUNCHER_PATH": "$(DotNetPath)",

View File

@ -12,11 +12,11 @@
"commandName": "Executable", "commandName": "Executable",
"executablePath": "$(IISExpressPath)", "executablePath": "$(IISExpressPath)",
"commandLineArgs": "$(IISExpressArguments)", "commandLineArgs": "$(IISExpressArguments)",
"nativeDebugging": true,
"environmentVariables": { "environmentVariables": {
"IIS_SITE_PATH": "$(MSBuildThisFileDirectory)", "IIS_SITE_PATH": "$(MSBuildThisFileDirectory)",
"ANCM_PATH": "$(TargetDir)\\$(AncmPath)", "ANCM_PATH": "$(AspNetCoreModuleV1ShimDll)",
"ANCMV2_PATH": "$(TargetDir)\\$(AncmV2Path)", "ANCMV2_PATH": "$(AspNetCoreModuleV2ShimDll)",
"ANCM_OUTOFPROCESS_HANDLER": "$(AspNetCoreModuleV2OutOfProcessHandlerDll)",
"LAUNCHER_ARGS": "$(TargetPath)", "LAUNCHER_ARGS": "$(TargetPath)",
"ASPNETCORE_ENVIRONMENT": "Development", "ASPNETCORE_ENVIRONMENT": "Development",
"LAUNCHER_PATH": "$(DotNetPath)", "LAUNCHER_PATH": "$(DotNetPath)",
@ -29,8 +29,9 @@
"commandLineArgs": "$(IISArguments)", "commandLineArgs": "$(IISArguments)",
"environmentVariables": { "environmentVariables": {
"IIS_SITE_PATH": "$(MSBuildThisFileDirectory)", "IIS_SITE_PATH": "$(MSBuildThisFileDirectory)",
"ANCM_PATH": "$(AncmPath)", "ANCM_PATH": "$(AspNetCoreModuleV1ShimDll)",
"ANCMV2_PATH": "$(AncmV2Path)", "ANCMV2_PATH": "$(AspNetCoreModuleV2ShimDll)",
"ASPNETCORE_MODULE_OUTOFPROCESS_HANDLER": "$(AspNetCoreModuleV2OutOfProcessHandlerDll)",
"LAUNCHER_ARGS": "$(TargetPath)", "LAUNCHER_ARGS": "$(TargetPath)",
"ASPNETCORE_ENVIRONMENT": "Development", "ASPNETCORE_ENVIRONMENT": "Development",
"LAUNCHER_PATH": "$(DotNetPath)", "LAUNCHER_PATH": "$(DotNetPath)",

View File

@ -12,11 +12,11 @@
"commandName": "Executable", "commandName": "Executable",
"executablePath": "$(IISExpressPath)", "executablePath": "$(IISExpressPath)",
"commandLineArgs": "$(IISExpressArguments)", "commandLineArgs": "$(IISExpressArguments)",
"nativeDebugging": true,
"environmentVariables": { "environmentVariables": {
"IIS_SITE_PATH": "$(MSBuildThisFileDirectory)", "IIS_SITE_PATH": "$(MSBuildThisFileDirectory)",
"ANCM_PATH": "$(TargetDir)\\$(AncmPath)", "ANCM_PATH": "$(AspNetCoreModuleV1ShimDll)",
"ANCMV2_PATH": "$(TargetDir)\\$(AncmV2Path)", "ANCMV2_PATH": "$(AspNetCoreModuleV2ShimDll)",
"ANCM_OUTOFPROCESS_HANDLER": "$(AspNetCoreModuleV2OutOfProcessHandlerDll)",
"LAUNCHER_ARGS": "$(TargetPath)", "LAUNCHER_ARGS": "$(TargetPath)",
"ASPNETCORE_ENVIRONMENT": "Development", "ASPNETCORE_ENVIRONMENT": "Development",
"LAUNCHER_PATH": "$(DotNetPath)", "LAUNCHER_PATH": "$(DotNetPath)",
@ -29,8 +29,9 @@
"commandLineArgs": "$(IISArguments)", "commandLineArgs": "$(IISArguments)",
"environmentVariables": { "environmentVariables": {
"IIS_SITE_PATH": "$(MSBuildThisFileDirectory)", "IIS_SITE_PATH": "$(MSBuildThisFileDirectory)",
"ANCM_PATH": "$(AncmPath)", "ANCM_PATH": "$(AspNetCoreModuleV1ShimDll)",
"ANCMV2_PATH": "$(AncmV2Path)", "ANCMV2_PATH": "$(AspNetCoreModuleV2ShimDll)",
"ASPNETCORE_MODULE_OUTOFPROCESS_HANDLER": "$(AspNetCoreModuleV2OutOfProcessHandlerDll)",
"LAUNCHER_ARGS": "$(TargetPath)", "LAUNCHER_ARGS": "$(TargetPath)",
"ASPNETCORE_ENVIRONMENT": "Development", "ASPNETCORE_ENVIRONMENT": "Development",
"LAUNCHER_PATH": "$(DotNetPath)", "LAUNCHER_PATH": "$(DotNetPath)",

View File

@ -68,10 +68,16 @@ namespace TestSite
} }
finally finally
{ {
Interlocked.Decrement(ref _waitingRequestCount); Interlocked.Decrement(ref _waitingRequestCount);
} }
} }
public Task Abort(HttpContext context)
{
context.Abort();
return Task.CompletedTask;
}
public async Task WaitingRequestCount(HttpContext context) public async Task WaitingRequestCount(HttpContext context)
{ {
await context.Response.WriteAsync(_waitingRequestCount.ToString()); await context.Response.WriteAsync(_waitingRequestCount.ToString());

View File

@ -57,8 +57,8 @@ function Setup-appverif($application)
function Shutdown-appverif($application) function Shutdown-appverif($application)
{ {
setx APPVERIFIER_ENABLED_CODES "`"`""; setx APPVERIFIER_ENABLED_CODES "NONE";
setx APPVERIFIER_LEVEL "`"`""; setx APPVERIFIER_LEVEL "NONE";
appverif.exe -disable * -for $application appverif.exe -disable * -for $application
} }