From 49579eb2b48ba0dbac2f8c8ddce38199f9d8b384 Mon Sep 17 00:00:00 2001 From: "Sergio R. Caprile" Date: Fri, 31 Mar 2023 17:00:05 -0300 Subject: [PATCH] Test host only TLS mode --- test/unit_test.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/test/unit_test.c b/test/unit_test.c index 7d31a53f..92ef0e6c 100644 --- a/test/unit_test.c +++ b/test/unit_test.c @@ -369,7 +369,7 @@ static void mqtt_cb(struct mg_connection *c, int ev, void *evd, void *fnd) { } static void test_mqtt_base(void); -static void test_mqtt_base() { +static void test_mqtt_base(void) { char buf[50] = {0}; struct mqtt_data test_data = {buf, 50, 0, 0}; struct mg_mgr mgr; @@ -1030,6 +1030,18 @@ static void test_http_client(void) { for (i = 0; i < 500 && ok <= 0; i++) mg_mgr_poll(&mgr, 10); ASSERT(ok == 777); mg_mgr_poll(&mgr, 1); + + // Test host validation only (no CA, no cert) + ok = 0; + opts.srvname = host; + opts.ca = NULL; + c = mg_http_connect(&mgr, url, f3, &ok); + ASSERT(c != NULL); + mg_tls_init(c, &opts); + for (i = 0; i < 1500 && ok <= 0; i++) mg_mgr_poll(&mgr, 10); + ASSERT(ok == 200); + c->is_closing = 1; + mg_mgr_poll(&mgr, 1); } #endif