Move config operations from helpers to functions on the deployment parameters (#1063)
This commit is contained in:
parent
97ebe36b13
commit
89fda83bbd
|
|
@ -1,4 +1,4 @@
|
|||
<Project>
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
</PropertyGroup>
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
<MicrosoftAspNetCoreHttpOverridesPackageVersion>2.2.0-preview1-34694</MicrosoftAspNetCoreHttpOverridesPackageVersion>
|
||||
<MicrosoftAspNetCoreHttpPackageVersion>2.2.0-preview1-34694</MicrosoftAspNetCoreHttpPackageVersion>
|
||||
<MicrosoftAspNetCoreHttpSysSourcesPackageVersion>2.2.0-preview1-34694</MicrosoftAspNetCoreHttpSysSourcesPackageVersion>
|
||||
<MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>0.6.0-a-preview1-pk-rem-iis-17083</MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>
|
||||
<MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>0.6.0-a-preview1-DeploymentParameters-17085</MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>
|
||||
<MicrosoftAspNetCoreServerKestrelPackageVersion>2.2.0-preview1-34694</MicrosoftAspNetCoreServerKestrelPackageVersion>
|
||||
<MicrosoftAspNetCoreTestHostPackageVersion>2.2.0-preview1-34694</MicrosoftAspNetCoreTestHostPackageVersion>
|
||||
<MicrosoftAspNetCoreTestingPackageVersion>2.2.0-preview1-34694</MicrosoftAspNetCoreTestingPackageVersion>
|
||||
|
|
|
|||
|
|
@ -2,10 +2,8 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting.Common;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
|
|
@ -14,12 +12,17 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
|
|||
/// <summary>
|
||||
/// Deployer for IIS.
|
||||
/// </summary>
|
||||
public partial class IISDeployer : ApplicationDeployer
|
||||
public partial class IISDeployer : IISDeployerBase
|
||||
{
|
||||
private IISApplication _application;
|
||||
private CancellationTokenSource _hostShutdownToken = new CancellationTokenSource();
|
||||
|
||||
public IISDeployer(DeploymentParameters deploymentParameters, ILoggerFactory loggerFactory)
|
||||
: base(new IISDeploymentParameters(deploymentParameters), loggerFactory)
|
||||
{
|
||||
}
|
||||
|
||||
public IISDeployer(IISDeploymentParameters deploymentParameters, ILoggerFactory loggerFactory)
|
||||
: base(deploymentParameters, loggerFactory)
|
||||
{
|
||||
}
|
||||
|
|
@ -53,18 +56,19 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
|
|||
DeploymentParameters.ServerConfigTemplateContent = File.ReadAllText("IIS.config");
|
||||
}
|
||||
|
||||
_application = new IISApplication(DeploymentParameters, Logger);
|
||||
_application = new IISApplication(IISDeploymentParameters, Logger);
|
||||
|
||||
// For now, only support using published output
|
||||
DeploymentParameters.PublishApplicationBeforeDeployment = true;
|
||||
|
||||
if (DeploymentParameters.PublishApplicationBeforeDeployment)
|
||||
{
|
||||
DotnetPublish();
|
||||
contentRoot = DeploymentParameters.PublishedApplicationRootPath;
|
||||
IISDeploymentParameters.AddDebugLogToWebConfig(Path.Combine(contentRoot, $"{_application.WebSiteName}.txt"));
|
||||
RunWebConfigActions();
|
||||
}
|
||||
|
||||
WebConfigHelpers.AddDebugLogToWebConfig(contentRoot, Path.Combine(contentRoot, $"{_application.WebSiteName}.txt"));
|
||||
|
||||
var uri = TestUriHelper.BuildTestUri(ServerType.IIS, DeploymentParameters.ApplicationBaseUriHint);
|
||||
// To prevent modifying the IIS setup concurrently.
|
||||
await _application.StartIIS(uri, contentRoot);
|
||||
|
|
@ -74,7 +78,7 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
|
|||
|
||||
return new DeploymentResult(
|
||||
LoggerFactory,
|
||||
DeploymentParameters,
|
||||
IISDeploymentParameters,
|
||||
applicationBaseUri: uri.ToString(),
|
||||
contentRoot: contentRoot,
|
||||
hostShutdownToken: _hostShutdownToken.Token
|
||||
|
|
|
|||
|
|
@ -0,0 +1,63 @@
|
|||
// 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.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
|
||||
{
|
||||
public abstract class IISDeployerBase : ApplicationDeployer
|
||||
{
|
||||
public IISDeploymentParameters IISDeploymentParameters { get; }
|
||||
|
||||
public IISDeployerBase(IISDeploymentParameters deploymentParameters, ILoggerFactory loggerFactory)
|
||||
: base(deploymentParameters, loggerFactory)
|
||||
{
|
||||
IISDeploymentParameters = deploymentParameters;
|
||||
}
|
||||
|
||||
public void RunWebConfigActions()
|
||||
{
|
||||
if (IISDeploymentParameters == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!DeploymentParameters.PublishApplicationBeforeDeployment)
|
||||
{
|
||||
throw new InvalidOperationException("Cannot modify web.config file if no published output.");
|
||||
}
|
||||
|
||||
var path = Path.Combine(DeploymentParameters.PublishedApplicationRootPath, "web.config");
|
||||
var webconfig = XDocument.Load(path);
|
||||
var xElement = webconfig.Descendants("system.webServer").Single();
|
||||
foreach (var action in IISDeploymentParameters.WebConfigActionList)
|
||||
{
|
||||
action.Invoke(xElement);
|
||||
}
|
||||
|
||||
webconfig.Save(path);
|
||||
}
|
||||
|
||||
public string RunServerConfigActions(string serverConfigString)
|
||||
{
|
||||
if (IISDeploymentParameters == null)
|
||||
{
|
||||
return serverConfigString;
|
||||
}
|
||||
|
||||
var serverConfig = XDocument.Parse(serverConfigString);
|
||||
var xElement = serverConfig.Descendants("configuration").FirstOrDefault();
|
||||
|
||||
foreach (var action in IISDeploymentParameters.ServerConfigActionList)
|
||||
{
|
||||
action.Invoke(xElement);
|
||||
}
|
||||
return xElement.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
// 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.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
|
||||
{
|
||||
public static class IISDeploymentParameterExtensions
|
||||
{
|
||||
public static void AddDebugLogToWebConfig(this IISDeploymentParameters parameters, string filename)
|
||||
{
|
||||
parameters.HandlerSettings["debugLevel"] = "4";
|
||||
parameters.HandlerSettings["debugFile"] = filename;
|
||||
}
|
||||
|
||||
public static void AddServerConfigAction(this IISDeploymentParameters parameters, Action<XElement> action)
|
||||
{
|
||||
parameters.ServerConfigActionList.Add(action);
|
||||
}
|
||||
|
||||
public static void ModifyWebConfig(this IISDeploymentParameters parameters, Action<XElement> transform)
|
||||
{
|
||||
parameters.WebConfigActionList.Add(transform);
|
||||
}
|
||||
|
||||
public static void ModifyAspNetCoreSectionInWebConfig(this IISDeploymentParameters parameters, string key, string value)
|
||||
=> ModifyAttributeInWebConfig(parameters, key, value, section: "aspNetCore");
|
||||
|
||||
|
||||
public static void ModifyAttributeInWebConfig(this IISDeploymentParameters parameters, string key, string value, string section)
|
||||
{
|
||||
parameters.WebConfigActionList.Add((element) =>
|
||||
{
|
||||
element.Descendants(section).SingleOrDefault().SetAttributeValue(key, value);
|
||||
});
|
||||
}
|
||||
|
||||
public static void AddHttpsToServerConfig(this IISDeploymentParameters parameters)
|
||||
{
|
||||
parameters.ServerConfigActionList.Add(
|
||||
element =>
|
||||
{
|
||||
element.Descendants("binding")
|
||||
.Single()
|
||||
.SetAttributeValue("protocol", "https");
|
||||
|
||||
element.Descendants("access")
|
||||
.Single()
|
||||
.SetAttributeValue("sslFlags", "Ssl, SslNegotiateCert");
|
||||
});
|
||||
}
|
||||
|
||||
public static void AddWindowsAuthToServerConfig(this IISDeploymentParameters parameters)
|
||||
{
|
||||
parameters.ServerConfigActionList.Add(
|
||||
element =>
|
||||
{
|
||||
element.Descendants("windowsAuthentication")
|
||||
.Single()
|
||||
.SetAttributeValue("enabled", "true");
|
||||
});
|
||||
}
|
||||
|
||||
public static void ModifyHandlerSectionInWebConfig(this IISDeploymentParameters parameters, string key, string value)
|
||||
{
|
||||
parameters.WebConfigActionList.Add(element =>
|
||||
{
|
||||
element.Descendants("handlers")
|
||||
.FirstOrDefault()
|
||||
.Descendants("add")
|
||||
.FirstOrDefault()
|
||||
.SetAttributeValue(key, value);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
// 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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
|
||||
{
|
||||
public class IISDeploymentParameters : DeploymentParameters
|
||||
{
|
||||
public IISDeploymentParameters() : base()
|
||||
{
|
||||
WebConfigActionList = CreateDefaultWebConfigActionList();
|
||||
}
|
||||
|
||||
public IISDeploymentParameters(TestVariant variant)
|
||||
: base(variant)
|
||||
{
|
||||
WebConfigActionList = CreateDefaultWebConfigActionList();
|
||||
}
|
||||
|
||||
public IISDeploymentParameters(
|
||||
string applicationPath,
|
||||
ServerType serverType,
|
||||
RuntimeFlavor runtimeFlavor,
|
||||
RuntimeArchitecture runtimeArchitecture)
|
||||
: base(applicationPath, serverType, runtimeFlavor, runtimeArchitecture)
|
||||
{
|
||||
WebConfigActionList = CreateDefaultWebConfigActionList();
|
||||
}
|
||||
|
||||
public IISDeploymentParameters(DeploymentParameters parameters)
|
||||
: base(parameters)
|
||||
{
|
||||
WebConfigActionList = CreateDefaultWebConfigActionList();
|
||||
|
||||
if (parameters is IISDeploymentParameters)
|
||||
{
|
||||
var tempParameters = (IISDeploymentParameters)parameters;
|
||||
WebConfigActionList = tempParameters.WebConfigActionList;
|
||||
ServerConfigActionList = tempParameters.ServerConfigActionList;
|
||||
WebConfigBasedEnvironmentVariables = tempParameters.WebConfigBasedEnvironmentVariables;
|
||||
HandlerSettings = tempParameters.HandlerSettings;
|
||||
}
|
||||
}
|
||||
|
||||
private IList<Action<XElement>> CreateDefaultWebConfigActionList()
|
||||
{
|
||||
return new List<Action<XElement>>() { AddWebConfigEnvironmentVariables(), AddHandlerSettings() };
|
||||
}
|
||||
|
||||
public IList<Action<XElement>> WebConfigActionList { get; }
|
||||
|
||||
public IList<Action<XElement>> ServerConfigActionList { get; } = new List<Action<XElement>>();
|
||||
|
||||
public IDictionary<string, string> WebConfigBasedEnvironmentVariables { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
public IDictionary<string, string> HandlerSettings { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
private Action<XElement> AddWebConfigEnvironmentVariables()
|
||||
{
|
||||
return xElement =>
|
||||
{
|
||||
if (WebConfigBasedEnvironmentVariables.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var element = xElement.Descendants("environmentVariables").SingleOrDefault();
|
||||
if (element == null)
|
||||
{
|
||||
element = new XElement("environmentVariables");
|
||||
xElement.Descendants("aspNetCore").SingleOrDefault().Add(element);
|
||||
}
|
||||
|
||||
foreach (var envVar in WebConfigBasedEnvironmentVariables)
|
||||
{
|
||||
CreateOrSetElement(element, envVar.Key, envVar.Value, "environmentVariable");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private Action<XElement> AddHandlerSettings()
|
||||
{
|
||||
return xElement =>
|
||||
{
|
||||
if (HandlerSettings.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var element = xElement.Descendants("handlerSettings").SingleOrDefault();
|
||||
if (element == null)
|
||||
{
|
||||
element = new XElement("handlerSettings");
|
||||
xElement.Descendants("aspNetCore").SingleOrDefault().Add(element);
|
||||
}
|
||||
|
||||
foreach (var handlerSetting in HandlerSettings)
|
||||
{
|
||||
CreateOrSetElement(element, handlerSetting.Key, handlerSetting.Value, "handlerSetting");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static void CreateOrSetElement(XElement rootElement, string name, string value, string elementName)
|
||||
{
|
||||
if (rootElement.Descendants()
|
||||
.Attributes()
|
||||
.Where(attribute => attribute.Value == name)
|
||||
.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
var element = new XElement(elementName);
|
||||
element.SetAttributeValue("name", name);
|
||||
element.SetAttributeValue("value", value);
|
||||
rootElement.Add(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
|
|||
/// <summary>
|
||||
/// Deployment helper for IISExpress.
|
||||
/// </summary>
|
||||
public class IISExpressDeployer : ApplicationDeployer
|
||||
public class IISExpressDeployer : IISDeployerBase
|
||||
{
|
||||
private const string IISExpressRunningMessage = "IIS Express is running.";
|
||||
private const string FailedToInitializeBindingsMessage = "Failed to initialize site bindings";
|
||||
|
|
@ -31,6 +31,11 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
|
|||
private Process _hostProcess;
|
||||
|
||||
public IISExpressDeployer(DeploymentParameters deploymentParameters, ILoggerFactory loggerFactory)
|
||||
: base(new IISDeploymentParameters(deploymentParameters), loggerFactory)
|
||||
{
|
||||
}
|
||||
|
||||
public IISExpressDeployer(IISDeploymentParameters deploymentParameters, ILoggerFactory loggerFactory)
|
||||
: base(deploymentParameters, loggerFactory)
|
||||
{
|
||||
}
|
||||
|
|
@ -94,7 +99,7 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
|
|||
// Right now this works only for urls like http://localhost:5001/. Does not work for http://localhost:5001/subpath.
|
||||
return new DeploymentResult(
|
||||
LoggerFactory,
|
||||
DeploymentParameters,
|
||||
IISDeploymentParameters,
|
||||
applicationBaseUri: actualUri.ToString(),
|
||||
contentRoot: contentRoot,
|
||||
hostShutdownToken: hostExitToken);
|
||||
|
|
@ -272,11 +277,12 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
|
|||
if (DeploymentParameters.PublishApplicationBeforeDeployment)
|
||||
{
|
||||
// For published apps, prefer the content in the web.config, but update it.
|
||||
ModifyAspNetCoreSectionInWebConfig(key: "hostingModel",
|
||||
IISDeploymentParameters.ModifyAspNetCoreSectionInWebConfig(key: "hostingModel",
|
||||
value: DeploymentParameters.HostingModel == HostingModel.InProcess ? "inprocess" : "");
|
||||
ModifyHandlerSectionInWebConfig(key: "modules", value: DeploymentParameters.AncmVersion.ToString());
|
||||
IISDeploymentParameters.ModifyHandlerSectionInWebConfig(key: "modules", value: DeploymentParameters.AncmVersion.ToString());
|
||||
ModifyDotNetExePathInWebConfig();
|
||||
serverConfig = RemoveRedundantElements(serverConfig);
|
||||
RunWebConfigActions();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -284,6 +290,7 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
|
|||
serverConfig = ReplacePlaceholder(serverConfig, "[HostingModel]", DeploymentParameters.HostingModel.ToString());
|
||||
serverConfig = ReplacePlaceholder(serverConfig, "[AspNetCoreModule]", DeploymentParameters.AncmVersion.ToString());
|
||||
}
|
||||
serverConfig = RunServerConfigActions(serverConfig);
|
||||
|
||||
DeploymentParameters.ServerConfigLocation = Path.GetTempFileName();
|
||||
Logger.LogDebug("Saving Config to {configPath}", DeploymentParameters.ServerConfigLocation);
|
||||
|
|
@ -394,29 +401,10 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
|
|||
{
|
||||
throw new Exception($"Unable to find '{executableName}'.'");
|
||||
}
|
||||
ModifyAspNetCoreSectionInWebConfig("processPath", executableName);
|
||||
IISDeploymentParameters.ModifyAspNetCoreSectionInWebConfig("processPath", executableName);
|
||||
}
|
||||
}
|
||||
|
||||
// Transforms the web.config file to set attributes like hostingModel="inprocess" element
|
||||
private void ModifyAspNetCoreSectionInWebConfig(string key, string value)
|
||||
{
|
||||
var webConfigFile = Path.Combine(DeploymentParameters.PublishedApplicationRootPath, "web.config");
|
||||
var config = XDocument.Load(webConfigFile);
|
||||
var element = config.Descendants("aspNetCore").FirstOrDefault();
|
||||
element.SetAttributeValue(key, value);
|
||||
config.Save(webConfigFile);
|
||||
}
|
||||
|
||||
private void ModifyHandlerSectionInWebConfig(string key, string value)
|
||||
{
|
||||
var webConfigFile = Path.Combine(DeploymentParameters.PublishedApplicationRootPath, "web.config");
|
||||
var config = XDocument.Load(webConfigFile);
|
||||
var element = config.Descendants("handlers").FirstOrDefault().Descendants("add").FirstOrDefault();
|
||||
element.SetAttributeValue(key, value);
|
||||
config.Save(webConfigFile);
|
||||
}
|
||||
|
||||
// These elements are duplicated in the web.config if you publish. Remove them from the host.config.
|
||||
private string RemoveRedundantElements(string serverConfig)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,50 +0,0 @@
|
|||
// 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.Xml.Linq;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
|
||||
{
|
||||
public class WebConfigHelpers
|
||||
{
|
||||
public static void AddDebugLogToWebConfig(string contentRoot, string filename)
|
||||
{
|
||||
var path = Path.Combine(contentRoot, "web.config");
|
||||
var webconfig = XDocument.Load(path);
|
||||
var xElement = webconfig.Descendants("aspNetCore").Single();
|
||||
|
||||
var element = xElement.Descendants("handlerSettings").SingleOrDefault();
|
||||
if (element == null)
|
||||
{
|
||||
element = new XElement("handlerSettings");
|
||||
xElement.Add(element);
|
||||
}
|
||||
|
||||
CreateOrSetElement(element, "debugLevel", "4");
|
||||
|
||||
CreateOrSetElement(element, "debugFile", Path.Combine(contentRoot, filename));
|
||||
|
||||
webconfig.Save(path);
|
||||
}
|
||||
|
||||
private static void CreateOrSetElement(XElement rootElement, string name, string value)
|
||||
{
|
||||
if (rootElement.Descendants()
|
||||
.Attributes()
|
||||
.Where(attribute => attribute.Value == name)
|
||||
.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
var element = new XElement("handlerSetting");
|
||||
element.SetAttributeValue("name", name);
|
||||
element.SetAttributeValue("value", value);
|
||||
rootElement.Add(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -21,17 +21,17 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
[InlineData("CheckLogFile")]
|
||||
public async Task CheckStdoutLoggingToFile(string path)
|
||||
{
|
||||
var deploymentParameters = Helpers.GetBaseDeploymentParameters();
|
||||
deploymentParameters.PublishApplicationBeforeDeployment = true;
|
||||
var deploymentParameters = Helpers.GetBaseDeploymentParameters(publish: true);
|
||||
|
||||
deploymentParameters.ModifyAspNetCoreSectionInWebConfig("stdoutLogEnabled", "true");
|
||||
|
||||
var pathToLogs = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
deploymentParameters.ModifyAspNetCoreSectionInWebConfig("stdoutLogFile", Path.Combine(pathToLogs, "std"));
|
||||
|
||||
var deploymentResult = await DeployAsync(deploymentParameters);
|
||||
var pathToLogs = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
|
||||
try
|
||||
{
|
||||
Helpers.ModifyAspNetCoreSectionInWebConfig(deploymentResult, "stdoutLogEnabled", "true");
|
||||
Helpers.ModifyAspNetCoreSectionInWebConfig(deploymentResult, "stdoutLogFile", Path.Combine(pathToLogs, "std"));
|
||||
|
||||
await Helpers.AssertStarts(deploymentResult, path);
|
||||
|
||||
StopServer();
|
||||
|
|
@ -63,10 +63,11 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
{
|
||||
var deploymentParameters = Helpers.GetBaseDeploymentParameters(publish: true);
|
||||
|
||||
deploymentParameters.ModifyAspNetCoreSectionInWebConfig("stdoutLogEnabled", "true");
|
||||
deploymentParameters.ModifyAspNetCoreSectionInWebConfig("stdoutLogFile", Path.Combine("Q:", "std"));
|
||||
|
||||
var deploymentResult = await DeployAsync(deploymentParameters);
|
||||
|
||||
Helpers.ModifyAspNetCoreSectionInWebConfig(deploymentResult, "stdoutLogEnabled", "true");
|
||||
Helpers.ModifyAspNetCoreSectionInWebConfig(deploymentResult, "stdoutLogFile", Path.Combine("Q:", "std"));
|
||||
|
||||
await Helpers.AssertStarts(deploymentResult, "HelloWorld");
|
||||
}
|
||||
|
|
@ -80,11 +81,10 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
{
|
||||
var deploymentParameters = Helpers.GetBaseDeploymentParameters(publish: true);
|
||||
deploymentParameters.EnvironmentVariables["ASPNETCORE_MODULE_DEBUG_FILE"] = tempFile;
|
||||
deploymentParameters.AddDebugLogToWebConfig(tempFile);
|
||||
|
||||
var deploymentResult = await DeployAsync(deploymentParameters);
|
||||
|
||||
Helpers.AddDebugLogToWebConfig(deploymentResult.DeploymentResult.ContentRoot, tempFile);
|
||||
|
||||
var response = await deploymentResult.RetryingHttpClient.GetAsync("/");
|
||||
|
||||
StopServer();
|
||||
|
|
@ -123,11 +123,11 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
public async Task CheckStdoutLoggingToPipeWithFirstWrite(string path)
|
||||
{
|
||||
var deploymentParameters = Helpers.GetBaseDeploymentParameters(publish: true);
|
||||
|
||||
var deploymentResult = await DeployAsync(deploymentParameters);
|
||||
var firstWriteString = path + path;
|
||||
|
||||
Helpers.ModifyEnvironmentVariableCollectionInWebConfig(deploymentResult, "ASPNETCORE_INPROCESS_INITIAL_WRITE", firstWriteString);
|
||||
deploymentParameters.WebConfigBasedEnvironmentVariables["ASPNETCORE_INPROCESS_INITIAL_WRITE"] = firstWriteString;
|
||||
|
||||
var deploymentResult = await DeployAsync(deploymentParameters);
|
||||
|
||||
await Helpers.AssertStarts(deploymentResult, path);
|
||||
|
||||
|
|
@ -152,9 +152,9 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
{
|
||||
var deploymentParameters = Helpers.GetBaseDeploymentParameters(publish: true);
|
||||
deploymentParameters.EnvironmentVariables["ASPNETCORE_MODULE_DEBUG_FILE"] = firstTempFile;
|
||||
deploymentParameters.AddDebugLogToWebConfig(secondTempFile);
|
||||
|
||||
var deploymentResult = await DeployAsync(deploymentParameters);
|
||||
WebConfigHelpers.AddDebugLogToWebConfig(deploymentParameters.PublishedApplicationRootPath, secondTempFile);
|
||||
|
||||
var response = await deploymentResult.RetryingHttpClient.GetAsync("/");
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
|||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
|
||||
using Microsoft.AspNetCore.Testing.xunit;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -25,15 +26,10 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
var deploymentParameters = Helpers.GetBaseDeploymentParameters("StartupExceptionWebsite", publish: true);
|
||||
|
||||
var randomNumberString = new Random(Guid.NewGuid().GetHashCode()).Next(10000000).ToString();
|
||||
|
||||
var environmentVariablesInWebConfig = new Dictionary<string, string>
|
||||
{
|
||||
["ASPNETCORE_INPROCESS_STARTUP_VALUE"] = path,
|
||||
["ASPNETCORE_INPROCESS_RANDOM_VALUE"] = randomNumberString
|
||||
};
|
||||
deploymentParameters.WebConfigBasedEnvironmentVariables["ASPNETCORE_INPROCESS_STARTUP_VALUE"] = path;
|
||||
deploymentParameters.WebConfigBasedEnvironmentVariables["ASPNETCORE_INPROCESS_RANDOM_VALUE"] = randomNumberString;
|
||||
|
||||
var deploymentResult = await DeployAsync(deploymentParameters);
|
||||
Helpers.AddEnvironmentVariablesToWebConfig(deploymentResult.DeploymentResult.ContentRoot, environmentVariablesInWebConfig);
|
||||
|
||||
var response = await deploymentResult.RetryingHttpClient.GetAsync(path);
|
||||
|
||||
|
|
@ -52,16 +48,10 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
public async Task CheckStdoutWithLargeWrites(string path)
|
||||
{
|
||||
var deploymentParameters = Helpers.GetBaseDeploymentParameters("StartupExceptionWebsite", publish: true);
|
||||
|
||||
var environmentVariablesInWebConfig = new Dictionary<string, string>
|
||||
{
|
||||
["ASPNETCORE_INPROCESS_STARTUP_VALUE"] = path
|
||||
};
|
||||
deploymentParameters.WebConfigBasedEnvironmentVariables["ASPNETCORE_INPROCESS_STARTUP_VALUE"] = path;
|
||||
|
||||
var deploymentResult = await DeployAsync(deploymentParameters);
|
||||
|
||||
Helpers.AddEnvironmentVariablesToWebConfig(deploymentResult.DeploymentResult.ContentRoot, environmentVariablesInWebConfig);
|
||||
|
||||
var response = await deploymentResult.RetryingHttpClient.GetAsync(path);
|
||||
|
||||
Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using System.IO;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
|
||||
using Microsoft.AspNetCore.Testing.xunit;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
|
@ -29,7 +30,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
{
|
||||
// The default in hosting sets windows auth to true.
|
||||
// Set it to the IISExpress.config file
|
||||
var deploymentParameters = new DeploymentParameters(variant)
|
||||
var deploymentParameters = new IISDeploymentParameters(variant)
|
||||
{
|
||||
ApplicationPath = Helpers.GetOutOfProcessTestSitesPath()
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
|
||||
using Microsoft.Extensions.Logging.Testing;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
|
|
@ -18,7 +19,7 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting
|
|||
|
||||
private ApplicationDeployer _deployer;
|
||||
|
||||
protected virtual async Task<IISDeploymentResult> DeployAsync(DeploymentParameters parameters)
|
||||
protected virtual async Task<IISDeploymentResult> DeployAsync(IISDeploymentParameters parameters)
|
||||
{
|
||||
if (!parameters.EnvironmentVariables.ContainsKey(DebugEnvironmentVariable))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
// 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.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -22,117 +24,16 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
public static string GetInProcessTestSitesPath() => GetTestWebSitePath("InProcessWebSite");
|
||||
|
||||
public static string GetOutOfProcessTestSitesPath() => GetTestWebSitePath("OutOfProcessWebSite");
|
||||
|
||||
public static void ModifyAspNetCoreSectionInWebConfig(IISDeploymentResult deploymentResult, string key, string value)
|
||||
=> ModifyAttributeInWebConfig(deploymentResult, key, value, section: "aspNetCore");
|
||||
|
||||
public static void ModifyAttributeInWebConfig(IISDeploymentResult deploymentResult, string key, string value, string section)
|
||||
{
|
||||
var webConfigFile = GetWebConfigFile(deploymentResult);
|
||||
var config = XDocument.Load(webConfigFile);
|
||||
|
||||
var element = config.Descendants(section).Single();
|
||||
element.SetAttributeValue(key, value);
|
||||
|
||||
config.Save(webConfigFile);
|
||||
}
|
||||
|
||||
public static void ModifyEnvironmentVariableCollectionInWebConfig(IISDeploymentResult deploymentResult, string key, string value)
|
||||
{
|
||||
var webConfigFile = GetWebConfigFile(deploymentResult);
|
||||
var config = XDocument.Load(webConfigFile);
|
||||
|
||||
var envVarElement = new XElement("environmentVariable");
|
||||
envVarElement.SetAttributeValue("name", key);
|
||||
envVarElement.SetAttributeValue("value", value);
|
||||
|
||||
config.Descendants("aspNetCore").Single()
|
||||
.Descendants("environmentVariables").Single()
|
||||
.Add(envVarElement);
|
||||
|
||||
config.Save(webConfigFile);
|
||||
}
|
||||
|
||||
public static void ModifyHandlerSectionInWebConfig(IISDeploymentResult deploymentResult, string handlerVersionValue)
|
||||
{
|
||||
var webConfigFile = GetWebConfigFile(deploymentResult);
|
||||
var config = XDocument.Load(webConfigFile);
|
||||
|
||||
var handlerVersionElement = new XElement("handlerSetting");
|
||||
handlerVersionElement.SetAttributeValue("name", "handlerVersion");
|
||||
handlerVersionElement.SetAttributeValue("value", handlerVersionValue);
|
||||
|
||||
config.Descendants("aspNetCore").Single()
|
||||
.Add(new XElement("handlerSettings", handlerVersionElement));
|
||||
|
||||
config.Save(webConfigFile);
|
||||
}
|
||||
|
||||
public static void AddDebugLogToWebConfig(string contentRoot, string filename)
|
||||
{
|
||||
var path = Path.Combine(contentRoot, "web.config");
|
||||
var webconfig = XDocument.Load(path);
|
||||
var xElement = webconfig.Descendants("aspNetCore").Single();
|
||||
|
||||
var element = xElement.Descendants("handlerSettings").SingleOrDefault();
|
||||
if (element == null)
|
||||
{
|
||||
element = new XElement("handlerSettings");
|
||||
xElement.Add(element);
|
||||
}
|
||||
|
||||
CreateOrSetElement(element, "debugLevel", "4", "handlerSetting");
|
||||
|
||||
CreateOrSetElement(element, "debugFile", Path.Combine(contentRoot, filename), "handlerSetting");
|
||||
|
||||
webconfig.Save(path);
|
||||
}
|
||||
|
||||
public static void AddEnvironmentVariablesToWebConfig(string contentRoot, IDictionary<string, string> environmentVariables)
|
||||
{
|
||||
var path = Path.Combine(contentRoot, "web.config");
|
||||
var webconfig = XDocument.Load(path);
|
||||
var xElement = webconfig.Descendants("aspNetCore").Single();
|
||||
|
||||
var element = xElement.Descendants("environmentVariables").SingleOrDefault();
|
||||
if (element == null)
|
||||
{
|
||||
element = new XElement("environmentVariables");
|
||||
xElement.Add(element);
|
||||
}
|
||||
|
||||
foreach (var envVar in environmentVariables)
|
||||
{
|
||||
CreateOrSetElement(element, envVar.Key, envVar.Value, "environmentVariable");
|
||||
}
|
||||
|
||||
webconfig.Save(path);
|
||||
}
|
||||
|
||||
public static void CreateOrSetElement(XElement rootElement, string name, string value, string elementName)
|
||||
{
|
||||
if (rootElement.Descendants()
|
||||
.Attributes()
|
||||
.Where(attribute => attribute.Value == name)
|
||||
.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
var element = new XElement(elementName);
|
||||
element.SetAttributeValue("name", name);
|
||||
element.SetAttributeValue("value", value);
|
||||
rootElement.Add(element);
|
||||
}
|
||||
|
||||
|
||||
// Defaults to inprocess specific deployment parameters
|
||||
public static DeploymentParameters GetBaseDeploymentParameters(string site = null, HostingModel hostingModel = HostingModel.InProcess, bool publish = false)
|
||||
public static IISDeploymentParameters GetBaseDeploymentParameters(string site = null, HostingModel hostingModel = HostingModel.InProcess, bool publish = false)
|
||||
{
|
||||
if (site == null)
|
||||
{
|
||||
site = hostingModel == HostingModel.InProcess ? "InProcessWebSite" : "OutOfProcessWebSite";
|
||||
}
|
||||
|
||||
return new DeploymentParameters(GetTestWebSitePath(site), DeployerSelector.ServerType, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64)
|
||||
return new IISDeploymentParameters(GetTestWebSitePath(site), DeployerSelector.ServerType, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64)
|
||||
{
|
||||
TargetFramework = Tfm.NetCoreApp22,
|
||||
ApplicationType = ApplicationType.Portable,
|
||||
|
|
@ -142,9 +43,6 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
};
|
||||
}
|
||||
|
||||
private static string GetWebConfigFile(IISDeploymentResult deploymentResult)
|
||||
=> Path.Combine(deploymentResult.DeploymentResult.ContentRoot, "web.config");
|
||||
|
||||
public static async Task AssertStarts(IISDeploymentResult deploymentResult, string path = "/HelloWorld")
|
||||
{
|
||||
var response = await deploymentResult.RetryingHttpClient.GetAsync(path);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,6 @@
|
|||
// 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.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
|
|
@ -16,36 +11,5 @@ namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities
|
|||
public IISFunctionalTestBase(ITestOutputHelper output = null) : base(output)
|
||||
{
|
||||
}
|
||||
|
||||
protected string GetServerConfig(Action<XElement> transform)
|
||||
{
|
||||
var doc = XDocument.Load(DeployerSelector.ServerType == ServerType.IIS ? "IIS.config" : "IISExpress.config");
|
||||
transform?.Invoke(doc.Root);
|
||||
return doc.ToString();
|
||||
}
|
||||
|
||||
protected string GetHttpsServerConfig()
|
||||
{
|
||||
return GetServerConfig(
|
||||
element => {
|
||||
element.Descendants("binding")
|
||||
.Single()
|
||||
.SetAttributeValue("protocol", "https");
|
||||
|
||||
element.Descendants("access")
|
||||
.Single()
|
||||
.SetAttributeValue("sslFlags", "Ssl, SslNegotiateCert");
|
||||
});
|
||||
}
|
||||
|
||||
protected string GetWindowsAuthConfig()
|
||||
{
|
||||
return GetServerConfig(
|
||||
element => {
|
||||
element.Descendants("windowsAuthentication")
|
||||
.Single()
|
||||
.SetAttributeValue("enabled", "true");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ 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;
|
||||
using Microsoft.Extensions.Logging.Testing;
|
||||
|
||||
|
|
@ -20,7 +21,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
{
|
||||
var logging = AssemblyTestLog.ForAssembly(typeof(IISTestSiteFixture).Assembly);
|
||||
|
||||
var deploymentParameters = new DeploymentParameters(Helpers.GetInProcessTestSitesPath(),
|
||||
var deploymentParameters = new IISDeploymentParameters(Helpers.GetInProcessTestSitesPath(),
|
||||
DeployerSelector.ServerType,
|
||||
RuntimeFlavor.CoreClr,
|
||||
RuntimeArchitecture.x64)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using System.Net;
|
|||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
|
||||
using Microsoft.AspNetCore.Testing.xunit;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -17,7 +18,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
public async Task Authentication_InProcess()
|
||||
{
|
||||
var deploymentParameters = Helpers.GetBaseDeploymentParameters(publish: true);
|
||||
deploymentParameters.ServerConfigTemplateContent = GetWindowsAuthConfig();
|
||||
deploymentParameters.AddWindowsAuthToServerConfig();
|
||||
|
||||
var deploymentResult = await DeployAsync(deploymentParameters);
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ using System.Net;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
|
||||
using Microsoft.AspNetCore.Testing.xunit;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
|
@ -27,8 +28,12 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
{
|
||||
// Point to dotnet installed in user profile.
|
||||
await AssertStarts(
|
||||
deploymentResult => Helpers.ModifyAspNetCoreSectionInWebConfig(deploymentResult, "processPath", "%DotnetPath%"),
|
||||
deploymentParameters => deploymentParameters.EnvironmentVariables["DotnetPath"] = _dotnetLocation);
|
||||
deploymentParameters =>
|
||||
{
|
||||
deploymentParameters.EnvironmentVariables["DotnetPath"] = _dotnetLocation;
|
||||
deploymentParameters.ModifyAspNetCoreSectionInWebConfig("processPath", "%DotnetPath%");
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
[ConditionalTheory]
|
||||
|
|
@ -38,11 +43,10 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
public async Task InvalidProcessPath_ExpectServerError(string path)
|
||||
{
|
||||
var deploymentParameters = GetBaseDeploymentParameters();
|
||||
deploymentParameters.ModifyAspNetCoreSectionInWebConfig("processPath", path);
|
||||
|
||||
var deploymentResult = await DeployAsync(deploymentParameters);
|
||||
|
||||
Helpers.ModifyAspNetCoreSectionInWebConfig(deploymentResult, "processPath", path);
|
||||
|
||||
var response = await deploymentResult.RetryingHttpClient.GetAsync("HelloWorld");
|
||||
|
||||
Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode);
|
||||
|
|
@ -54,16 +58,23 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
var dotnetLocationWithoutExtension = _dotnetLocation.Substring(0, _dotnetLocation.LastIndexOf("."));
|
||||
|
||||
await AssertStarts(
|
||||
deploymentResult => Helpers.ModifyAspNetCoreSectionInWebConfig(deploymentResult, "processPath", dotnetLocationWithoutExtension));
|
||||
deploymentParameters =>
|
||||
{
|
||||
deploymentParameters.ModifyAspNetCoreSectionInWebConfig("processPath", dotnetLocationWithoutExtension);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
[ConditionalFact]
|
||||
public async Task StartsWithDotnetLocationUppercase()
|
||||
{
|
||||
var dotnetLocationWithoutExtension = _dotnetLocation.Substring(0, _dotnetLocation.LastIndexOf(".")).ToUpperInvariant();
|
||||
|
||||
await AssertStarts(
|
||||
deploymentResult => Helpers.ModifyAspNetCoreSectionInWebConfig(deploymentResult, "processPath", dotnetLocationWithoutExtension));
|
||||
deploymentParameters =>
|
||||
{
|
||||
deploymentParameters.ModifyAspNetCoreSectionInWebConfig("processPath", dotnetLocationWithoutExtension);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
[ConditionalTheory]
|
||||
|
|
@ -72,14 +83,18 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
public async Task StartsWithDotnetOnThePath(string path)
|
||||
{
|
||||
await AssertStarts(
|
||||
deploymentResult => Helpers.ModifyAspNetCoreSectionInWebConfig(deploymentResult, "processPath", path),
|
||||
deploymentParameters => deploymentParameters.EnvironmentVariables["PATH"] = Path.GetDirectoryName(_dotnetLocation));
|
||||
deploymentParameters =>
|
||||
{
|
||||
deploymentParameters.EnvironmentVariables["PATH"] = Path.GetDirectoryName(_dotnetLocation);
|
||||
deploymentParameters.ModifyAspNetCoreSectionInWebConfig("processPath", path);
|
||||
}
|
||||
);
|
||||
|
||||
// Verify that in this scenario where.exe was invoked only once by shim and request handler uses cached value
|
||||
Assert.Equal(1, TestSink.Writes.Count(w => w.Message.Contains("Invoking where.exe to find dotnet.exe")));
|
||||
}
|
||||
|
||||
private async Task AssertStarts(Action<IISDeploymentResult> postDeploy, Action<DeploymentParameters> preDeploy = null)
|
||||
private async Task AssertStarts(Action<IISDeploymentParameters> preDeploy = null)
|
||||
{
|
||||
var deploymentParameters = GetBaseDeploymentParameters();
|
||||
|
||||
|
|
@ -87,8 +102,6 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
|
||||
var deploymentResult = await DeployAsync(deploymentParameters);
|
||||
|
||||
postDeploy?.Invoke(deploymentResult);
|
||||
|
||||
var response = await deploymentResult.RetryingHttpClient.GetAsync("HelloWorld");
|
||||
|
||||
var responseText = await response.Content.ReadAsStringAsync();
|
||||
|
|
@ -105,7 +118,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
[MemberData(nameof(TestVariants))]
|
||||
public async Task HelloWorld(TestVariant variant)
|
||||
{
|
||||
var deploymentParameters = new DeploymentParameters(variant)
|
||||
var deploymentParameters = new IISDeploymentParameters(variant)
|
||||
{
|
||||
ApplicationPath = Helpers.GetInProcessTestSitesPath(),
|
||||
PublishApplicationBeforeDeployment = true
|
||||
|
|
@ -132,9 +145,9 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
}
|
||||
|
||||
// Defaults to inprocess specific deployment parameters
|
||||
public static DeploymentParameters GetBaseDeploymentParameters(string site = "InProcessWebSite")
|
||||
public static IISDeploymentParameters GetBaseDeploymentParameters(string site = "InProcessWebSite")
|
||||
{
|
||||
return new DeploymentParameters(Helpers.GetTestWebSitePath(site), DeployerSelector.ServerType, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64)
|
||||
return new IISDeploymentParameters(Helpers.GetTestWebSitePath(site), DeployerSelector.ServerType, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64)
|
||||
{
|
||||
TargetFramework = Tfm.NetCoreApp22,
|
||||
ApplicationType = ApplicationType.Portable,
|
||||
|
|
|
|||
|
|
@ -1,16 +1,15 @@
|
|||
// 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.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
|
||||
using Microsoft.AspNetCore.Testing.xunit;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
||||
{
|
||||
|
|
@ -28,7 +27,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
var deploymentParameters = GetGlobalVersionBaseDeploymentParameters();
|
||||
deploymentParameters.PublishApplicationBeforeDeployment = false;
|
||||
|
||||
deploymentParameters.ServerConfigTemplateContent = GetServerConfig(
|
||||
deploymentParameters.AddServerConfigAction(
|
||||
element =>
|
||||
{
|
||||
var handlerVersionElement = new XElement("handlerSetting");
|
||||
|
|
@ -52,11 +51,10 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
public async Task GlobalVersion_NewVersionNumber_Fails(string version)
|
||||
{
|
||||
var deploymentParameters = GetGlobalVersionBaseDeploymentParameters();
|
||||
deploymentParameters.HandlerSettings["handlerVersion"] = version;
|
||||
|
||||
var deploymentResult = await DeployAsync(deploymentParameters);
|
||||
|
||||
Helpers.ModifyHandlerSectionInWebConfig(deploymentResult, version);
|
||||
|
||||
var response = await deploymentResult.RetryingHttpClient.GetAsync(_helloWorldRequest);
|
||||
Assert.False(response.IsSuccessStatusCode);
|
||||
}
|
||||
|
|
@ -68,11 +66,10 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
{
|
||||
var deploymentParameters = GetGlobalVersionBaseDeploymentParameters();
|
||||
deploymentParameters.AdditionalPublishParameters = $"{_outOfProcessVersionVariable}{version}";
|
||||
deploymentParameters.HandlerSettings["handlerVersion"] = version;
|
||||
|
||||
var deploymentResult = await DeployAsync(deploymentParameters);
|
||||
|
||||
Helpers.ModifyHandlerSectionInWebConfig(deploymentResult, version);
|
||||
|
||||
var response = await deploymentResult.RetryingHttpClient.GetAsync(_helloWorldRequest);
|
||||
var responseText = await response.Content.ReadAsStringAsync();
|
||||
Assert.Equal(_helloWorldResponse, responseText);
|
||||
|
|
@ -140,9 +137,9 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
AssertLoadedVersion(version);
|
||||
}
|
||||
|
||||
private DeploymentParameters GetGlobalVersionBaseDeploymentParameters()
|
||||
private IISDeploymentParameters GetGlobalVersionBaseDeploymentParameters()
|
||||
{
|
||||
return new DeploymentParameters(Helpers.GetOutOfProcessTestSitesPath(), DeployerSelector.ServerType, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64)
|
||||
return new IISDeploymentParameters(Helpers.GetOutOfProcessTestSitesPath(), DeployerSelector.ServerType, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64)
|
||||
{
|
||||
TargetFramework = Tfm.NetCoreApp22,
|
||||
ApplicationType = ApplicationType.Portable,
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
|||
using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting.Common;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
|
||||
using Microsoft.AspNetCore.Testing.xunit;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
|
@ -33,13 +34,14 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
public async Task HttpsHelloWorld(TestVariant variant)
|
||||
{
|
||||
var port = TestPortHelper.GetNextSSLPort();
|
||||
var deploymentParameters = new DeploymentParameters(variant)
|
||||
var deploymentParameters = new IISDeploymentParameters(variant)
|
||||
{
|
||||
ApplicationPath = Helpers.GetOutOfProcessTestSitesPath(),
|
||||
ApplicationBaseUriHint = $"https://localhost:{port}/",
|
||||
ServerConfigTemplateContent = GetHttpsServerConfig()
|
||||
ApplicationBaseUriHint = $"https://localhost:{port}/"
|
||||
};
|
||||
|
||||
deploymentParameters.AddHttpsToServerConfig();
|
||||
|
||||
var deploymentResult = await DeployAsync(deploymentParameters);
|
||||
|
||||
var handler = new HttpClientHandler
|
||||
|
|
@ -71,13 +73,14 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
private async Task HttpsHelloWorldCerts(TestVariant variant, bool sendClientCert)
|
||||
{
|
||||
var port = TestPortHelper.GetNextSSLPort();
|
||||
var deploymentParameters = new DeploymentParameters(variant)
|
||||
var deploymentParameters = new IISDeploymentParameters(variant)
|
||||
{
|
||||
ApplicationPath = Helpers.GetOutOfProcessTestSitesPath(),
|
||||
ApplicationBaseUriHint = $"https://localhost:{port}/",
|
||||
ServerConfigTemplateContent = GetHttpsServerConfig()
|
||||
};
|
||||
|
||||
deploymentParameters.AddHttpsToServerConfig();
|
||||
|
||||
var deploymentResult = await DeployAsync(deploymentParameters);
|
||||
|
||||
var handler = new HttpClientHandler
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using System.Net.Http;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
|
||||
using Microsoft.AspNetCore.Testing.xunit;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
|
@ -31,13 +32,14 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
[MemberData(nameof(TestVariants))]
|
||||
public async Task NtlmAuthentication(TestVariant variant)
|
||||
{
|
||||
var deploymentParameters = new DeploymentParameters(variant)
|
||||
var deploymentParameters = new IISDeploymentParameters(variant)
|
||||
{
|
||||
ApplicationPath = Helpers.GetOutOfProcessTestSitesPath(),
|
||||
ApplicationBaseUriHint = $"http://localhost:0/",
|
||||
ServerConfigTemplateContent = GetWindowsAuthConfig()
|
||||
ApplicationBaseUriHint = $"http://localhost:0/"
|
||||
};
|
||||
|
||||
deploymentParameters.AddWindowsAuthToServerConfig();
|
||||
|
||||
var result = await DeployAsync(deploymentParameters);
|
||||
var response = await result.RetryingHttpClient.GetAsync("/HelloWorld");
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using System.IO;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
|
||||
using Microsoft.AspNetCore.Testing.xunit;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
|
@ -27,11 +28,11 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
[MemberData(nameof(TestVariants))]
|
||||
public async Task WindowsAuthTest(TestVariant variant)
|
||||
{
|
||||
var deploymentParameters = new DeploymentParameters(variant)
|
||||
var deploymentParameters = new IISDeploymentParameters(variant)
|
||||
{
|
||||
ApplicationPath = Helpers.GetOutOfProcessTestSitesPath(),
|
||||
ServerConfigTemplateContent = GetWindowsAuthConfig()
|
||||
};
|
||||
deploymentParameters.AddWindowsAuthToServerConfig();
|
||||
|
||||
// The default in hosting sets windows auth to true.
|
||||
var deploymentResult = await DeployAsync(deploymentParameters);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using System.Linq;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
|
||||
using Microsoft.AspNetCore.Testing.xunit;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
|
@ -59,7 +60,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
|
||||
private async Task UpgradeFeatureDetectionDeployer(bool disableWebSocket, string sitePath, string expected, HostingModel hostingModel)
|
||||
{
|
||||
var deploymentParameters = new DeploymentParameters(sitePath, DeployerSelector.ServerType, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64)
|
||||
var deploymentParameters = new IISDeploymentParameters(sitePath, DeployerSelector.ServerType, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64)
|
||||
{
|
||||
TargetFramework = Tfm.NetCoreApp22,
|
||||
ApplicationType = ApplicationType.Portable,
|
||||
|
|
@ -71,7 +72,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
if (disableWebSocket)
|
||||
{
|
||||
// For IIS, we need to modify the apphost.config file
|
||||
deploymentParameters.ServerConfigTemplateContent = GetServerConfig(
|
||||
deploymentParameters.AddServerConfigAction(
|
||||
element => element.Descendants("webSocket")
|
||||
.Single()
|
||||
.SetAttributeValue("enabled", "false"));
|
||||
|
|
|
|||
Loading…
Reference in New Issue