コード例 #1
0
 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");
     }
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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");
            }
        }
コード例 #5
0
ファイル: DtlsX509.cs プロジェクト: jakubfindura/CoAP-CSharp
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
 public void TestRpk()
 {
     DTLSClientEndPoint ep = new DTLSClientEndPoint(RpkOneKey);
 }
コード例 #8
0
 public void TestNoKey()
 {
     DTLSClientEndPoint ep = new DTLSClientEndPoint(null);
 }
コード例 #9
0
 public void TestRpk()
 {
     TlsKeyPair         tlsKey = new TlsKeyPair(RpkOneKey.PublicKey(), RpkOneKey);
     DTLSClientEndPoint ep     = new DTLSClientEndPoint(RpkOneKey);
 }