Merge branch 'merge/release/2.2-to-master'
This commit is contained in:
commit
0fa48ea997
|
|
@ -12,11 +12,11 @@
|
|||
"commandName": "Executable",
|
||||
"executablePath": "$(IISExpressPath)",
|
||||
"commandLineArgs": "$(IISExpressArguments)",
|
||||
"nativeDebugging": true,
|
||||
"environmentVariables": {
|
||||
"IIS_SITE_PATH": "$(MSBuildThisFileDirectory)",
|
||||
"ANCM_PATH": "$(TargetDir)\\$(AncmPath)",
|
||||
"ANCMV2_PATH": "$(TargetDir)\\$(AncmV2Path)",
|
||||
"ANCM_PATH": "$(AspNetCoreModuleV1ShimDll)",
|
||||
"ANCMV2_PATH": "$(AspNetCoreModuleV2ShimDll)",
|
||||
"ANCM_OUTOFPROCESS_HANDLER": "$(AspNetCoreModuleV2OutOfProcessHandlerDll)",
|
||||
"LAUNCHER_ARGS": "$(TargetPath)",
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"LAUNCHER_PATH": "$(DotNetPath)",
|
||||
|
|
@ -29,8 +29,9 @@
|
|||
"commandLineArgs": "$(IISArguments)",
|
||||
"environmentVariables": {
|
||||
"IIS_SITE_PATH": "$(MSBuildThisFileDirectory)",
|
||||
"ANCM_PATH": "$(AncmPath)",
|
||||
"ANCMV2_PATH": "$(AncmV2Path)",
|
||||
"ANCM_PATH": "$(AspNetCoreModuleV1ShimDll)",
|
||||
"ANCMV2_PATH": "$(AspNetCoreModuleV2ShimDll)",
|
||||
"ASPNETCORE_MODULE_OUTOFPROCESS_HANDLER": "$(AspNetCoreModuleV2OutOfProcessHandlerDll)",
|
||||
"LAUNCHER_ARGS": "$(TargetPath)",
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"LAUNCHER_PATH": "$(DotNetPath)",
|
||||
|
|
|
|||
|
|
@ -36,8 +36,6 @@
|
|||
<IISExpressArguments>/config:"$(IISExpressAppHostConfig)" /systray:false</IISExpressArguments>
|
||||
<IISArguments>-h "$(IISAppHostConfig)"</IISArguments>
|
||||
|
||||
<AncmPath>$(AspNetCoreModuleV1ShimDll)</AncmPath>
|
||||
<AncmV2Path>$(AspNetCoreModuleV2ShimDll)</AncmV2Path>
|
||||
<AncmInProcessRHPath>aspnetcorev2_inprocess.dll</AncmInProcessRHPath>
|
||||
<DotNetPath>$(userprofile)\.dotnet\$(NativePlatform)\dotnet.exe</DotNetPath>
|
||||
</PropertyGroup>
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@
|
|||
"commandName": "Executable",
|
||||
"executablePath": "$(IISExpressPath)",
|
||||
"commandLineArgs": "$(IISExpressArguments)",
|
||||
"nativeDebugging": true,
|
||||
"environmentVariables": {
|
||||
"IIS_SITE_PATH": "$(MSBuildThisFileDirectory)",
|
||||
"ANCM_PATH": "$(TargetDir)\\$(AncmPath)",
|
||||
"ANCMV2_PATH": "$(TargetDir)\\$(AncmV2Path)",
|
||||
"ANCM_PATH": "$(AncmPath)",
|
||||
"ANCMV2_PATH": "$(AncmV2Path)",
|
||||
"ANCM_OUTOFPROCESS_HANDLER": "$(AspNetCoreModuleV2OutOfProcessHandlerDll)",
|
||||
"LAUNCHER_ARGS": "$(TargetPath)",
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"LAUNCHER_PATH": "$(DotNetPath)",
|
||||
|
|
@ -31,6 +31,7 @@
|
|||
"IIS_SITE_PATH": "$(MSBuildThisFileDirectory)",
|
||||
"ANCM_PATH": "$(AncmPath)",
|
||||
"ANCMV2_PATH": "$(AncmV2Path)",
|
||||
"ANCM_OUTOFPROCESS_HANDLER": "$(AspNetCoreModuleV2OutOfProcessHandlerDll)",
|
||||
"LAUNCHER_ARGS": "$(TargetPath)",
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"LAUNCHER_PATH": "$(DotNetPath)",
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
#include "WebConfigConfigurationSource.h"
|
||||
#include "ModuleHelpers.h"
|
||||
#include "BaseOutputManager.h"
|
||||
#include "Environment.h"
|
||||
|
||||
const PCWSTR HandlerResolver::s_pwzAspnetcoreInProcessRequestHandlerName = L"aspnetcorev2_inprocess.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());
|
||||
|
||||
hRequestHandlerDll = LoadLibrary(handlerDllPath.c_str());
|
||||
RETURN_LAST_ERROR_IF_NULL(hRequestHandlerDll);
|
||||
if (preventUnload)
|
||||
{
|
||||
// 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");
|
||||
|
|
@ -150,7 +151,7 @@ HandlerResolver::GetApplicationFactory(const IHttpApplication &pApplication, std
|
|||
m_loadedApplicationHostingModel = options.QueryHostingModel();
|
||||
m_loadedApplicationId = pApplication.GetApplicationId();
|
||||
RETURN_IF_FAILED(LoadRequestHandlerAssembly(pApplication, options, pApplicationFactory));
|
||||
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
|
@ -171,6 +172,13 @@ HandlerResolver::FindNativeAssemblyFromGlobalLocation(
|
|||
{
|
||||
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);
|
||||
|
||||
modulePath = GlobalVersionUtility::RemoveFileNameFromFolderPath(modulePath);
|
||||
|
|
|
|||
|
|
@ -119,12 +119,18 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
|
|||
key: "hostingModel",
|
||||
value: DeploymentParameters.HostingModel.ToString());
|
||||
|
||||
if (DeploymentParameters.ApplicationType == ApplicationType.Portable)
|
||||
{
|
||||
yield return WebConfigHelpers.AddOrModifyAspNetCoreSection(
|
||||
"processPath",
|
||||
DotNetCommands.GetDotNetExecutable(DeploymentParameters.RuntimeArchitecture));
|
||||
}
|
||||
yield return (element, _) => {
|
||||
var aspNetCore = element
|
||||
.Descendants("system.webServer")
|
||||
.Single()
|
||||
.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(
|
||||
key: "modules",
|
||||
|
|
@ -399,8 +405,10 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
|
|||
redirectionSection.Attributes["enabled"].Value = false;
|
||||
|
||||
serverManager.CommitChanges();
|
||||
|
||||
Directory.Delete(_configPath, true);
|
||||
if (Directory.Exists(_configPath))
|
||||
{
|
||||
Directory.Delete(_configPath, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,14 +43,22 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
|
|||
|
||||
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.AddServerConfigAction(
|
||||
element =>
|
||||
{
|
||||
element.Descendants("windowsAuthentication")
|
||||
.Single()
|
||||
.SetAttributeValue("enabled", enabled);
|
||||
var windowsAuthentication = element
|
||||
.RequiredElement("system.webServer")
|
||||
.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(
|
||||
element =>
|
||||
{
|
||||
element.Descendants("anonymousAuthentication")
|
||||
.Single()
|
||||
element
|
||||
.RequiredElement("system.webServer")
|
||||
.RequiredElement("security")
|
||||
.RequiredElement("authentication")
|
||||
.GetOrAdd("anonymousAuthentication")
|
||||
.SetAttributeValue("enabled", enabled);
|
||||
});
|
||||
}
|
||||
|
|
@ -72,12 +83,33 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
|
|||
parameters.AddServerConfigAction(
|
||||
element =>
|
||||
{
|
||||
element.Descendants("basicAuthentication")
|
||||
.Single()
|
||||
element
|
||||
.RequiredElement("system.webServer")
|
||||
.RequiredElement("security")
|
||||
.RequiredElement("authentication")
|
||||
.GetOrAdd("basicAuthentication")
|
||||
.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)
|
||||
{
|
||||
deploymentParameters.WebConfigActionList.Add(
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using System.Net.Http;
|
|||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
|
||||
|
|
@ -32,7 +31,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
.WithAllAncmVersions()
|
||||
.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)]
|
||||
[MemberData(nameof(TestVariants))]
|
||||
public async Task BasicAuthTest(TestVariant variant)
|
||||
|
|
@ -63,7 +63,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
else
|
||||
{
|
||||
// We expect out-of-proc not allowing basic auth
|
||||
Assert.Equal("Windows:", responseText);
|
||||
Assert.Equal("Windows", responseText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,6 +23,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
}
|
||||
|
||||
[ConditionalFact]
|
||||
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
|
||||
public async Task IncludesAdditionalErrorPageTextInProcessHandlerLoadFailure()
|
||||
{
|
||||
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
|
||||
|
|
@ -37,6 +38,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
}
|
||||
|
||||
[ConditionalFact]
|
||||
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
|
||||
public async Task IncludesAdditionalErrorPageTextOutOfProcessStartupFailure()
|
||||
{
|
||||
var deploymentParameters = _fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess, publish: true);
|
||||
|
|
@ -51,6 +53,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
}
|
||||
|
||||
[ConditionalFact]
|
||||
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
|
||||
public async Task IncludesAdditionalErrorPageTextOutOfProcessHandlerLoadFailure()
|
||||
{
|
||||
var deploymentParameters = _fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess, publish: true);
|
||||
|
|
@ -69,6 +72,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
}
|
||||
|
||||
[ConditionalFact]
|
||||
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
|
||||
public async Task IncludesAdditionalErrorPageTextInProcessStartupFailure()
|
||||
{
|
||||
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
|
||||
|
|
@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
{
|
||||
_fixture = fixture;
|
||||
}
|
||||
|
||||
|
||||
public override void Initialize(MethodInfo methodInfo, object[] testMethodArguments, ITestOutputHelper testOutputHelper)
|
||||
{
|
||||
base.Initialize(methodInfo, testMethodArguments, testOutputHelper);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// 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 System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
|
|
@ -32,18 +33,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
public async Task GlobalVersion_DefaultWorks()
|
||||
{
|
||||
var deploymentParameters = GetGlobalVersionBaseDeploymentParameters();
|
||||
deploymentParameters.PublishApplicationBeforeDeployment = false;
|
||||
|
||||
deploymentParameters.AddServerConfigAction(
|
||||
element =>
|
||||
{
|
||||
var handlerVersionElement = new XElement("handlerSetting");
|
||||
handlerVersionElement.SetAttributeValue("name", "handlerVersion");
|
||||
handlerVersionElement.SetAttributeValue("value", _handlerVersion20);
|
||||
|
||||
element.Descendants("aspNetCore").Single()
|
||||
.Add(new XElement("handlerSettings", handlerVersionElement));
|
||||
});
|
||||
deploymentParameters.HandlerSettings["handlerVersion"] = _handlerVersion20;
|
||||
|
||||
var deploymentResult = await DeployAsync(deploymentParameters);
|
||||
|
||||
|
|
@ -52,6 +43,35 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
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]
|
||||
[InlineData("2.1.0")]
|
||||
[InlineData("2.1.0-preview")]
|
||||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -57,7 +57,7 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting
|
|||
|
||||
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()}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
|
|||
using Microsoft.AspNetCore.Testing;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
||||
|
|
@ -203,5 +202,12 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
var output = JsonConvert.SerializeObject(depsFileContent);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,4 +13,17 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
{
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
|
@ -12,6 +11,33 @@ using Microsoft.Extensions.Logging.Testing;
|
|||
|
||||
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
|
||||
{
|
||||
private ApplicationDeployer _deployer;
|
||||
|
|
|
|||
|
|
@ -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.";
|
||||
}
|
||||
}
|
||||
|
|
@ -31,6 +31,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
private readonly string _dotnetLocation = DotNetCommands.GetDotNetExecutable(RuntimeArchitecture.x64);
|
||||
|
||||
[ConditionalFact]
|
||||
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
|
||||
public async Task ExpandEnvironmentVariableInWebConfig()
|
||||
{
|
||||
// Point to dotnet installed in user profile.
|
||||
|
|
@ -90,6 +91,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
[ConditionalTheory]
|
||||
[InlineData("dotnet")]
|
||||
[InlineData("dotnet.EXE")]
|
||||
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
|
||||
public async Task StartsWithDotnetOnThePath(string path)
|
||||
{
|
||||
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
|
||||
|
|
@ -120,9 +122,13 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
}
|
||||
|
||||
[ConditionalFact]
|
||||
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
|
||||
public async Task StartsWithPortableAndBootstraperExe()
|
||||
{
|
||||
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
|
||||
deploymentParameters.ApplicationPublisher = null;
|
||||
// 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");
|
||||
Assert.Equal(HttpStatusCode.InternalServerError, result.StatusCode);
|
||||
|
||||
// Config load errors might not allow us to initialize log file
|
||||
deploymentResult.AllowNoLogs();
|
||||
|
||||
StopServer();
|
||||
|
||||
EventLogHelpers.VerifyEventLogEvents(deploymentResult,
|
||||
|
|
@ -78,13 +78,9 @@ namespace IIS.FunctionalTests
|
|||
|
||||
private static void EnablePreload(IISDeploymentParameters baseDeploymentParameters)
|
||||
{
|
||||
baseDeploymentParameters.EnsureSection("applicationInitialization", "system.webServer");
|
||||
baseDeploymentParameters.ServerConfigActionList.Add(
|
||||
(config, _) => {
|
||||
config
|
||||
.RequiredElement("configSections")
|
||||
.GetOrAdd("sectionGroup", "name", "system.webServer")
|
||||
.GetOrAdd("section", "name", "applicationInitialization")
|
||||
.SetAttributeValue("overrideModeDefault", "Allow");
|
||||
|
||||
config
|
||||
.RequiredElement("system.applicationHost")
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@
|
|||
"commandName": "Executable",
|
||||
"executablePath": "$(IISExpressPath)",
|
||||
"commandLineArgs": "$(IISExpressArguments)",
|
||||
"nativeDebugging": true,
|
||||
"environmentVariables": {
|
||||
"IIS_SITE_PATH": "$(MSBuildThisFileDirectory)",
|
||||
"ANCM_PATH": "$(TargetDir)\\$(AncmPath)",
|
||||
"ANCMV2_PATH": "$(TargetDir)\\$(AncmV2Path)",
|
||||
"ANCM_PATH": "$(AspNetCoreModuleV1ShimDll)",
|
||||
"ANCMV2_PATH": "$(AspNetCoreModuleV2ShimDll)",
|
||||
"ANCM_OUTOFPROCESS_HANDLER": "$(AspNetCoreModuleV2OutOfProcessHandlerDll)",
|
||||
"LAUNCHER_ARGS": "$(TargetPath)",
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"LAUNCHER_PATH": "$(DotNetPath)",
|
||||
|
|
@ -29,8 +29,9 @@
|
|||
"commandLineArgs": "$(IISArguments)",
|
||||
"environmentVariables": {
|
||||
"IIS_SITE_PATH": "$(MSBuildThisFileDirectory)",
|
||||
"ANCM_PATH": "$(AncmPath)",
|
||||
"ANCMV2_PATH": "$(AncmV2Path)",
|
||||
"ANCM_PATH": "$(AspNetCoreModuleV1ShimDll)",
|
||||
"ANCMV2_PATH": "$(AspNetCoreModuleV2ShimDll)",
|
||||
"ASPNETCORE_MODULE_OUTOFPROCESS_HANDLER": "$(AspNetCoreModuleV2OutOfProcessHandlerDll)",
|
||||
"LAUNCHER_ARGS": "$(TargetPath)",
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"LAUNCHER_PATH": "$(DotNetPath)",
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@
|
|||
"commandName": "Executable",
|
||||
"executablePath": "$(IISExpressPath)",
|
||||
"commandLineArgs": "$(IISExpressArguments)",
|
||||
"nativeDebugging": true,
|
||||
"environmentVariables": {
|
||||
"IIS_SITE_PATH": "$(MSBuildThisFileDirectory)",
|
||||
"ANCM_PATH": "$(TargetDir)\\$(AncmPath)",
|
||||
"ANCMV2_PATH": "$(TargetDir)\\$(AncmV2Path)",
|
||||
"ANCM_PATH": "$(AspNetCoreModuleV1ShimDll)",
|
||||
"ANCMV2_PATH": "$(AspNetCoreModuleV2ShimDll)",
|
||||
"ANCM_OUTOFPROCESS_HANDLER": "$(AspNetCoreModuleV2OutOfProcessHandlerDll)",
|
||||
"LAUNCHER_ARGS": "$(TargetPath)",
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"LAUNCHER_PATH": "$(DotNetPath)",
|
||||
|
|
@ -29,8 +29,9 @@
|
|||
"commandLineArgs": "$(IISArguments)",
|
||||
"environmentVariables": {
|
||||
"IIS_SITE_PATH": "$(MSBuildThisFileDirectory)",
|
||||
"ANCM_PATH": "$(AncmPath)",
|
||||
"ANCMV2_PATH": "$(AncmV2Path)",
|
||||
"ANCM_PATH": "$(AspNetCoreModuleV1ShimDll)",
|
||||
"ANCMV2_PATH": "$(AspNetCoreModuleV2ShimDll)",
|
||||
"ASPNETCORE_MODULE_OUTOFPROCESS_HANDLER": "$(AspNetCoreModuleV2OutOfProcessHandlerDll)",
|
||||
"LAUNCHER_ARGS": "$(TargetPath)",
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"LAUNCHER_PATH": "$(DotNetPath)",
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@
|
|||
"commandName": "Executable",
|
||||
"executablePath": "$(IISExpressPath)",
|
||||
"commandLineArgs": "$(IISExpressArguments)",
|
||||
"nativeDebugging": true,
|
||||
"environmentVariables": {
|
||||
"IIS_SITE_PATH": "$(MSBuildThisFileDirectory)",
|
||||
"ANCM_PATH": "$(TargetDir)\\$(AncmPath)",
|
||||
"ANCMV2_PATH": "$(TargetDir)\\$(AncmV2Path)",
|
||||
"ANCM_PATH": "$(AspNetCoreModuleV1ShimDll)",
|
||||
"ANCMV2_PATH": "$(AspNetCoreModuleV2ShimDll)",
|
||||
"ANCM_OUTOFPROCESS_HANDLER": "$(AspNetCoreModuleV2OutOfProcessHandlerDll)",
|
||||
"LAUNCHER_ARGS": "$(TargetPath)",
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"LAUNCHER_PATH": "$(DotNetPath)",
|
||||
|
|
@ -29,8 +29,9 @@
|
|||
"commandLineArgs": "$(IISArguments)",
|
||||
"environmentVariables": {
|
||||
"IIS_SITE_PATH": "$(MSBuildThisFileDirectory)",
|
||||
"ANCM_PATH": "$(AncmPath)",
|
||||
"ANCMV2_PATH": "$(AncmV2Path)",
|
||||
"ANCM_PATH": "$(AspNetCoreModuleV1ShimDll)",
|
||||
"ANCMV2_PATH": "$(AspNetCoreModuleV2ShimDll)",
|
||||
"ASPNETCORE_MODULE_OUTOFPROCESS_HANDLER": "$(AspNetCoreModuleV2OutOfProcessHandlerDll)",
|
||||
"LAUNCHER_ARGS": "$(TargetPath)",
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"LAUNCHER_PATH": "$(DotNetPath)",
|
||||
|
|
|
|||
|
|
@ -68,10 +68,16 @@ namespace TestSite
|
|||
}
|
||||
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)
|
||||
{
|
||||
await context.Response.WriteAsync(_waitingRequestCount.ToString());
|
||||
|
|
|
|||
|
|
@ -57,8 +57,8 @@ function Setup-appverif($application)
|
|||
|
||||
function Shutdown-appverif($application)
|
||||
{
|
||||
setx APPVERIFIER_ENABLED_CODES "`"`"";
|
||||
setx APPVERIFIER_LEVEL "`"`"";
|
||||
setx APPVERIFIER_ENABLED_CODES "NONE";
|
||||
setx APPVERIFIER_LEVEL "NONE";
|
||||
|
||||
appverif.exe -disable * -for $application
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue