Add test scenario client-body-filter-https
authorFabian Keil <fk@fabiankeil.de>
Fri, 26 Mar 2021 11:01:28 +0000 (12:01 +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

19 files changed:
tests/cts/client-body-filter-https/client-body-filter.action [new file with mode: 0644]
tests/cts/client-body-filter-https/client-body-filter.filter [new file with mode: 0644]
tests/cts/client-body-filter-https/data/test1 [new file with mode: 0644]
tests/cts/client-body-filter-https/data/test10 [new file with mode: 0644]
tests/cts/client-body-filter-https/data/test12 [new file with mode: 0644]
tests/cts/client-body-filter-https/data/test13 [new file with mode: 0644]
tests/cts/client-body-filter-https/data/test14 [new file with mode: 0644]
tests/cts/client-body-filter-https/data/test15 [new file with mode: 0644]
tests/cts/client-body-filter-https/data/test16 [new file with mode: 0644]
tests/cts/client-body-filter-https/data/test17 [new file with mode: 0644]
tests/cts/client-body-filter-https/data/test2 [new file with mode: 0644]
tests/cts/client-body-filter-https/data/test3 [new file with mode: 0644]
tests/cts/client-body-filter-https/data/test4 [new file with mode: 0644]
tests/cts/client-body-filter-https/data/test5 [new file with mode: 0644]
tests/cts/client-body-filter-https/data/test6 [new file with mode: 0644]
tests/cts/client-body-filter-https/data/test7 [new file with mode: 0644]
tests/cts/client-body-filter-https/data/test8 [new file with mode: 0644]
tests/cts/client-body-filter-https/data/test9 [new file with mode: 0644]
tests/cts/client-body-filter-https/privoxy.conf [new file with mode: 0644]

diff --git a/tests/cts/client-body-filter-https/client-body-filter.action b/tests/cts/client-body-filter-https/client-body-filter.action
new file mode 100644 (file)
index 0000000..40cf782
--- /dev/null
@@ -0,0 +1,8 @@
+{+client-body-filter{blafasel-to-bumfidel}}
+/
+
+{+client-body-filter{bumfidel-to-tralala}}
+/bumfidel-to-tralala
+
+{+client-body-filter{empty-body}}
+/.*/empty-body/
diff --git a/tests/cts/client-body-filter-https/client-body-filter.filter b/tests/cts/client-body-filter-https/client-body-filter.filter
new file mode 100644 (file)
index 0000000..ecc3798
--- /dev/null
@@ -0,0 +1,8 @@
+CLIENT-BODY-FILTER: blafasel-to-bumfidel Changes "blafasel" to "bumfidel"
+s@blafasel@bumfidel@
+
+CLIENT-BODY-FILTER: bumfidel-to-tralala Changes "bumfidel" to "tralala"
+s@bumfidel@tralala@
+
+CLIENT-BODY-FILTER: empty-body Only applies to empty content bodies
+s@^$@empty-body detected that there was no data@
diff --git a/tests/cts/client-body-filter-https/data/test1 b/tests/cts/client-body-filter-https/data/test1
new file mode 100644 (file)
index 0000000..b2ddb31
--- /dev/null
@@ -0,0 +1,61 @@
+<testcase>
+<info>
+<keywords>
+HTTPS
+HTTP POST
+client-body-filter
+</keywords>
+</info>
+
+<reply>
+<data>
+HTTP/1.1 200 OK
+Connection: close
+Content-Type: text/html
+X-Connection: swsclose
+
+Received your input.
+</data>
+</reply>
+
+<proxy-reply>
+<data>
+HTTP/1.1 200 Connection established\r
+\r
+HTTP/1.1 200 OK\r
+Connection: close\r
+Content-Type: text/html\r
+X-Connection: swsclose\r
+\r
+Received your input.
+</data>
+</proxy-reply>
+
+<client>
+<server>
+https
+</server>
+<name>
+Replace whole https request body with client-body-filter{blafasel-to-bumfidel}
+</name>
+<features>
+proxy
+</features>
+<command>
+-d blafasel --insecure https://%HOSTIP:%HTTPSPORT/%TESTNUMBER
+</command>
+</client>
+
+<verify>
+<protocol nonewline="yes">
+POST /%TESTNUMBER HTTP/1.1\r
+Host: %HOSTIP:%HTTPSPORT\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+Content-Length: 8\r
+Content-Type: application/x-www-form-urlencoded\r
+\r
+bumfidel
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/cts/client-body-filter-https/data/test10 b/tests/cts/client-body-filter-https/data/test10
new file mode 100644 (file)
index 0000000..f7c32a3
--- /dev/null
@@ -0,0 +1,57 @@
+<testcase>
+<info>
+<keywords>
+HTTPS
+HTTP POST
+client-body-filter
+</keywords>
+</info>
+
+<reply>
+<data>
+HTTP/1.1 200 OK
+Connection: close
+Content-Type: text/html
+X-Connection: swsclose
+
+Received your input.
+</data>
+</reply>
+
+<proxy-reply>
+<data>
+HTTP/1.1 200 Connection established\r
+\r
+HTTP/1.1 200 OK\r
+Connection: close\r
+Content-Type: text/html\r
+X-Connection: swsclose\r
+\r
+Received your input.
+</data>
+</proxy-reply>
+
+<client>
+<server>
+https
+</server>
+<name>
+Attempt to apply client-body-filter{blafasel-to-bumfidel} to client request that does not completely arrive in time. (XXX: Privoxy send a "Connection failed" message instead of a timeout message which would be more appropriate)
+</name>
+<features>
+proxy
+</features>
+# Sending the first request to appease the test framework.
+# We mainly care about the second request where we overwrite the Content-Length
+# header so curl sends less data than Privoxy expects.
+<command>
+-s --insecure https://%HOSTIP:%HTTPSPORT/first-request/%TESTNUMBER --next -s --write-out '%{stderr}%{response_code}\n' --limit-rate 5000 -d "blafasel%repeat[100 x padding]%" -H "Content-Length: 8000" --insecure https://%HOSTIP:%HTTPSPORT/second-request/%TESTNUMBER
+</command>
+</client>
+
+<verify>
+<stderr>
+400
+</stderr>
+</verify>
+</testcase>
diff --git a/tests/cts/client-body-filter-https/data/test12 b/tests/cts/client-body-filter-https/data/test12
new file mode 100644 (file)
index 0000000..42d3312
--- /dev/null
@@ -0,0 +1,84 @@
+<testcase>
+<info>
+<keywords>
+HTTPS
+HTTP POST
+client-body-filter
+</keywords>
+</info>
+
+<reply>
+<data>
+HTTP/1.1 200 OK
+Connection: close
+Content-Type: text/html
+X-Connection: swsclose
+
+Received your first request.
+</data>
+<data1>
+HTTP/1.1 200 OK
+Connection: close
+Content-Type: text/html
+X-Connection: swsclose
+
+Received your second request.
+</data1>
+</reply>
+
+<proxy-reply>
+<data>
+HTTP/1.1 200 Connection established\r
+\r
+HTTP/1.1 200 OK\r
+Connection: close\r
+Content-Type: text/html\r
+X-Connection: swsclose\r
+\r
+Received your first request.
+</data>
+<data1>
+HTTP/1.1 200 OK\r
+Connection: close\r
+Content-Type: text/html\r
+X-Connection: swsclose\r
+\r
+Received your second request.
+</data1>
+</proxy-reply>
+
+<client>
+<server>
+https
+</server>
+<name>
+Attempt to apply client-body-filter{blafasel-to-bumfidel} to client request that is too large to buffer.
+</name>
+<features>
+proxy
+</features>
+# Sending the first request to appease the test framework.
+# We mainly care about the second request which is too large for Privoxy to buffer it.
+<command>
+--insecure https://%HOSTIP:%HTTPSPORT/first-request/%TESTNUMBER --next -d "blafasel%repeat[20000 x padding]%" --insecure https://%HOSTIP:%HTTPSPORT/second-request/%TESTNUMBER
+</command>
+</client>
+
+<verify>
+<protocol nonewline="yes">
+GET /first-request/%TESTNUMBER HTTP/1.1\r
+Host: %HOSTIP:%HTTPSPORT\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+\r
+POST /second-request/%TESTNUMBER HTTP/1.1\r
+Host: %HOSTIP:%HTTPSPORT\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+Content-Length: 140008\r
+Content-Type: application/x-www-form-urlencoded\r
+\r
+blafasel%repeat[20000 x padding]%
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/cts/client-body-filter-https/data/test13 b/tests/cts/client-body-filter-https/data/test13
new file mode 100644 (file)
index 0000000..995c1ee
--- /dev/null
@@ -0,0 +1,82 @@
+<testcase>
+<info>
+<keywords>
+HTTPS
+HTTP POST
+client-body-filter
+</keywords>
+</info>
+
+<reply>
+<data>
+HTTP/1.1 200 OK
+Connection: keep-alive
+Content-Type: text/html
+Content-Length: 21
+
+Received your input.
+</data>
+<data1>
+HTTP/1.1 200 OK
+Connection: close
+Content-Type: text/html
+X-Connection: swsclose
+
+Received your input.
+</data1>
+</reply>
+
+<proxy-reply>
+<data>
+HTTP/1.1 200 Connection established\r
+\r
+HTTP/1.1 200 OK\r
+Connection: keep-alive\r
+Content-Type: text/html\r
+Content-Length: 21\r
+\r
+Received your input.
+</data>
+<data1>
+HTTP/1.1 200 OK\r
+Connection: close\r
+Content-Type: text/html\r
+X-Connection: swsclose\r
+\r
+Received your input.
+</data1>
+</proxy-reply>
+
+<client>
+<server>
+https
+</server>
+<name>
+Modify parts of the client body of a request on a reused connection with client-body-filter{blafasel-to-bumfidel} (based on test 2)
+</name>
+<features>
+proxy
+</features>
+<command>
+--insecure https://%HOSTIP:%HTTPSPORT/%TESTNUMBER --next -d "foo blafasel bar" --insecure https://%HOSTIP:%HTTPSPORT/%TESTNUMBER
+</command>
+</client>
+
+<verify>
+<protocol nonewline="yes">
+GET /%TESTNUMBER HTTP/1.1\r
+Host: %HOSTIP:%HTTPSPORT\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+\r
+POST /%TESTNUMBER HTTP/1.1\r
+Host: %HOSTIP:%HTTPSPORT\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+Content-Length: 16\r
+Content-Type: application/x-www-form-urlencoded\r
+\r
+foo bumfidel bar
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/cts/client-body-filter-https/data/test14 b/tests/cts/client-body-filter-https/data/test14
new file mode 100644 (file)
index 0000000..517fb71
--- /dev/null
@@ -0,0 +1,80 @@
+<testcase>
+<info>
+<keywords>
+HTTPS
+HTTP POST
+client-body-filter
+</keywords>
+</info>
+
+<reply>
+<data>
+HTTP/1.1 200 OK
+Content-Length: 21
+Content-Type: text/html
+
+Received your input.
+</data>
+<data1>
+HTTP/1.1 200 OK
+Connection: close
+Content-Type: text/html
+X-Connection: swsclose
+
+Received your input.
+</data1>
+</reply>
+
+<proxy-reply>
+<data>
+HTTP/1.1 200 Connection established\r
+\r
+HTTP/1.1 200 OK\r
+Content-Length: 21\r
+Content-Type: text/html\r
+\r
+Received your input.
+</data>
+<data1>
+HTTP/1.1 200 OK\r
+Connection: close\r
+Content-Type: text/html\r
+X-Connection: swsclose\r
+\r
+Received your input.
+</data1>
+</proxy-reply>
+
+<client>
+<server>
+https
+</server>
+<name>
+Applying client-body-filter{blafasel-to-bumfidel} to client request on a reused connection that is too large to read at once (based on test 5)
+</name>
+<features>
+proxy
+</features>
+<command>
+--insecure https://%HOSTIP:%HTTPSPORT/%TESTNUMBER --next -d "blafasel%repeat[5000 x padding]%" --insecure https://%HOSTIP:%HTTPSPORT/%TESTNUMBER
+</command>
+</client>
+
+<verify>
+<protocol nonewline="yes">
+GET /%TESTNUMBER HTTP/1.1\r
+Host: %HOSTIP:%HTTPSPORT\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+\r
+POST /%TESTNUMBER HTTP/1.1\r
+Host: %HOSTIP:%HTTPSPORT\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+Content-Length: 35008\r
+Content-Type: application/x-www-form-urlencoded\r
+\r
+bumfidel%repeat[5000 x padding]%
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/cts/client-body-filter-https/data/test15 b/tests/cts/client-body-filter-https/data/test15
new file mode 100644 (file)
index 0000000..b36e828
--- /dev/null
@@ -0,0 +1,72 @@
+<testcase>
+<info>
+<keywords>
+HTTPS
+HTTP POST
+client-body-filter
+</keywords>
+</info>
+
+<reply>
+<data>
+HTTP/1.1 200 OK
+Content-Length: 21
+Content-Type: text/html
+
+Received your input.
+</data>
+<data1>
+HTTP/1.1 200 OK
+Connection: close
+Content-Type: text/html
+X-Connection: swsclose
+
+Received your input.
+</data1>
+</reply>
+
+<proxy-reply>
+<data>
+HTTP/1.1 200 Connection established\r
+\r
+HTTP/1.1 200 OK\r
+Content-Length: 21\r
+Content-Type: text/html\r
+\r
+Received your input.
+</data>
+</proxy-reply>
+
+<client>
+<server>
+https
+</server>
+<name>
+Two filters applied to client request on a reused connection reusing the already filtered content (based on test 7)
+</name>
+<features>
+proxy
+</features>
+<command>
+--insecure https://%HOSTIP:%HTTPSPORT/bumfidel-to-tralala/%TESTNUMBER --next -d "blafasel" --insecure https://%HOSTIP:%HTTPSPORT/bumfidel-to-tralala/%TESTNUMBER
+</command>
+</client>
+
+<verify>
+<protocol nonewline="yes">
+GET /bumfidel-to-tralala/%TESTNUMBER HTTP/1.1\r
+Host: %HOSTIP:%HTTPSPORT\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+\r
+POST /bumfidel-to-tralala/%TESTNUMBER HTTP/1.1\r
+Host: %HOSTIP:%HTTPSPORT\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+Content-Length: 7\r
+Content-Type: application/x-www-form-urlencoded\r
+\r
+tralala
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/cts/client-body-filter-https/data/test16 b/tests/cts/client-body-filter-https/data/test16
new file mode 100644 (file)
index 0000000..4e828be
--- /dev/null
@@ -0,0 +1,71 @@
+<testcase>
+<info>
+<keywords>
+HTTPS
+HTTP POST
+client-body-filter
+</keywords>
+</info>
+
+<reply>
+<data>
+HTTP/1.1 200 OK
+Content-Length: 21
+Content-Type: text/html
+
+Received your input.
+</data>
+<data1>
+HTTP/1.1 200 OK
+Connection: close
+Content-Type: text/html
+X-Connection: swsclose
+
+Received your input.
+</data1>
+</reply>
+
+<proxy-reply>
+<data>
+HTTP/1.1 200 Connection established\r
+\r
+HTTP/1.1 200 OK\r
+Content-Length: 21\r
+Content-Type: text/html\r
+\r
+Received your input.
+</data>
+<data1>
+HTTP/1.1 200 OK\r
+Connection: close\r
+Content-Type: text/html\r
+X-Connection: swsclose\r
+\r
+Received your input.
+</data1>
+</proxy-reply>
+
+<client>
+<server>
+https
+</server>
+<name>
+Attempt to apply client-body-filter{blafasel-to-bumfidel} to client request that does not completely arrive in time on a reused connection. (based on test 10)
+</name>
+<features>
+proxy
+</features>
+# Sending the first request to appease the test framework.
+# We mainly care about the second request where we overwrite the Content-Length
+# header so curl sends less data than Privoxy expects.
+<command>
+-s --insecure https://%HOSTIP:%HTTPSPORT/first-request/%TESTNUMBER --next -s --write-out '%{stderr}%{response_code}\n' --limit-rate 5000 -d "blafasel%repeat[100 x padding]%" -H "Content-Length: 8000" --insecure https://%HOSTIP:%HTTPSPORT/second-request/%TESTNUMBER
+</command>
+</client>
+
+<verify>
+<stderr>
+400
+</stderr>
+</verify>
+</testcase>
diff --git a/tests/cts/client-body-filter-https/data/test17 b/tests/cts/client-body-filter-https/data/test17
new file mode 100644 (file)
index 0000000..57ba21c
--- /dev/null
@@ -0,0 +1,81 @@
+<testcase>
+<info>
+<keywords>
+HTTPS
+HTTP POST
+client-body-filter
+</keywords>
+</info>
+
+<reply>
+<data>
+HTTP/1.1 200 OK
+Content-Length: 29\r
+Content-Type: text/html
+
+Received your first request.
+</data>
+<data1>
+HTTP/1.1 200 OK
+Connection: close
+Content-Type: text/html
+X-Connection: swsclose
+
+Received your second request.
+</data1>
+</reply>
+
+<proxy-reply>
+<data>
+HTTP/1.1 200 Connection established\r
+\r
+HTTP/1.1 200 OK\r
+Content-Length: 29\r
+Content-Type: text/html\r
+\r
+Received your first request.
+</data>
+<data1>
+HTTP/1.1 200 OK\r
+Connection: close\r
+Content-Type: text/html\r
+X-Connection: swsclose\r
+\r
+Received your second request.
+</data1>
+</proxy-reply>
+
+<client>
+<server>
+https
+</server>
+<name>
+Attempt to apply client-body-filter{blafasel-to-bumfidel} to client request on reused connection that is too large to buffer. (based on test12)
+</name>
+<features>
+proxy
+</features>
+# We mainly care about the second request which is too large for Privoxy to buffer it.
+<command>
+--insecure https://%HOSTIP:%HTTPSPORT/first-request/%TESTNUMBER --next -d "blafasel%repeat[20000 x padding]%" --insecure https://%HOSTIP:%HTTPSPORT/second-request/%TESTNUMBER
+</command>
+</client>
+
+<verify>
+<protocol nonewline="yes">
+GET /first-request/%TESTNUMBER HTTP/1.1\r
+Host: %HOSTIP:%HTTPSPORT\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+\r
+POST /second-request/%TESTNUMBER HTTP/1.1\r
+Host: %HOSTIP:%HTTPSPORT\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+Content-Length: 140008\r
+Content-Type: application/x-www-form-urlencoded\r
+\r
+blafasel%repeat[20000 x padding]%
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/cts/client-body-filter-https/data/test2 b/tests/cts/client-body-filter-https/data/test2
new file mode 100644 (file)
index 0000000..2a2bd3e
--- /dev/null
@@ -0,0 +1,61 @@
+<testcase>
+<info>
+<keywords>
+HTTPS
+HTTP POST
+client-body-filter
+</keywords>
+</info>
+
+<reply>
+<data>
+HTTP/1.1 200 OK
+Connection: close
+Content-Type: text/html
+X-Connection: swsclose
+
+Received your input.
+</data>
+</reply>
+
+<proxy-reply>
+<data>
+HTTP/1.1 200 Connection established\r
+\r
+HTTP/1.1 200 OK\r
+Connection: close\r
+Content-Type: text/html\r
+X-Connection: swsclose\r
+\r
+Received your input.
+</data>
+</proxy-reply>
+
+<client>
+<server>
+https
+</server>
+<name>
+Modify parts of the client body with client-body-filter{blafasel-to-bumfidel}
+</name>
+<features>
+proxy
+</features>
+<command>
+-d "foo blafasel bar" --insecure https://%HOSTIP:%HTTPSPORT/%TESTNUMBER
+</command>
+</client>
+
+<verify>
+<protocol nonewline="yes">
+POST /%TESTNUMBER HTTP/1.1\r
+Host: %HOSTIP:%HTTPSPORT\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+Content-Length: 16\r
+Content-Type: application/x-www-form-urlencoded\r
+\r
+foo bumfidel bar
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/cts/client-body-filter-https/data/test3 b/tests/cts/client-body-filter-https/data/test3
new file mode 100644 (file)
index 0000000..429127c
--- /dev/null
@@ -0,0 +1,61 @@
+<testcase>
+<info>
+<keywords>
+HTTPS
+HTTP POST
+client-body-filter
+</keywords>
+</info>
+
+<reply>
+<data>
+HTTP/1.1 200 OK
+Connection: close
+Content-Type: text/html
+X-Connection: swsclose
+
+Received your input.
+</data>
+</reply>
+
+<proxy-reply>
+<data>
+HTTP/1.1 200 Connection established\r
+\r
+HTTP/1.1 200 OK\r
+Connection: close\r
+Content-Type: text/html\r
+X-Connection: swsclose\r
+\r
+Received your input.
+</data>
+</proxy-reply>
+
+<client>
+<server>
+https
+</server>
+<name>
+Apply client-body-filter{blafasel-to-bumfidel} to request that does not contain blafasel
+</name>
+<features>
+proxy
+</features>
+<command>
+-d "foo bar" --insecure https://%HOSTIP:%HTTPSPORT/%TESTNUMBER
+</command>
+</client>
+
+<verify>
+<protocol nonewline="yes">
+POST /%TESTNUMBER HTTP/1.1\r
+Host: %HOSTIP:%HTTPSPORT\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+Content-Length: 7\r
+Content-Type: application/x-www-form-urlencoded\r
+\r
+foo bar
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/cts/client-body-filter-https/data/test4 b/tests/cts/client-body-filter-https/data/test4
new file mode 100644 (file)
index 0000000..4816554
--- /dev/null
@@ -0,0 +1,63 @@
+<testcase>
+<info>
+<keywords>
+HTTPS
+HTTP POST
+client-body-filter
+</keywords>
+</info>
+
+<reply>
+<data>
+HTTP/1.1 200 OK
+Connection: close
+Content-Type: text/html
+
+Received your input.
+
+Will keep the connection open despite the "Connection: Close" header.
+</data>
+</reply>
+
+<proxy-reply>
+<data>
+HTTP/1.1 200 Connection established\r
+\r
+HTTP/1.1 200 OK\r
+Connection: close\r
+Content-Type: text/html\r
+\r
+Received your input.
+
+Will keep the connection open despite the "Connection: Close" header.
+</data>
+</proxy-reply>
+
+<client>
+<server>
+https
+</server>
+<name>
+Using client-body-filter{blafasel-to-bumfidel} with server connection that times out after delivering the response
+</name>
+<features>
+proxy
+</features>
+<command>
+-d "blafasel" --insecure https://%HOSTIP:%HTTPSPORT/%TESTNUMBER
+</command>
+</client>
+
+<verify>
+<protocol nonewline="yes">
+POST /%TESTNUMBER HTTP/1.1\r
+Host: %HOSTIP:%HTTPSPORT\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+Content-Length: 8\r
+Content-Type: application/x-www-form-urlencoded\r
+\r
+bumfidel
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/cts/client-body-filter-https/data/test5 b/tests/cts/client-body-filter-https/data/test5
new file mode 100644 (file)
index 0000000..6a253fe
--- /dev/null
@@ -0,0 +1,61 @@
+<testcase>
+<info>
+<keywords>
+HTTPS
+HTTP POST
+client-body-filter
+</keywords>
+</info>
+
+<reply>
+<data>
+HTTP/1.1 200 OK
+Connection: close
+Content-Type: text/html
+X-Connection: swsclose
+
+Received your input.
+</data>
+</reply>
+
+<proxy-reply>
+<data>
+HTTP/1.1 200 Connection established\r
+\r
+HTTP/1.1 200 OK\r
+Connection: close\r
+Content-Type: text/html\r
+X-Connection: swsclose\r
+\r
+Received your input.
+</data>
+</proxy-reply>
+
+<client>
+<server>
+https
+</server>
+<name>
+Applying client-body-filter{blafasel-to-bumfidel} to client request that is too large to read at once
+</name>
+<features>
+proxy
+</features>
+<command>
+-d "blafasel%repeat[5000 x padding]%" --insecure https://%HOSTIP:%HTTPSPORT/%TESTNUMBER
+</command>
+</client>
+
+<verify>
+<protocol nonewline="yes">
+POST /%TESTNUMBER HTTP/1.1\r
+Host: %HOSTIP:%HTTPSPORT\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+Content-Length: 35008\r
+Content-Type: application/x-www-form-urlencoded\r
+\r
+bumfidel%repeat[5000 x padding]%
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/cts/client-body-filter-https/data/test6 b/tests/cts/client-body-filter-https/data/test6
new file mode 100644 (file)
index 0000000..305d298
--- /dev/null
@@ -0,0 +1,61 @@
+<testcase>
+<info>
+<keywords>
+HTTPS
+HTTP POST
+client-body-filter
+</keywords>
+</info>
+
+<reply>
+<data>
+HTTP/1.1 200 OK
+Connection: close
+Content-Type: text/html
+X-Connection: swsclose
+
+Received your input.
+</data>
+</reply>
+
+<proxy-reply>
+<data>
+HTTP/1.1 200 Connection established\r
+\r
+HTTP/1.1 200 OK\r
+Connection: close\r
+Content-Type: text/html\r
+X-Connection: swsclose\r
+\r
+Received your input.
+</data>
+</proxy-reply>
+
+<client>
+<server>
+https
+</server>
+<name>
+Applying client-body-filter{blafasel-to-bumfidel} to client request that is too large to be read at once and arrives slowly
+</name>
+<features>
+proxy
+</features>
+<command>
+--limit-rate 4k -d "blafasel%repeat[5000 x padding]%" --insecure https://%HOSTIP:%HTTPSPORT/%TESTNUMBER
+</command>
+</client>
+
+<verify>
+<protocol nonewline="yes">
+POST /%TESTNUMBER HTTP/1.1\r
+Host: %HOSTIP:%HTTPSPORT\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+Content-Length: 35008\r
+Content-Type: application/x-www-form-urlencoded\r
+\r
+bumfidel%repeat[5000 x padding]%
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/cts/client-body-filter-https/data/test7 b/tests/cts/client-body-filter-https/data/test7
new file mode 100644 (file)
index 0000000..2ce0924
--- /dev/null
@@ -0,0 +1,61 @@
+<testcase>
+<info>
+<keywords>
+HTTPS
+HTTP POST
+client-body-filter
+</keywords>
+</info>
+
+<reply>
+<data>
+HTTP/1.1 200 OK
+Connection: close
+Content-Type: text/html
+X-Connection: swsclose
+
+Received your input.
+</data>
+</reply>
+
+<proxy-reply>
+<data>
+HTTP/1.1 200 Connection established\r
+\r
+HTTP/1.1 200 OK\r
+Connection: close\r
+Content-Type: text/html\r
+X-Connection: swsclose\r
+\r
+Received your input.
+</data>
+</proxy-reply>
+
+<client>
+<server>
+https
+</server>
+<name>
+Two filters applied to client request reusing the already filtered content
+</name>
+<features>
+proxy
+</features>
+<command>
+-d "blafasel" --insecure https://%HOSTIP:%HTTPSPORT/bumfidel-to-tralala/%TESTNUMBER
+</command>
+</client>
+
+<verify>
+<protocol nonewline="yes">
+POST /bumfidel-to-tralala/%TESTNUMBER HTTP/1.1\r
+Host: %HOSTIP:%HTTPSPORT\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+Content-Length: 7\r
+Content-Type: application/x-www-form-urlencoded\r
+\r
+tralala
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/cts/client-body-filter-https/data/test8 b/tests/cts/client-body-filter-https/data/test8
new file mode 100644 (file)
index 0000000..2a12987
--- /dev/null
@@ -0,0 +1,61 @@
+<testcase>
+<info>
+<keywords>
+HTTPS
+HTTP POST
+client-body-filter
+</keywords>
+</info>
+
+<reply>
+<data>
+HTTP/1.1 200 OK
+Connection: close
+Content-Type: text/html
+X-Connection: swsclose
+
+Received your input.
+</data>
+</reply>
+
+<proxy-reply>
+<data>
+HTTP/1.1 200 Connection established\r
+\r
+HTTP/1.1 200 OK\r
+Connection: close\r
+Content-Type: text/html\r
+X-Connection: swsclose\r
+\r
+Received your input.
+</data>
+</proxy-reply>
+
+<client>
+<server>
+https
+</server>
+<name>
+Three filters applied to client request reusing the already filtered content. Last filter does not modify content.
+</name>
+<features>
+proxy
+</features>
+<command>
+-d "blafasel" --insecure https://%HOSTIP:%HTTPSPORT/bumfidel-to-tralala/empty-body/%TESTNUMBER
+</command>
+</client>
+
+<verify>
+<protocol nonewline="yes">
+POST /bumfidel-to-tralala/empty-body/%TESTNUMBER HTTP/1.1\r
+Host: %HOSTIP:%HTTPSPORT\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+Content-Length: 7\r
+Content-Type: application/x-www-form-urlencoded\r
+\r
+tralala
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/cts/client-body-filter-https/data/test9 b/tests/cts/client-body-filter-https/data/test9
new file mode 100644 (file)
index 0000000..80ea75e
--- /dev/null
@@ -0,0 +1,63 @@
+<testcase>
+<info>
+<keywords>
+HTTPS
+HTTP POST
+client-body-filter
+# This test currently doesn't work as Privoxy truncates the request.
+# Sending no Content-Length header is an error but truncating the
+# request still doesn't seem ideal. Probably Privoxy should reject
+# the request instead of forwarding it.
+skip
+</keywords>
+</info>
+
+<reply>
+<data>
+HTTP/1.1 200 OK
+Connection: close
+Content-Type: text/html
+
+Received your input.
+</data>
+</reply>
+
+<proxy-reply>
+<data>
+HTTP/1.1 200 Connection established\r
+\r
+HTTP/1.1 200 OK\r
+Connection: close\r
+Content-Type: text/html\r
+\r
+Received your input.
+</data>
+</proxy-reply>
+
+<client>
+<server>
+https
+</server>
+<name>
+Attempt to apply client-body-filter{blafasel-to-bumfidel} to client request without Content-Length header
+</name>
+<features>
+proxy
+</features>
+<command>
+--limit-rate 1000 -d "blafasel%repeat[5000 x padding]%" -H "Content-Length:" --insecure https://%HOSTIP:%HTTPSPORT/%TESTNUMBER
+</command>
+</client>
+
+<verify>
+<protocol nonewline="yes">
+POST /%TESTNUMBER HTTP/1.1\r
+Host: %HOSTIP:%HTTPSPORT\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+Content-Type: application/x-www-form-urlencoded\r
+\r
+bumfidel%repeat[5000 x padding]%
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/cts/client-body-filter-https/privoxy.conf b/tests/cts/client-body-filter-https/privoxy.conf
new file mode 100644 (file)
index 0000000..3a6eecf
--- /dev/null
@@ -0,0 +1,37 @@
+listen-address 127.0.0.1:9119
+
+ca-directory          ../ca-directory
+ca-cert-file          privoxy-test-cacert.crt
+ca-key-file           privoxy-test-cakey.pem
+ca-password           blafasel
+# We don't check certificate anyway
+trusted-cas-file      privoxy-test-cacert.crt
+
+certificate-directory ../certs
+
+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 ../blocked-https-requests/https-inspection.action
+actionsfile ../client-body-filter/client-body-filter.action
+filterfile ../client-body-filter/client-body-filter.filter
+
+socket-timeout 3
+
+templdir ../../../templates/
+
+# Reduce buffer limit so tests can reach it sooner.
+buffer-limit 100
+
+keep-alive-timeout 10
+default-server-timeout 10