summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-08-28 23:00:53 -0700
committerGarrett D'Amore <garrett@damore.org>2018-08-28 23:00:53 -0700
commitce9f0cb155ad0e97cfc7703d9d7c8e5bec3201bc (patch)
tree01fc3b118dd74a2202ac794dce69f380c39a35f4 /tests
parent05852bc279a6d88722cff8e8399b5d08853b9c32 (diff)
downloadnng-ce9f0cb155ad0e97cfc7703d9d7c8e5bec3201bc.tar.gz
nng-ce9f0cb155ad0e97cfc7703d9d7c8e5bec3201bc.tar.bz2
nng-ce9f0cb155ad0e97cfc7703d9d7c8e5bec3201bc.zip
fixes #678 local binding for TLS+TCP sockets
Diffstat (limited to 'tests')
-rw-r--r--tests/tcp.c2
-rw-r--r--tests/tls.c43
2 files changed, 44 insertions, 1 deletions
diff --git a/tests/tcp.c b/tests/tcp.c
index d13cc83d..2c49f509 100644
--- a/tests/tcp.c
+++ b/tests/tcp.c
@@ -108,7 +108,7 @@ TestMain("TCP Transport", {
nng_strfree(addr);
});
- Convey("We can use local interface to connet", {
+ Convey("We can use local interface to connect", {
nng_socket s1;
nng_socket s2;
char addr[NNG_MAXADDRLEN];
diff --git a/tests/tls.c b/tests/tls.c
index 84c939e8..8915b265 100644
--- a/tests/tls.c
+++ b/tests/tls.c
@@ -368,6 +368,49 @@ TestMain("TLS Transport", {
NNG_EADDRINVAL);
});
+ Convey("We can use local interface to connect", {
+ nng_socket s1;
+ nng_socket s2;
+ nng_listener l;
+ nng_dialer d;
+ char addr[NNG_MAXADDRLEN];
+
+ So(nng_pair_open(&s1) == 0);
+ So(nng_pair_open(&s2) == 0);
+ Reset({
+ nng_close(s2);
+ nng_close(s1);
+ });
+ trantest_next_address(addr, "tls+tcp://127.0.0.1:%u");
+ So(nng_listener_create(&l, s1, addr) == 0);
+ So(init_listener_tls(l) == 0);
+ So(nng_listener_start(l, 0) == 0);
+ // reset port back one
+ trantest_prev_address(
+ addr, "tls+tcp://127.0.0.1;127.0.0.1:%u");
+ So(nng_dialer_create(&d, s2, addr) == 0);
+ So(init_dialer_tls(d) == 0);
+ So(nng_dialer_start(d, 0) == 0);
+ });
+
+ Convey("Botched local interfaces fail resonably", {
+ nng_socket s1;
+
+ So(nng_pair_open(&s1) == 0);
+ Reset({ nng_close(s1); });
+ So(nng_dial(s1, "tcp://1x.2;127.0.0.1:80", NULL, 0) ==
+ NNG_EADDRINVAL);
+ });
+
+ Convey("Can't specify address that isn't ours", {
+ nng_socket s1;
+
+ So(nng_pair_open(&s1) == 0);
+ Reset({ nng_close(s1); });
+ So(nng_dial(s1, "tcp://8.8.8.8;127.0.0.1:80", NULL, 0) ==
+ NNG_EADDRINVAL);
+ });
+
#if 0
// We really need to have pipe start/negotiate as one of the key steps during
// connect establish. Until that happens, we cannot verify the peer.