mirror of
https://github.com/lammertb/libhttp.git
synced 2025-12-22 04:02:04 +03:00
Add unit tests for SSL redirects
This commit is contained in:
@@ -32,6 +32,8 @@ addons:
|
||||
apt:
|
||||
packages:
|
||||
- cmake
|
||||
- openssl
|
||||
- libssl-dev
|
||||
sources:
|
||||
- kubuntu-backports
|
||||
|
||||
@@ -48,8 +50,7 @@ install:
|
||||
before_script:
|
||||
# Generate the build scripts with CMake
|
||||
- pwd
|
||||
- ldd crypto
|
||||
- ldd ssl
|
||||
- ls -l
|
||||
- mkdir output
|
||||
- cd output
|
||||
- cmake --version
|
||||
|
||||
@@ -535,6 +535,7 @@ START_TEST(test_request_handlers)
|
||||
short ipv4r_port = 8194;
|
||||
short ipv6_port = 8086;
|
||||
short ipv6s_port = 8096;
|
||||
short ipv6r_port = 8196;
|
||||
#elif !defined(USE_IPV6) && !defined(NO_SSL)
|
||||
const char *HTTP_PORT = "8084,8194r,8094s";
|
||||
short ipv4_port = 8084;
|
||||
@@ -639,7 +640,7 @@ START_TEST(test_request_handlers)
|
||||
|
||||
|
||||
#if defined(USE_IPV6)
|
||||
/* Get data from callback using [::1] */
|
||||
/* Get data from callback using http://[::1] */
|
||||
conn =
|
||||
mg_download("[::1]", ipv6_port, 0, ebuf, sizeof(ebuf), "%s", request);
|
||||
ck_assert(conn != NULL);
|
||||
@@ -654,6 +655,7 @@ START_TEST(test_request_handlers)
|
||||
mg_close_connection(conn);
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(NO_SSL)
|
||||
/* Get data from callback using https://127.0.0.1 */
|
||||
conn = mg_download(
|
||||
@@ -668,6 +670,47 @@ START_TEST(test_request_handlers)
|
||||
buf[i] = 0;
|
||||
ck_assert_str_eq(buf, expected);
|
||||
mg_close_connection(conn);
|
||||
|
||||
/* Get redirect from callback using http://127.0.0.1 */
|
||||
conn = mg_download(
|
||||
"127.0.0.1", ipv4r_port, 0, ebuf, sizeof(ebuf), "%s", request);
|
||||
ck_assert(conn != NULL);
|
||||
ri = mg_get_request_info(conn);
|
||||
|
||||
ck_assert(ri != NULL);
|
||||
ck_assert_str_eq(ri->uri, "302");
|
||||
i = mg_read(conn, buf, sizeof(buf));
|
||||
ck_assert_int_eq(i, -1);
|
||||
mg_close_connection(conn);
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(USE_IPV6) && !defined(NO_SSL)
|
||||
/* Get data from callback using https://[::1] */
|
||||
conn =
|
||||
mg_download("[::1]", ipv6s_port, 1, ebuf, sizeof(ebuf), "%s", request);
|
||||
ck_assert(conn != NULL);
|
||||
ri = mg_get_request_info(conn);
|
||||
|
||||
ck_assert(ri != NULL);
|
||||
ck_assert_str_eq(ri->uri, "200");
|
||||
i = mg_read(conn, buf, sizeof(buf));
|
||||
ck_assert_int_eq(i, strlen(expected));
|
||||
buf[i] = 0;
|
||||
ck_assert_str_eq(buf, expected);
|
||||
mg_close_connection(conn);
|
||||
|
||||
/* Get redirect from callback using http://127.0.0.1 */
|
||||
conn =
|
||||
mg_download("[::1]", ipv6r_port, 0, ebuf, sizeof(ebuf), "%s", request);
|
||||
ck_assert(conn != NULL);
|
||||
ri = mg_get_request_info(conn);
|
||||
|
||||
ck_assert(ri != NULL);
|
||||
ck_assert_str_eq(ri->uri, "302");
|
||||
i = mg_read(conn, buf, sizeof(buf));
|
||||
ck_assert_int_eq(i, -1);
|
||||
mg_close_connection(conn);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user