diff --git a/tests/IceRpc.Quic.Tests/Transports/QuicTransportSslAuthenticationTests.cs b/tests/IceRpc.Quic.Tests/Transports/QuicTransportSslAuthenticationTests.cs index 14f606b2b..83abf70fa 100644 --- a/tests/IceRpc.Quic.Tests/Transports/QuicTransportSslAuthenticationTests.cs +++ b/tests/IceRpc.Quic.Tests/Transports/QuicTransportSslAuthenticationTests.cs @@ -12,7 +12,7 @@ namespace IceRpc.Tests.Transports; /// Test Ssl authentication with Quic transport. -public class QuicTransportSslAuthenticationConformanceTests +public class QuicTransportSslAuthenticationTests { [OneTimeSetUp] public void FixtureSetUp() @@ -24,7 +24,7 @@ public void FixtureSetUp() } [Test] - public async Task Ssl_client_connection_connect_fails_when_server_provides_untrusted_certificate() + public async Task Quic_client_connection_connect_fails_when_server_provides_untrusted_certificate() { // Arrange await using ServiceProvider provider = CreateServiceCollection() @@ -59,7 +59,7 @@ public async Task Ssl_client_connection_connect_fails_when_server_provides_untru "CA5359:Do Not Disable Certificate Validation", Justification = "The client doesn't need to validate the server certificate for this test")] [Test] - public async Task Ssl_server_connection_connect_fails_when_client_provides_untrusted_certificate() + public async Task Quic_server_connection_connect_fails_when_client_provides_untrusted_certificate() { // Arrange await using ServiceProvider provider = CreateServiceCollection() diff --git a/tests/IceRpc.Tests/Transports/Slic/SlicTransportSslAuthenticationTests.cs b/tests/IceRpc.Tests/Transports/Slic/SlicTransportSslAuthenticationTests.cs index f18e32fac..cb61f303d 100644 --- a/tests/IceRpc.Tests/Transports/Slic/SlicTransportSslAuthenticationTests.cs +++ b/tests/IceRpc.Tests/Transports/Slic/SlicTransportSslAuthenticationTests.cs @@ -13,10 +13,10 @@ namespace IceRpc.Tests.Transports.Slic; /// Test Ssl authentication with Slic transport. [Parallelizable(ParallelScope.All)] -public class SlicTransportSslAuthenticationConformanceTests +public class SlicTransportSslAuthenticationTests { [Test] - public async Task Ssl_client_connection_connect_fails_when_server_provides_untrusted_certificate() + public async Task Slic_over_ssl_client_connection_connect_fails_when_server_provides_untrusted_certificate() { // Arrange await using ServiceProvider provider = CreateServiceCollection() @@ -39,19 +39,10 @@ public async Task Ssl_client_connection_connect_fails_when_server_provides_untru // Start the TLS handshake. Task clientConnectTask = sut.Client.ConnectAsync(default); (IMultiplexedConnection serverConnection, _) = await listener.AcceptAsync(default); - var serverConnectTask = serverConnection.ConnectAsync(default); + _ = serverConnection.ConnectAsync(default); // Act/Assert Assert.That(async () => await clientConnectTask, Throws.TypeOf()); - - // The client will typically close the transport connection after receiving AuthenticationException - await sut.Client.DisposeAsync(); - var exception = Assert.ThrowsAsync(async () => await serverConnectTask!); - Assert.That( - exception?.IceRpcError, - Is.EqualTo(IceRpcError.ConnectionAborted).Or.EqualTo(IceRpcError.IceRpcError), - $"The test failed with an unexpected IceRpcError {exception}"); - await serverConnection.DisposeAsync(); } [System.Diagnostics.CodeAnalysis.SuppressMessage( @@ -59,7 +50,7 @@ public async Task Ssl_client_connection_connect_fails_when_server_provides_untru "CA5359:Do Not Disable Certificate Validation", Justification = "The client doesn't need to validate the server certificate for this test")] [Test] - public async Task Ssl_server_connection_connect_fails_when_client_provides_untrusted_certificate() + public async Task Slic_over_ssl_server_connection_connect_fails_when_client_provides_untrusted_certificate() { // Arrange await using ServiceProvider provider = CreateServiceCollection() @@ -85,28 +76,13 @@ public async Task Ssl_server_connection_connect_fails_when_client_provides_untru var listener = provider.GetRequiredService>(); // Start the TLS handshake. - var clientConnectTask = sut.Client.ConnectAsync(default); + _ = sut.Client.ConnectAsync(default); // Act/Assert - IMultiplexedConnection? serverConnection = null; + (IMultiplexedConnection? serverConnection, _) = await listener.AcceptAsync(default); Assert.That( - async () => - { - (serverConnection, _) = await listener.AcceptAsync(default); - await serverConnection.ConnectAsync(default); - }, + async () => await serverConnection.ConnectAsync(default), Throws.TypeOf()); - - Assert.That( - async () => - { - if (serverConnection is not null) - { - await serverConnection.DisposeAsync(); - } - await clientConnectTask; - }, - Throws.TypeOf().Or.TypeOf()); } private static IServiceCollection CreateServiceCollection() =>