]>
Commit | Line | Data |
---|---|---|
1c2d079d | 1 | #ifndef BOOST_TEST_DYN_LINK |
35eb2fcf | 2 | #define BOOST_TEST_DYN_LINK |
1c2d079d FM |
3 | #endif |
4 | ||
35eb2fcf OM |
5 | #define BOOST_TEST_NO_MAIN |
6 | ||
7 | #include <boost/test/unit_test.hpp> | |
8 | #include "webserver.hh" | |
9 | ||
10 | BOOST_AUTO_TEST_SUITE(test_webserver_cc) | |
11 | ||
12 | BOOST_AUTO_TEST_CASE(test_validURL) | |
13 | { | |
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}, | |
7ab40a80 OM |
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}, | |
30 | {"/?\xff", false}, | |
35eb2fcf OM |
31 | }; |
32 | ||
33 | for (const auto& testcase : urls) { | |
35eb2fcf OM |
34 | BOOST_CHECK_EQUAL(WebServer::validURL(testcase.first), testcase.second); |
35 | } | |
36 | } | |
37 | ||
38 | BOOST_AUTO_TEST_SUITE_END(); |