| 1 |
# |
| 2 |
# Part of the ht://Dig package <http://www.htdig.org/> |
| 3 |
# Copyright (c) 1999-2004 The ht://Dig Group |
| 4 |
# For copyright details, see the file COPYING in your distribution |
| 5 |
# or the GNU Library General Public License (LGPL) version 2 or later |
| 6 |
# <http://www.gnu.org/copyleft/lgpl.html> |
| 7 |
# |
| 8 |
# $Id: t_htdig,v 1.16 2004/06/05 06:26:22 lha Exp $ |
| 9 |
# |
| 10 |
|
| 11 |
# Tests the following config attributes: |
| 12 |
# case_sensitive |
| 13 |
# common_url_parts |
| 14 |
# limit_urls_to |
| 15 |
# robotstxt_name |
| 16 |
# url_part_aliases |
| 17 |
# url_rewrite_rules |
| 18 |
|
| 19 |
flags="$@" |
| 20 |
|
| 21 |
try() { |
| 22 |
config=$1 |
| 23 |
expected=$2 |
| 24 |
|
| 25 |
# $htdig "$flags" -t -i -c $config # crashes on Solaris, HP-UX -- lha |
| 26 |
$htdig $flags -t -i -c $config |
| 27 |
# One test gives empty database -- suppress this warning. |
| 28 |
$htpurge -c $config 2&> /dev/null |
| 29 |
|
| 30 |
# only used when url_part_aliases was set before the call... |
| 31 |
set_attr url_part_aliases "bar foo" |
| 32 |
|
| 33 |
got=`./document -c $config -u | sort` |
| 34 |
|
| 35 |
if [ "$expected" != "$got" ] |
| 36 |
then |
| 37 |
fail "running htdig: expected |
| 38 |
$expected |
| 39 |
but got |
| 40 |
$got" |
| 41 |
|
| 42 |
fi |
| 43 |
} |
| 44 |
|
| 45 |
test_functions_action=--start-apache |
| 46 |
. ./test_functions |
| 47 |
|
| 48 |
conf=$testdir/conf/htdig.conf.tmp |
| 49 |
cp $testdir/conf/htdig.conf $conf |
| 50 |
|
| 51 |
# complete dig of set 1 |
| 52 |
|
| 53 |
try $conf \ |
| 54 |
'http://localhost:7400/set1/ |
| 55 |
http://localhost:7400/set1/bad_local.htm |
| 56 |
http://localhost:7400/set1/script.html |
| 57 |
http://localhost:7400/set1/site%201.html |
| 58 |
http://localhost:7400/set1/site2.html |
| 59 |
http://localhost:7400/set1/site3.html |
| 60 |
http://localhost:7400/set1/site4.html |
| 61 |
http://localhost:7400/set1/sub%2520dir/ |
| 62 |
http://localhost:7400/set1/sub%2520dir/empty%20file.html |
| 63 |
http://localhost:7400/set1/title.html' |
| 64 |
|
| 65 |
|
| 66 |
# Check common_url_parts being encoded properly |
| 67 |
set_attr common_url_parts "dummy1 dummy2 dummy3 dummy4 dummy5 dummy6 dummy7 dummy8 dummy9 dummy10 dummy11 dummy12" |
| 68 |
got=`./document -c $config -u | sort` |
| 69 |
expected='dummy1localhost:7400/set1/ |
| 70 |
dummy1localhost:7400/set1/bad_localdummy7 |
| 71 |
dummy1localhost:7400/set1/scriptdummy6 |
| 72 |
dummy1localhost:7400/set1/site%201dummy6 |
| 73 |
dummy1localhost:7400/set1/site2dummy6 |
| 74 |
dummy1localhost:7400/set1/site3dummy6 |
| 75 |
dummy1localhost:7400/set1/site4dummy6 |
| 76 |
dummy1localhost:7400/set1/sub%2520dir/ |
| 77 |
dummy1localhost:7400/set1/sub%2520dir/empty%20filedummy6 |
| 78 |
dummy1localhost:7400/set1/titledummy6' |
| 79 |
if [ "$expected" != "$got" ] |
| 80 |
then |
| 81 |
fail "running htdig: expected |
| 82 |
$expected |
| 83 |
but got |
| 84 |
$got" |
| 85 |
fi |
| 86 |
|
| 87 |
|
| 88 |
# Pretend we are another user; robots.txt bans us from seeing 'site*' |
| 89 |
|
| 90 |
set_attr robotstxt_name other |
| 91 |
# (Reverse mapping from 'foo' to 'bar' implemented in try.) |
| 92 |
set_attr url_part_aliases "http://localhost:7400/set1 foo" |
| 93 |
|
| 94 |
try $conf \ |
| 95 |
'bar/ |
| 96 |
bar/bad_local.htm |
| 97 |
bar/script.html |
| 98 |
bar/sub%2520dir/ |
| 99 |
bar/sub%2520dir/empty%20file.html |
| 100 |
bar/title.html' |
| 101 |
|
| 102 |
# back to default. |
| 103 |
set_attr url_part_aliases |
| 104 |
|
| 105 |
# check limit_urls_to obeys case sensitive |
| 106 |
set_attr start_url HTTP://LocalHost:7400/Set1/ |
| 107 |
try $conf "" |
| 108 |
|
| 109 |
set_attr case_sensitive false |
| 110 |
set_attr robotstxt_name htdig |
| 111 |
# common_url_parts is case sensitive, despite case_sensitive=false |
| 112 |
set_attr common_url_parts "http:// http://local HTTP://LocalHost 7400/set1" |
| 113 |
# Replace site4.html by a file:/// URL. Must explicitly add leading chars |
| 114 |
set_attr url_rewrite_rules '(.*)si[a-z]*[4-9]*\.([a-z]*)tml file:///'$PWD'/htdocs/set1/site4.\\2tml' |
| 115 |
set_attr limit_urls_to '${start_url} site4.html' |
| 116 |
|
| 117 |
try $conf \ |
| 118 |
'file://'$PWD'/htdocs/set1/site4.html |
| 119 |
http://localhost:7400/set1/ |
| 120 |
http://localhost:7400/set1/bad_local.htm |
| 121 |
http://localhost:7400/set1/script.html |
| 122 |
http://localhost:7400/set1/site%201.html |
| 123 |
http://localhost:7400/set1/site2.html |
| 124 |
http://localhost:7400/set1/site3.html |
| 125 |
http://localhost:7400/set1/sub%2520dir/ |
| 126 |
http://localhost:7400/set1/sub%2520dir/empty%20file.html |
| 127 |
http://localhost:7400/set1/title.html' |
| 128 |
|
| 129 |
# Check common_url_parts being encoded properly |
| 130 |
set_attr common_url_parts "dummy1 dummy2 dummy3 dummy4" |
| 131 |
got=`./document -c $config -u | sort` |
| 132 |
expected='dummy2host:dummy4/ |
| 133 |
dummy2host:dummy4/bad_local.htm |
| 134 |
dummy2host:dummy4/script.html |
| 135 |
dummy2host:dummy4/site%201.html |
| 136 |
dummy2host:dummy4/site2.html |
| 137 |
dummy2host:dummy4/site3.html |
| 138 |
dummy2host:dummy4/sub%2520dir/ |
| 139 |
dummy2host:dummy4/sub%2520dir/empty%20file.html |
| 140 |
dummy2host:dummy4/title.html |
| 141 |
file://'$PWD'/htdocs/set1/site4.html' |
| 142 |
if [ "$expected" != "$got" ] |
| 143 |
then |
| 144 |
fail "running htdig: expected |
| 145 |
$expected |
| 146 |
but got |
| 147 |
$got" |
| 148 |
fi |
| 149 |
|
| 150 |
test_functions_action=--stop-apache |
| 151 |
. ./test_functions |