public void TestNoKey() { try { DTLSClientEndPoint ep = new DTLSClientEndPoint((TlsKeyPair)null); ep.Dispose(); Assert.Fail("Should not have reached here."); } catch (ArgumentNullException e) { Assert.AreEqual(e.ParamName, "userKey"); } }
public void NoEndPoint() { DTLSClientEndPoint ep = new DTLSClientEndPoint(PskOneKey); Request req = new Request(Method.GET) { URI = new Uri("coaps://localhost:5682/.well-known/core"), EndPoint = ep }; ep.Start(); req.Send(); req.WaitForResponse(5000); }
public void CoapURL() { DTLSClientEndPoint ep = new DTLSClientEndPoint(PskOneKey); Request req = new Request(Method.GET) { URI = new Uri("coap://localhost/.well-known/core"), EndPoint = ep }; ep.Start(); Exception e = Assert.Throws <Exception>(() => req.Send()); Assert.That(e.Message == "Schema is incorrect for the end point"); req.WaitForResponse(5000); }
public void CoapURL() { DTLSClientEndPoint ep = new DTLSClientEndPoint(PskOneKey); Request req = new Request(Method.GET) { URI = new Uri("coap://localhost/.well-known/core"), EndPoint = ep }; ep.Start(); try { req.Send(); req.WaitForResponse(5000); } catch (Exception e) { Assert.AreEqual(e.Message, "Schema is incorrect for the end point"); } }
public void TestX509() { Uri uri = new Uri($"coaps://localhost:{_serverPort}/Hello1"); DTLSClientEndPoint client = new DTLSClientEndPoint(X509Client); client.TlsEventHandler += ClientTlsEvents; client.Start(); Request req = new Request(Method.GET) { URI = uri, EndPoint = client }; req.Send(); String txt = req.WaitForResponse(50000).ResponseText; Assert.AreEqual("Hello from CN=COSE EE Five", txt); client.Stop(); Thread.Sleep(5000); }
public void DTLSTestPskAsyncGet() { Uri uri = new Uri($"coaps://localhost:{_serverPort}/Hello1"); DTLSClientEndPoint client = new DTLSClientEndPoint(PskOne); client.Start(); Request req = new Request(Method.GET) { URI = uri, EndPoint = client }; DTLSClientEndPoint client2 = new DTLSClientEndPoint(PskTwo); client2.Start(); Request req2 = new Request(Method.GET) { URI = uri, EndPoint = client2 }; req.Send(); req2.Send(); String txt = req.WaitForResponse(50000).ResponseText; Assert.AreEqual("Hello from KeyOne", txt); txt = req2.WaitForResponse(50000).ResponseText; Assert.AreEqual("Hello from KeyTwo", txt); client2.Stop(); client.Stop(); Thread.Sleep(5000); }
public void TestRpk() { DTLSClientEndPoint ep = new DTLSClientEndPoint(RpkOneKey); }
public void TestNoKey() { DTLSClientEndPoint ep = new DTLSClientEndPoint(null); }
public void TestRpk() { TlsKeyPair tlsKey = new TlsKeyPair(RpkOneKey.PublicKey(), RpkOneKey); DTLSClientEndPoint ep = new DTLSClientEndPoint(RpkOneKey); }