Skip to content

Fix H3 Client Cert tests #42346

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,15 @@ static void AssertTlsConnectionFeature(IFeatureCollection features, X509Certific

[ConditionalFact]
[MsQuicSupported]
// https://github.com/dotnet/runtime/issues/57308, RemoteCertificateValidationCallback should allow us to accept a null cert,
// but it doesn't right now.
[OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)]
[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/41894")]
public async Task ClientCertificate_Required_NotSent_ConnectionAborted()
public async Task ClientCertificate_Required_NotSent_AcceptedViaCallback()
{
await using var connectionListener = await QuicTestHelpers.CreateConnectionListenerFactory(LoggerFactory, clientCertificateRequired: true);

var options = QuicTestHelpers.CreateClientConnectionOptions(connectionListener.EndPoint);
using var clientConnection = new QuicConnection(options);

var qex = await Assert.ThrowsAnyAsync<QuicException>(async () => await clientConnection.ConnectAsync().DefaultTimeout());
Assert.StartsWith("Connection has been shutdown by transport:", qex.Message);
await clientConnection.ConnectAsync().DefaultTimeout();
Assert.True(clientConnection.Connected);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ public async Task POST_ClientCancellationUpload_RequestAbortRaised(HttpProtocols
[MsQuicSupported]
[InlineData(HttpProtocols.Http3)]
[InlineData(HttpProtocols.Http2)]
[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/35070")]
public async Task POST_ServerAbort_ClientReceivesAbort(HttpProtocols protocol)
{
// Arrange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,17 +196,16 @@ public async Task ClientCertificate_AllowOrRequire_Available_Invalid_Refused(Cli

if (!serverAllowInvalid)
{
// In .NET 6 there is a race condition between throwing HttpRequestException and QuicException.
// Unable to test the exact error.
var ex = await Assert.ThrowsAnyAsync<Exception>(() => sendTask).DefaultTimeout();
var ex = await Assert.ThrowsAnyAsync<HttpRequestException>(() => sendTask).DefaultTimeout();
Logger.LogInformation(ex, "SendAsync successfully threw error.");
}
else
{
// Because we can't verify the exact error reason, check that the cert is the cause be successfully
// Because we can't verify the exact error reason, check that the cert is the cause by successfully
// making a call when invalid certs are allowed.
var response = await sendTask.DefaultTimeout();
using var response = await sendTask.DefaultTimeout();
response.EnsureSuccessStatusCode();
Assert.Equal("True", await response.Content.ReadAsStringAsync().DefaultTimeout());
}

await host.StopAsync().DefaultTimeout();
Expand All @@ -215,7 +214,6 @@ public async Task ClientCertificate_AllowOrRequire_Available_Invalid_Refused(Cli
[ConditionalFact]
[MsQuicSupported]
[OSSkipCondition(OperatingSystems.MacOSX | OperatingSystems.Linux, SkipReason = "https://github.com/dotnet/aspnetcore/issues/35800")]
[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/41894")]
public async Task ClientCertificate_Allow_NotAvailable_Optional()
{
var builder = CreateHostBuilder(async context =>
Expand Down Expand Up @@ -245,9 +243,9 @@ public async Task ClientCertificate_Allow_NotAvailable_Optional()
request.Version = HttpVersion.Version30;
request.VersionPolicy = HttpVersionPolicy.RequestVersionExact;

// https://github.com/dotnet/runtime/issues/57308, optional client certs aren't supported.
var ex = await Assert.ThrowsAsync<HttpRequestException>(() => client.SendAsync(request, CancellationToken.None).DefaultTimeout());
Assert.StartsWith("Connection has been shutdown by transport:", ex.Message);
var response = await client.SendAsync(request, CancellationToken.None).DefaultTimeout();
Assert.True(response.IsSuccessStatusCode);
Assert.Equal("False", await response.Content.ReadAsStringAsync());

await host.StopAsync().DefaultTimeout();
}
Expand Down