#!/bin/sh
#
# unittest_re_optim_wget - # test the RE optimisation patch
#
# The squid.conf file should have to see all debug output
# debug_options ALL,1 28,9
# squid.conf of this unit test assumes that there is a squid tree in /local/test
# the configuration file needs to be edited in case an other directory is used.
# squid.conf has various url_regex directives and 2 references to files with REs:
#    acl URLREGEX1 url_regex "/local/test/etc/re.4lines"
#    acl URLREGEX2 url_regex "/local/test/etc/re.200lines"
#
# NOTE: use "squid -X -f /local/test/etc/squidtest.conf"  to see the debug output during startup

# To support multiple Squid instances, squidtest.conf has
#    http_port 33129
http_proxy=localhost:33129
export http_proxy

# squidtest.conf has url_regex ACLs which are used in 'always_direct allow foo' directives.
# and there is a  standard acl: acl QUERY urlpath_regex cgi-bin \?
# The following wget commands trigger the RE matching functions.

wget -q -O ttt01 http://www.example.com/abc/def?x=0
# aclRegexData::match: match '(cgi-bin)|(\?)' found in '/abc/def?x=0'
# aclRegexData::match: match '(.example.com/abc)' found in 'http://www.example.com/abc/def?x=0'

wget -q -O ttt02 http://www.example.com/cgi-bin/report.pl?a=9
# aclRegexData::match: match '(cgi-bin)|(\?)' found in '/cgi-bin/report.pl?a=9'

wget -q -O ttt03 http://www.example.com/-1-2-exx-3-a.html
# aclRegexData::match: match '(axx)|(bxx)|(cxx)|(dxx)|(exx)|(fxx)' found in 'http://www.example.com/-1-2-exx-3-a.html'

wget -q -O ttt04 http://40john-doe.example.com/foo/bar/index.php
# aclRegexData::match: match '(foo\.example\.com/html/another-very-long-url-to-test-buffers-of-the-re-optimisation-algorithm\.php)|(31john.*doe.example.com/.*/index.php)|(abc.example.com/scripts/cgi-bin/31example.cgi)|(foo\.example\.com/html/index\.php)|(foo\.example\.com/html/33k3k3second\.php)|(foo\.example\.com/html/another-very-long-url-to-test-buffers-of-the-re-optimisation-algorithm\.php)|(32john.*doe.example.com/.*/index.php)|(abc.example.com/scripts/cgi-bin/32example.cgi)|(foo\.example\.com/html/index\.php)|(foo\.example\.com/html/44k44k4k4second\.php)|(foo\.example\.com/html/another-very-long-url-to-test-buffers-of-the-re-optimisation-algorithm\.php)|(33john.*doe.example.com/.*/index.php)|(abc.example.com/scripts/cgi-bin/33example.cgi)|(foo\.example\.com/html/index\.php)|(foo\.example\.com/html/00d0d0d0second\.php)|(foo\.example\.com/html/another-very-long-url-to-test-buffers-of-the-re-optimisation-algorithm\.php)|(34john.*doe.example.com/.*/index.php)|(abc.example.com/scripts/cgi-bin/34example.cgi)|(foo\.example\.com/html/index\.php)|(foo\.example\.com/html/2k2k2k2second\.php)|(foo\.example\.com/html/another-very-long-url-to-test-buffers-of-the-re-optimisation-algorithm\.php)|(35john.*doe.example.com/.*/index.php)|(abc.example.com/scripts/cgi-bin/35example.cgi)|(foo\.example\.com/html/index\.php)|(foo\.example\.com/html/aaananasecond\.php)|(foo\.example\.com/html/another-very-long-url-to-test-buffers-of-the-re-optimisation-algorithm\.php)|(36john.*doe.example.com/.*/index.php)|(abc.example.com/scripts/cgi-bin/36example.cgi)|(foo\.example\.com/html/index\.php)|(foo\.example\.com/html/kwkwkwkwkwsecond\.php)|(foo\.example\.com/html/another-very-long-url-to-test-buffers-of-the-re-optimisation-algorithm\.php)|(37john.*doe.example.com/.*/index.php)|(abc.example.com/scripts/cgi-bin/37example.cgi)|(foo\.example\.com/html/index\.php)|(foo\.example\.com/html/qkqkqkqkqjsdsecond\.php)|(foo\.example\.com/html/another-very-long-url-to-test-buffers-of-the-re-optimisation-algorithm\.php)|(38john.*doe.example.com/.*/index.php)|(abc.example.com/scripts/cgi-bin/38example.cgi)|(foo\.example\.com/html/index\.php)|(foo\.example\.com/html/oododofofnsecond\.php)|(foo\.example\.com/html/another-very-long-url-to-test-buffers-of-the-re-optimisation-algorithm\.php)|(39john.*doe.example.com/.*/index.php)|(abc.example.com/scripts/cgi-bin/39example.cgi)|(foo\.example\.com/html/index\.php)|(foo\.example\.com/html/oeoeoeoekkfnsecond\.php)|(foo\.example\.com/html/another-very-long-url-to-test-buffers-of-the-re-optimisation-algorithm\.php)|(40john.*doe.example.com/.*/index.php)' found in 'http://40john-doe.example.com/foo/bar/index.php'

wget -q -O ttt05 http://www.foo.example.com/html/another-very-long-url-to-test-buffers-of-the-re-optimisation-algorithm.php?var=6
# aclRegexData::match: match '(cgi-bin)|(\?)' found in '/html/another-very-long-url-to-test-buffers-of-the-re-optimisation-algorithm.php?var=6'

# 2011/06/02 14:10:59.889| aclRegexData::match: match '(abc.example.com/scripts/cgi-bin/40example.cgi)| ... (edited) ... |(foo\.example\.com/html/utututututsecond\.php)|(foo\.example\.com/html/another-very-long-url-to-test-buffers-of-the-re-optimisation-algorithm\.php)|(27john.*doe.example.com/.*/index.php)|(abc.example.com/scripts/cgi-bin/27example.cgi)|(foo\.example\.com/html/index\.php)|(foo\.example\.com/html/kfkfkfkfksecond\.php)|(foo\.example\.com/html/another-very-long-url-to-test-buffers-of-the-re-optimisation-algorithm\.php)|(28john.*doe.example.com/.*/index.php)|(abc.example.com/scripts/cgi-bin/28example.cgi)|(foo\.example\.com/html/index\.php)|(foo\.example\.com/html/kkkkksecond\.php)|(foo\.example\.com/html/another-very-long-url-to-test-buffers-of-the-re-optimisation-algorithm\.php)|(29john.*doe.example.com/.*/index.php)|(abc.example.com/scripts/cgi-bin/29example.cgi)|(foo\.example\.com/html/index\.php)|(foo\.example\.com/html/qqqqnsecond\.php)|(foo\.example\.com/html/another-very-long-url-to-test-buffers-of-the-re-optimisation-algorithm\.php)|(30john.*doe.example.com/.*/index.php)|(abc.example.com/scripts/cgi-bin/30example.cgi)|(foo\.example\.com/html/index\.php)|(foo\.example\.com/html/kkkkskskssecond\.php)' found in 'http://www.foo.example.com/html/another-very-long-url-to-test-buffers-of-the-re-optimisation-algorithm.php?var=6'

wget -q -O ttt06 http://www.foo.example.com/error.html
# aclRegexData::match: match 'err' found in 'http://www.foo.example.com/error.html'

rm -f ./ttt??

