Skip to content

Commit

Permalink
Kestrel HttpClient Http2 interop tests #4763
Browse files Browse the repository at this point in the history
  • Loading branch information
Tratcher committed Jul 25, 2019
1 parent a07ad16 commit 749cc98
Show file tree
Hide file tree
Showing 5 changed files with 364 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// 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 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));
}
}
}
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
28 changes: 18 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,14 @@ public static TheoryData<H2SpecTestCase> H2SpecTestCases
var dataset = new TheoryData<H2SpecTestCase>();
var toSkip = new string[] { /*"http2/5.1/8"*/ };

var supportsAlpn =
// "Missing Windows ALPN support: https://en.wikipedia.org/wiki/Application-Layer_Protocol_Negotiation#Support"
new MinimumOSVersionAttribute(OperatingSystems.Windows, WindowsVersions.Win81).IsMet
// "Missing SslStream ALPN support: https://github.com/dotnet/corefx/issues/30492"
&& new OSSkipConditionAttribute(OperatingSystems.MacOSX).IsMet
// Debian 8 uses OpenSSL 1.0.1 which does not support ALPN
&& new SkipOnHelixAttribute("https://github.com/aspnet/AspNetCore/issues/10428") { Queues = "Debian.8.Amd64.Open" }.IsMet;

foreach (var testcase in H2SpecCommands.EnumerateTestCases())
{
string skip = null;
Expand All @@ -77,13 +81,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
Loading

0 comments on commit 749cc98

Please sign in to comment.