Browse Source

Fix H3 Client Cert tests #41894 (#42346)

Chris Ross 3 years ago
parent
commit
7ae0d9f1f8

+ 3 - 6
src/Servers/Kestrel/Transport.Quic/test/QuicConnectionListenerTests.cs

@@ -101,18 +101,15 @@ public class QuicConnectionListenerTests : TestApplicationErrorLoggerLoggedTest
 
     [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 = await QuicConnection.ConnectAsync(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);
     }
 }

+ 0 - 1
src/Servers/Kestrel/test/Interop.FunctionalTests/Http3/Http3RequestTests.cs

@@ -393,7 +393,6 @@ public class Http3RequestTests : LoggedTest
     [MsQuicSupported]
     [InlineData(HttpProtocols.Http3)]
     [InlineData(HttpProtocols.Http2)]
-    [QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/35070")]
     public async Task POST_ServerAbort_ClientReceivesAbort(HttpProtocols protocol)
     {
         // Arrange

+ 7 - 9
src/Servers/Kestrel/test/Interop.FunctionalTests/Http3/Http3TlsTests.cs

@@ -196,17 +196,16 @@ public class Http3TlsTests : LoggedTest
 
         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();
@@ -215,7 +214,6 @@ public class Http3TlsTests : LoggedTest
     [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 =>
@@ -245,9 +243,9 @@ public class Http3TlsTests : LoggedTest
         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();
     }