]>
git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/test-webserver_cc.cc
1 #ifndef BOOST_TEST_DYN_LINK
2 #define BOOST_TEST_DYN_LINK
5 #define BOOST_TEST_NO_MAIN
7 #include <boost/test/unit_test.hpp>
8 #include "webserver.hh"
10 BOOST_AUTO_TEST_SUITE(test_webserver_cc
)
12 BOOST_AUTO_TEST_CASE(test_validURL
)
14 // We cannot test\x00 as embedded NULs are not handled by YaHTTP other than stopping the parsing
15 const std::vector
<std::pair
<string
, bool>> urls
= {
16 {"http://www.powerdns.com/?foo=123", true},
17 {"http://ww.powerdns.com/?foo=%ff", true},
18 {"http://\x01ww.powerdns.com/?foo=123", false},
19 {"http://\xffwww.powerdns.com/?foo=123", false},
20 {"http://www.powerdns.com/?foo=123\x01", false},
21 {"http://www.powerdns.com/\x7f?foo=123", false},
22 {"http://www.powerdns.com/\x80?foo=123", false},
23 {"http://www.powerdns.com/?\xff", false},
24 {"/?foo=123&bar", true},
25 {"/?foo=%ff&bar", true},
26 {"/?\x01foo=123", false},
27 {"/?foo=123\x01", false},
28 {"/\x7f?foo=123", false},
29 {"/\x80?foo=123", false},
33 for (const auto& testcase
: urls
) {
34 BOOST_CHECK_EQUAL(WebServer::validURL(testcase
.first
), testcase
.second
);
38 BOOST_AUTO_TEST_SUITE_END();