Skip to content

Commit

Permalink
Kestrel HttpClient Http2 interop tests #4763 (#11869)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tratcher committed Jul 26, 2019
1 parent 2a35f8e commit 5631b97
Show file tree
Hide file tree
Showing 6 changed files with 640 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// 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.Globalization;
using System.Linq;
using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.AspNetCore.Hosting.Server.Features;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace Microsoft.AspNetCore.Hosting
{
public static class IHostPortExtensions
{
public static int GetPort(this IHost host)
{
return host.GetPorts().First();
}

public static IEnumerable<int> GetPorts(this IHost host)
{
return host.GetUris()
.Select(u => u.Port);
}

public static IEnumerable<Uri> GetUris(this IHost host)
{
return host.Services.GetRequiredService<IServer>().Features.Get<IServerAddressesFeature>().Addresses
.Select(a => new Uri(a));
}

public static string MakeUrl(this IHost host, string scheme)
{
return $"{scheme}://127.0.0.1:{host.GetPort().ToString(CultureInfo.InvariantCulture)}/";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public HandshakeTests()
ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
})
{
DefaultRequestVersion = new Version(2, 0),
DefaultRequestVersion = HttpVersion.Version20,
};
}

Expand Down Expand Up @@ -82,7 +82,7 @@ public void TlsAndHttp2NotSupportedOnWin7()
[ConditionalFact]
[OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Missing SslStream ALPN support: https://github.com/dotnet/corefx/issues/30492")]
[SkipOnHelix("https://github.com/aspnet/AspNetCore/issues/10428", Queues = "Debian.8.Amd64.Open")] // Debian 8 uses OpenSSL 1.0.1 which does not support HTTP/2
[MinimumOSVersion(OperatingSystems.Windows, WindowsVersions.Win10)]
[MinimumOSVersion(OperatingSystems.Windows, WindowsVersions.Win81)]
public async Task TlsAlpnHandshakeSelectsHttp2From1and2()
{
using (var server = new TestServer(context =>
Expand Down Expand Up @@ -113,7 +113,7 @@ public async Task TlsAlpnHandshakeSelectsHttp2From1and2()
[ConditionalFact]
[OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Missing SslStream ALPN support: https://github.com/dotnet/corefx/issues/30492")]
[SkipOnHelix("https://github.com/aspnet/AspNetCore/issues/10428", Queues = "Debian.8.Amd64.Open")] // Debian 8 uses OpenSSL 1.0.1 which does not support HTTP/2
[MinimumOSVersion(OperatingSystems.Windows, WindowsVersions.Win10)]
[MinimumOSVersion(OperatingSystems.Windows, WindowsVersions.Win81)]
public async Task TlsAlpnHandshakeSelectsHttp2()
{
using (var server = new TestServer(context =>
Expand Down
22 changes: 12 additions & 10 deletions src/Servers/Kestrel/test/Interop.FunctionalTests/H2SpecTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@

namespace Interop.FunctionalTests
{
[OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Missing SslStream ALPN support: https://github.com/dotnet/corefx/issues/30492")]
[MinimumOSVersion(OperatingSystems.Windows, WindowsVersions.Win81,
SkipReason = "Missing Windows ALPN support: https://en.wikipedia.org/wiki/Application-Layer_Protocol_Negotiation#Support")]
[SkipOnHelix("https://github.com/aspnet/AspNetCore/issues/10428", Queues = "Debian.8.Amd64.Open")] // Debian 8 uses OpenSSL 1.0.1 which does not support HTTP/2
public class H2SpecTests : LoggedTest
{
[ConditionalTheory]
Expand Down Expand Up @@ -61,6 +57,8 @@ public static TheoryData<H2SpecTestCase> H2SpecTestCases
var dataset = new TheoryData<H2SpecTestCase>();
var toSkip = new string[] { /*"http2/5.1/8"*/ };

var supportsAlpn = Utilities.CurrentPlatformSupportsAlpn();

foreach (var testcase in H2SpecCommands.EnumerateTestCases())
{
string skip = null;
Expand All @@ -77,13 +75,17 @@ public static TheoryData<H2SpecTestCase> H2SpecTestCases
Skip = skip,
});

dataset.Add(new H2SpecTestCase
// https://github.com/aspnet/AspNetCore/issues/11301 We should use Skip but it's broken at the moment.
if (supportsAlpn)
{
Id = testcase.Item1,
Description = testcase.Item2,
Https = true,
Skip = skip,
});
dataset.Add(new H2SpecTestCase
{
Id = testcase.Item1,
Description = testcase.Item2,
Https = true,
Skip = skip,
});
}
}

return dataset;
Expand Down

0 comments on commit 5631b97

Please sign in to comment.