]> git.deb.at Git - rhonda/impostor.hazel.git/commitdiff
Leverage existing tests for DTLS listener
authorMatthew Endsley <mendsley@gmail.com>
Wed, 3 Feb 2021 11:10:41 +0000 (03:10 -0800)
committerMatthew Endsley <mendsley@gmail.com>
Wed, 3 Feb 2021 22:40:57 +0000 (14:40 -0800)
Hazel.UnitTests/Dtls/ConnectionTests.cs

index c6132fa5ac9170af7cf1f93dc7dfaf4ca61088fd..0a8077eb92d1eab2950e2982c6332fa9aaa68b8b 100644 (file)
@@ -1,4 +1,6 @@
 using Hazel.Dtls;
+using Hazel.Udp;
+using Hazel.Udp.FewerThreads;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using System.Net;
 using System.Security.Cryptography;
@@ -8,7 +10,7 @@ using System.Threading;
 namespace Hazel.UnitTests.Dtls
 {
     [TestClass]
-    public class ConnectionTests
+    public class ConnectionTests : BaseThreadLimitedUdpConnectionTests
     {
         // Created with command line
         // openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 100000 -out certificate.pem
@@ -85,6 +87,21 @@ IsdbLCwHYD3GVgk/D7NVxyU=
             return clientCertificates;
         }
 
+        protected override ThreadLimitedUdpConnectionListener CreateListener(int numWorkers, IPEndPoint endPoint, ILogger logger, IPMode ipMode = IPMode.IPv4)
+        {
+            DtlsConnectionListener listener = new DtlsConnectionListener(2, endPoint, logger, ipMode);
+            listener.SetCertificate(GetCertificateForServer());
+            return listener;
+
+        }
+
+        protected override UdpConnection CreateConnection(IPEndPoint endPoint, ILogger logger, IPMode ipMode = IPMode.IPv4)
+        {
+            DtlsUnityConnection connection = new DtlsUnityConnection(logger, endPoint, ipMode);
+            connection.SetValidServerCertificates(GetCertificateForClient());
+            return connection;
+        }
+
         [TestMethod]
         public void TestClientConnects()
         {