From d1ecca18d97238aa6312c85521f1a4874699f1c4 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Wed, 11 Jan 2023 16:04:05 +0100 Subject: Added tests, example configuration --- tests/test-webserver.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test-webserver.cpp b/tests/test-webserver.cpp index f23b8cd..e9e6df5 100644 --- a/tests/test-webserver.cpp +++ b/tests/test-webserver.cpp @@ -441,7 +441,7 @@ BOOST_DATA_TEST_CASE_F(Fixture, http_get_file_not_found, data::make({false, true BOOST_REQUIRE(!fs::exists("./webserver.confSUFFIX")); auto response{(https ? HTTPS("/webserver.confSUFFIX", ipv6, http11, method) : HTTP("/webserver.confSUFFIX", ipv6, http11, method))}; BOOST_REQUIRE(serverProcess.is_running()); - BOOST_REQUIRE_EQUAL(response.first, fmt::format("HTTP/{} 404 Not Found\r\nServer: Reichwein.IT Webserver " VERSION "\r\nContent-Type: text/html\r\nContent-Length: {}\r\n\r\n", http11 ? "1.1" : "1.0", method == boost::beast::http::verb::head ? 0 : 36)); + BOOST_REQUIRE_EQUAL(response.first, fmt::format("HTTP/{} 404 Not Found\r\nServer: Reichwein.IT Webserver " VERSION "\r\nContent-Type: text/plain\r\nContent-Length: {}\r\n\r\n", http11 ? "1.1" : "1.0", method == boost::beast::http::verb::head ? 0 : 36)); BOOST_REQUIRE_EQUAL(response.second, method == boost::beast::http::verb::head ? "" : "404 Not found: /webserver.confSUFFIX"); } @@ -1050,3 +1050,18 @@ echo -ne "HTTP_HOST: $HTTP_HOST\r\n" BOOST_CHECK_EQUAL(result.second, "500 Bad Script: test2.sh/path1"); } +BOOST_FIXTURE_TEST_CASE(empty_config, Fixture) +{ + WebserverProcess serverProcess{""}; + BOOST_REQUIRE_EQUAL(serverProcess.is_running(), false); +} + +BOOST_FIXTURE_TEST_CASE(incomplete_config, Fixture) +{ + std::string webserver_config{R"CONFIG( + www-data + www-data +)CONFIG"}; + WebserverProcess serverProcess{webserver_config}; + BOOST_REQUIRE_EQUAL(serverProcess.is_running(), false); +} -- cgit v1.2.3