Skip to content

Commit 7ae0d9f

Browse files
authored
Fix H3 Client Cert tests #41894 (#42346)
1 parent 8546f1e commit 7ae0d9f

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

src/Servers/Kestrel/Transport.Quic/test/QuicConnectionListenerTests.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,15 @@ static void AssertTlsConnectionFeature(IFeatureCollection features, X509Certific
101101

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

112109
var options = QuicTestHelpers.CreateClientConnectionOptions(connectionListener.EndPoint);
113110
using var clientConnection = await QuicConnection.ConnectAsync(options);
114111

115-
var qex = await Assert.ThrowsAnyAsync<QuicException>(async () => await clientConnection.ConnectAsync().DefaultTimeout());
116-
Assert.StartsWith("Connection has been shutdown by transport:", qex.Message);
112+
await clientConnection.ConnectAsync().DefaultTimeout();
113+
Assert.True(clientConnection.Connected);
117114
}
118115
}

src/Servers/Kestrel/test/Interop.FunctionalTests/Http3/Http3RequestTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,6 @@ public async Task POST_ClientCancellationUpload_RequestAbortRaised(HttpProtocols
393393
[MsQuicSupported]
394394
[InlineData(HttpProtocols.Http3)]
395395
[InlineData(HttpProtocols.Http2)]
396-
[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/35070")]
397396
public async Task POST_ServerAbort_ClientReceivesAbort(HttpProtocols protocol)
398397
{
399398
// Arrange

src/Servers/Kestrel/test/Interop.FunctionalTests/Http3/Http3TlsTests.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -196,17 +196,16 @@ public async Task ClientCertificate_AllowOrRequire_Available_Invalid_Refused(Cli
196196

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

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

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

252250
await host.StopAsync().DefaultTimeout();
253251
}

0 commit comments

Comments
 (0)