From 2a55e0a279a0b94e204e0ffead73505100a0481f Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Mon, 9 Nov 2020 22:27:43 -0800 Subject: 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. --- tests/testutil.h | 1 + tests/ws.c | 91 -------------------------------------------------------- 2 files changed, 1 insertion(+), 91 deletions(-) (limited to 'tests') 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 +#include #ifdef __cplusplus extern "C" { diff --git a/tests/ws.c b/tests/ws.c index 4e12a788..70d2e8da 100644 --- a/tests/ws.c +++ b/tests/ws.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(); }) -- cgit v1.2.3-70-g09d2