-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrts.tests
287 lines (201 loc) · 7.17 KB
/
rts.tests
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
#!/bin/sh
cleanup() {
rm -rf '0' 0virtual httpd '127.0.0.1' '::1' '@dXNlcjpwYXNzd29yZA' authhost
}
trap "cleanup" EXIT TERM INT
rm -f httpd
#ln -s publicfile httpd
ln -s httpfile httpd
umask 022
TCPREMOTEIP=1.2.3.4; export TCPREMOTEIP
rm -rf 0
mkdir 0
echo 'Hello, world' > 0/foo
echo '--- httpd handles HTTP/1.0 GET'
echo 'GET foo HTTP/1.0
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd handles HTTP/1.0 HEAD'
echo 'HEAD foo HTTP/1.0
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd handles HTTP/1.0 %xx'
echo 'GET %66%6F%6f HTTP/1.0
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd handles HTTP/1.1 GET with Host'
echo 'GET foo HTTP/1.1
One: Two
Host: 0
Three: Four
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd rejects HTTP/1.1 GET without host'
echo 'GET foo HTTP/1.1
' | ./httpd 2>&1 | sed 's/^Date: .*/Date: .../'
echo '--- httpd handles HTTP/1.1 HEAD with Host'
echo 'HEAD foo HTTP/1.1
One: Two
Host: 0
Three: Four
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd handles multiple HTTP/1.1 requests'
echo 'Hi' > 0/bar
echo 'GET foo HTTP/1.1
Host: 0
GET bar HTTP/1.1
Host: 0
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd prints error message for ENOENT'
echo 'GET nonexistent HTTP/1.0
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd omits body from HEAD error message'
echo 'HEAD nonexistent HTTP/1.0
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd prints error message for ELOOP'
ln -s loop 0/loop
echo 'GET loop HTTP/1.0
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd prints error message for file not group-readable'
echo wrong > 0/unreadable
chmod 604 0/unreadable
echo 'GET unreadable HTTP/1.0
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd prints error message for file not world-readable'
chmod 640 0/unreadable
echo 'GET unreadable HTTP/1.0
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd prints error message for 101 001'
chmod 645 0/unreadable
echo 'GET unreadable HTTP/1.0
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd prints error message for directory'
mkdir 0/subdirectory
echo 'GET subdirectory HTTP/1.0
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd lowercases host names'
rm -rf 0virtual
mkdir 0virtual
echo '<html><body>Virtual</body></html>' > 0virtual/index.html
echo 'GET index.html HTTP/1.0
Host: 0Virtual
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd does index.html rewriting'
echo 'GET / HTTP/1.0
Host: 0Virtual
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd rewrites dots after slashes'
mkdir 0virtual/:.
mkdir 0virtual/:./:
echo '<html><body>colons</body></html>' > 0virtual/:./:/index.html
echo 'GET .././ HTTP/1.0
Host: 0Virtual
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd rejects unrecognized requests'
echo 'POST .././ HTTP/1.0
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd rejects lowercase requests'
echo 'Head / HTTP/1.0
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd rejects Expect'
echo 'GET .././ HTTP/1.0
Expect: whatever
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd converts names to file types'
( for i in 'audio=vnd:digital-winds' dvi gif gz html jpeg mpeg pdf png ps
do
touch 0/foo...$i
echo 'HEAD foo...'$i' HTTP/1.1
Host: 0
'
done
) | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd prints Last-Modified'
echo test > 0/old
./utime 0/old 12345
echo 'GET old HTTP/1.0
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd handles If-Modified-Since'
echo 'GET old HTTP/1.0
If-Modified-Since: second line takes precedence
If-MoDiFiEd-SiNcE: Thu, 01 Jan 1970 03:25:45 GMTxxx
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
# NEW
echo '--- httpd accepts Host: IPv4:port, [IPv6]:port'
rm -rf 127.0.0.1 ::1
mkdir 127.0.0.1 ::1
echo '<html><body>IPv4</body></html>' > 127.0.0.1/index.html
echo '<html><body>IPv6</body></html>' > ::1/index.html
echo 'GET / HTTP/1.1
Host: 127.0.0.1
GET / HTTP/1.1
Host: 127.0.0.1:80
GET / HTTP/1.1
Host: ::1
GET / HTTP/1.1
Host: [::1]:80
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
for len in 0 1 2 3; do
for min in 0 1 2 3 ''; do
for max in 0 1 2 3 ''; do
dd if=/dev/zero of=0/range bs=1 "count=${len}" 2>/dev/null
echo "--- httpd handles Range request \"${min}-${max}\" and length ${len}"
echo "GET range HTTP/1.0
Range: bytes=${min}-${max}
" | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
done
done
done
echo '--- httpd handles Range request with ,'
echo 'GET range HTTP/1.0
Range: bytes=0-1,1-2
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd rejects Range request with big number (long long overflow)'
echo 'GET range HTTP/1.0
Range: bytes=-9223372036854775808
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd rejects Range request with big number (long long overflow)'
echo 'GET range HTTP/1.0
Range: bytes=-10000000000000000000000000
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
mkdir -p '@dXNlcjpwYXNzd29yZA/authhost'
echo 'authorized' > '@dXNlcjpwYXNzd29yZA/authhost/auth'
rm -f authhost
mkfifo authhost
echo '--- httpd handles basic authorization'
echo 'GET auth HTTP/1.0
Host: authhost
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd handles basic authorization'
echo 'GET auth HTTP/1.0
Host: authhost
Authorization: basic dXNlcjpwYXNzd29yZA==
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd handles 8 custom headers'
echo 'GET foo HTTP/1.0
Host: 0
' | ( ./httpd -h '1: 1' -h '2: 2' -h '3: 3' -h '4: 4' -h '5: 5' -h '6: 6' -h '7: 7' -h '8: 8' 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd rejects more than 8 custom headers'
echo 'GET foo HTTP/1.0
Host: 0
' | ( ./httpd -q -h '1: 1' -h '2: 2' -h '3: 3' -h '4: 4' -h '5: 5' -h '6: 6' -h '7: 7' -h '8: 8' -h 'a: a' 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
for badheader in '' 'nocolon' 'twocolon: x:x' 'nocolonspace:x' ' firstcharacterisiaspace: x' ' firstcharacterisiatab: x' 'nonprintablecr: ' 'colonattheend:' 'spaceattheend: '; do
echo "--- httpd rejects bad header \"${badheader}\""
echo 'GET foo HTTP/1.0
Host: 0
' | ( ./httpd -q -h "${badheader}" 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
done
echo '--- httpd accepts -t timeout'
echo 'GET foo HTTP/1.0
Host: 0
' | ( ./httpd -t 10 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd accepts -T timeout'
echo 'GET foo HTTP/1.0
Host: 0
' | ( ./httpd -T 10 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
for opt in '-t' '-T'; do
for badtm in '' 'badtimeout' '10badtimeout' '0' '-1' '86401'; do
echo "--- httpd rejects ${opt} \"${badtm}\""
echo 'GET foo HTTP/1.0
Host: 0
' | ( ./httpd -q "${opt}" "${badtm}" 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
done
done
exit 0