Add test scenario header-filters
authorFabian Keil <fk@fabiankeil.de>
Fri, 22 Jan 2021 15:32:10 +0000 (16:32 +0100)
committerFabian Keil <fk@fabiankeil.de>
Wed, 20 Mar 2024 11:38:39 +0000 (12:38 +0100)
Sponsored by: Privoxy project funds collected at SPI

tests/cts/header-filters/data/test1 [new file with mode: 0644]
tests/cts/header-filters/data/test2 [new file with mode: 0644]
tests/cts/header-filters/data/test3 [new file with mode: 0644]
tests/cts/header-filters/data/test4 [new file with mode: 0644]
tests/cts/header-filters/data/test5 [new file with mode: 0644]
tests/cts/header-filters/data/test6 [new file with mode: 0644]
tests/cts/header-filters/data/test7 [new file with mode: 0644]
tests/cts/header-filters/header-filters.action [new file with mode: 0644]
tests/cts/header-filters/privoxy.conf [new file with mode: 0644]

diff --git a/tests/cts/header-filters/data/test1 b/tests/cts/header-filters/data/test1
new file mode 100644 (file)
index 0000000..763ea61
--- /dev/null
@@ -0,0 +1,59 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP GET
+server-header-filter x-httpd-php-to-html
+</keywords>
+</info>
+
+<reply>
+<data>
+HTTP/1.1 200 OK\r
+Date: Thu, 22 Jul 2010 11:22:33 GMT\r
+Connection: close\r
+Content-Type: application/x-httpd-php\r
+X-Control: swsclose\r
+Content-Length: 0\r
+\r
+</data>
+</reply>
+
+<proxy-reply>
+<data>
+HTTP/1.1 200 OK\r
+Date: Thu, 22 Jul 2010 11:22:33 GMT\r
+Connection: close\r
+Content-Type: text/html\r
+X-Control: swsclose\r
+Content-Length: 0\r
+\r
+</data>
+</proxy-reply>
+
+<client>
+<server>
+http
+</server>
+<name>
++server-header-filter{x-httpd-php-to-html}
+</name>
+<features>
+proxy
+</features>
+<command>
+--head http://%HOSTIP:%HTTPPORT/x-httpd-php-to-html/%TESTNUMBER
+</command>
+</client>
+
+<verify>
+<protocol>
+HEAD /x-httpd-php-to-html/%TESTNUMBER HTTP/1.1\r
+Host: %HOSTIP:%HTTPPORT\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+Connection: close\r
+\r
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/cts/header-filters/data/test2 b/tests/cts/header-filters/data/test2
new file mode 100644 (file)
index 0000000..77bcc76
--- /dev/null
@@ -0,0 +1,61 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP GET
+server-header-filter html-to-xml
+</keywords>
+</info>
+
+<reply>
+<data>
+HTTP/1.1 200 OK\r
+Date: Thu, 22 Jul 2010 11:22:33 GMT\r
+Connection: close\r
+Content-Type: text/html\r
+Content-Type: text/html; blafasel\r
+X-Control: swsclose\r
+Content-Length: 0\r
+\r
+</data>
+</reply>
+
+<proxy-reply>
+<data>
+HTTP/1.1 200 OK\r
+Date: Thu, 22 Jul 2010 11:22:33 GMT\r
+Connection: close\r
+Content-Type: application/xhtml+xml\r
+Content-Type: application/xhtml+xml; blafasel\r
+X-Control: swsclose\r
+Content-Length: 0\r
+\r
+</data>
+</proxy-reply>
+
+<client>
+<server>
+http
+</server>
+<name>
++server-header-filter{html-to-xml}
+</name>
+<features>
+proxy
+</features>
+<command>
+--head http://%HOSTIP:%HTTPPORT/html-to-xml/%TESTNUMBER
+</command>
+</client>
+
+<verify>
+<protocol>
+HEAD /html-to-xml/%TESTNUMBER HTTP/1.1\r
+Host: %HOSTIP:%HTTPPORT\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+Connection: close\r
+\r
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/cts/header-filters/data/test3 b/tests/cts/header-filters/data/test3
new file mode 100644 (file)
index 0000000..776fab8
--- /dev/null
@@ -0,0 +1,67 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP GET
+server-header-filter xml-to-html
+</keywords>
+</info>
+
+<reply>
+<data>
+HTTP/1.1 200 OK\r
+Date: Thu, 22 Jul 2010 11:22:33 GMT\r
+Connection: close\r
+Content-Type: application/xhtml+xml; blafasel\r
+Content-Type: application/xml; blafasel\r
+Content-Type: application/xml\r
+Content-Type: text/xml; blafasel\r
+Content-Type: text/xml\r
+X-Control: swsclose\r
+Content-Length: 0\r
+\r
+</data>
+</reply>
+
+<proxy-reply>
+<data>
+HTTP/1.1 200 OK\r
+Date: Thu, 22 Jul 2010 11:22:33 GMT\r
+Connection: close\r
+Content-Type: text/html; blafasel\r
+Content-Type: text/html; blafasel\r
+Content-Type: text/html\r
+Content-Type: text/html; blafasel\r
+Content-Type: text/html\r
+X-Control: swsclose\r
+Content-Length: 0\r
+\r
+</data>
+</proxy-reply>
+
+<client>
+<server>
+http
+</server>
+<name>
++server-header-filter{xml-to-html}
+</name>
+<features>
+proxy
+</features>
+<command>
+--head http://%HOSTIP:%HTTPPORT/xml-to-html/%TESTNUMBER
+</command>
+</client>
+
+<verify>
+<protocol>
+HEAD /xml-to-html/%TESTNUMBER HTTP/1.1\r
+Host: %HOSTIP:%HTTPPORT\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+Connection: close\r
+\r
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/cts/header-filters/data/test4 b/tests/cts/header-filters/data/test4
new file mode 100644 (file)
index 0000000..37ebfd4
--- /dev/null
@@ -0,0 +1,60 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP GET
+client-header-filter hide-tor-exit-notation
+</keywords>
+</info>
+
+<reply>
+<data>
+HTTP/1.1 200 OK\r
+Date: Thu, 22 Jul 2010 11:22:33 GMT\r
+Connection: close\r
+Content-Type: text/html\r
+X-Control: swsclose\r
+Content-Length: 0\r
+\r
+</data>
+</reply>
+
+<proxy-reply>
+<data>
+HTTP/1.1 200 OK\r
+Date: Thu, 22 Jul 2010 11:22:33 GMT\r
+Connection: close\r
+Content-Type: text/html\r
+X-Control: swsclose\r
+Content-Length: 0\r
+\r
+</data>
+</proxy-reply>
+
+<client>
+<server>
+http
+</server>
+<name>
++client-header-filter{hide-tor-exit-notation} with http:// Referer:
+</name>
+<features>
+proxy
+</features>
+<command>
+--head -H "Referer: http://www.example.org.blafasel.exit/" -H "Host: www.example.org.blafasel.exit" http://%HOSTIP:%HTTPPORT/hide-tor-exit-notation/%TESTNUMBER
+</command>
+</client>
+
+<verify>
+<protocol>
+HEAD /hide-tor-exit-notation/%TESTNUMBER HTTP/1.1\r
+Host: www.example.org\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+Referer: http://www.example.org/\r
+Connection: close\r
+\r
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/cts/header-filters/data/test5 b/tests/cts/header-filters/data/test5
new file mode 100644 (file)
index 0000000..f614a55
--- /dev/null
@@ -0,0 +1,60 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP GET
+client-header-filter hide-tor-exit-notation
+</keywords>
+</info>
+
+<reply>
+<data>
+HTTP/1.1 200 OK\r
+Date: Thu, 22 Jul 2010 11:22:33 GMT\r
+Connection: close\r
+Content-Type: text/html\r
+X-Control: swsclose\r
+Content-Length: 0\r
+\r
+</data>
+</reply>
+
+<proxy-reply>
+<data>
+HTTP/1.1 200 OK\r
+Date: Thu, 22 Jul 2010 11:22:33 GMT\r
+Connection: close\r
+Content-Type: text/html\r
+X-Control: swsclose\r
+Content-Length: 0\r
+\r
+</data>
+</proxy-reply>
+
+<client>
+<server>
+http
+</server>
+<name>
++client-header-filter{hide-tor-exit-notation} with https:// Referer:
+</name>
+<features>
+proxy
+</features>
+<command>
+--head -H "Referer: https://www.example.org.blafasel.exit/secure/" -H "Host: www.example.org.blafasel.exit" http://%HOSTIP:%HTTPPORT/hide-tor-exit-notation/%TESTNUMBER
+</command>
+</client>
+
+<verify>
+<protocol>
+HEAD /hide-tor-exit-notation/%TESTNUMBER HTTP/1.1\r
+Host: www.example.org\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+Referer: https://www.example.org/secure/\r
+Connection: close\r
+\r
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/cts/header-filters/data/test6 b/tests/cts/header-filters/data/test6
new file mode 100644 (file)
index 0000000..802d9f5
--- /dev/null
@@ -0,0 +1,62 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP GET
+client-header-filter no-brotli-accepted
+</keywords>
+</info>
+
+<reply>
+<data>
+HTTP/1.1 200 OK\r
+Date: Thu, 22 Jul 2010 11:22:33 GMT\r
+Connection: close\r
+Content-Type: text/html\r
+X-Control: swsclose\r
+Content-Length: 0\r
+\r
+</data>
+</reply>
+
+<proxy-reply>
+<data>
+HTTP/1.1 200 OK\r
+Date: Thu, 22 Jul 2010 11:22:33 GMT\r
+Connection: close\r
+Content-Type: text/html\r
+X-Control: swsclose\r
+Content-Length: 0\r
+\r
+</data>
+</proxy-reply>
+
+<client>
+<server>
+http
+</server>
+<name>
++client-header-filter{no-brotli-accepted}
+</name>
+<features>
+proxy
+</features>
+<command>
+--head -H "Accept-Encoding: br" -H "Accept-Encoding: gzip, br" -H "Accept-Encoding: br, gzip" http://%HOSTIP:%HTTPPORT/no-brotli-accepted/%TESTNUMBER
+</command>
+</client>
+
+<verify>
+<protocol>
+HEAD /no-brotli-accepted/%TESTNUMBER HTTP/1.1\r
+Host: %HOSTIP:%HTTPPORT\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+Accept-Encoding: \r
+Accept-Encoding: gzip\r
+Accept-Encoding: gzip\r
+Connection: close\r
+\r
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/cts/header-filters/data/test7 b/tests/cts/header-filters/data/test7
new file mode 100644 (file)
index 0000000..6706141
--- /dev/null
@@ -0,0 +1,78 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP GET
+server-header-filter less-download-windows
+</keywords>
+</info>
+
+<reply>
+<data>
+HTTP/1.1 200 OK\r
+Date: Thu, 22 Jul 2010 11:22:33 GMT\r
+Connection: close\r
+Content-Disposition: blafasel filename="foo.png" tralala\r
+Content-Disposition: blafasel filename="foo.gif" tralala\r
+Content-Disposition: blafasel filename="foo.jpeg" tralala\r
+Content-Disposition: blafasel filename="foo.jpg" tralala\r
+Content-Disposition: blafasel filename="foo.diff" tralala\r
+Content-Disposition: blafasel filename="foo.patch" tralala\r
+Content-Disposition: blafasel filename="foo.dpatch" tralala\r
+Content-Disposition: blafasel filename='foo.c' tralala\r
+Content-Disposition: blafasel filename="foo.h" tralala\r
+Content-Disposition: blafasel filename=foo.pl tralala\r
+Content-Disposition: blafasel filename="foo.shar" tralala\r
+Content-Type: message/news\r
+Content-Type: message/rfc822\r
+Content-Type: message/text-blafasel\r
+Content-Type: application/x-sh\r
+Content-Type: application/x-sh \r
+X-Control: swsclose\r
+Content-Length: 0\r
+\r
+</data>
+</reply>
+
+<proxy-reply>
+<data>
+HTTP/1.1 200 OK\r
+Date: Thu, 22 Jul 2010 11:22:33 GMT\r
+Connection: close\r
+Content-Type: text/plain\r
+Content-Type: text/plain\r
+Content-Type: message/text-blafasel\r
+Content-Type: text/plain\r
+Content-Type: text/plain\r
+X-Control: swsclose\r
+Content-Length: 0\r
+\r
+</data>
+</proxy-reply>
+
+<client>
+<server>
+http
+</server>
+<name>
++server-header-filter{less-download-windows}
+</name>
+<features>
+proxy
+</features>
+<command>
+--head http://%HOSTIP:%HTTPPORT/less-download-windows/%TESTNUMBER
+</command>
+</client>
+
+<verify>
+<protocol>
+HEAD /less-download-windows/%TESTNUMBER HTTP/1.1\r
+Host: %HOSTIP:%HTTPPORT\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+Connection: close\r
+\r
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/cts/header-filters/header-filters.action b/tests/cts/header-filters/header-filters.action
new file mode 100644 (file)
index 0000000..bcb6095
--- /dev/null
@@ -0,0 +1,17 @@
+{+server-header-filter{x-httpd-php-to-html}}
+/x-httpd-php-to-html/
+
+{+server-header-filter{html-to-xml}}
+/html-to-xml/
+
+{+server-header-filter{xml-to-html}}
+/xml-to-html/
+
+{+client-header-filter{hide-tor-exit-notation}}
+/hide-tor-exit-notation/
+
+{+client-header-filter{no-brotli-accepted}}
+/no-brotli-accepted/
+
+{+server-header-filter{less-download-windows}}
+/less-download-windows/
diff --git a/tests/cts/header-filters/privoxy.conf b/tests/cts/header-filters/privoxy.conf
new file mode 100644 (file)
index 0000000..7ffc629
--- /dev/null
@@ -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
+
+filterfile ../../../default.filter
+actionsfile ./header-filters.action