From: Fabian Keil Date: Sun, 28 Mar 2021 09:09:29 +0000 (+0200) Subject: Add test scenario client-tags X-Git-Url: http://www.privoxy.org/gitweb/filter-file.html?p=privoxy.git;a=commitdiff_plain;h=fbe7e8e67e1a3ba74edcdb2d254192fcff3dcccb Add test scenario client-tags Sponsored by: Privoxy project funds collected at SPI --- diff --git a/tests/cts/client-tags/client-tags.action b/tests/cts/client-tags/client-tags.action new file mode 100644 index 00000000..6fb6b3b5 --- /dev/null +++ b/tests/cts/client-tags/client-tags.action @@ -0,0 +1,8 @@ +{+block{Blocked based on the path}} +/block-request/ + +{-block} +CLIENT-TAG:^overrule-blocks$ + +{-filter} +CLIENT-TAG:^overrule-filters$ diff --git a/tests/cts/client-tags/data/test1 b/tests/cts/client-tags/data/test1 new file mode 100644 index 00000000..1c6ea1a2 --- /dev/null +++ b/tests/cts/client-tags/data/test1 @@ -0,0 +1,26 @@ + + + +HTTP +HTTP GET + + + + + +none + + +Request to blocked URL with now client-tags active + + +-s --write-out '%{stderr}%{response_code}\n' http://www.electrobsd.org/block-request/ + + + + + +403 + + + diff --git a/tests/cts/client-tags/data/test2 b/tests/cts/client-tags/data/test2 new file mode 100644 index 00000000..59f8b12b --- /dev/null +++ b/tests/cts/client-tags/data/test2 @@ -0,0 +1,27 @@ + + + +HTTP +HTTP GET + + + + + +http + + +Attempt to enable client-tag to disable block action for follow-up request without trusted Referer + + +-s --write-out '%{stderr}%{response_code}\n' 'http://p.p/toggle-client-tag?tag=overrule-blocks&toggle-state=1&expires=1' --next -s --write-out '%{stderr}%{response_code}\n' http://%HOSTIP:%HTTPPORT/block-request/ + + + + + +403 +403 + + + diff --git a/tests/cts/client-tags/data/test3 b/tests/cts/client-tags/data/test3 new file mode 100644 index 00000000..8b0d6ace --- /dev/null +++ b/tests/cts/client-tags/data/test3 @@ -0,0 +1,39 @@ + + + +HTTP +HTTP GET + + + + + +HTTP/1.1 200 OK +Connection: close +Content-Type: text/html +X-Connection: swsclose + +Received your input. + + + + + +http + + +Enabling client-tag to disable block action for follow-up request with trusted Referer + +# Limit the transfer rate for the second request so tag timed out by the time the next test is executed. + +-s --write-out '%{stderr}%{response_code}\n' --referer "http://p.p/client-tags" 'http://p.p/toggle-client-tag?tag=overrule-blocks&toggle-state=1&expires=1' --next -s --include --output log/curl%TESTNUMBER.out --write-out '%{stderr}%{response_code}\n' --limit-rate 10 http://%HOSTIP:%HTTPPORT/block-request/ + + + + + +302 +200 + + + diff --git a/tests/cts/client-tags/data/test4 b/tests/cts/client-tags/data/test4 new file mode 100644 index 00000000..6a2240b4 --- /dev/null +++ b/tests/cts/client-tags/data/test4 @@ -0,0 +1,40 @@ + + + +HTTP +HTTP GET + + + + + +HTTP/1.1 200 OK +Connection: close +Content-Type: text/html +X-Connection: swsclose + +Received your input. + + + + + +http + + +Enabling client-tag to disable block action for follow-up request with trusted Referer and disabling it again + + +-s --write-out '%{stderr}%{response_code}\n' --referer "http://p.p/client-tags" 'http://p.p/toggle-client-tag?tag=overrule-blocks&toggle-state=1&expires=1' --next -s --include --output log/curl%TESTNUMBER.out --write-out '%{stderr}%{response_code}\n' http://%HOSTIP:%HTTPPORT/block-request/ --next -s --write-out '%{stderr}%{response_code}\n' --referer "http://p.p/client-tags" 'http://p.p/toggle-client-tag?tag=overrule-blocks&toggle-state=0&expires=1' --next --write-out '%{stderr}%{response_code}\n' http://%HOSTIP:%HTTPPORT/block-request/ + + + + + +302 +200 +302 +403 + + + diff --git a/tests/cts/client-tags/data/test5 b/tests/cts/client-tags/data/test5 new file mode 100644 index 00000000..4eddbc59 --- /dev/null +++ b/tests/cts/client-tags/data/test5 @@ -0,0 +1,39 @@ + + + +HTTP +HTTP GET + + + + + +HTTP/1.1 200 OK +Content-Length: 21 +Content-Type: text/html + +Received your input. + + + + + +http + + +Enabling client-tag to disable block action for follow-up request with trusted Referer and disabling it again reusing the connection (based on test 4) + + +-s --write-out '%{stderr}%{response_code}\n' --referer "http://p.p/client-tags" 'http://p.p/toggle-client-tag?tag=overrule-blocks&toggle-state=1&expires=1' --next -s --include --output log/curl%TESTNUMBER.out --write-out '%{stderr}%{response_code}\n' http://%HOSTIP:%HTTPPORT/block-request/ --next -s --write-out '%{stderr}%{response_code}\n' --referer "http://p.p/client-tags" 'http://p.p/toggle-client-tag?tag=overrule-blocks&toggle-state=0&expires=1' --next --write-out '%{stderr}%{response_code}\n' http://%HOSTIP:%HTTPPORT/block-request/ + + + + + +302 +200 +302 +403 + + + diff --git a/tests/cts/client-tags/data/test6 b/tests/cts/client-tags/data/test6 new file mode 100644 index 00000000..c11365a6 --- /dev/null +++ b/tests/cts/client-tags/data/test6 @@ -0,0 +1,39 @@ + + + +HTTP +HTTP GET + + + + + +HTTP/1.1 200 OK +Content-Length: 21 +Content-Type: text/html + +Received your input. + + + + + +http + + +Enabling client-tag to disable block action for follow-up request with Referer specified with trusted-cgi-referer and disabling the tag again reusing the connection (based on test 5) + + +-s --write-out '%{stderr}%{response_code}\n' --referer "http://www.electrobsd.org/" 'http://p.p/toggle-client-tag?tag=overrule-blocks&toggle-state=1&expires=1' --next -s --include --output log/curl%TESTNUMBER.out --write-out '%{stderr}%{response_code}\n' http://%HOSTIP:%HTTPPORT/block-request/ --next -s --write-out '%{stderr}%{response_code}\n' --referer "http://www.electrobsd.org/" 'http://p.p/toggle-client-tag?tag=overrule-blocks&toggle-state=0&expires=1' --next --write-out '%{stderr}%{response_code}\n' http://%HOSTIP:%HTTPPORT/block-request/ + + + + + +302 +200 +302 +403 + + + diff --git a/tests/cts/client-tags/data/test7 b/tests/cts/client-tags/data/test7 new file mode 100644 index 00000000..905cab51 --- /dev/null +++ b/tests/cts/client-tags/data/test7 @@ -0,0 +1,38 @@ + + + +HTTP +HTTP GET + + + + + +HTTP/1.1 302 Done dealing with toggle request +Location: //config.privoxy.org/client-tags +Access-Control-Allow-Origin: http://www.electrobsd.org/ +Access-Control-Allow-Methods: GET,POST +Access-Control-Allow-Headers: X-Requested-With +Access-Control-Max-Age: 86400 +Content-Length: 0 +X-Ignore-Header: Date +Date: Sun, 28 Mar 2021 09:35:05 GMT + + + + + + +none + + +Confirm that the cors-allowed-origin directives results in headers being are added to CGI responses. + + +--head --referer http://www.electrobsd.org/ 'http://p.p/toggle-client-tag' + + + + + + diff --git a/tests/cts/client-tags/privoxy.conf b/tests/cts/client-tags/privoxy.conf new file mode 100644 index 00000000..443b78ae --- /dev/null +++ b/tests/cts/client-tags/privoxy.conf @@ -0,0 +1,36 @@ +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 +debug 65536 # log applying actions +#debug 16 # log all data written to the network into the logfile +#debug 32768 # log all data read from the network + +actionsfile client-tags.action +filterfile ../../../default.filter + +socket-timeout 3 + +templdir ../../../templates/ + +client-specific-tag overrule-blocks Overrule block sections. +client-specific-tag overrule-filters Overrule filter sections. + +# Try to let tags timeout between tests. This is racy but works for me. +client-tag-lifetime 1 + +trusted-cgi-referer http://www.electrobsd.org/ +cors-allowed-origin http://www.electrobsd.org/ + +keep-alive-timeout 10 +default-server-timeout 10