From: Fabian Keil <fk@fabiankeil.de>
Date: Fri, 22 Jan 2021 15:32:10 +0000 (+0100)
Subject: Add test scenario header-filters
X-Git-Tag: v_4_0_0~99
X-Git-Url: http://www.privoxy.org/gitweb/%22https:/faq/static/@default-cgi@show-url-info?a=commitdiff_plain;h=e4a7ec439a8ff4199c00718922f5cf255d2dabdf;p=privoxy.git

Add test scenario header-filters

Sponsored by: Privoxy project funds collected at SPI
---

diff --git a/tests/cts/header-filters/data/test1 b/tests/cts/header-filters/data/test1
new file mode 100644
index 00000000..763ea61d
--- /dev/null
+++ b/tests/cts/header-filters/data/test1
@@ -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
+Date: Thu, 22 Jul 2010 11:22:33 GMT
+Connection: close
+Content-Type: application/x-httpd-php
+X-Control: swsclose
+Content-Length: 0
+
+</data>
+</reply>
+
+<proxy-reply>
+<data>
+HTTP/1.1 200 OK
+Date: Thu, 22 Jul 2010 11:22:33 GMT
+Connection: close
+Content-Type: text/html
+X-Control: swsclose
+Content-Length: 0
+
+</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
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+Connection: close
+
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/cts/header-filters/data/test2 b/tests/cts/header-filters/data/test2
new file mode 100644
index 00000000..77bcc769
--- /dev/null
+++ b/tests/cts/header-filters/data/test2
@@ -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
+Date: Thu, 22 Jul 2010 11:22:33 GMT
+Connection: close
+Content-Type: text/html
+Content-Type: text/html; blafasel
+X-Control: swsclose
+Content-Length: 0
+
+</data>
+</reply>
+
+<proxy-reply>
+<data>
+HTTP/1.1 200 OK
+Date: Thu, 22 Jul 2010 11:22:33 GMT
+Connection: close
+Content-Type: application/xhtml+xml
+Content-Type: application/xhtml+xml; blafasel
+X-Control: swsclose
+Content-Length: 0
+
+</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
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+Connection: close
+
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/cts/header-filters/data/test3 b/tests/cts/header-filters/data/test3
new file mode 100644
index 00000000..776fab80
--- /dev/null
+++ b/tests/cts/header-filters/data/test3
@@ -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
+Date: Thu, 22 Jul 2010 11:22:33 GMT
+Connection: close
+Content-Type: application/xhtml+xml; blafasel
+Content-Type: application/xml; blafasel
+Content-Type: application/xml
+Content-Type: text/xml; blafasel
+Content-Type: text/xml
+X-Control: swsclose
+Content-Length: 0
+
+</data>
+</reply>
+
+<proxy-reply>
+<data>
+HTTP/1.1 200 OK
+Date: Thu, 22 Jul 2010 11:22:33 GMT
+Connection: close
+Content-Type: text/html; blafasel
+Content-Type: text/html; blafasel
+Content-Type: text/html
+Content-Type: text/html; blafasel
+Content-Type: text/html
+X-Control: swsclose
+Content-Length: 0
+
+</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
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+Connection: close
+
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/cts/header-filters/data/test4 b/tests/cts/header-filters/data/test4
new file mode 100644
index 00000000..37ebfd4b
--- /dev/null
+++ b/tests/cts/header-filters/data/test4
@@ -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
+Date: Thu, 22 Jul 2010 11:22:33 GMT
+Connection: close
+Content-Type: text/html
+X-Control: swsclose
+Content-Length: 0
+
+</data>
+</reply>
+
+<proxy-reply>
+<data>
+HTTP/1.1 200 OK
+Date: Thu, 22 Jul 2010 11:22:33 GMT
+Connection: close
+Content-Type: text/html
+X-Control: swsclose
+Content-Length: 0
+
+</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
+Host: www.example.org
+User-Agent: curl/%VERSION
+Accept: */*
+Referer: http://www.example.org/
+Connection: close
+
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/cts/header-filters/data/test5 b/tests/cts/header-filters/data/test5
new file mode 100644
index 00000000..f614a550
--- /dev/null
+++ b/tests/cts/header-filters/data/test5
@@ -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
+Date: Thu, 22 Jul 2010 11:22:33 GMT
+Connection: close
+Content-Type: text/html
+X-Control: swsclose
+Content-Length: 0
+
+</data>
+</reply>
+
+<proxy-reply>
+<data>
+HTTP/1.1 200 OK
+Date: Thu, 22 Jul 2010 11:22:33 GMT
+Connection: close
+Content-Type: text/html
+X-Control: swsclose
+Content-Length: 0
+
+</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
+Host: www.example.org
+User-Agent: curl/%VERSION
+Accept: */*
+Referer: https://www.example.org/secure/
+Connection: close
+
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/cts/header-filters/data/test6 b/tests/cts/header-filters/data/test6
new file mode 100644
index 00000000..802d9f5a
--- /dev/null
+++ b/tests/cts/header-filters/data/test6
@@ -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
+Date: Thu, 22 Jul 2010 11:22:33 GMT
+Connection: close
+Content-Type: text/html
+X-Control: swsclose
+Content-Length: 0
+
+</data>
+</reply>
+
+<proxy-reply>
+<data>
+HTTP/1.1 200 OK
+Date: Thu, 22 Jul 2010 11:22:33 GMT
+Connection: close
+Content-Type: text/html
+X-Control: swsclose
+Content-Length: 0
+
+</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
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+Accept-Encoding: 
+Accept-Encoding: gzip
+Accept-Encoding: gzip
+Connection: close
+
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/cts/header-filters/data/test7 b/tests/cts/header-filters/data/test7
new file mode 100644
index 00000000..6706141f
--- /dev/null
+++ b/tests/cts/header-filters/data/test7
@@ -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
+Date: Thu, 22 Jul 2010 11:22:33 GMT
+Connection: close
+Content-Disposition: blafasel filename="foo.png" tralala
+Content-Disposition: blafasel filename="foo.gif" tralala
+Content-Disposition: blafasel filename="foo.jpeg" tralala
+Content-Disposition: blafasel filename="foo.jpg" tralala
+Content-Disposition: blafasel filename="foo.diff" tralala
+Content-Disposition: blafasel filename="foo.patch" tralala
+Content-Disposition: blafasel filename="foo.dpatch" tralala
+Content-Disposition: blafasel filename='foo.c' tralala
+Content-Disposition: blafasel filename="foo.h" tralala
+Content-Disposition: blafasel filename=foo.pl tralala
+Content-Disposition: blafasel filename="foo.shar" tralala
+Content-Type: message/news
+Content-Type: message/rfc822
+Content-Type: message/text-blafasel
+Content-Type: application/x-sh
+Content-Type: application/x-sh 
+X-Control: swsclose
+Content-Length: 0
+
+</data>
+</reply>
+
+<proxy-reply>
+<data>
+HTTP/1.1 200 OK
+Date: Thu, 22 Jul 2010 11:22:33 GMT
+Connection: close
+Content-Type: text/plain
+Content-Type: text/plain
+Content-Type: message/text-blafasel
+Content-Type: text/plain
+Content-Type: text/plain
+X-Control: swsclose
+Content-Length: 0
+
+</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
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+Connection: close
+
+</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
index 00000000..bcb60951
--- /dev/null
+++ b/tests/cts/header-filters/header-filters.action
@@ -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
index 00000000..7ffc6293
--- /dev/null
+++ b/tests/cts/header-filters/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
+
+filterfile ../../../default.filter
+actionsfile ./header-filters.action