Http2 test for IIS (#14644)
This commit is contained in:
parent
73f2bbdb10
commit
d427e43d78
|
|
@ -54,7 +54,7 @@ namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests
|
|||
var port = TestPortHelper.GetNextSSLPort();
|
||||
var deploymentParameters = Fixture.GetBaseDeploymentParameters(variant);
|
||||
deploymentParameters.ApplicationBaseUriHint = $"https://localhost:{port}/";
|
||||
deploymentParameters.AddHttpsToServerConfig();
|
||||
deploymentParameters.AddHttpsWithClientCertToServerConfig();
|
||||
|
||||
var handler = new HttpClientHandler
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
|
|
@ -79,6 +80,7 @@ namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests
|
|||
var deploymentParameters = Fixture.GetBaseDeploymentParameters(HostingModel.InProcess);
|
||||
deploymentParameters.ApplicationBaseUriHint = $"https://localhost:{port}/";
|
||||
deploymentParameters.AddHttpsToServerConfig();
|
||||
deploymentParameters.SetWindowsAuth(false);
|
||||
deploymentParameters.AddServerConfigAction(
|
||||
(element, root) => {
|
||||
element.Descendants("site").Single().Element("application").SetAttributeValue("path", "/" + appName);
|
||||
|
|
@ -87,10 +89,27 @@ namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests
|
|||
|
||||
var deploymentResult = await DeployAsync(deploymentParameters);
|
||||
var client = CreateNonValidatingClient(deploymentResult);
|
||||
|
||||
Assert.Equal(deploymentParameters.ApplicationBaseUriHint + appName, await client.GetStringAsync($"/{appName}/ServerAddresses"));
|
||||
}
|
||||
|
||||
[ConditionalFact]
|
||||
[RequiresNewHandler]
|
||||
[OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, WindowsVersions.Win81)]
|
||||
public async Task CheckProtocolIsHttp2()
|
||||
{
|
||||
var port = TestPortHelper.GetNextSSLPort();
|
||||
var deploymentParameters = Fixture.GetBaseDeploymentParameters(HostingModel.InProcess);
|
||||
deploymentParameters.ApplicationBaseUriHint = $"https://localhost:{port}/";
|
||||
deploymentParameters.AddHttpsToServerConfig();
|
||||
deploymentParameters.SetWindowsAuth(false);
|
||||
|
||||
var deploymentResult = await DeployAsync(deploymentParameters);
|
||||
var client = CreateNonValidatingClient(deploymentResult);
|
||||
client.DefaultRequestVersion = HttpVersion.Version20;
|
||||
|
||||
Assert.Equal("HTTP/2", await client.GetStringAsync($"/CheckProtocol"));
|
||||
}
|
||||
|
||||
[ConditionalFact]
|
||||
[RequiresNewHandler]
|
||||
[RequiresNewShim]
|
||||
|
|
|
|||
|
|
@ -63,6 +63,11 @@ namespace TestSite
|
|||
await ctx.Response.WriteAsync(string.Join(",", serverAddresses.Addresses));
|
||||
}
|
||||
|
||||
private async Task CheckProtocol(HttpContext ctx)
|
||||
{
|
||||
await ctx.Response.WriteAsync(ctx.Request.Protocol);
|
||||
}
|
||||
|
||||
private async Task ConsoleWrite(HttpContext ctx)
|
||||
{
|
||||
Console.WriteLine("TEST MESSAGE");
|
||||
|
|
|
|||
|
|
@ -27,6 +27,21 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
|
|||
}
|
||||
|
||||
public static void AddHttpsToServerConfig(this IISDeploymentParameters parameters)
|
||||
{
|
||||
parameters.AddServerConfigAction(
|
||||
element =>
|
||||
{
|
||||
element.Descendants("binding")
|
||||
.Single()
|
||||
.SetAttributeValue("protocol", "https");
|
||||
|
||||
element.Descendants("access")
|
||||
.Single()
|
||||
.SetAttributeValue("sslFlags", "None");
|
||||
});
|
||||
}
|
||||
|
||||
public static void AddHttpsWithClientCertToServerConfig(this IISDeploymentParameters parameters)
|
||||
{
|
||||
parameters.AddServerConfigAction(
|
||||
element =>
|
||||
|
|
|
|||
Loading…
Reference in New Issue