diff options
author | Arno Töll <arno@debian.org> | 2012-11-21 23:03:51 +0100 |
---|---|---|
committer | Arno Töll <arno@debian.org> | 2012-11-21 23:03:51 +0100 |
commit | f1532bfdd56dc641ae366f6ecd4c490c11117aac (patch) | |
tree | e58012163da210efa84fdbdcefd069ee511fd3e4 /tests | |
parent | 3f9e670856f606be4d9899e2d2a9ed4708575f10 (diff) | |
download | lighttpd-f1532bfdd56dc641ae366f6ecd4c490c11117aac.tar.gz |
Imported Upstream version 1.4.19upstream/1.4.19
Diffstat (limited to 'tests')
33 files changed, 596 insertions, 92 deletions
diff --git a/tests/LightyTest.pm b/tests/LightyTest.pm index 33eca61..6e3f5c2 100755 --- a/tests/LightyTest.pm +++ b/tests/LightyTest.pm @@ -72,7 +72,7 @@ sub stop_proc { if (defined $pid) { kill('TERM',$pid) or return -1; - select(undef, undef, undef, 0.01); + select(undef, undef, undef, 0.1); } return 0; @@ -92,6 +92,8 @@ sub start_proc { unlink($self->{LIGHTTPD_PIDFILE}); if (defined $ENV{"TRACEME"} && $ENV{"TRACEME"} eq 'strace') { system("strace -tt -s 512 -o strace ".$self->{LIGHTTPD_PATH}." -D -f ".$self->{SRCDIR}."/".$self->{CONFIGFILE}." -m ".$self->{MODULES_PATH}." &"); + } elsif (defined $ENV{"TRACEME"} && $ENV{"TRACEME"} eq 'truss') { + system("/usr/dtrctkit/bin/dtruss -d -e ".$self->{LIGHTTPD_PATH}." -D -f ".$self->{SRCDIR}."/".$self->{CONFIGFILE}." -m ".$self->{MODULES_PATH}." 2> strace &"); } elsif (defined $ENV{"TRACEME"} && $ENV{"TRACEME"} eq 'valgrind') { system("valgrind --tool=memcheck --show-reachable=yes --leak-check=yes --log-file=valgrind ".$self->{LIGHTTPD_PATH}." -D -f ".$self->{SRCDIR}."/".$self->{CONFIGFILE}." -m ".$self->{MODULES_PATH}." &"); } else { diff --git a/tests/Makefile.am b/tests/Makefile.am index dfdf06b..c353730 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -31,14 +31,20 @@ CONFS=fastcgi-10.conf \ core-response.t \ core-keepalive.t \ core.t \ + mod-proxy.t \ + proxy.conf \ + mod-secdownload.t \ mod-access.t \ mod-auth.t \ mod-cgi.t \ mod-compress.t \ mod-fastcgi.t \ mod-redirect.t \ - mod-userdir.t \ mod-rewrite.t \ + mod-userdir.t \ + env-variables.t \ + env-variables.conf \ + symlink.t \ request.t \ mod-ssi.t \ LightyTest.pm \ @@ -49,12 +55,12 @@ CONFS=fastcgi-10.conf \ core-404-handler.t \ 404-handler.conf - TESTS_ENVIRONMENT=$(srcdir)/wrapper.sh $(srcdir) $(top_builddir) EXTRA_DIST=wrapper.sh lighttpd.conf \ lighttpd.user \ lighttpd.htpasswd \ + SConscript \ $(CONFS) \ $(TESTS) diff --git a/tests/Makefile.in b/tests/Makefile.in index 429efd1..4a792b1 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -244,14 +244,20 @@ CONFS = fastcgi-10.conf \ core-response.t \ core-keepalive.t \ core.t \ + mod-proxy.t \ + proxy.conf \ + mod-secdownload.t \ mod-access.t \ mod-auth.t \ mod-cgi.t \ mod-compress.t \ mod-fastcgi.t \ mod-redirect.t \ - mod-userdir.t \ mod-rewrite.t \ + mod-userdir.t \ + env-variables.t \ + env-variables.conf \ + symlink.t \ request.t \ mod-ssi.t \ LightyTest.pm \ @@ -266,6 +272,7 @@ TESTS_ENVIRONMENT = $(srcdir)/wrapper.sh $(srcdir) $(top_builddir) EXTRA_DIST = wrapper.sh lighttpd.conf \ lighttpd.user \ lighttpd.htpasswd \ + SConscript \ $(CONFS) \ $(TESTS) diff --git a/tests/SConscript b/tests/SConscript new file mode 100644 index 0000000..07c76c9 --- /dev/null +++ b/tests/SConscript @@ -0,0 +1,45 @@ +Import('env') + +tests = Split('prepare.sh \ + run-tests.pl \ + cleanup.sh') + +extra_dist = Split('fastcgi-10.conf \ + fastcgi-auth.conf \ + fastcgi-responder.conf \ + fastcgi-13.conf \ + bug-06.conf \ + bug-12.conf \ + core-var-include.t \ + var-include.conf \ + var-include-sub.conf \ + condition.conf \ + core-condition.t \ + core-request.t \ + core-response.t \ + core-keepalive.t \ + core.t \ + mod-access.t \ + mod-auth.t \ + mod-cgi.t \ + mod-compress.t \ + mod-fastcgi.t \ + mod-redirect.t \ + mod-userdir.t \ + mod-rewrite.t \ + request.t \ + mod-ssi.t \ + LightyTest.pm \ + mod-setenv.t') + +t = env.Command('foo1', 'prepare.sh', '(cd ./tests/; ./prepare.sh; cd ..)') +t += env.Command('foo2', 'run-tests.pl', '( cd ./tests/; SHELL=/bin/sh ./run-tests.pl; cd ..)') +t += env.Command('foo3', 'cleanup.sh', '(cd ./tests/; ./cleanup.sh; cd ..)') + +if env['LIBFCGI']: + fcgis = [] + fcgis += env.Program("fcgi-auth", "fcgi-auth.c", LIBS=env['LIBFCGI']) + fcgis += env.Program("fcgi-responder", "fcgi-responder.c", LIBS=env['LIBFCGI']) + env.Depends(t, fcgis) + +env.Alias('check', t ) diff --git a/tests/cachable.t b/tests/cachable.t index 0d1e1b4..605a68f 100755 --- a/tests/cachable.t +++ b/tests/cachable.t @@ -1,9 +1,9 @@ #!/usr/bin/env perl BEGIN { - # add current source dir to the include-path - # we need this for make distcheck - (my $srcdir = $0) =~ s#/[^/]+$#/#; - unshift @INC, $srcdir; + # add current source dir to the include-path + # we need this for make distcheck + (my $srcdir = $0) =~ s,/[^/]+$,/,; + unshift @INC, $srcdir; } use strict; diff --git a/tests/core-404-handler.t b/tests/core-404-handler.t index b9c5df1..599ade2 100644 --- a/tests/core-404-handler.t +++ b/tests/core-404-handler.t @@ -10,10 +10,10 @@ # returning no status -> 200 # BEGIN { - # add current source dir to the include-path - # we need this for make distcheck - (my $srcdir = $0) =~ s#/[^/]+$#/#; - unshift @INC, $srcdir; + # add current source dir to the include-path + # we need this for make distcheck + (my $srcdir = $0) =~ s,/[^/]+$,/,; + unshift @INC, $srcdir; } use strict; diff --git a/tests/core-condition.t b/tests/core-condition.t index 96b05d8..53919a1 100755 --- a/tests/core-condition.t +++ b/tests/core-condition.t @@ -1,9 +1,9 @@ #!/usr/bin/env perl BEGIN { - # add current source dir to the include-path - # we need this for make distcheck - (my $srcdir = $0) =~ s#/[^/]+$#/#; - unshift @INC, $srcdir; + # add current source dir to the include-path + # we need this for make distcheck + (my $srcdir = $0) =~ s,/[^/]+$,/,; + unshift @INC, $srcdir; } use strict; diff --git a/tests/core-keepalive.t b/tests/core-keepalive.t index 8d91b4c..b4f51f9 100755 --- a/tests/core-keepalive.t +++ b/tests/core-keepalive.t @@ -1,10 +1,9 @@ #!/usr/bin/env perl - BEGIN { - # add current source dir to the include-path - # we need this for make distcheck - (my $srcdir = $0) =~ s#/[^/]+$#/#; - unshift @INC, $srcdir; + # add current source dir to the include-path + # we need this for make distcheck + (my $srcdir = $0) =~ s,/[^/]+$,/,; + unshift @INC, $srcdir; } use strict; diff --git a/tests/core-request.t b/tests/core-request.t index fc6e25f..a24777f 100755 --- a/tests/core-request.t +++ b/tests/core-request.t @@ -1,9 +1,9 @@ #!/usr/bin/env perl BEGIN { - # add current source dir to the include-path - # we need this for make distcheck - (my $srcdir = $0) =~ s#/[^/]+$#/#; - unshift @INC, $srcdir; + # add current source dir to the include-path + # we need this for make distcheck + (my $srcdir = $0) =~ s,/[^/]+$,/,; + unshift @INC, $srcdir; } use strict; diff --git a/tests/core-response.t b/tests/core-response.t index c7a158c..ff2cf1d 100755 --- a/tests/core-response.t +++ b/tests/core-response.t @@ -1,10 +1,9 @@ #!/usr/bin/env perl - BEGIN { - # add current source dir to the include-path - # we need this for make distcheck - (my $srcdir = $0) =~ s#/[^/]+$#/#; - unshift @INC, $srcdir; + # add current source dir to the include-path + # we need this for make distcheck + (my $srcdir = $0) =~ s,/[^/]+$,/,; + unshift @INC, $srcdir; } use strict; diff --git a/tests/core-var-include.t b/tests/core-var-include.t index b26790f..8161751 100755 --- a/tests/core-var-include.t +++ b/tests/core-var-include.t @@ -1,9 +1,9 @@ #!/usr/bin/env perl BEGIN { - # add current source dir to the include-path - # we need this for make distcheck - (my $srcdir = $0) =~ s#/[^/]+$#/#; - unshift @INC, $srcdir; + # add current source dir to the include-path + # we need this for make distcheck + (my $srcdir = $0) =~ s,/[^/]+$,/,; + unshift @INC, $srcdir; } use strict; diff --git a/tests/core.t b/tests/core.t index 6de933c..b196666 100755 --- a/tests/core.t +++ b/tests/core.t @@ -1,10 +1,9 @@ #!/usr/bin/env perl - BEGIN { - # add current source dir to the include-path - # we need this for make distcheck - (my $srcdir = $0) =~ s#/[^/]+$#/#; - unshift @INC, $srcdir; + # add current source dir to the include-path + # we need this for make distcheck + (my $srcdir = $0) =~ s,/[^/]+$,/,; + unshift @INC, $srcdir; } use strict; diff --git a/tests/env-variables.conf b/tests/env-variables.conf new file mode 100644 index 0000000..043e788 --- /dev/null +++ b/tests/env-variables.conf @@ -0,0 +1 @@ +server.document-root = env.CWD diff --git a/tests/env-variables.t b/tests/env-variables.t new file mode 100644 index 0000000..ee48ee9 --- /dev/null +++ b/tests/env-variables.t @@ -0,0 +1,21 @@ +#!/usr/bin/perl +BEGIN { + # add current source dir to the include-path + # we need this for make distcheck + (my $srcdir = $0) =~ s,/[^/]+$,/,; + unshift @INC, $srcdir; +} + +use strict; +use IO::Socket; +use Test::More tests => 2; +use LightyTest; + +my $tf = LightyTest->new(); +$tf->{CONFIGFILE} = 'env-variables.conf'; + +TODO: { + local $TODO = 'we still crash on undefined environment variables'; + ok($tf->start_proc == 0, "Starting lighttpd"); + ok($tf->stop_proc == 0, "Stopping lighttpd"); +}; diff --git a/tests/fcgi-auth.c b/tests/fcgi-auth.c index bb7ae69..26bbd0f 100644 --- a/tests/fcgi-auth.c +++ b/tests/fcgi-auth.c @@ -1,4 +1,6 @@ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #ifdef HAVE_FASTCGI_FASTCGI_H #include <fastcgi/fcgi_stdio.h> #else diff --git a/tests/fcgi-responder.c b/tests/fcgi-responder.c index 9270295..721c2ce 100644 --- a/tests/fcgi-responder.c +++ b/tests/fcgi-responder.c @@ -1,4 +1,6 @@ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #ifdef HAVE_FASTCGI_FASTCGI_H #include <fastcgi/fcgi_stdio.h> #else diff --git a/tests/lowercase.t b/tests/lowercase.t index b9ee8e8..f6f6f2c 100755 --- a/tests/lowercase.t +++ b/tests/lowercase.t @@ -1,9 +1,9 @@ #!/usr/bin/env perl BEGIN { - # add current source dir to the include-path - # we need this for make distcheck - (my $srcdir = $0) =~ s#/[^/]+$#/#; - unshift @INC, $srcdir; + # add current source dir to the include-path + # we need this for make distcheck + (my $srcdir = $0) =~ s,/[^/]+$,/,; + unshift @INC, $srcdir; } use strict; diff --git a/tests/mod-access.t b/tests/mod-access.t index 82275df..58c01ac 100755 --- a/tests/mod-access.t +++ b/tests/mod-access.t @@ -1,9 +1,9 @@ #!/usr/bin/env perl BEGIN { - # add current source dir to the include-path - # we need this for make distcheck - (my $srcdir = $0) =~ s#/[^/]+$#/#; - unshift @INC, $srcdir; + # add current source dir to the include-path + # we need this for make distcheck + (my $srcdir = $0) =~ s,/[^/]+$,/,; + unshift @INC, $srcdir; } use strict; diff --git a/tests/mod-auth.t b/tests/mod-auth.t index cfeb042..475a5f6 100755 --- a/tests/mod-auth.t +++ b/tests/mod-auth.t @@ -1,14 +1,14 @@ #!/usr/bin/env perl BEGIN { - # add current source dir to the include-path - # we need this for make distcheck - (my $srcdir = $0) =~ s#/[^/]+$#/#; - unshift @INC, $srcdir; + # add current source dir to the include-path + # we need this for make distcheck + (my $srcdir = $0) =~ s,/[^/]+$,/,; + unshift @INC, $srcdir; } use strict; use IO::Socket; -use Test::More tests => 13; +use Test::More tests => 14; use LightyTest; my $tf = LightyTest->new(); @@ -48,6 +48,16 @@ EOF $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; ok($tf->handle_http($t) == 0, 'Basic-Auth: Valid Auth-token - htpasswd (des)'); +$t->{REQUEST} = ( <<EOF +GET /server-config HTTP/1.0 +Host: auth-htpasswd.example.org +Authorization: basic ZGVzOmRlcw== +EOF + ); +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; +ok($tf->handle_http($t) == 0, 'Basic-Auth: Valid Auth-token - htpasswd (des) (lowercase)'); + + SKIP: { skip "no md5 for crypt under cygwin", 1 if $^O eq 'cygwin'; $t->{REQUEST} = ( <<EOF diff --git a/tests/mod-cgi.t b/tests/mod-cgi.t index b89a1af..24777ca 100755 --- a/tests/mod-cgi.t +++ b/tests/mod-cgi.t @@ -1,9 +1,9 @@ #!/usr/bin/env perl BEGIN { - # add current source dir to the include-path - # we need this for make distcheck - (my $srcdir = $0) =~ s#/[^/]+$#/#; - unshift @INC, $srcdir; + # add current source dir to the include-path + # we need this for make distcheck + (my $srcdir = $0) =~ s,/[^/]+$,/,; + unshift @INC, $srcdir; } use strict; diff --git a/tests/mod-compress.t b/tests/mod-compress.t index f243832..4fa66db 100755 --- a/tests/mod-compress.t +++ b/tests/mod-compress.t @@ -1,9 +1,9 @@ #!/usr/bin/env perl BEGIN { - # add current source dir to the include-path - # we need this for make distcheck - (my $srcdir = $0) =~ s#/[^/]+$#/#; - unshift @INC, $srcdir; + # add current source dir to the include-path + # we need this for make distcheck + (my $srcdir = $0) =~ s,/[^/]+$,/,; + unshift @INC, $srcdir; } use strict; diff --git a/tests/mod-fastcgi.t b/tests/mod-fastcgi.t index 2c1dedb..44b4b03 100755 --- a/tests/mod-fastcgi.t +++ b/tests/mod-fastcgi.t @@ -1,13 +1,13 @@ #!/usr/bin/env perl BEGIN { - # add current source dir to the include-path - # we need this for make distcheck - (my $srcdir = $0) =~ s#/[^/]+$#/#; - unshift @INC, $srcdir; + # add current source dir to the include-path + # we need this for make distcheck + (my $srcdir = $0) =~ s,/[^/]+$,/,; + unshift @INC, $srcdir; } use strict; -use Test::More tests => 46; +use Test::More tests => 47; use LightyTest; my $tf = LightyTest->new(); @@ -223,7 +223,7 @@ EOF } SKIP: { - skip "no php found", 4 unless -x "/usr/bin/php-cgi"; + skip "no php found", 5 unless -x "/usr/bin/php-cgi"; $tf->{CONFIGFILE} = 'fastcgi-13.conf'; ok($tf->start_proc == 0, "Starting lighttpd with $tf->{CONFIGFILE}") or die(); $t->{REQUEST} = ( <<EOF @@ -234,6 +234,15 @@ EOF $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; ok($tf->handle_http($t) == 0, 'FastCGI + local spawning'); + $t->{REQUEST} = ( <<EOF +HEAD /indexfile/index.php HTTP/1.0 +Host: www.example.org +EOF + ); + $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '-Content-Length' => '0' } ]; + # Of course a valid content-length != 0 would be ok, but we assume for now that such one is not generated. + ok($tf->handle_http($t) == 0, 'Check for buggy content length with HEAD'); + $t->{REQUEST} = ( <<EOF GET /get-env.php?env=MAIL HTTP/1.0 Host: www.example.org diff --git a/tests/mod-proxy.t b/tests/mod-proxy.t new file mode 100755 index 0000000..b43c465 --- /dev/null +++ b/tests/mod-proxy.t @@ -0,0 +1,53 @@ +#!/usr/bin/env perl +BEGIN { + # add current source dir to the include-path + # we need this for make distcheck + (my $srcdir = $0) =~ s,/[^/]+$,/,; + unshift @INC, $srcdir; +} + +use strict; +use IO::Socket; +use Test::More tests => 6; +use LightyTest; + +my $tf_real = LightyTest->new(); +my $tf_proxy = LightyTest->new(); + +my $t; + +## we need two procs +## 1. the real webserver +## 2. the proxy server + +$tf_real->{PORT} = 2048; +$tf_real->{CONFIGFILE} = 'lighttpd.conf'; +$tf_real->{LIGHTTPD_PIDFILE} = $tf_real->{TESTDIR}.'/tmp/lighttpd/lighttpd.pid'; + +$tf_proxy->{PORT} = 2050; +$tf_proxy->{CONFIGFILE} = 'proxy.conf'; +$tf_proxy->{LIGHTTPD_PIDFILE} = $tf_proxy->{TESTDIR}.'/tmp/lighttpd/lighttpd-proxy.pid'; + +ok($tf_real->start_proc == 0, "Starting lighttpd") or die(); + +ok($tf_proxy->start_proc == 0, "Starting lighttpd as proxy") or die(); + +$t->{REQUEST} = ( <<EOF +GET /index.html HTTP/1.0 +Host: www.example.org +EOF + ); +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; +ok($tf_proxy->handle_http($t) == 0, 'valid request'); + +$t->{REQUEST} = ( <<EOF +GET /index.html HTTP/1.0 +Host: www.example.org +EOF + ); +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'Server' => 'Apache 1.3.29' } ]; +ok($tf_proxy->handle_http($t) == 0, 'drop Server from real server'); + +ok($tf_proxy->stop_proc == 0, "Stopping lighttpd proxy"); + +ok($tf_real->stop_proc == 0, "Stopping lighttpd"); diff --git a/tests/mod-redirect.t b/tests/mod-redirect.t index 076a4b3..14669d9 100755 --- a/tests/mod-redirect.t +++ b/tests/mod-redirect.t @@ -1,9 +1,9 @@ #!/usr/bin/env perl BEGIN { - # add current source dir to the include-path - # we need this for make distcheck - (my $srcdir = $0) =~ s#/[^/]+$#/#; - unshift @INC, $srcdir; + # add current source dir to the include-path + # we need this for make distcheck + (my $srcdir = $0) =~ s,/[^/]+$,/,; + unshift @INC, $srcdir; } use strict; diff --git a/tests/mod-rewrite.t b/tests/mod-rewrite.t index a1e2193..4de8c10 100755 --- a/tests/mod-rewrite.t +++ b/tests/mod-rewrite.t @@ -1,9 +1,9 @@ #!/usr/bin/env perl BEGIN { - # add current source dir to the include-path - # we need this for make distcheck - (my $srcdir = $0) =~ s#/[^/]+$#/#; - unshift @INC, $srcdir; + # add current source dir to the include-path + # we need this for make distcheck + (my $srcdir = $0) =~ s,/[^/]+$,/,; + unshift @INC, $srcdir; } use strict; diff --git a/tests/mod-secdownload.t b/tests/mod-secdownload.t new file mode 100755 index 0000000..c8cad38 --- /dev/null +++ b/tests/mod-secdownload.t @@ -0,0 +1,79 @@ +#!/usr/bin/env perl +BEGIN { + # add current source dir to the include-path + # we need this for make distcheck + (my $srcdir = $0) =~ s,/[^/]+$,/,; + unshift @INC, $srcdir; +} + +use strict; +use IO::Socket; +use Test::More tests => 7; +use LightyTest; +use Digest::MD5 qw(md5_hex); + +my $tf = LightyTest->new(); +my $t; + +ok($tf->start_proc == 0, "Starting lighttpd") or die(); + +my $secret = "verysecret"; +my $f = "/index.html"; +my $thex = sprintf("%08x", time); +my $m = md5_hex($secret.$f.$thex); + +$t->{REQUEST} = ( <<EOF +GET /sec/$m/$thex$f HTTP/1.0 +Host: vvv.example.org +EOF + ); +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; + +ok($tf->handle_http($t) == 0, 'secdownload'); + +$thex = sprintf("%08x", time - 1800); +$m = md5_hex($secret.$f.$thex); + +$t->{REQUEST} = ( <<EOF +GET /sec/$m/$thex$f HTTP/1.0 +Host: vvv.example.org +EOF + ); +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 410 } ]; + +ok($tf->handle_http($t) == 0, 'secdownload - gone (timeout)'); + +$t->{REQUEST} = ( <<EOF +GET /sec$f HTTP/1.0 +Host: vvv.example.org +EOF + ); +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ]; + +ok($tf->handle_http($t) == 0, 'secdownload - direct access'); + +$t->{REQUEST} = ( <<EOF +GET $f HTTP/1.0 +Host: www.example.org +EOF + ); +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; + +ok($tf->handle_http($t) == 0, 'secdownload - conditional access'); + + +$f = "/noexists"; +$thex = sprintf("%08x", time); +$m = md5_hex($secret.$f.$thex); + +$t->{REQUEST} = ( <<EOF +GET /sec/$m/$thex$f HTTP/1.0 +Host: vvv.example.org +EOF + ); +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ]; + +ok($tf->handle_http($t) == 0, 'secdownload - timeout'); + +ok($tf->stop_proc == 0, "Stopping lighttpd"); + diff --git a/tests/mod-setenv.t b/tests/mod-setenv.t index a5c2b7e..1e56301 100755 --- a/tests/mod-setenv.t +++ b/tests/mod-setenv.t @@ -1,10 +1,9 @@ #!/usr/bin/env perl - BEGIN { - # add current source dir to the include-path - # we need this for make distcheck - (my $srcdir = $0) =~ s#/[^/]+$#/#; - unshift @INC, $srcdir; + # add current source dir to the include-path + # we need this for make distcheck + (my $srcdir = $0) =~ s,/[^/]+$,/,; + unshift @INC, $srcdir; } use strict; diff --git a/tests/mod-ssi.t b/tests/mod-ssi.t index a6b021b..d5d69db 100755 --- a/tests/mod-ssi.t +++ b/tests/mod-ssi.t @@ -1,9 +1,9 @@ #!/usr/bin/env perl BEGIN { - # add current source dir to the include-path - # we need this for make distcheck - (my $srcdir = $0) =~ s#/[^/]+$#/#; - unshift @INC, $srcdir; + # add current source dir to the include-path + # we need this for make distcheck + (my $srcdir = $0) =~ s,/[^/]+$,/,; + unshift @INC, $srcdir; } use strict; diff --git a/tests/mod-userdir.t b/tests/mod-userdir.t index 13a8e1b..40f55ef 100755 --- a/tests/mod-userdir.t +++ b/tests/mod-userdir.t @@ -1,9 +1,9 @@ #!/usr/bin/env perl BEGIN { - # add current source dir to the include-path - # we need this for make distcheck - (my $srcdir = $0) =~ s#/[^/]+$#/#; - unshift @INC, $srcdir; + # add current source dir to the include-path + # we need this for make distcheck + (my $srcdir = $0) =~ s,/[^/]+$,/,; + unshift @INC, $srcdir; } use strict; diff --git a/tests/proxy.conf b/tests/proxy.conf new file mode 100644 index 0000000..2d1ab0d --- /dev/null +++ b/tests/proxy.conf @@ -0,0 +1,156 @@ +server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" +server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd-proxy.pid" + +## bind to port (default: 80) +server.port = 2050 + +## bind to localhost (default: all interfaces) +server.bind = "localhost" +server.errorlog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log" +server.name = "www.example.org" +server.tag = "Proxy" + +server.dir-listing = "enable" + +#server.event-handler = "linux-sysepoll" +#server.event-handler = "linux-rtsig" + +#server.modules.path = "" +server.modules = ( + "mod_rewrite", + "mod_setenv", + "mod_access", + "mod_auth", +# "mod_httptls", + "mod_status", + "mod_expire", + "mod_simple_vhost", + "mod_redirect", +# "mod_evhost", +# "mod_localizer", + "mod_fastcgi", + "mod_proxy", + "mod_cgi", + "mod_compress", + "mod_userdir", + "mod_accesslog" ) + +server.indexfiles = ( "index.php", "index.html", + "index.htm", "default.htm" ) + + +######################## MODULE CONFIG ############################ + + +accesslog.filename = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.access.log" + +mimetype.assign = ( ".png" => "image/png", + ".jpg" => "image/jpeg", + ".jpeg" => "image/jpeg", + ".gif" => "image/gif", + ".html" => "text/html", + ".htm" => "text/html", + ".pdf" => "application/pdf", + ".swf" => "application/x-shockwave-flash", + ".spl" => "application/futuresplash", + ".txt" => "text/plain", + ".tar.gz" => "application/x-tgz", + ".tgz" => "application/x-tgz", + ".gz" => "application/x-gzip", + ".c" => "text/plain", + ".conf" => "text/plain" ) + +compress.cache-dir = env.SRCDIR + "/tmp/lighttpd/cache/compress/" +compress.filetype = ("text/plain", "text/html") + +setenv.add-environment = ( "TRAC_ENV" => "foo") +setenv.add-request-header = ( "FOO" => "foo") +setenv.add-response-header = ( "BAR" => "foo") + +proxy.debug = 1 +proxy.server = ( "" => ( + "grisu" => ( + "host" => "127.0.0.1", + "port" => 2048, + ) + ) + ) + + +cgi.assign = ( ".pl" => "/usr/bin/perl", + ".cgi" => "/usr/bin/perl", + ".py" => "/usr/bin/python" ) + +userdir.include-user = ( "jan" ) +userdir.path = "/" + +ssl.engine = "disable" +ssl.pemfile = "server.pem" + +auth.backend = "plain" +auth.backend.plain.userfile = env.SRCDIR + "/tmp/lighttpd/lighttpd.user" +auth.backend.plain.groupfile = "lighttpd.group" + +auth.backend.ldap.hostname = "localhost" +auth.backend.ldap.base-dn = "dc=my-domain,dc=com" +auth.backend.ldap.filter = "(uid=$)" + +auth.require = ( "/server-status" => + ( + "method" => "digest", + "realm" => "download archiv", +# "require" => ("group=www", "user=jan", "host=192.168.2.10") + "require" => "group=www|user=jan|host=192.168.2.10" + ), + "/auth.php" => + ( + "method" => "basic", + "realm" => "download archiv", +# "require" => ("group=www", "user=jan", "host=192.168.2.10") + "require" => "user=jan" + ), + "/server-config" => + ( + "method" => "basic", + "realm" => "download archiv", +# "require" => ("group=www", "user=jan", "user=weigon", "host=192.168.2.10") + "require" => "group=www|user=jan|host=192.168.2.10" + ) + ) + +url.access-deny = ( "~", ".inc") + +url.redirect = ( "^/redirect/$" => "http://localhost:2048/" ) + +url.rewrite = ( "^/rewrite/foo($|\?.+)" => "/indexfile/rewrite.php$1", + "^/rewrite/bar(?:$|\?(.+))" => "/indexfile/rewrite.php?bar&$1" ) + +expire.url = ( "/expire/access" => "access 2 hours", + "/expire/modification" => "access plus 1 seconds 2 minutes") + +#cache.cache-dir = "/home/weigon/wwwroot/cache/" + +#### status module +status.status-url = "/server-status" +status.config-url = "/server-config" + +$HTTP["host"] == "vvv.example.org" { + server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" +} + +$HTTP["host"] == "zzz.example.org" { + server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" + server.name = "zzz.example.org" +} + +$HTTP["host"] == "no-simple.example.org" { + server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/123.example.org/pages/" + server.name = "zzz.example.org" +} + +$HTTP["host"] !~ "(no-simple\.example\.org)" { + simple-vhost.document-root = "pages" + simple-vhost.server-root = env.SRCDIR + "/tmp/lighttpd/servers/" + simple-vhost.default-host = "www.example.org" +} + diff --git a/tests/request.t b/tests/request.t index c153b21..d2c8819 100755 --- a/tests/request.t +++ b/tests/request.t @@ -1,9 +1,9 @@ #!/usr/bin/env perl BEGIN { - # add current source dir to the include-path - # we need this for make distcheck - (my $srcdir = $0) =~ s#/[^/]+$#/#; - unshift @INC, $srcdir; + # add current source dir to the include-path + # we need this for make distcheck + (my $srcdir = $0) =~ s,/[^/]+$,/,; + unshift @INC, $srcdir; } use strict; diff --git a/tests/run-tests.pl b/tests/run-tests.pl index 6dae9a8..818f1c2 100755 --- a/tests/run-tests.pl +++ b/tests/run-tests.pl @@ -3,7 +3,7 @@ use strict; use Test::Harness qw(&runtests $verbose); -$verbose=0; +$verbose = (defined $ENV{'VERBOSE'} ? $ENV{'VERBOSE'} : 0);; my $srcdir = (defined $ENV{'srcdir'} ? $ENV{'srcdir'} : '.'); diff --git a/tests/symlink.t b/tests/symlink.t new file mode 100644 index 0000000..9b275bd --- /dev/null +++ b/tests/symlink.t @@ -0,0 +1,115 @@ +#!/usr/bin/env perl +BEGIN { + # add current source dir to the include-path + # we need this for make distcheck + (my $srcdir = $0) =~ s,/[^/]+$,/,; + unshift @INC, $srcdir; +} + +use strict; +use IO::Socket; +use Test::More tests => 10; +use LightyTest; + +my $tf = LightyTest->new(); +my $t; +my $docroot = $tf->{'TESTDIR'}."/tmp/lighttpd/servers/www.example.org/pages"; + +sub init_testbed { + return 0 unless eval { symlink("",""); 1 }; + my $f = "$docroot/index.html"; + my $l = "$docroot/index.xhtml"; + my $rc = undef; + unless (-l $l) { + return 0 unless symlink($f,$l); + }; + $f = "$docroot/expire"; + $l = "$docroot/symlinked"; + $rc = undef; + unless (-l $l) { + return 0 unless symlink($f,$l); + } + return 1; +}; + +SKIP: { + skip "perl does not support symlinking or setting up the symlinks failed.", 10 unless init_testbed; + ok($tf->start_proc == 0, "Starting lighttpd") or die(); + +# allow case +# simple file + $t->{REQUEST} = ( <<EOF +GET /index.html HTTP/1.0 +Host: symlink.example.org +EOF + ); + $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; + ok($tf->handle_http($t) == 0, 'allow: simple file'); + +# symlinked file + $t->{REQUEST} = ( <<EOF +GET /index.xhtml HTTP/1.0 +Host: symlink.example.org +EOF + ); + $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; + ok($tf->handle_http($t) == 0, 'allow: symlinked file'); + +# directly symlinked dir + $t->{REQUEST} = ( <<EOF +GET /symlinked/ HTTP/1.0 +Host: symlink.example.org +EOF + ); + $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; + ok($tf->handle_http($t) == 0, 'allow: directly symlinked dir'); + +# symlinked dir in path + $t->{REQUEST} = ( <<EOF +GET /symlinked/access.txt HTTP/1.0 +Host: symlink.example.org +EOF + ); + $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; + ok($tf->handle_http($t) == 0, 'allow: symlinked dir in path'); + +# deny case +# simple file + $t->{REQUEST} = ( <<EOF +GET /index.html HTTP/1.0 +Host: nosymlink.example.org +EOF + ); + $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; + ok($tf->handle_http($t) == 0, 'deny: simple file'); + +# symlinked file + $t->{REQUEST} = ( <<EOF +GET /index.xhtml HTTP/1.0 +Host: nosymlink.example.org +EOF + ); + $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ]; + ok($tf->handle_http($t) == 0, 'deny: symlinked file'); + +# directly symlinked dir + $t->{REQUEST} = ( <<EOF +GET /symlinked/ HTTP/1.0 +Host: nosymlink.example.org +EOF + ); + $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ]; + ok($tf->handle_http($t) == 0, 'deny: directly symlinked dir'); + +# symlinked dir in path + $t->{REQUEST} = ( <<EOF +GET /symlinked/access.txt HTTP/1.0 +Host: nosymlink.example.org +EOF + ); + $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ]; + ok($tf->handle_http($t) == 0, 'deny: symlinked dir in path'); + +# cleanup + ok($tf->stop_proc == 0, "Stopping lighttpd"); +}; |