diff options
| author | Garrett D'Amore <garrett@damore.org> | 2020-11-09 22:27:43 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2020-11-09 22:27:43 -0800 |
| commit | 2a55e0a279a0b94e204e0ffead73505100a0481f (patch) | |
| tree | d49051c76a0b1dc134281d5ba83869c519dd0f2d /tests | |
| parent | ac03c65f4f53265a5ef05d4792e84cf590f5e73e (diff) | |
| download | nng-2a55e0a279a0b94e204e0ffead73505100a0481f.tar.gz nng-2a55e0a279a0b94e204e0ffead73505100a0481f.tar.bz2 nng-2a55e0a279a0b94e204e0ffead73505100a0481f.zip | |
fixes #1332 Test nng.ws failed, "Incorrect URL paths do not work"
This moves some of the fragile tests to a new test suite that
is a bit more careful with IPv4 vs. IPv6. Hopefully it will be
a bit more resilient as a result.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/testutil.h | 1 | ||||
| -rw-r--r-- | tests/ws.c | 91 |
2 files changed, 1 insertions, 91 deletions
diff --git a/tests/testutil.h b/tests/testutil.h index eb7ab7d1..63979cff 100644 --- a/tests/testutil.h +++ b/tests/testutil.h @@ -15,6 +15,7 @@ // The following headers are provided for test code convenience. #include <nng/nng.h> +#include <nng/supplemental/util/platform.h> #ifdef __cplusplus extern "C" { @@ -84,96 +84,5 @@ check_props_v4(nng_msg *msg) TestMain("WebSocket Transport", { trantest_test_extended("ws://127.0.0.1:%u/test", check_props_v4); - Convey("Empty hostname works", { - nng_socket s1; - nng_socket s2; - 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, "ws4://:%u/test"); - So(nng_listen(s1, addr, NULL, 0) == 0); - nng_msleep(100); - // reset port back one - trantest_prev_address(addr, "ws://127.0.0.1:%u/test"); - So(nng_dial(s2, addr, NULL, 0) == 0); - }); - - Convey("Wild card hostname works", { - nng_socket s1; - nng_socket s2; - 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, "ws4://*:%u/test"); - So(nng_listen(s1, addr, NULL, 0) == 0); - nng_msleep(100); - // reset port back one - trantest_prev_address(addr, "ws://127.0.0.1:%u/test"); - So(nng_dial(s2, addr, NULL, 0) == 0); - }); - - Convey("Incorrect URL paths do not work", { - nng_socket s1; - nng_socket s2; - 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, "ws://:%u/test"); - So(nng_listen(s1, addr, NULL, 0) == 0); - // reset port back one - trantest_prev_address(addr, "ws://localhost:%u/nothere"); - So(nng_dial(s2, addr, NULL, 0) == NNG_ECONNREFUSED); - }); - - // This test covers bug 821. - Convey("Double wildcard listen works", { - nng_socket s1; - nng_socket s2; - So(nng_pair_open(&s1) == 0); - So(nng_pair_open(&s2) == 0); - Reset({ - nng_close(s1); - nng_close(s2); - }); - So(nng_listen(s1, "ws4://*:5599/one", NULL, 0) == 0); - So(nng_listen(s1, "ws4://*:5599/two", NULL, 0) == 0); - So(nng_dial(s2, "ws://127.0.0.1:5599/one", NULL, 0) == 0); - }); - - Convey("Wild card port works and can be used again", { - nng_socket s1; - nng_socket s2; - nng_listener l1; - int port; - char ws_url[128]; - So(nng_pair_open(&s1) == 0); - So(nng_pair_open(&s2) == 0); - Reset({ - nng_close(s1); - nng_close(s2); - }); - So(nng_listen(s1, "ws://*:0/one", &l1, 0) == 0); - So(nng_listener_getopt_int( - l1, NNG_OPT_TCP_BOUND_PORT, &port) == 0); - So(port != 0); - snprintf(ws_url, sizeof(ws_url), "ws://*:%d/two", port); - So(nng_listen(s2, ws_url, NULL, 0) == 0); - }); - nng_fini(); }) |
