#include #include #include #include #include #include #include #include #include #include "config.h" #include "libreichwein/file.h" using namespace std::string_literals; namespace fs = std::filesystem; const fs::path testConfigFilename{"test-webserver.conf"}; class ConfigFixture { public: ConfigFixture(){} ~ConfigFixture(){} void setup() { } void teardown() { std::error_code ec; fs::remove(testConfigFilename); fs::remove("stats.db"); } }; BOOST_FIXTURE_TEST_CASE(config, ConfigFixture) { Reichwein::File::setFile(testConfigFilename, R"CONFIG( user1 www-data 10 stats.db plugins antcom.de lists.antcom.de antcom.de www.antcom.de ip6-localhost 127.0.0.1 [::1] reichwein.mooo.com [2001:a61:410:c001:5e51:4fff:fea2:ec7f] static-files /home/ernie/homepage/test webbox /home/ernie/testbox Testbox1 0 /home/ernie/code/webserver/plugins/webbox/html webbox /home/ernie/testbox Testbox1 1 /home/ernie/code/webserver/plugins/webbox/html statistics cgi /home/ernie/code/webserver/cgi-bin fcgi 127.0.0.1:9000 fcgi /home/ernie/code/webserver/fastcgi/socket fcgi /run/php/php-fpm.sock fcgi 127.0.0.1:9001 fcgi 127.0.0.1:9002 fcgi 127.0.0.1:9003 static-files /home/ernie/code/webshop/html static-files /home/ernie/code/downtube/html fcgi 127.0.0.1:9004 static-files /home/ernie/code/whiteboard/html fcgi 127.0.0.1:9014 redirect https://www.antcom.de/ 301 Redirecting to antcom.de ... /home/ernie/code/webserver/fullchain.pem /home/ernie/code/webserver/privkey.pem marx marx.antcom.de marx1.antcom.de localhost static-files /home/ernie/homepage/test1 cgi /home/ernie/code/webserver/cgi-bin cgi /usr/lib/cgit/cgit.cgi static-files /usr/share/cgit /home/ernie/code/webserver/cert.pem /home/ernie/code/webserver/key.pem
127.0.0.1
8080 http antcom.de marx
2001:a61:410:c001:5e51:4fff:fea2:ec7f
80 http antcom.de
::1
8080 http
127.0.0.1
8081 https
::1
8081 https
127.0.0.1
443 https
)CONFIG"); Config config{testConfigFilename}; BOOST_CHECK_EQUAL(config.User(), "user1"); BOOST_CHECK_EQUAL(config.Group(), "www-data"); BOOST_CHECK_EQUAL(config.Threads(), 10); auto pd{config.PluginDirectories()}; BOOST_CHECK_EQUAL(pd.size(), 1); BOOST_CHECK_EQUAL(pd[0], "plugins"); auto sites{config.Sites()}; BOOST_CHECK_EQUAL(sites.size(), 2); auto sockets{config.Sockets()}; BOOST_CHECK_EQUAL(sockets.size(), 4); // 2 privileged ports skipped const Path& p {config.GetPath(sockets[0], "antcom.de", "/webbox1/path1/abc.txt")}; BOOST_CHECK_EQUAL(p.requested, "/webbox1"); BOOST_CHECK_EQUAL(config.PluginIsConfigured("webbox"), true); BOOST_CHECK_EQUAL(config.PluginIsConfigured("webmux"), false); (void)config.dump(); }