From 93e53c91f741d2393a12ba043366ac6f55f56cc7 Mon Sep 17 00:00:00 2001 From: yhirose Date: Sat, 10 Dec 2022 11:45:56 -0500 Subject: [PATCH] Updated unit test --- test/test.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/test.cc b/test/test.cc index 32eb127..23a6956 100644 --- a/test/test.cc +++ b/test/test.cc @@ -1325,7 +1325,12 @@ TEST(NoContentTest, ContentLength) { } TEST(RoutingHandlerTest, PreRoutingHandler) { +#ifdef CPPHTTPLIB_OPENSSL_SUPPORT + SSLServer svr(SERVER_CERT_FILE, SERVER_PRIVATE_KEY_FILE); + ASSERT_TRUE(svr.is_valid()); +#else Server svr; +#endif svr.set_pre_routing_handler([](const Request &req, Response &res) { if (req.path == "/routing_handler") { @@ -1356,7 +1361,12 @@ TEST(RoutingHandlerTest, PreRoutingHandler) { std::this_thread::sleep_for(std::chrono::seconds(1)); { +#ifdef CPPHTTPLIB_OPENSSL_SUPPORT + SSLClient cli(HOST, PORT); + cli.enable_server_certificate_verification(false); +#else Client cli(HOST, PORT); +#endif auto res = cli.Get("/routing_handler"); ASSERT_TRUE(res); @@ -1369,7 +1379,12 @@ TEST(RoutingHandlerTest, PreRoutingHandler) { } { +#ifdef CPPHTTPLIB_OPENSSL_SUPPORT + SSLClient cli(HOST, PORT); + cli.enable_server_certificate_verification(false); +#else Client cli(HOST, PORT); +#endif auto res = cli.Get("/hi"); ASSERT_TRUE(res); @@ -1380,7 +1395,12 @@ TEST(RoutingHandlerTest, PreRoutingHandler) { } { +#ifdef CPPHTTPLIB_OPENSSL_SUPPORT + SSLClient cli(HOST, PORT); + cli.enable_server_certificate_verification(false); +#else Client cli(HOST, PORT); +#endif auto res = cli.Get("/aaa"); ASSERT_TRUE(res);