Browse Source

moved most of the tests to run-tests.pl

- more tests
- less code to maintain
- more speed


git-svn-id: svn://svn.lighttpd.net/lighttpd/trunk@42 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/release-1.3.12
Jan Kneschke 17 years ago
parent
commit
9c380cbbde
  1. 84
      tests/Makefile.am
  2. 16
      tests/auth-01.sh
  3. 17
      tests/auth-02.sh
  4. 17
      tests/auth-03.sh
  5. 16
      tests/basic-01.sh
  6. 18
      tests/basic-02.sh
  7. 17
      tests/basic-03.sh
  8. 17
      tests/basic-05.sh
  9. 16
      tests/basic-06.sh
  10. 23
      tests/basic-07.sh
  11. 16
      tests/basic-08.sh
  12. 16
      tests/basic-09.sh
  13. 21
      tests/basic-10.sh
  14. 21
      tests/basic-11.sh
  15. 18
      tests/broken-header-01.sh
  16. 17
      tests/broken-key-01.sh
  17. 17
      tests/broken-key-02.sh
  18. 17
      tests/broken-key-03.sh
  19. 18
      tests/broken-key-04.sh
  20. 16
      tests/cgi-01.sh
  21. 17
      tests/cgi-02.sh
  22. 17
      tests/cgi-03.sh
  23. 32
      tests/content-01.sh
  24. 32
      tests/content-02.sh
  25. 32
      tests/content-03.sh
  26. 36
      tests/content-04.sh
  27. 18
      tests/content-length-01.sh
  28. 18
      tests/content-length-02.sh
  29. 18
      tests/content-length-03.sh
  30. 18
      tests/content-length-04.sh
  31. 18
      tests/content-length-05.sh
  32. 18
      tests/continue-01.sh
  33. 2
      tests/docroot/123/dummyfile.bla
  34. 17
      tests/host-01.sh
  35. 16
      tests/host-02.sh
  36. 17
      tests/host-03.sh
  37. 17
      tests/host-04.sh
  38. 17
      tests/host-05.sh
  39. 17
      tests/http11-01.sh
  40. 18
      tests/http11-02.sh
  41. 16
      tests/http11-03.sh
  42. 17
      tests/leak-01.sh
  43. 17
      tests/leak-02.sh
  44. 17
      tests/leak-03.sh
  45. 17
      tests/leak-04.sh
  46. 17
      tests/leak-05.sh
  47. 17
      tests/leak-06.sh
  48. 17
      tests/leak-07.sh
  49. 17
      tests/leak-08.sh
  50. 17
      tests/leak-09.sh
  51. 17
      tests/leak-10.sh
  52. 17
      tests/leak-11.sh
  53. 17
      tests/leak-12.sh
  54. 17
      tests/leak-13.sh
  55. 17
      tests/leak-14.sh
  56. 17
      tests/leak-15.sh
  57. 17
      tests/leak-16.sh
  58. 17
      tests/leak-17.sh
  59. 16
      tests/missing-01.sh
  60. 16
      tests/missing-02.sh
  61. 16
      tests/post-01.sh
  62. 18
      tests/post-02.sh
  63. 17
      tests/redirect-01.sh
  64. 17
      tests/redirect-02.sh
  65. 17
      tests/redirect-03.sh
  66. 980
      tests/run-tests.pl

84
tests/Makefile.am

