From: Fabian Keil Date: Sat, 9 Jan 2021 18:54:09 +0000 (+0100) Subject: Add tests for destination rewrite X-Git-Url: http://www.privoxy.org/gitweb/show-status?p=privoxy.git;a=commitdiff_plain;h=3a3ae4c610365e3afe85eff96b3952a35275c187 Add tests for destination rewrite Sponsored by: Privoxy project funds collected at SPI --- diff --git a/tests/cts/rewrite-behind-client-back/data/test1 b/tests/cts/rewrite-behind-client-back/data/test1 new file mode 100644 index 00000000..dd0175bc --- /dev/null +++ b/tests/cts/rewrite-behind-client-back/data/test1 @@ -0,0 +1,45 @@ + + + +HTTP +HTTP GET + + + + + +HTTP/1.1 200 OK +Connection: close +Content-Type: text/html +Content-Length: 29 + +Not actually used. + + + + + +HTTP/1.1 400 Malformed request after rewriting +Content-Type: text/plain +Connection: close + +Bad request. Messed up with header filters. + + + + + + +none + + +Rewrite behind the client's back: invalid upgrade to https + + +http://%HOSTIP/%TESTNUMBER-upgrade-to-https + + + + + + diff --git a/tests/cts/rewrite-behind-client-back/data/test2 b/tests/cts/rewrite-behind-client-back/data/test2 new file mode 100644 index 00000000..b145d732 --- /dev/null +++ b/tests/cts/rewrite-behind-client-back/data/test2 @@ -0,0 +1,41 @@ + + + +HTTP +HTTP GET + + + + + +HTTP/1.1 200 OK +Date: Thu, 22 Jul 2010 11:22:33 GMT +Content-Length: 9 + +Blafasel + + + + + + +http + + +Rewrite path behind the client's back + + +http://%HOSTIP:%HTTPPORT/%TESTNUMBER-remove-this + + + + + +GET /%TESTNUMBER HTTP/1.1 +Host: %HOSTIP:%HTTPPORT +User-Agent: curl/%VERSION +Accept: */* + + + + diff --git a/tests/cts/rewrite-behind-client-back/data/test3 b/tests/cts/rewrite-behind-client-back/data/test3 new file mode 100644 index 00000000..61e35577 --- /dev/null +++ b/tests/cts/rewrite-behind-client-back/data/test3 @@ -0,0 +1,42 @@ + + + +HTTP +HTTP GET + + + + + +HTTP/1.1 200 OK +Date: Thu, 22 Jul 2010 11:22:33 GMT +Content-Length: 9 + +Blafasel + + + + + + +http + + +Rewrite host behind the client's back + + +http://www.example.org/%TESTNUMBER-%HOSTIP:%HTTPPORT + + + + + +GET /%TESTNUMBER HTTP/1.1 +Host: www.example.org +User-Agent: curl/%VERSION +Accept: */* +Connection: close + + + + diff --git a/tests/cts/rewrite-behind-client-back/data/test4 b/tests/cts/rewrite-behind-client-back/data/test4 new file mode 100644 index 00000000..d7c10f89 --- /dev/null +++ b/tests/cts/rewrite-behind-client-back/data/test4 @@ -0,0 +1,42 @@ + + + +HTTP +HTTP GET + + + + + +HTTP/1.1 200 OK +Date: Thu, 22 Jul 2010 11:22:33 GMT +Content-Length: 9 + +Blafasel + + + + + + +http + + +Client header filter that doesn't match anything. According to Valgrind it triggers a "Conditional jump or move depends on uninitialised value(s)" + + +http:///%HOSTIP:%HTTPPORT/%TESTNUMBER + + + + + +GET /%TESTNUMBER HTTP/1.1 +Host: %HOSTIP:%HTTPPORT +User-Agent: curl/%VERSION +Accept: */* +Connection: close + + + + diff --git a/tests/cts/rewrite-behind-client-back/data/test5 b/tests/cts/rewrite-behind-client-back/data/test5 new file mode 100644 index 00000000..82da79df --- /dev/null +++ b/tests/cts/rewrite-behind-client-back/data/test5 @@ -0,0 +1,44 @@ + + + +HTTP +HTTP GET + + + + + +HTTP/1.1 200 OK +Connection: close +Content-Type: text/html +Content-Length: 29 + +Not actually used. + + + + + +HTTP/1.1 400 Malformed request after rewriting +Content-Type: text/plain +Connection: close + +Bad request. Messed up with header filters. + + + + + +none + + +Rewrite behind the client's back: unsupported http version + + +http://%HOSTIP/%TESTNUMBER + + + + + + diff --git a/tests/cts/rewrite-behind-client-back/privoxy.conf b/tests/cts/rewrite-behind-client-back/privoxy.conf new file mode 100644 index 00000000..06304307 --- /dev/null +++ b/tests/cts/rewrite-behind-client-back/privoxy.conf @@ -0,0 +1,17 @@ +listen-address 127.0.0.1:9119 + +debug 1 # Log the destination for each request Privoxy let through. See also debug 1024. +debug 2 # show each connection status +debug 4 # show tagging-related messages +debug 8 # show header parsing +debug 32 # debug force feature +debug 64 # debug regular expression filters +debug 128 # debug redirects +debug 256 # debug GIF de-animation +debug 512 # Common Log Format +debug 1024 # Log the destination for requests Privoxy didn't let through, and the reason why. +debug 4096 # Startup banner and warnings. +debug 8192 # Non-fatal errors + +actionsfile rewrites.action +filterfile rewrites.filter diff --git a/tests/cts/rewrite-behind-client-back/rewrites.action b/tests/cts/rewrite-behind-client-back/rewrites.action new file mode 100644 index 00000000..78d3b5f5 --- /dev/null +++ b/tests/cts/rewrite-behind-client-back/rewrites.action @@ -0,0 +1,14 @@ +{+client-header-filter{http-to-https}} +/1-upgrade-to-https + +{+client-header-filter{truncate-path}} +/2-remove-this + +{+client-header-filter{rewrite-host}} +/3 + +{+client-header-filter{non-matching-rewriter}} +/4 + +{+client-header-filter{invalid-http-version}} +/5 diff --git a/tests/cts/rewrite-behind-client-back/rewrites.filter b/tests/cts/rewrite-behind-client-back/rewrites.filter new file mode 100644 index 00000000..30f59de3 --- /dev/null +++ b/tests/cts/rewrite-behind-client-back/rewrites.filter @@ -0,0 +1,16 @@ +CLIENT-HEADER-FILTER: http-to-https Upgrade http requests to https behind the client's back. Not actually supported. +s@^(\w+)\s+http://@$1 https://@i + +CLIENT-HEADER-FILTER: truncate-path Removes '-remove-this' from the path +s@(/\d)-remove-this (HTTP/1.1)@$1 $2@i + +CLIENT-HEADER-FILTER: rewrite-host Replaces the host with the one specified in the path +s@GET .*/(\d)-(\d+\.\d+\.\d+\.\d+\:\d+) (HTTP/1.1)@GET http://$2/$1 $3@i + +# Results in Conditional jump or move depends on uninitialised value(s)? +CLIENT-HEADER-FILTER: non-matching-rewriter Does not actually match +s@/-@@ + +CLIENT-HEADER-FILTER: invalid-http-version Rewrites the request line with an invalid HTTP version +s@HTTP/1.1@HTTP/9000@ +