internal Server(DtlsTestCase outer, DtlsTestServerProtocol serverProtocol, DatagramTransport serverTransport, TlsTestServerImpl serverImpl) { this.mOuter = outer; this.mServerProtocol = serverProtocol; this.mServerTransport = serverTransport; this.mServerImpl = serverImpl; }
public void RunTest(TlsTestConfig config) { CheckDtlsVersion(config.clientMinimumVersion); CheckDtlsVersion(config.clientOfferVersion); CheckDtlsVersion(config.serverMaximumVersion); CheckDtlsVersion(config.serverMinimumVersion); SecureRandom secureRandom = new SecureRandom(); DtlsTestClientProtocol clientProtocol = new DtlsTestClientProtocol(secureRandom, config); DtlsTestServerProtocol serverProtocol = new DtlsTestServerProtocol(secureRandom, config); MockDatagramAssociation network = new MockDatagramAssociation(1500); TlsTestClientImpl clientImpl = new TlsTestClientImpl(config); TlsTestServerImpl serverImpl = new TlsTestServerImpl(config); Server server = new Server(this, serverProtocol, network.Server, serverImpl); Thread serverThread = new Thread(new ThreadStart(server.Run)); serverThread.Start(); Exception caught = null; try { DatagramTransport clientTransport = network.Client; if (TlsTestConfig.DEBUG) { clientTransport = new LoggingDatagramTransport(clientTransport, Console.Out); } DtlsTransport dtlsClient = clientProtocol.Connect(clientImpl, clientTransport); for (int i = 1; i <= 10; ++i) { byte[] data = new byte[i]; Arrays.Fill(data, (byte)i); dtlsClient.Send(data, 0, data.Length); } byte[] buf = new byte[dtlsClient.GetReceiveLimit()]; while (dtlsClient.Receive(buf, 0, buf.Length, 100) >= 0) { } dtlsClient.Close(); } catch (Exception e) { caught = e; LogException(caught); } server.Shutdown(serverThread); // TODO Add checks that the various streams were closed Assert.AreEqual(config.expectFatalAlertConnectionEnd, clientImpl.FirstFatalAlertConnectionEnd, "Client fatal alert connection end"); Assert.AreEqual(config.expectFatalAlertConnectionEnd, serverImpl.FirstFatalAlertConnectionEnd, "Server fatal alert connection end"); Assert.AreEqual(config.expectFatalAlertDescription, clientImpl.FirstFatalAlertDescription, "Client fatal alert description"); Assert.AreEqual(config.expectFatalAlertDescription, serverImpl.FirstFatalAlertDescription, "Server fatal alert description"); if (config.expectFatalAlertConnectionEnd == -1) { Assert.IsNull(caught, "Unexpected client exception"); Assert.IsNull(server.mCaught, "Unexpected server exception"); } }
public void RunTest(TlsTestConfig config) { CheckDtlsVersion(config.clientMinimumVersion); CheckDtlsVersion(config.clientOfferVersion); CheckDtlsVersion(config.serverMaximumVersion); CheckDtlsVersion(config.serverMinimumVersion); SecureRandom secureRandom = new SecureRandom(); DtlsTestClientProtocol clientProtocol = new DtlsTestClientProtocol(secureRandom, config); DtlsTestServerProtocol serverProtocol = new DtlsTestServerProtocol(secureRandom, config); MockDatagramAssociation network = new MockDatagramAssociation(1500); TlsTestClientImpl clientImpl = new TlsTestClientImpl(config); TlsTestServerImpl serverImpl = new TlsTestServerImpl(config); Server server = new Server(this, serverProtocol, network.Server, serverImpl); Thread serverThread = new Thread(new ThreadStart(server.Run)); serverThread.Start(); Exception caught = null; try { DatagramTransport clientTransport = network.Client; if (TlsTestConfig.DEBUG) { clientTransport = new LoggingDatagramTransport(clientTransport, Console.Out); } DtlsTransport dtlsClient = clientProtocol.Connect(clientImpl, clientTransport); for (int i = 1; i <= 10; ++i) { byte[] data = new byte[i]; Arrays.Fill(data, (byte)i); dtlsClient.Send(data, 0, data.Length); } byte[] buf = new byte[dtlsClient.GetReceiveLimit()]; while (dtlsClient.Receive(buf, 0, buf.Length, 100) >= 0) { } dtlsClient.Close(); } catch (Exception e) { caught = e; LogException(caught); } server.Shutdown(serverThread); // TODO Add checks that the various streams were closed Assert.AreEqual(config.expectFatalAlertConnectionEnd, clientImpl.FirstFatalAlertConnectionEnd, "Client fatal alert connection end"); Assert.AreEqual(config.expectFatalAlertConnectionEnd, serverImpl.FirstFatalAlertConnectionEnd, "Server fatal alert connection end"); Assert.AreEqual(config.expectFatalAlertDescription, clientImpl.FirstFatalAlertDescription, "Client fatal alert description"); Assert.AreEqual(config.expectFatalAlertDescription, serverImpl.FirstFatalAlertDescription, "Server fatal alert description"); if (config.expectFatalAlertConnectionEnd == -1) { Assert.IsNull(caught, "Unexpected client exception"); Assert.IsNull(server.mCaught, "Unexpected server exception"); } }
internal Server(DtlsTestCase outer, DtlsTestServerProtocol serverProtocol, DatagramTransport serverTransport, TlsTestServerImpl serverImpl) { this.mOuter = outer; this.mServerProtocol = serverProtocol; this.mServerTransport = serverTransport; this.mServerImpl = serverImpl; }