@ -1,106 +1,28 @@
# lighttpd.conf and conformance.pl expect this directory
testdir=/tmp/lighttpd/
if CHECK_WITH_FASTCGI
check_PROGRAMS=fcgi-auth
fcgi_auth_SOURCES=fcgi-auth.c
fcgi_auth_LDADD=-lfcgi
endif
TESTS=\
prepare.sh \
basic-01.sh \
basic-02.sh \
basic-03.sh \
basic-05.sh \
basic-06.sh \
basic-07.sh \
basic-08.sh \
basic-09.sh \
basic-10.sh \
basic-11.sh \
bug-urldecode-00.sh \
check.pl \
bug-03.sh \
bug-06.sh \
bug-12.sh \
bug-14.sh \
bug-15.sh \
bug-15-2.sh \
bug-15-3.sh \
broken-header-01.sh \
content-length-01.sh \
content-length-02.sh \
content-length-03.sh \
content-length-04.sh \
content-length-05.sh \
head-01.sh \
post-01.sh \
post-02.sh \
host-01.sh \
host-02.sh \
host-03.sh \
host-04.sh \
host-05.sh \
http11-01.sh \
http11-02.sh \
http11-03.sh \
missing-01.sh \
missing-02.sh \
large-header-01.sh \
accessdeny-01.sh \
cgi-01.sh \
cgi-02.sh \
cgi-03.sh \
compress-01.sh \
compress-02.sh \
compress-03.sh \
compress-04.sh \
fastcgi-01.sh \
fastcgi-02.sh \
fastcgi-03.sh \
fastcgi-04.sh \
fastcgi-05.sh \
fastcgi-06.sh \
fastcgi-07.sh \
fastcgi-08.sh \
fastcgi-09.sh \
fastcgi-10.sh \
fastcgi-11.sh \
fastcgi-12.sh \
fastcgi-13.sh \
auth-01.sh \
auth-02.sh \
auth-03.sh \
content-01.sh \
content-02.sh \
content-03.sh \
content-04.sh \
leak-01.sh \
leak-02.sh \
leak-03.sh \
leak-04.sh \
leak-05.sh \
leak-06.sh \
leak-07.sh \
leak-08.sh \
leak-09.sh \
leak-10.sh \
leak-11.sh \
leak-12.sh \
leak-13.sh \
leak-14.sh \
leak-15.sh \
leak-16.sh \
leak-17.sh \
redirect-01.sh \
redirect-02.sh \
redirect-03.sh \
pathinfo-01.sh \
pathinfo-02.sh \
broken-key-01.sh \
broken-key-02.sh \
broken-key-03.sh \
broken-key-04.sh \
continue-01.sh \
cleanup.sh
CONFS=fastcgi-10.conf \

16
tests/auth-01.sh

@ -1,16 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
auth required, no token sent
GET /server-status HTTP/1.0
Status: 401
EOF
run_test

17
tests/auth-02.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
auth required, wrong token
GET /server-status HTTP/1.0
Authorization: Basic amFuOmphb
Status: 401
EOF
run_test

17
tests/auth-03.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
auth required, good token
GET /server-config HTTP/1.0
Authorization: Basic amFuOmphbg==
Status: 200
EOF
run_test

16
tests/basic-01.sh

@ -1,16 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
valid request
GET / HTTP/1.0
Status: 200
EOF
run_test

18
tests/basic-02.sh

@ -1,18 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Missing Protocol
GET /
Status: 400
Protocol: HTTP/0.9
EOF
run_test

17
tests/basic-03.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Missing Protocol + Unknown Method
ABC /
Status: 400
Protocol: HTTP/0.9
EOF
run_test

17
tests/basic-05.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Broken Request Header
ASd
Status: 400
Protocol: HTTP/0.9
EOF
run_test

16
tests/basic-06.sh

@ -1,16 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Unknown Method
ABC / HTTP/1.0
Status: 501
EOF
run_test

23
tests/basic-07.sh

@ -1,23 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
##
# using a higher protocol is always allowed as we can
# downgrade the protocol on our own in the response
#
cat > $TMPFILE <<EOF
Protocoll == HTTP/1.3
GET / HTTP/1.3
Host: testbase.home.kneschke.de
Status: 505
EOF
run_test

16
tests/basic-08.sh

@ -1,16 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
HTTP/1.1, with missing host
GET / HTTP/1.1
Status: 400
EOF
run_test

16
tests/basic-09.sh

@ -1,16 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
HTTP/1.0, host in URI
GET http://www.yahoo.com/ HTTP/1.0
Status: 200
EOF
run_test

21
tests/basic-10.sh

@ -1,21 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
##
# apache excepts broken request headers
#
#
cat > $TMPFILE <<EOF
broken requestline (4 fields)
GET http://www.yahoo.com/ HTTP/1.0 jsdh
Status: 400
EOF
run_test

21
tests/basic-11.sh

@ -1,21 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
##
#
# apache sends 400
#
cat > $TMPFILE <<EOF
Docroot protection
GET /../ HTTP/1.0
Status: 200
EOF
run_test

18
tests/broken-header-01.sh

@ -1,18 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Header appears twice
GET / HTTP/1.0
Foo: foo
Foo: foo
Status: 200
EOF
run_test

17
tests/broken-key-01.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Broken Key-Value pairs
GET / HTTP/1.0
ABC : jsajfsfdg
Status: 200
EOF
run_test

17
tests/broken-key-02.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Broken Key-Value pairs
GET / HTTP/1.0
ABC a: jsajfsfdg
Status: 400
EOF
run_test

