public void NoEndPoint()
        {
            TLSClientEndPoint ep  = new TLSClientEndPoint(PskOneKey);
            Request           req = new Request(Method.GET)
            {
                URI      = new Uri("coaps+tcp://localhost:5682/.well-known/core"),
                EndPoint = ep
            };

            ep.Start();

            req.Send();
            req.WaitForResponse(5000);
        }
        public void CoapURL()
        {
            TLSClientEndPoint ep  = new TLSClientEndPoint(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");
            }
        }
Esempio n. 3
0
        public void TestX509()
        {
            Uri uri = new Uri($"coaps+tcp://localhost:{_serverPort}/Hello1");
            TLSClientEndPoint client = new TLSClientEndPoint(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);

        }
Esempio n. 4
0
        public void TlsTestPskEvents()
        {
            Uri uri = new Uri($"coaps+tcp://localhost:{_serverPort}/Hello1");
            TLSClientEndPoint client = new TLSClientEndPoint(PskOne);

            client.Start();

            Request req = new Request(Method.GET)
            {
                URI      = uri,
                EndPoint = client
            };

            req.Send();
            Response resp = req.WaitForResponse(50000);

            Assert.AreEqual(null, resp);
            client.Stop();

            TLSClientEndPoint client2 = new TLSClientEndPoint(PskTwo);

            client2.Start();
            Request req2 = new Request(Method.GET)
            {
                URI      = uri,
                EndPoint = client2
            };

            req2.Send();
            string txt = req2.WaitForResponse(50000).ResponseText;

            Assert.AreEqual("Hello from KeyTwo", txt);

            client2.Stop();

            Thread.Sleep(5000);
        }