Skip to content

Commit

Permalink
Consolidate tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tratcher committed Jun 8, 2021
1 parent 0d5103b commit 9b6878e
Showing 1 changed file with 5 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -526,13 +526,15 @@ void ConfigureListenOptions(ListenOptions listenOptions)
await AssertConnectionResult(stream, true);
}

[ConditionalFact]
[ConditionalTheory]
[InlineData(HttpProtocols.Http1)]
[InlineData(HttpProtocols.Http1AndHttp2)] // Make sure turning on Http/2 doesn't regress HTTP/1
[OSSkipCondition(OperatingSystems.MacOSX | OperatingSystems.Linux, SkipReason = "Not supported yet.")]
public async Task CanRenegotiateForClientCertificateOnHttp1()
public async Task CanRenegotiateForClientCertificate(HttpProtocols httpProtocols)
{
void ConfigureListenOptions(ListenOptions listenOptions)
{
listenOptions.Protocols = HttpProtocols.Http1;
listenOptions.Protocols = httpProtocols;
listenOptions.UseHttps(options =>
{
options.ServerCertificate = _x509Certificate2;
Expand Down Expand Up @@ -652,49 +654,6 @@ void ConfigureListenOptions(ListenOptions listenOptions)
await AssertConnectionResult(stream, true);
}

[ConditionalFact(Skip = "Depends on https://github.com/dotnet/runtime/pull/53719")]
[OSSkipCondition(OperatingSystems.MacOSX | OperatingSystems.Linux, SkipReason = "Not supported yet.")]
// Turning on HTTP/2 disables renegotiation.
// TODO: Tomas is changing it so AllowRenegotiation only applies to the remote,
// NegotiateClientCertificateAsync call be called locally and it's up to us to prevent that
// on HTTP/2.
public async Task CanRenegotiateForClientCertificateOnHttp1WithHttp2()
{
void ConfigureListenOptions(ListenOptions listenOptions)
{
listenOptions.Protocols = HttpProtocols.Http1AndHttp2;
listenOptions.UseHttps(options =>
{
options.ServerCertificate = _x509Certificate2;
options.ClientCertificateMode = ClientCertificateMode.DelayCertificate;
options.AllowAnyClientCertificate();
});
}

await using var server = new TestServer(async context =>
{
var tlsFeature = context.Features.Get<ITlsConnectionFeature>();
Assert.NotNull(tlsFeature);
Assert.Null(tlsFeature.ClientCertificate);
Assert.Null(context.Connection.ClientCertificate);
var cert = await context.Connection.GetClientCertificateAsync();
Assert.NotNull(cert);
Assert.NotNull(tlsFeature.ClientCertificate);
Assert.NotNull(context.Connection.ClientCertificate);
await context.Response.WriteAsync("hello world");
}, new TestServiceContext(LoggerFactory), ConfigureListenOptions);

using var connection = server.CreateConnection();
// SslStream is used to ensure the certificate is actually passed to the server
// HttpClient might not send the certificate because it is invalid or it doesn't match any
// of the certificate authorities sent by the server in the SSL handshake.
var stream = OpenSslStreamWithCert(connection.Stream);
await stream.AuthenticateAsClientAsync(Guid.NewGuid().ToString());
await AssertConnectionResult(stream, true);
}

[ConditionalFact]
[OSSkipCondition(OperatingSystems.MacOSX | OperatingSystems.Linux, SkipReason = "Not supported yet.")]
public async Task RenegotiateForClientCertificateOnPostWithoutBufferingThrows()
Expand Down

0 comments on commit 9b6878e

Please sign in to comment.