From 0f3e2ae610d2ea753beb46588088b2a515869a71 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Wed, 12 Jul 2023 10:48:46 +0700 Subject: Refactoring in Tls.Tests --- crypto/test/src/tls/test/DtlsProtocolTest.cs | 10 +++++----- crypto/test/src/tls/test/DtlsPskProtocolTest.cs | 10 +++++----- crypto/test/src/tls/test/DtlsTestCase.cs | 12 ++++++------ crypto/test/src/tls/test/PskTls13ServerTest.cs | 8 ++++---- crypto/test/src/tls/test/PskTlsServerTest.cs | 8 ++++---- crypto/test/src/tls/test/Tls13PskProtocolTest.cs | 8 ++++---- crypto/test/src/tls/test/TlsProtocolTest.cs | 8 ++++---- crypto/test/src/tls/test/TlsPskProtocolTest.cs | 8 ++++---- crypto/test/src/tls/test/TlsRawKeysProtocolTest.cs | 8 ++++---- crypto/test/src/tls/test/TlsServerRawKeysTest.cs | 8 ++++---- crypto/test/src/tls/test/TlsServerTest.cs | 8 ++++---- crypto/test/src/tls/test/TlsSrpProtocolTest.cs | 8 ++++---- crypto/test/src/tls/test/TlsTestCase.cs | 12 ++++++------ 13 files changed, 58 insertions(+), 58 deletions(-) (limited to 'crypto/test') diff --git a/crypto/test/src/tls/test/DtlsProtocolTest.cs b/crypto/test/src/tls/test/DtlsProtocolTest.cs index 79b919999..0591b35c8 100644 --- a/crypto/test/src/tls/test/DtlsProtocolTest.cs +++ b/crypto/test/src/tls/test/DtlsProtocolTest.cs @@ -24,9 +24,9 @@ namespace Org.BouncyCastle.Tls.Tests MockDatagramAssociation network = new MockDatagramAssociation(1500); - Server server = new Server(serverProtocol, network.Server); + ServerTask serverTask = new ServerTask(serverProtocol, network.Server); - Thread serverThread = new Thread(new ThreadStart(server.Run)); + Thread serverThread = new Thread(new ThreadStart(serverTask.Run)); serverThread.Start(); DatagramTransport clientTransport = network.Client; @@ -53,16 +53,16 @@ namespace Org.BouncyCastle.Tls.Tests dtlsClient.Close(); - server.Shutdown(serverThread); + serverTask.Shutdown(serverThread); } - internal class Server + internal class ServerTask { private readonly DtlsServerProtocol m_serverProtocol; private readonly DatagramTransport m_serverTransport; private volatile bool m_isShutdown = false; - internal Server(DtlsServerProtocol serverProtocol, DatagramTransport serverTransport) + internal ServerTask(DtlsServerProtocol serverProtocol, DatagramTransport serverTransport) { this.m_serverProtocol = serverProtocol; this.m_serverTransport = serverTransport; diff --git a/crypto/test/src/tls/test/DtlsPskProtocolTest.cs b/crypto/test/src/tls/test/DtlsPskProtocolTest.cs index f0e685541..b30dbb847 100644 --- a/crypto/test/src/tls/test/DtlsPskProtocolTest.cs +++ b/crypto/test/src/tls/test/DtlsPskProtocolTest.cs @@ -21,9 +21,9 @@ namespace Org.BouncyCastle.Tls.Tests MockDatagramAssociation network = new MockDatagramAssociation(1500); - Server server = new Server(serverProtocol, network.Server); + ServerTask serverTask = new ServerTask(serverProtocol, network.Server); - Thread serverThread = new Thread(new ThreadStart(server.Run)); + Thread serverThread = new Thread(new ThreadStart(serverTask.Run)); serverThread.Start(); DatagramTransport clientTransport = network.Client; @@ -50,16 +50,16 @@ namespace Org.BouncyCastle.Tls.Tests dtlsClient.Close(); - server.Shutdown(serverThread); + serverTask.Shutdown(serverThread); } - internal class Server + internal class ServerTask { private readonly DtlsServerProtocol m_serverProtocol; private readonly DatagramTransport m_serverTransport; private volatile bool m_isShutdown = false; - internal Server(DtlsServerProtocol serverProtocol, DatagramTransport serverTransport) + internal ServerTask(DtlsServerProtocol serverProtocol, DatagramTransport serverTransport) { this.m_serverProtocol = serverProtocol; this.m_serverTransport = serverTransport; diff --git a/crypto/test/src/tls/test/DtlsTestCase.cs b/crypto/test/src/tls/test/DtlsTestCase.cs index d93f17c27..32ddc6c21 100644 --- a/crypto/test/src/tls/test/DtlsTestCase.cs +++ b/crypto/test/src/tls/test/DtlsTestCase.cs @@ -36,9 +36,9 @@ namespace Org.BouncyCastle.Tls.Tests TlsTestClientImpl clientImpl = new TlsTestClientImpl(config); TlsTestServerImpl serverImpl = new TlsTestServerImpl(config); - Server server = new Server(this, serverProtocol, network.Server, serverImpl); + ServerTask serverTask = new ServerTask(this, serverProtocol, network.Server, serverImpl); - Thread serverThread = new Thread(new ThreadStart(server.Run)); + Thread serverThread = new Thread(new ThreadStart(serverTask.Run)); serverThread.Start(); Exception caught = null; @@ -73,7 +73,7 @@ namespace Org.BouncyCastle.Tls.Tests LogException(caught); } - server.Shutdown(serverThread); + serverTask.Shutdown(serverThread); // TODO Add checks that the various streams were closed @@ -90,7 +90,7 @@ namespace Org.BouncyCastle.Tls.Tests if (config.expectFatalAlertConnectionEnd == -1) { Assert.IsNull(caught, "Unexpected client exception"); - Assert.IsNull(server.Caught, "Unexpected server exception"); + Assert.IsNull(serverTask.Caught, "Unexpected server exception"); } } @@ -103,7 +103,7 @@ namespace Org.BouncyCastle.Tls.Tests } } - internal class Server + internal class ServerTask { private readonly DtlsTestCase m_outer; private readonly DtlsTestServerProtocol m_serverProtocol; @@ -113,7 +113,7 @@ namespace Org.BouncyCastle.Tls.Tests private volatile bool m_isShutdown = false; private Exception m_caught = null; - internal Server(DtlsTestCase outer, DtlsTestServerProtocol serverProtocol, + internal ServerTask(DtlsTestCase outer, DtlsTestServerProtocol serverProtocol, DatagramTransport serverTransport, TlsTestServerImpl serverImpl) { this.m_outer = outer; diff --git a/crypto/test/src/tls/test/PskTls13ServerTest.cs b/crypto/test/src/tls/test/PskTls13ServerTest.cs index f48832fe9..7b5f23665 100644 --- a/crypto/test/src/tls/test/PskTls13ServerTest.cs +++ b/crypto/test/src/tls/test/PskTls13ServerTest.cs @@ -28,8 +28,8 @@ namespace Org.BouncyCastle.Tls.Tests TcpClient s = ss.AcceptTcpClient(); Console.WriteLine("--------------------------------------------------------------------------------"); Console.WriteLine("Accepted " + s); - Server serverRun = new Server(s, stdout); - Thread t = new Thread(new ThreadStart(serverRun.Run)); + ServerTask serverTask = new ServerTask(s, stdout); + Thread t = new Thread(new ThreadStart(serverTask.Run)); t.Start(); } } @@ -39,12 +39,12 @@ namespace Org.BouncyCastle.Tls.Tests } } - internal class Server + internal class ServerTask { private readonly TcpClient s; private readonly Stream stdout; - internal Server(TcpClient s, Stream stdout) + internal ServerTask(TcpClient s, Stream stdout) { this.s = s; this.stdout = stdout; diff --git a/crypto/test/src/tls/test/PskTlsServerTest.cs b/crypto/test/src/tls/test/PskTlsServerTest.cs index 4d1d4c722..3a54ee4ff 100644 --- a/crypto/test/src/tls/test/PskTlsServerTest.cs +++ b/crypto/test/src/tls/test/PskTlsServerTest.cs @@ -33,8 +33,8 @@ namespace Org.BouncyCastle.Tls.Tests TcpClient s = ss.AcceptTcpClient(); Console.WriteLine("--------------------------------------------------------------------------------"); Console.WriteLine("Accepted " + s); - Server serverRun = new Server(s, stdout); - Thread t = new Thread(new ThreadStart(serverRun.Run)); + ServerTask serverTask = new ServerTask(s, stdout); + Thread t = new Thread(new ThreadStart(serverTask.Run)); t.Start(); } } @@ -44,12 +44,12 @@ namespace Org.BouncyCastle.Tls.Tests } } - internal class Server + internal class ServerTask { private readonly TcpClient s; private readonly Stream stdout; - internal Server(TcpClient s, Stream stdout) + internal ServerTask(TcpClient s, Stream stdout) { this.s = s; this.stdout = stdout; diff --git a/crypto/test/src/tls/test/Tls13PskProtocolTest.cs b/crypto/test/src/tls/test/Tls13PskProtocolTest.cs index b66e781a2..7684a54f4 100644 --- a/crypto/test/src/tls/test/Tls13PskProtocolTest.cs +++ b/crypto/test/src/tls/test/Tls13PskProtocolTest.cs @@ -24,8 +24,8 @@ namespace Org.BouncyCastle.Tls.Tests MockPskTls13Client client = new MockPskTls13Client(); MockPskTls13Server server = new MockPskTls13Server(); - Server serverRun = new Server(serverProtocol, server); - Thread serverThread = new Thread(new ThreadStart(serverRun.Run)); + ServerTask serverTask = new ServerTask(serverProtocol, server); + Thread serverThread = new Thread(new ThreadStart(serverTask.Run)); serverThread.Start(); clientProtocol.Connect(client); @@ -47,12 +47,12 @@ namespace Org.BouncyCastle.Tls.Tests serverThread.Join(); } - internal class Server + internal class ServerTask { private readonly TlsServerProtocol m_serverProtocol; private readonly TlsServer m_server; - internal Server(TlsServerProtocol serverProtocol, TlsServer server) + internal ServerTask(TlsServerProtocol serverProtocol, TlsServer server) { this.m_serverProtocol = serverProtocol; this.m_server = server; diff --git a/crypto/test/src/tls/test/TlsProtocolTest.cs b/crypto/test/src/tls/test/TlsProtocolTest.cs index c0287d913..aa3347fdb 100644 --- a/crypto/test/src/tls/test/TlsProtocolTest.cs +++ b/crypto/test/src/tls/test/TlsProtocolTest.cs @@ -24,8 +24,8 @@ namespace Org.BouncyCastle.Tls.Tests MockTlsClient client = new MockTlsClient(null); MockTlsServer server = new MockTlsServer(); - Server serverRun = new Server(serverProtocol, server); - Thread serverThread = new Thread(new ThreadStart(serverRun.Run)); + ServerTask serverTask = new ServerTask(serverProtocol, server); + Thread serverThread = new Thread(new ThreadStart(serverTask.Run)); serverThread.Start(); clientProtocol.Connect(client); @@ -47,12 +47,12 @@ namespace Org.BouncyCastle.Tls.Tests serverThread.Join(); } - internal class Server + internal class ServerTask { private readonly TlsServerProtocol m_serverProtocol; private readonly TlsServer m_server; - internal Server(TlsServerProtocol serverProtocol, TlsServer server) + internal ServerTask(TlsServerProtocol serverProtocol, TlsServer server) { this.m_serverProtocol = serverProtocol; this.m_server = server; diff --git a/crypto/test/src/tls/test/TlsPskProtocolTest.cs b/crypto/test/src/tls/test/TlsPskProtocolTest.cs index 449f9ea16..a9ee95f3d 100644 --- a/crypto/test/src/tls/test/TlsPskProtocolTest.cs +++ b/crypto/test/src/tls/test/TlsPskProtocolTest.cs @@ -24,8 +24,8 @@ namespace Org.BouncyCastle.Tls.Tests MockPskTlsClient client = new MockPskTlsClient(null); MockPskTlsServer server = new MockPskTlsServer(); - Server serverRun = new Server(serverProtocol, server); - Thread serverThread = new Thread(new ThreadStart(serverRun.Run)); + ServerTask serverTask = new ServerTask(serverProtocol, server); + Thread serverThread = new Thread(new ThreadStart(serverTask.Run)); serverThread.Start(); clientProtocol.Connect(client); @@ -47,12 +47,12 @@ namespace Org.BouncyCastle.Tls.Tests serverThread.Join(); } - internal class Server + internal class ServerTask { private readonly TlsServerProtocol m_serverProtocol; private readonly TlsServer m_server; - internal Server(TlsServerProtocol serverProtocol, TlsServer server) + internal ServerTask(TlsServerProtocol serverProtocol, TlsServer server) { this.m_serverProtocol = serverProtocol; this.m_server = server; diff --git a/crypto/test/src/tls/test/TlsRawKeysProtocolTest.cs b/crypto/test/src/tls/test/TlsRawKeysProtocolTest.cs index 976df4009..7c13cb27e 100644 --- a/crypto/test/src/tls/test/TlsRawKeysProtocolTest.cs +++ b/crypto/test/src/tls/test/TlsRawKeysProtocolTest.cs @@ -228,8 +228,8 @@ namespace Org.BouncyCastle.Tls.Tests TlsClientProtocol clientProtocol = new TlsClientProtocol(clientPipe); TlsServerProtocol serverProtocol = new TlsServerProtocol(serverPipe); - Server serverRun = new Server(serverProtocol, server); - Thread serverThread = new Thread(new ThreadStart(serverRun.Run)); + ServerTask serverTask = new ServerTask(serverProtocol, server); + Thread serverThread = new Thread(new ThreadStart(serverTask.Run)); serverThread.Start(); clientProtocol.Connect(client); @@ -254,12 +254,12 @@ namespace Org.BouncyCastle.Tls.Tests serverThread.Join(); } - internal class Server + internal class ServerTask { private readonly TlsServerProtocol m_serverProtocol; private readonly TlsServer m_server; - internal Server(TlsServerProtocol serverProtocol, TlsServer server) + internal ServerTask(TlsServerProtocol serverProtocol, TlsServer server) { m_serverProtocol = serverProtocol; m_server = server; diff --git a/crypto/test/src/tls/test/TlsServerRawKeysTest.cs b/crypto/test/src/tls/test/TlsServerRawKeysTest.cs index 22e35505c..70b6a24c1 100644 --- a/crypto/test/src/tls/test/TlsServerRawKeysTest.cs +++ b/crypto/test/src/tls/test/TlsServerRawKeysTest.cs @@ -37,8 +37,8 @@ namespace Org.BouncyCastle.Tls.Tests TcpClient s = ss.AcceptTcpClient(); Console.WriteLine("--------------------------------------------------------------------------------"); Console.WriteLine("Accepted " + s); - Server serverRun = new Server(s, stdout, tlsVersion); - Thread t = new Thread(new ThreadStart(serverRun.Run)); + ServerTask serverTask = new ServerTask(s, stdout, tlsVersion); + Thread t = new Thread(new ThreadStart(serverTask.Run)); t.Start(); } } @@ -48,13 +48,13 @@ namespace Org.BouncyCastle.Tls.Tests } } - internal class Server + internal class ServerTask { private readonly TcpClient s; private readonly Stream stdout; private readonly ProtocolVersion tlsVersion; - internal Server(TcpClient s, Stream stdout, ProtocolVersion tlsVersion) + internal ServerTask(TcpClient s, Stream stdout, ProtocolVersion tlsVersion) { this.s = s; this.stdout = stdout; diff --git a/crypto/test/src/tls/test/TlsServerTest.cs b/crypto/test/src/tls/test/TlsServerTest.cs index 2f2285942..0a19373ec 100644 --- a/crypto/test/src/tls/test/TlsServerTest.cs +++ b/crypto/test/src/tls/test/TlsServerTest.cs @@ -33,8 +33,8 @@ namespace Org.BouncyCastle.Tls.Tests TcpClient s = ss.AcceptTcpClient(); Console.WriteLine("--------------------------------------------------------------------------------"); Console.WriteLine("Accepted " + s); - Server serverRun = new Server(s, stdout); - Thread t = new Thread(new ThreadStart(serverRun.Run)); + ServerTask serverTask = new ServerTask(s, stdout); + Thread t = new Thread(new ThreadStart(serverTask.Run)); t.Start(); } } @@ -44,12 +44,12 @@ namespace Org.BouncyCastle.Tls.Tests } } - internal class Server + internal class ServerTask { private readonly TcpClient s; private readonly Stream stdout; - internal Server(TcpClient s, Stream stdout) + internal ServerTask(TcpClient s, Stream stdout) { this.s = s; this.stdout = stdout; diff --git a/crypto/test/src/tls/test/TlsSrpProtocolTest.cs b/crypto/test/src/tls/test/TlsSrpProtocolTest.cs index f85a67dd5..60f0bc9d5 100644 --- a/crypto/test/src/tls/test/TlsSrpProtocolTest.cs +++ b/crypto/test/src/tls/test/TlsSrpProtocolTest.cs @@ -24,8 +24,8 @@ namespace Org.BouncyCastle.Tls.Tests MockSrpTlsClient client = new MockSrpTlsClient(null, MockSrpTlsServer.TEST_SRP_IDENTITY); MockSrpTlsServer server = new MockSrpTlsServer(); - Server serverRun = new Server(serverProtocol, server); - Thread serverThread = new Thread(new ThreadStart(serverRun.Run)); + ServerTask serverTask = new ServerTask(serverProtocol, server); + Thread serverThread = new Thread(new ThreadStart(serverTask.Run)); serverThread.Start(); clientProtocol.Connect(client); @@ -47,12 +47,12 @@ namespace Org.BouncyCastle.Tls.Tests serverThread.Join(); } - internal class Server + internal class ServerTask { private readonly TlsServerProtocol m_serverProtocol; private readonly TlsServer m_server; - internal Server(TlsServerProtocol serverProtocol, TlsServer server) + internal ServerTask(TlsServerProtocol serverProtocol, TlsServer server) { this.m_serverProtocol = serverProtocol; this.m_server = server; diff --git a/crypto/test/src/tls/test/TlsTestCase.cs b/crypto/test/src/tls/test/TlsTestCase.cs index cb136db92..ad2dfee0c 100644 --- a/crypto/test/src/tls/test/TlsTestCase.cs +++ b/crypto/test/src/tls/test/TlsTestCase.cs @@ -49,8 +49,8 @@ namespace Org.BouncyCastle.Tls.Tests TlsTestClientImpl clientImpl = new TlsTestClientImpl(config); TlsTestServerImpl serverImpl = new TlsTestServerImpl(config); - Server serverRun = new Server(this, serverProtocol, serverImpl); - Thread serverThread = new Thread(new ThreadStart(serverRun.Run)); + ServerTask serverTask = new ServerTask(this, serverProtocol, serverImpl); + Thread serverThread = new Thread(new ThreadStart(serverTask.Run)); serverThread.Start(); Exception caught = null; @@ -89,7 +89,7 @@ namespace Org.BouncyCastle.Tls.Tests LogException(caught); } - serverRun.AllowExit(); + serverTask.AllowExit(); serverThread.Join(); Assert.IsTrue(clientNet.IsClosed, "Client Stream not closed"); @@ -108,7 +108,7 @@ namespace Org.BouncyCastle.Tls.Tests if (config.expectFatalAlertConnectionEnd == -1) { Assert.IsNull(caught, "Unexpected client exception"); - Assert.IsNull(serverRun.m_caught, "Unexpected server exception"); + Assert.IsNull(serverTask.m_caught, "Unexpected server exception"); } } @@ -121,7 +121,7 @@ namespace Org.BouncyCastle.Tls.Tests } } - internal class Server + internal class ServerTask { protected readonly TlsTestCase m_outer; protected readonly TlsServerProtocol m_serverProtocol; @@ -130,7 +130,7 @@ namespace Org.BouncyCastle.Tls.Tests internal bool m_canExit = false; internal Exception m_caught = null; - internal Server(TlsTestCase outer, TlsTestServerProtocol serverProtocol, TlsServer server) + internal ServerTask(TlsTestCase outer, TlsTestServerProtocol serverProtocol, TlsServer server) { this.m_outer = outer; this.m_serverProtocol = serverProtocol; -- cgit 1.4.1