17
tests/broken-key-03.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Broken Key-Value pairs
GET / HTTP/1.0
ABC:jsajfsfdg
Status: 200
EOF
run_test

18
tests/broken-key-04.sh

@ -1,18 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Broken Key-Value pairs
GET / HTTP/1.0
ABC : jsajfsfdg
kde.org
Status: 200
EOF
run_test

16
tests/cgi-01.sh

@ -1,16 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
CGI
GET /cgi.pl HTTP/1.0
Status: 200
EOF
run_test

17
tests/cgi-02.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
CGI - SCRIPT_NAME (+pathinfo)
GET /cgi.pl/foo HTTP/1.0
Status: 200
Content: /cgi.pl
EOF
run_test

17
tests/cgi-03.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
CGI + pathinfo
GET /cgi-pathinfo.pl/foo HTTP/1.0
Status: 200
Content: /foo
EOF
run_test

32
tests/content-01.sh

@ -1,32 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
docroot=/tmp/lighttpd/servers/123.example.org/pages/
reqfile=12345.txt
test -d $docroot || exit 77
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Content-Type
GET /$reqfile HTTP/1.0
Host: 123.example.org
Content-Type: text/plain
EOF
run_test_script
if test x$exitcode = x0; then
if cat $NAME.out | sed '1,/^.$/d' | cmp - $docroot/$reqfile; then
a=a
else
exitcode=-1
fi
fi
run_test_exit

32
tests/content-02.sh

@ -1,32 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
docroot=/tmp/lighttpd/servers/123.example.org/pages/
reqfile=12345.html
test -d $docroot || exit 77
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Content-Type
GET /$reqfile HTTP/1.0
Host: 123.example.org
Content-Type: text/html
EOF
run_test_script
if test x$exitcode = x0; then
if cat $NAME.out | sed '1,/^.$/d' | cmp - $docroot/$reqfile; then
a=a
else
exitcode=-1
fi
fi
run_test_exit

32
tests/content-03.sh

@ -1,32 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
docroot=/tmp/lighttpd/servers/123.example.org/pages/
reqfile=dummyfile.bla
test -d $docroot || exit 77
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Content-Type
GET /$reqfile HTTP/1.0
Host: 123.example.org
Content-Type: application/octet-stream
EOF
run_test_script
if test x$exitcode = x0; then
if cat $NAME.out | sed '1,/^.$/d' | cmp - $docroot/$reqfile; then
a=a
else
exitcode=-1
fi
fi
run_test_exit

36
tests/content-04.sh

@ -1,36 +0,0 @@
#!/bin/sh
if pidof php > /dev/null; then
echo -n
else
printf "%-40s" "Getting PHP code"
exit 77
fi
test x$srcdir = x && srcdir=.
docroot=/tmp/lighttpd/servers/123.example.org/pages/
reqfile=phpinfo.php
test -d $docroot || exit 77
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Content-Type
GET /$reqfile HTTP/1.0
Host: 123.example.org
EOF
run_test_script
if test x$exitcode = x0; then
# got the source of the php-file
if cat $NAME.out | sed '1,/^.$/d' | cmp - $docroot/$reqfile; then
exitcode=-1
fi > /dev/null
fi
run_test_exit

18
tests/content-length-01.sh

@ -1,18 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Content-Length, HTML
GET /12345.html HTTP/1.0
Host: 123.example.org
Status: 200
Content-Length: 6
EOF
run_test

18
tests/content-length-02.sh

@ -1,18 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Content-Length, HTML
GET /12345.txt HTTP/1.0
Host: 123.example.org
Status: 200
Content-Length: 6
EOF
run_test

18
tests/content-length-03.sh

@ -1,18 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Content-Length < 0
POST /12345.txt HTTP/1.0
Host: 123.example.org
Content-Length: -473
Status: 400
EOF
run_test

18
tests/content-length-04.sh

@ -1,18 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Content-Length < 0
POST /12345.txt HTTP/1.0
Host: 123.example.org
Content-Length: 2147483648
Status: 413
EOF
run_test

18
tests/content-length-05.sh

@ -1,18 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Content-Length < 0
POST /12345.txt HTTP/1.0
Host: 123.example.org
Content-Length:
Status: 411
EOF
run_test

18
tests/continue-01.sh

@ -1,18 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Continue Handling
GET / HTTP/1.1
Connection: Close
Expect: 100-continue
Status: 417
EOF
run_test

2
tests/docroot/123/dummyfile.bla

