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 --- TODO | 3 +-- debian/webserver.docs | 2 +- debian/webserver.example-websocket.conf | 26 ++++++++++++++++++++++++++ tests/test-webserver.cpp | 17 ++++++++++++++++- 4 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 debian/webserver.example-websocket.conf diff --git a/TODO b/TODO index ce61789..6a8294f 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,7 @@ example conf files: -- websockets - php +- fcgi test: -- bad config - FCGI Big file bug - dynamic plugin interface (file buffer, ...) diff --git a/debian/webserver.docs b/debian/webserver.docs index 0b7c406..ea758e8 100644 --- a/debian/webserver.docs +++ b/debian/webserver.docs @@ -1,2 +1,2 @@ README.txt -webserver.example-cgi.conf +debian/webserver.example-*.conf diff --git a/debian/webserver.example-websocket.conf b/debian/webserver.example-websocket.conf new file mode 100644 index 0000000..06d8676 --- /dev/null +++ b/debian/webserver.example-websocket.conf @@ -0,0 +1,26 @@ + + www-data + www-data + 10 + /var/lib/webserver/stats.db + /usr/lib/webserver/plugins + + + localhost + localhost + [::1] + + websocket + ::1:8765 + + + + + +
::1
+ 8080 + http + localhost +
+
+
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