Debian Codegraph @

tests/namazu-cgi-4

raw symbols SCIP
1 #! /bin/sh
2 #
3 # Test for namazu.cgi with NMZ.access.
4 #
5 # NOTE: If error occurred, consult idx1/NMZ.access.
6 #
7 LOG=`pwd`/test-log
8 echo ' *** starting ' $0 >>$LOG
9 . ${srcdir}/commonfuncs
10
11 pwd=`pwd`
12
13 tmprc="$pwd/../src/.namazurc"
14 echo "Index $pwd" > $tmprc
15 duprcs
16
17 tmpaccess="$pwd/idx1/NMZ.access"
18
19 # To make messages English
20 unset LANG; export LANG
21 LANGUAGE=C; export LANGUAGE
22 LC_ALL=C; export LC_ALL
23 unset LC_MESSAGES; export LC_MESSAGES
24 unset LC_CTYPE; export LC_CTYPE
25
26 SCRIPT_NAME='namazu.cgi'
27 QUERY_STRING='query=namazu&idxname=idx1&lang=C'
28 export SCRIPT_NAME QUERY_STRING
29
30 REMOTE_HOST='foo.bar.jp'
31 REMOTE_ADDR='1.2.3.4'
32 export REMOTE_HOST REMOTE_ADDR
33
34 cd ../src
35
36 # should be denied - ||
37 cat <<EOF > $tmpaccess
38 deny all
39 EOF
40
41 ./namazu.cgi | \
42 grep "You don't have a permission to access the index" > /dev/null || exit 1
43
44
45 # should be allowed - &&
46 cat <<EOF > $tmpaccess
47 allow all
48 EOF
49
50 ./namazu.cgi | \
51 grep "You don't have a permission to access the index" > /dev/null && exit 1
52
53
54 # should be allowed - &&
55 cat <<EOF > $tmpaccess
56 deny all
57 allow all
58 EOF
59
60 ./namazu.cgi | \
61 grep "You don't have a permission to access the index" > /dev/null && exit 1
62
63 # should be denied - ||
64 cat <<EOF > $tmpaccess
65 allow all
66 deny all
67 EOF
68
69 ./namazu.cgi | \
70 grep "You don't have a permission to access the index" > /dev/null || exit 1
71
72 # should be allowed - &&
73 cat <<EOF > $tmpaccess
74 deny all
75 allow foo.bar.jp
76 EOF
77
78 ./namazu.cgi | \
79 grep "You don't have a permission to access the index" > /dev/null && exit 1
80
81 # should be allowed - &&
82 cat <<EOF > $tmpaccess
83 deny all
84 allow bar.jp
85 EOF
86
87 ./namazu.cgi | \
88 grep "You don't have a permission to access the index" > /dev/null && exit 1
89
90 # should be denied - ||
91 cat <<EOF > $tmpaccess
92 deny all
93 allow foo
94 EOF
95
96 ./namazu.cgi | \
97 grep "You don't have a permission to access the index" > /dev/null || exit 1
98
99 # should be allowed - &&
100 cat <<EOF > $tmpaccess
101 deny all
102 allow 1.2.3.4
103 EOF
104
105 ./namazu.cgi | \
106 grep "You don't have a permission to access the index" > /dev/null && exit 1
107
108 # should be allowed - &&
109 cat <<EOF > $tmpaccess
110 deny all
111 allow 1.2.3
112 EOF
113
114 ./namazu.cgi | \
115 grep "You don't have a permission to access the index" > /dev/null && exit 1
116
117 # should be denied - ||
118 cat <<EOF > $tmpaccess
119 deny all
120 allow 2.3.4
121 EOF
122
123 ./namazu.cgi | \
124 grep "You don't have a permission to access the index" > /dev/null || exit 1
125
126 rm -f $tmprc
127 rm -f $tmpaccess
128
129 exit 0