@ -1 +1 @@
ߤ¨*rð.üGC䳜‰nÑ$ê�.ª!bgX¥8{©³[)ûx¸”žÕTª­¨ç¸jã+ ò~ Ä/V¼¼U�ŒúCI vn{ÀXKïFŽÝÍܸ¥íyÕ Â(bE¨¼çD‡>ŒÏÛ†[Q ²¦´ :±ô=¬H+Ç>{ó½fK�ÝÆaO€ûžod¹ šï$ÜÍ­ÎUïayø«Üç&QWÑ$¡§Œšóqìu~&o^Û5ˆ�&….¶ë˜04gšt€.nä ¤Ò…O28%W @;8Ì&4 k9¸h/«Ú™Zø £™m°ÅÁ[ä´ß¿0õìL@úÖÐè'^øjfð–‹bJ ¼ðí±cAÖ/i‹>.§ÆÔPxüÛ–ÝiÐ2„HîÅʇḻ48ÿËÄ'ZkÎàÀþ¼&¡!?@Fü-o©j&€Âÿ}õ¹`1Í«!ϸ�¤†
12345

17
tests/host-01.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Host set to weigon.dyndns.org
GET / HTTP/1.0
Host: weigon.dyndns.org
Status: 200
EOF
run_test

16
tests/host-02.sh

@ -1,16 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Host not set
GET / HTTP/1.0
Status: 200
EOF
run_test

17
tests/host-03.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Host not set
GET / HTTP/1.0
Host: grisu.home.kneschke.de
Status: 200
EOF
run_test

17
tests/host-04.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Host not set
GET / HTTP/1.0
Host: ../123.org/
Status: 400
EOF
run_test

17
tests/host-05.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
IPv6
GET / HTTP/1.0
Host: [::1]:80
Status: 200
EOF
run_test

17
tests/http11-01.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
valid HTTP/1.1 request
GET / HTTP/1.1
Host: weigon.dyndns.org
Status: 200
EOF
run_test

18
tests/http11-02.sh

@ -1,18 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
valid HTTP/1.1 request + req: Date
GET / HTTP/1.1
Host: weigon.dyndns.org
Status: 200
MUST: Date
EOF
run_test

16
tests/http11-03.sh

@ -1,16 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
HTTP/1.0 + absoluteURI
GET http://www.example.org/ HTTP/1.0
Status: 200
EOF
run_test

17
tests/leak-01.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Host: leading dot
GET / HTTP/1.0
Host: .jsdh.sfdg.sdfg.
Status: 400
EOF
run_test

17
tests/leak-02.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Host: good name
GET / HTTP/1.0
Host: jsdh.sfdg.sdfg
Status: 200
EOF
run_test

17
tests/leak-03.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Host: two dots
GET / HTTP/1.0
Host: .jsdh..sfdg.sdfg
Status: 400
EOF
run_test

17
tests/leak-04.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Host: trailing dot
GET / HTTP/1.0
Host: .jsdh.sfdg.sdfg.:aasd
Status: 400
EOF
run_test

17
tests/leak-05.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Host: missing host
GET / HTTP/1.0
Host: :.jsdh.sfdg.sdfg.
Status: 400
EOF
run_test

17
tests/leak-06.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Host: broken host/port
GET / HTTP/1.0
Host: .jsdh.sfdg.:sdfg.
Status: 400
EOF
run_test

17
tests/leak-07.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Host: broken name/port
GET / HTTP/1.0
Host: ..jsdh..sfdg..:sdfg.
Status: 400
EOF
run_test

17
tests/leak-08.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Host: good name
GET / HTTP/1.0
Host: abc.de
Status: 200
EOF
run_test

17
tests/leak-09.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Host: good name
GET / HTTP/1.0
Host: a-b.de
Status: 200
EOF
run_test

17
tests/leak-10.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Host: leading dash
GET / HTTP/1.0
Host: -ab.de
Status: 400
EOF
run_test

17
tests/leak-11.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Host: good name
GET / HTTP/1.0
Host: a-b.de124
Status: 200
EOF
run_test

17
tests/leak-12.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Host: broken name
GET / HTTP/1.0
Host: .
Status: 400
EOF
run_test

17
tests/leak-13.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Host: broken port
GET / HTTP/1.0
Host: abc.de:avs
Status: 400
EOF
run_test

17
tests/leak-14.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Host: good name
GET / HTTP/1.0
Host: abc.de:1234
Status: 200
EOF
run_test

17
tests/leak-15.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Host: good IP
GET / HTTP/1.0
Host: 192.168.2.10:1234
Status: 200
EOF
run_test

17
tests/leak-16.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Host: broken name/ip
GET / HTTP/1.0
Host: a192.168.2.10:1234
Status: 400
EOF
run_test

17
tests/leak-17.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Host: broken IP
GET / HTTP/1.0
Host: 192.168.2:1234
Status: 400
EOF
run_test

16
tests/missing-01.sh

@ -1,16 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
missing file
GET /cjhdhfdjgfdg HTTP/1.0
Status: 404
EOF
run_test

16
tests/missing-02.sh

@ -1,16 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
missing file + get-vars
GET /cjhdhfdjgfdg?jdfjh=dnfdh HTTP/1.0
Status: 404
EOF
run_test

16
tests/post-01.sh

@ -1,16 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
POST without Content-Length
POST / HTTP/1.0
Status: 411
EOF
run_test

18
tests/post-02.sh

@ -1,18 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
POST without Content-Length
POST / HTTP/1.0
Content-type: application/x-www-form-urlencoded
Content-length: 0
Status: 200
EOF
run_test

17
tests/redirect-01.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
Internal Redirect
GET /dummydir HTTP/1.0
Status: 301
Location: http://localhost:2048/dummydir/
EOF
run_test

17
tests/redirect-02.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
redirect module test
GET /redirect/ HTTP/1.0
Status: 301
Location: http://localhost:2048/
EOF
run_test

17
tests/redirect-03.sh

@ -1,17 +0,0 @@
#!/bin/sh
test x$srcdir = x && srcdir=.
. $srcdir/testbase.sh
prepare_test
cat > $TMPFILE <<EOF
redirect module test
GET /dummydir?foo HTTP/1.0
Status: 301
Location: http://localhost:2048/dummydir/?foo
EOF
run_test

980
tests/run-tests.pl

@ -0,0 +1,980 @@
#! /usr/bin/perl -w
use strict;
use IO::Socket;
use Test::More tests => 87;
my $testname;
my @request;
my @response;
my $configfile = 'lighttpd.conf';
my $lighttpd_path = '../src/lighttpd';
my $pidfile = '/tmp/lighttpd/lighttpd.pid';
my $pidoffile = '/tmp/lighttpd/pidof.pid';
sub pidof {
my $prog = $_[0];
system("ps ax | grep $prog | awk '{ print \$1 }' > $pidoffile") or
system("ps -ef | grep $prog | awk '{ print \$1 }' > $pidoffile") or
return -1;
open F, $pidfile or return -1;
my $pid = <F>;
close F;
return $pid;
}
sub stop_proc {
open F, $pidfile or return -1;
my $pid = <F>;
close F;
kill('TERM',$pid) or return -1;
return 0;
}
sub start_proc {
# kill old proc if necessary
stop_proc;
unlink($pidfile);
system($lighttpd_path." -f ".$configfile);
if (-e $pidfile) {
return 0;
} else {
return -1;
}
}
sub handle_http {
my $EOL = "\015\012";
my $BLANK = $EOL x 2;
my $port = 2048;
my $host = "127.0.0.1";
my $remote =
IO::Socket::INET->new(Proto => "tcp",
PeerAddr => $host,
PeerPort => $port)
or return -1;
$remote->autoflush(1);
foreach(@request) {
# pipeline requests
s/\r//g;
s/\n/$EOL/g;
print $remote $_.$BLANK;
}
my $lines = "";
# read everything
while(<$remote>) {
$lines .= $_;
}
close $remote;
my $href;
foreach $href (@response) {
# first line is always response header
my %resp_hdr;
my $resp_body;
my $resp_line;
my $conditions = $_;
for (my $ln = 0; defined $lines; $ln++) {
(my $line, $lines) = split($EOL, $lines, 2);
# header finished
last if(length($line) == 0);
if ($ln == 0) {
# response header
$resp_line = $line;
} else {
# response vars
if ($line =~ /^([^:]+):\s*(.+)$/) {
(my $h = $1) =~ tr/[A-Z]/[a-z]/;
$resp_hdr{$h} = $2;
} else {
return -1;
}
}
}
# check length
if (defined $resp_hdr{"content-length"}) {
($resp_body, $lines) = split("^.".$resp_hdr{"content-length"}, $lines, 2);
} else {
$resp_body = $lines;
undef $lines;
}
# check conditions
if ($resp_line =~ /^(HTTP\/1\.[01]) ([0-9]{3}) .+$/) {
if ($href->{'HTTP-Protocol'} ne $1) {
diag(sprintf("proto failed: expected '%s', got '%s'\n", $href->{'HTTP-Protocol'}, $1));
return -1;
}
if ($href->{'HTTP-Status'} ne $2) {
diag(sprintf("status failed: expected '%s', got '%s'\n", $href->{'HTTP-Status'}, $2));
return -1;
}
} else {
return -1;
}
if (defined $href->{'HTTP-Content'}) {
if ($href->{'HTTP-Content'} ne $resp_body) {
diag(sprintf("body failed: expected '%s', got '%s'\n", $href->{'HTTP-Content'}, $resp_body));
return -1;
}
}
if (defined $href->{'-HTTP-Content'}) {
if (defined $resp_body && $resp_body ne '') {
diag(sprintf("body failed: expected empty body, got '%s'\n", $resp_body));
return -1;
}
}
foreach (keys %{ $href }) {
next if $_ eq 'HTTP-Protocol';
next if $_ eq 'HTTP-Status';
next if $_ eq 'HTTP-Content';
next if $_ eq '-HTTP-Content';
(my $k = $_) =~ tr/[A-Z]/[a-z]/;
my $no_val = 0;
if (substr($k, 0, 1) eq '+') {
$k = substr($k, 1);
$no_val = 1;
}
if (!defined $resp_hdr{$k}) {
diag(sprintf("required header '%s' is missing\n", $_));
return -1;
}
if ($no_val == 0 &&
$href->{$_} ne $resp_hdr{$k}) {
diag(sprintf("response-header failed: expected '%s', got '%s'\n", $href->{$_}, $resp_hdr{$k}));
return -1;
}
}
}
# we should have sucked up everything
return -1 if (defined $lines);
return 0;
}
print "\nStart-Up\n";
ok(start_proc == 0, "Starting lighttpd") or die();
print "\nRequest Line\n";
@request = ( <<EOF
GET / HTTP/1.0
EOF
);
@response = ( { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } );
ok(handle_http == 0, 'Valid HTTP/1.0 Request') or die();
@request = ( <<EOF
GET /
EOF
);
@response = ( { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 400 } );
ok(handle_http == 0, 'missing Protocol');
@request = ( <<EOF
BC /
EOF
);
@response = ( { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 400 } );
ok(handle_http == 0, 'missing protocol + unknown method');
@request = ( <<EOF
ABC
EOF
);
@response = ( { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 400 } );
ok(handle_http == 0, 'missing protocol + unknown method + missing URI');
@request = ( <<EOF
ABC / HTTP/1.0
EOF
);
@response = ( { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 501 } );
ok(handle_http == 0, 'unknown method');
@request = ( <<EOF
GET / HTTP/1.3
EOF
);
@response = ( { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 505 } );
ok(handle_http == 0, 'unknown protocol');
@request = ( <<EOF
GET http://www.example.org/ HTTP/1.0
EOF
);
@response = ( { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } );
ok(handle_http == 0, 'absolute URI');
print "\nLow-Level Request-Header Parsing\n";
@request = ( <<EOF
GET / HTTP/1.0
ABC : foo
EOF
);
@response = ( { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } );
ok(handle_http == 0, 'whitespace after key');
@request = ( <<EOF
GET / HTTP/1.0
ABC a: foo
EOF
);
@response = ( { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 400 } );
ok(handle_http == 0, 'whitespace with-in key');
@request = ( <<EOF
GET / HTTP/1.0
ABC:foo
EOF
);
@response = ( { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } );
ok(handle_http == 0, 'no whitespace');
@request = ( <<EOF
GET / HTTP/1.0
ABC:foo
bc
EOF
);
@response = ( { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } );
ok(handle_http == 0, 'line-folding');
print "\nLow-Level Request-Header Parsing - URI\n";
@request = ( <<EOF
GET /index%2ehtml HTTP/1.0
EOF
);
@response = ( { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } );
ok(handle_http == 0, 'URL-encoding');
@request = ( <<EOF
GET /index.html%00 HTTP/1.0
EOF
);
@response = ( { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } );
ok(handle_http == 0, 'URL-encoding, %00');
print "\nLow-Level Request-Header Parsing - Host:\n";
@request = ( <<EOF
GET / HTTP/1.0
Host: www.example.org
EOF
);
@response = ( { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } );
ok(handle_http == 0, 'hostname');
@request = ( <<EOF
GET / HTTP/1.0