X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=src%2Ftest_filter_rewrite.cpp;h=374950975b1354882aed8fd423324e613a49a2f0;hb=9c5a788489d7fc2bb6796b87ffe6d631f5ef0c90;hp=68b63f71c40c32224a1464795c1fb27ab3010e38;hpb=2b862fc3e525e3d53854e9825ae2e22683e8a03c;p=metaproxy-moved-to-github.git diff --git a/src/test_filter_rewrite.cpp b/src/test_filter_rewrite.cpp index 68b63f7..3749509 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 @@ -38,20 +38,23 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA using namespace boost::unit_test; namespace mp = metaproxy_1; - +/* + * The global testconfig is commented out, as it won't even compile + * on old Centos5 machines struct TestConfig { - TestConfig() + TestConfig() { - std::cout << "global setup\n"; + std::cout << "global setup\n"; yaz_log_init_level(YLOG_ALL); } - ~TestConfig() - { - std::cout << "global teardown\n"; + ~TestConfig() + { + std::cout << "global teardown\n"; } }; BOOST_GLOBAL_FIXTURE( TestConfig ); +*/ BOOST_AUTO_TEST_CASE( test_filter_rewrite_1 ) { @@ -60,154 +63,38 @@ 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); - - router.append(fhr); - - // create an http request - mp::Package pack; - - mp::odr odr; - Z_GDU *gdu_req = z_get_HTTP_Request_uri(odr, - "http://proxyhost/proxypath/targetsite/page1.html", 0, 1); - - pack.request() = gdu_req; - - //create the http response - - /* response, content */ - const char *resp_buf = - /*123456789012345678 */ - "HTTP/1.1 200 OK\r\n" - "Content-Length: 3000\r\n" - "Content-Type: text/html\r\n" - "Link: ; rel=absolute\r\r" - "Link: ; rel=relative\r\r" - "\r\n" - "Hello proxy!" - "" - "" - "" - "" - "

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

Welcome to our website. It doesn't make it easy to get pro" - "xified" - "" - " An absolute link" - "\n" "\n" - " \n" - " https?://)(?<pxhost>[^ /?#]+)/(?<pxpath>[^ /]+)" "/(?<host>[^ /]+)(?<path>[^ ]*)'\n" " to='${proto}${host}${path}' />\n" - " \n" + " \n" + " \n" + " \n" + " \n" " \n" - " \n" - " \n" + " \n" + " \n" + " to='${proto}${pxhost}/${pxpath}/${host}/${path}' />\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" " \n" "\n" ; @@ -220,28 +107,26 @@ BOOST_AUTO_TEST_CASE( test_filter_rewrite_2 ) xmlNode *root_element = xmlDocGetRootElement(doc); fhr.configure(root_element, true, ""); xmlFreeDoc(doc); - + router.append(fhr); // create an http request mp::Package pack; mp::odr odr; - Z_GDU *gdu_req = z_get_HTTP_Request_uri(odr, + Z_GDU *gdu_req = z_get_HTTP_Request_uri(odr, "http://proxyhost/proxypath/targetsite/page1.html", 0, 1); pack.request() = gdu_req; //create the http response - /* response, content */ const char *resp_buf = - /*123456789012345678 */ "HTTP/1.1 200 OK\r\n" - "Content-Length: 3000\r\n" + "Content-Length: 441\r\n" "Content-Type: text/html\r\n" - "Link: ; rel=absolute\r\r" - "Link: ; rel=relative\r\r" + "Link: ; rel=absolute\r\n" + "Link: ; rel=relative\r\n" "\r\n" "Hello proxy!" "" "" - "" + "" "" "

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