54 lines
1.7 KiB
C#
54 lines
1.7 KiB
C#
// 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.IntegrationTesting;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace IISIntegration.FunctionalTests.Utilities
|
|
{
|
|
public class IISFunctionalTestBase : FunctionalTestsBase
|
|
{
|
|
public IISFunctionalTestBase(ITestOutputHelper output = null) : base(output)
|
|
{
|
|
}
|
|
|
|
protected override Task<IISDeploymentResult> DeployAsync(DeploymentParameters parameters)
|
|
{
|
|
if (parameters.SiteName == null)
|
|
{
|
|
parameters.SiteName = "HttpTestSite";
|
|
}
|
|
if (parameters.ServerConfigTemplateContent == null)
|
|
{
|
|
parameters.ServerConfigTemplateContent = GetServerConfig(null);
|
|
}
|
|
return base.DeployAsync(parameters);
|
|
}
|
|
|
|
protected string GetServerConfig(Action<XElement> transform)
|
|
{
|
|
var doc = XDocument.Load("AppHostConfig/Http.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");
|
|
});
|
|
}
|
|
}
|
|
}
|