X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=src%2Ftest_filter_rewrite.cpp;h=cb9c47ce1f4d9ca3d8134dc8f03f454919129bef;hb=fe8ab21a7dfdd452298ec356395b2956c25d18fa;hp=8e539813334415941ba2a62484662dfca5419587;hpb=fc60434912ceab56484a525b650089310526746f;p=metaproxy-moved-to-github.git diff --git a/src/test_filter_rewrite.cpp b/src/test_filter_rewrite.cpp index 8e53981..cb9c47c 100644 --- a/src/test_filter_rewrite.cpp +++ b/src/test_filter_rewrite.cpp @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "filter_http_client.hpp" #include "filter_http_rewrite.hpp" #include -#include "router_chain.hpp" +#include #include #include @@ -60,27 +60,36 @@ BOOST_AUTO_TEST_CASE( test_filter_rewrite_1 ) std::cout << "Running non-xml config test case" << std::endl; mp::RouterChain router; mp::filter::HttpRewrite fhr; - - //configure the filter - mp::filter::HttpRewrite::spair_vec vec_req; - vec_req.push_back(std::make_pair( - "(?http\\:\\/\\/s?)(?[^\\/?#]+)\\/(?[^\\/]+)" - "\\/(?[^\\/]+)(?.*)", - "${proto}${host}${path}" - )); - vec_req.push_back(std::make_pair( - "(?:Host\\: )(.*)", - "Host: ${host}" - )); - - mp::filter::HttpRewrite::spair_vec vec_res; - vec_res.push_back(std::make_pair( - "(?http\\:\\/\\/s?)(?[^\\/?# \"'>]+)\\/(?[^ \"'>]+)", - "${proto}${pxhost}/${pxpath}/${host}/${path}" - )); - - fhr.configure(vec_req, vec_res); - + + std::string xmlconf = + "\n" + "\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + "\n" + ; + + std::cout << xmlconf; + + // reading and parsing XML conf + xmlDocPtr doc = xmlParseMemory(xmlconf.c_str(), xmlconf.size()); + BOOST_CHECK(doc); + xmlNode *root_element = xmlDocGetRootElement(doc); + fhr.configure(root_element, true, ""); + xmlFreeDoc(doc); + router.append(fhr); // create an http request @@ -94,11 +103,9 @@ BOOST_AUTO_TEST_CASE( test_filter_rewrite_1 ) //create the http response - /* response, content */ const char *resp_buf = - /*123456789012345678 */ "HTTP/1.1 200 OK\r\n" - "Content-Length: 50\r\n" + "Content-Length: 441\r\n" "Content-Type: text/html\r\n" "Link: ; rel=absolute\r\n" "Link: ; rel=relative\r\n" @@ -121,11 +128,9 @@ BOOST_AUTO_TEST_CASE( test_filter_rewrite_1 ) "" ""; - /* response, content */ - const char *resp_result = - /*123456789012345678 */ + const char *resp_expected = "HTTP/1.1 200 OK\r\n" - "Content-Length: 50\r\n" + "Content-Length: 521\r\n" "Content-Type: text/html\r\n" "Link: ; rel=absolute\r\n" "Link: ; rel=relative\r\n" @@ -141,11 +146,11 @@ BOOST_AUTO_TEST_CASE( test_filter_rewrite_1 ) "" "

Welcome to our website. It doesn't make it easy to get pro" "xified" - "" + "" " An absolute link" "