summaryrefslogtreecommitdiffhomepage
path: root/tests/test-webserver.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2023-01-04 20:08:12 +0100
committerRoland Reichwein <mail@reichwein.it>2023-01-04 20:08:12 +0100
commit8475a181be2301702c409a20dc99115ee54ec9cc (patch)
tree6b87fd4eb6bb3d746872087aad14498dda13f715 /tests/test-webserver.cpp
parentfb7219b2f8553cebc9871427fed134ad4b162bac (diff)
Added test for HTTP 404
Diffstat (limited to 'tests/test-webserver.cpp')
-rw-r--r--tests/test-webserver.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/tests/test-webserver.cpp b/tests/test-webserver.cpp
index aa09a01..de38cf3 100644
--- a/tests/test-webserver.cpp
+++ b/tests/test-webserver.cpp
@@ -360,16 +360,30 @@ public:
~Fixture(){}
};
-BOOST_DATA_TEST_CASE_F(Fixture, http_download, data::make({false, true}) * data::make({false, true}) * data::make({false, true}), ipv6, http11, https)
+BOOST_DATA_TEST_CASE_F(Fixture, http_get, data::make({false, true}) * data::make({false, true}) * data::make({false, true}), ipv6, http11, https)
{
WebserverProcess serverProcess;
BOOST_REQUIRE(serverProcess.isRunning());
auto response{(https ? HTTPSGet("/webserver.conf") : HTTPGet("/webserver.conf"))};
BOOST_REQUIRE(serverProcess.isRunning());
- BOOST_REQUIRE_EQUAL(response.first, "HTTP/1.1 200 OK\r\nServer: Reichwein.IT Webserver 1.17\r\nContent-Type: application/text\r\nContent-Length: 1021\r\n\r\n");
+ BOOST_REQUIRE_EQUAL(response.first, "HTTP/1.1 200 OK\r\nServer: Reichwein.IT Webserver " VERSION "\r\nContent-Type: application/text\r\nContent-Length: 1021\r\n\r\n");
BOOST_REQUIRE_EQUAL(response.second, File::getFile(serverProcess.testConfigFilename));
auto output{serverProcess.output()};
BOOST_REQUIRE_MESSAGE(boost::algorithm::contains(output, "Serving"), "Bad output: "s + output);
}
+BOOST_DATA_TEST_CASE_F(Fixture, http_get_file_not_found, data::make({false, true}) * data::make({false, true}) * data::make({false, true}), ipv6, http11, https)
+{
+ WebserverProcess serverProcess;
+
+ BOOST_REQUIRE(serverProcess.isRunning());
+ BOOST_REQUIRE(!fs::exists("./webserver.confSUFFIX"));
+ auto response{(https ? HTTPSGet("/webserver.confSUFFIX") : HTTPGet("/webserver.confSUFFIX"))};
+ BOOST_REQUIRE(serverProcess.isRunning());
+ BOOST_REQUIRE_EQUAL(response.first, "HTTP/1.1 404 Not Found\r\nServer: Reichwein.IT Webserver " VERSION "\r\nContent-Type: text/html\r\nContent-Length: 36\r\n\r\n");
+ BOOST_REQUIRE_EQUAL(response.second, "404 Not found: /webserver.confSUFFIX");
+ auto output{serverProcess.output()};
+ BOOST_REQUIRE_MESSAGE(boost::algorithm::contains(output, "Serving"), "Bad output: "s + output);
+}
+