From 3b42785c57768e619ade198f7b4760e16288e0f3 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sat, 14 Jan 2023 11:12:21 +0100 Subject: Added config tests, moved from BSD license to CC0 --- tests/test-webserver.cpp | 118 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 115 insertions(+), 3 deletions(-) (limited to 'tests/test-webserver.cpp') diff --git a/tests/test-webserver.cpp b/tests/test-webserver.cpp index 5353c6a..72f2ab2 100644 --- a/tests/test-webserver.cpp +++ b/tests/test-webserver.cpp @@ -532,14 +532,14 @@ 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) +BOOST_FIXTURE_TEST_CASE(config_empty, Fixture) { - WebserverProcess serverProcess{""}; + WebserverProcess serverProcess{std::string{}}; std::this_thread::sleep_for(std::chrono::milliseconds(50)); BOOST_REQUIRE_EQUAL(serverProcess.is_running(), false); } -BOOST_FIXTURE_TEST_CASE(incomplete_config, Fixture) +BOOST_FIXTURE_TEST_CASE(config_incomplete, Fixture) { std::string webserver_config{R"CONFIG( www-data @@ -550,6 +550,118 @@ BOOST_FIXTURE_TEST_CASE(incomplete_config, Fixture) BOOST_REQUIRE_EQUAL(serverProcess.is_running(), false); } +BOOST_FIXTURE_TEST_CASE(config_bad_syntax, Fixture) +{ + std::string config{R"CONFIG( + www-data + www-data + 10 + stats.db + ../plugins + + + localhost + ip6-localhost + localhost + 127.0.0.1 + [::1] + + static-files + . + + testchain.pem + testkey.pem + + + + +
127.0.0.1
+ 8080 + http + localhost +
+ +
::1
+ 8080 + http + localhost +
+ +
127.0.0.1
+ 8081 + https + localhost +
+ +
::1
+ 8081 + https + localhost + +
+
+)CONFIG"}; + WebserverProcess serverProcess{config, false}; + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + BOOST_REQUIRE_EQUAL(serverProcess.is_running(), false); +} + +BOOST_FIXTURE_TEST_CASE(config_bad_socket, Fixture) +{ + std::string config{R"CONFIG( + www-data + www-data + 10 + stats.db + ../plugins + + + localhost + ip6-localhost + localhost + 127.0.0.1 + [::1] + + static-files + . + + testchain.pem + testkey.pem + + + + +
127.0.0.1
+ 8080 + http + localhost +
+ +
::1
+ 8080 + http + localhost +
+ +
127.0.0.1
+ 8081 + https + localhost +
+ +
1234:5678::1
+ 8081 + https + localhost +
+
+
+)CONFIG"}; + WebserverProcess serverProcess{config, false}; + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + BOOST_REQUIRE_EQUAL(serverProcess.is_running(), false); +} + BOOST_FIXTURE_TEST_CASE(http_redirect, Fixture) { std::string webserver_config{R"CONFIG( -- cgit v1.2.3