diff --git a/src/Servers/IIS/IIS/test/Common.FunctionalTests/ClientCertificateTests.cs b/src/Servers/IIS/IIS/test/Common.FunctionalTests/ClientCertificateTests.cs index 6d39a56921..fbd9f7b679 100644 --- a/src/Servers/IIS/IIS/test/Common.FunctionalTests/ClientCertificateTests.cs +++ b/src/Servers/IIS/IIS/test/Common.FunctionalTests/ClientCertificateTests.cs @@ -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 { diff --git a/src/Servers/IIS/IIS/test/Common.FunctionalTests/HttpsTests.cs b/src/Servers/IIS/IIS/test/Common.FunctionalTests/HttpsTests.cs index 8e3251570b..5b206b101a 100644 --- a/src/Servers/IIS/IIS/test/Common.FunctionalTests/HttpsTests.cs +++ b/src/Servers/IIS/IIS/test/Common.FunctionalTests/HttpsTests.cs @@ -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] diff --git a/src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Startup.cs b/src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Startup.cs index 504c544e7f..85debbc4c1 100644 --- a/src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Startup.cs +++ b/src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Startup.cs @@ -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"); diff --git a/src/Servers/IIS/IntegrationTesting.IIS/src/IISDeploymentParameterExtensions.cs b/src/Servers/IIS/IntegrationTesting.IIS/src/IISDeploymentParameterExtensions.cs index 90f76fd8c2..89b50d5450 100644 --- a/src/Servers/IIS/IntegrationTesting.IIS/src/IISDeploymentParameterExtensions.cs +++ b/src/Servers/IIS/IntegrationTesting.IIS/src/IISDeploymentParameterExtensions.cs @@ -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 =>