diff options
Diffstat (limited to 'tests/test-webserver.cpp')
-rw-r--r-- | tests/test-webserver.cpp | 118 |
1 files changed, 115 insertions, 3 deletions
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(<webserver> <user>www-data</user> @@ -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(<webserver> + <user>www-data</user> + <group>www-data</group> + <threads>10</threads> + <statisticspath>stats.db</statisticspath> + <plugin-directory>../plugins</plugin-directory> + <sites> + <site> + <name>localhost</name> + <host>ip6-localhost</host> + <host>localhost</host> + <host>127.0.0.1</host> + <host>[::1]</host> + <path requested="/"> + <plugin>static-files</plugin> + <target>.</target> + </path> + <certpath>testchain.pem</certpath> + <keypath>testkey.pem</keypath> + </site> + </sites> + <sockets> + <socket> + <address>127.0.0.1</address> + <port>8080</port> + <protocol>http</protocol> + <site>localhost</site> + </socket> + <socket> + <address>::1</address> + <port>8080</port> + <protocol>http</protocol> + <site>localhost</site> + </socket> + <socket> + <address>127.0.0.1</address> + <port>8081</port> + <protocol>https</protocol> + <site>localhost</site> + </socket> + <socket> + <address>::1</address> + <port>8081</port> + <protocol>https</protocol> + <site>localhost</site> + <!-- </socket> --> + </sockets> +</webserver> +)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(<webserver> + <user>www-data</user> + <group>www-data</group> + <threads>10</threads> + <statisticspath>stats.db</statisticspath> + <plugin-directory>../plugins</plugin-directory> + <sites> + <site> + <name>localhost</name> + <host>ip6-localhost</host> + <host>localhost</host> + <host>127.0.0.1</host> + <host>[::1]</host> + <path requested="/"> + <plugin>static-files</plugin> + <target>.</target> + </path> + <certpath>testchain.pem</certpath> + <keypath>testkey.pem</keypath> + </site> + </sites> + <sockets> + <socket> + <address>127.0.0.1</address> + <port>8080</port> + <protocol>http</protocol> + <site>localhost</site> + </socket> + <socket> + <address>::1</address> + <port>8080</port> + <protocol>http</protocol> + <site>localhost</site> + </socket> + <socket> + <address>127.0.0.1</address> + <port>8081</port> + <protocol>https</protocol> + <site>localhost</site> + </socket> + <socket> + <address>1234:5678::1</address> + <port>8081</port> + <protocol>https</protocol> + <site>localhost</site> + </socket> + </sockets> +</webserver> +)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(<webserver> |