summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArno Töll <arno@debian.org>2012-11-21 23:03:41 +0100
committerArno Töll <arno@debian.org>2012-11-21 23:03:41 +0100
commit6a6df8dc258631c6eaccb03bf08845241f6dfa4a (patch)
tree01eee8de64a85e5e2fef929050663ea2d3c850bd /tests
parentec2cb646eff482dfe32955d01781b01211b0a77c (diff)
downloadlighttpd-6a6df8dc258631c6eaccb03bf08845241f6dfa4a.tar.gz
Imported Upstream version 1.4.12upstream/1.4.12
Diffstat (limited to 'tests')
-rwxr-xr-xtests/LightyTest.pm11
-rw-r--r--tests/Makefile.am5
-rw-r--r--tests/Makefile.in5
-rwxr-xr-xtests/cachable.t112
-rw-r--r--tests/lowercase.conf80
-rwxr-xr-xtests/lowercase.t94
6 files changed, 302 insertions, 5 deletions
diff --git a/tests/LightyTest.pm b/tests/LightyTest.pm
index 81f9292..0426d45 100755
--- a/tests/LightyTest.pm
+++ b/tests/LightyTest.pm
@@ -90,10 +90,12 @@ sub start_proc {
$ENV{'SRCDIR'} = $self->{BASEDIR}.'/tests';
unlink($self->{LIGHTTPD_PIDFILE});
- if (1) {
- system($self->{LIGHTTPD_PATH}." -f ".$self->{SRCDIR}."/".$self->{CONFIGFILE}." -m ".$self->{MODULES_PATH});
+ 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 '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 {
- system("valgrind --tool=memcheck --show-reachable=yes --leak-check=yes --logfile=foo ".$self->{LIGHTTPD_PATH}." -D -f ".$self->{TESTDIR}."/tmp/cfg.file -m ".$self->{MODULES_PATH}." &");
+ system($self->{LIGHTTPD_PATH}." -f ".$self->{SRCDIR}."/".$self->{CONFIGFILE}." -m ".$self->{MODULES_PATH});
}
select(undef, undef, undef, 0.1);
@@ -195,6 +197,9 @@ sub handle_http {
}
}
+ $t->{etag} = $resp_hdr{'etag'};
+ $t->{date} = $resp_hdr{'date'};
+
# check length
if (defined $resp_hdr{"content-length"}) {
$resp_body = substr($lines, 0, $resp_hdr{"content-length"});
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d4a9b10..584d9c9 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -42,7 +42,10 @@ CONFS=fastcgi-10.conf \
request.t \
mod-ssi.t \
LightyTest.pm \
- mod-setenv.t
+ mod-setenv.t \
+ lowercase.t \
+ lowercase.conf \
+ cachable.t
TESTS_ENVIRONMENT=$(srcdir)/wrapper.sh $(srcdir) $(top_builddir)
diff --git a/tests/Makefile.in b/tests/Makefile.in
index feea307..93ac0f6 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -257,7 +257,10 @@ CONFS = fastcgi-10.conf \
request.t \
mod-ssi.t \
LightyTest.pm \
- mod-setenv.t
+ mod-setenv.t \
+ lowercase.t \
+ lowercase.conf \
+ cachable.t
TESTS_ENVIRONMENT = $(srcdir)/wrapper.sh $(srcdir) $(top_builddir)
EXTRA_DIST = wrapper.sh lighttpd.conf \
diff --git a/tests/cachable.t b/tests/cachable.t
new file mode 100755
index 0000000..74d9a4b
--- /dev/null
+++ b/tests/cachable.t
@@ -0,0 +1,112 @@
+#!/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 => 12;
+use LightyTest;
+
+my $tf = LightyTest->new();
+my $t;
+
+$tf->{CONFIGFILE} = 'lighttpd.conf';
+
+ok($tf->start_proc == 0, "Starting lighttpd") or die();
+
+## check if If-Modified-Since, If-None-Match works
+
+$t->{REQUEST} = ( <<EOF
+GET / HTTP/1.0
+If-Modified-Since: Sun, 01 Jan 1970 00:00:01 GMT
+EOF
+ );
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
+ok($tf->handle_http($t) == 0, 'Conditional GET - old If-Modified-Since');
+
+$t->{REQUEST} = ( <<EOF
+GET / HTTP/1.0
+If-Modified-Since: Sun, 01 Jan 1970 00:00:01 GMT; foo
+EOF
+ );
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Last-Modified' => ''} ];
+ok($tf->handle_http($t) == 0, 'Conditional GET - old If-Modified-Since, comment');
+
+my $now = $t->{date};
+
+$t->{REQUEST} = ( <<EOF
+GET / HTTP/1.0
+If-Modified-Since: $now
+EOF
+ );
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304 } ];
+ok($tf->handle_http($t) == 0, 'Conditional GET - new If-Modified-Since');
+
+$t->{REQUEST} = ( <<EOF
+GET / HTTP/1.0
+If-Modified-Since: $now; foo
+EOF
+ );
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304 } ];
+ok($tf->handle_http($t) == 0, 'Conditional GET - new If-Modified-Since, comment');
+
+$t->{REQUEST} = ( <<EOF
+GET / HTTP/1.0
+If-None-Match: foo
+EOF
+ );
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+ETag' => ''} ];
+ok($tf->handle_http($t) == 0, 'Conditional GET - old If-None-Match');
+
+my $etag = $t->{etag};
+
+$t->{REQUEST} = ( <<EOF
+GET / HTTP/1.0
+If-None-Match: $etag
+EOF
+ );
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304 } ];
+ok($tf->handle_http($t) == 0, 'Conditional GET - old If-None-Match');
+
+$t->{REQUEST} = ( <<EOF
+GET / HTTP/1.0
+If-None-Match: $etag
+If-Modified-Since: Sun, 01 Jan 1970 00:00:01 GMT; foo
+EOF
+ );
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
+ok($tf->handle_http($t) == 0, 'Conditional GET - ETag + old Last-Modified');
+
+$t->{REQUEST} = ( <<EOF
+GET / HTTP/1.0
+If-None-Match: $etag
+If-Modified-Since: $now; foo
+EOF
+ );
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304 } ];
+ok($tf->handle_http($t) == 0, 'Conditional GET - ETag, Last-Modified + comment');
+
+$t->{REQUEST} = ( <<EOF
+GET / HTTP/1.0
+If-None-Match: Foo
+If-Modified-Since: Sun, 01 Jan 1970 00:00:01 GMT; foo
+EOF
+ );
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
+ok($tf->handle_http($t) == 0, 'Conditional GET - old ETAG + old Last-Modified');
+
+$t->{REQUEST} = ( <<EOF
+GET / HTTP/1.0
+If-None-Match: $etag
+If-Modified-Since: $now foo
+EOF
+ );
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 412 } ];
+ok($tf->handle_http($t) == 0, 'Conditional GET - ETag + Last-Modified + overlong timestamp');
+
+ok($tf->stop_proc == 0, "Stopping lighttpd");
+
diff --git a/tests/lowercase.conf b/tests/lowercase.conf
new file mode 100644
index 0000000..60eb40f
--- /dev/null
+++ b/tests/lowercase.conf
@@ -0,0 +1,80 @@
+server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/"
+server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid"
+
+## bind to port (default: 80)
+server.port = 2048
+
+## bind to localhost (default: all interfaces)
+server.bind = "localhost"
+server.errorlog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
+
+server.force-lowercase-filenames = "enable"
+
+server.dir-listing = "enable"
+
+server.modules = (
+ "mod_rewrite",
+ "mod_setenv",
+ "mod_secdownload",
+ "mod_access",
+ "mod_auth",
+ "mod_status",
+ "mod_expire",
+ "mod_redirect",
+ "mod_fastcgi",
+ "mod_cgi" )
+
+server.indexfiles = ( "index.php", "index.html",
+ "index.htm", "default.htm" )
+
+
+######################## MODULE CONFIG ############################
+
+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" )
+
+fastcgi.debug = 0
+fastcgi.server = ( ".php" => ( ( "host" => "127.0.0.1", "port" => 1026, "broken-scriptfilename" => "enable" ) ),
+ "/prefix.fcgi" => ( ( "host" => "127.0.0.1", "port" => 1026, "check-local" => "disable", "broken-scriptfilename" => "enable" ) )
+ )
+
+
+cgi.assign = ( ".pl" => "/usr/bin/perl",
+ ".cgi" => "/usr/bin/perl",
+ ".py" => "/usr/bin/python" )
+
+auth.backend = "plain"
+auth.backend.plain.userfile = env.SRCDIR + "/tmp/lighttpd/lighttpd.user"
+
+auth.backend.htpasswd.userfile = env.SRCDIR + "/tmp/lighttpd/lighttpd.htpasswd"
+
+$HTTP["host"] == "lowercase-auth" {
+ auth.require = ( "/image.jpg" =>
+ (
+ "method" => "digest",
+ "realm" => "download archiv",
+ "require" => "valid-user"
+ )
+ )
+}
+
+$HTTP["host"] == "lowercase-deny" {
+ url.access-deny = ( ".jpg")
+}
+
+$HTTP["host"] == "lowercase-exclude" {
+ static-file.exclude-extensions = ( ".jpg" )
+}
diff --git a/tests/lowercase.t b/tests/lowercase.t
new file mode 100755
index 0000000..e127cdd
--- /dev/null
+++ b/tests/lowercase.t
@@ -0,0 +1,94 @@
+#!/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;
+
+$tf->{CONFIGFILE} = 'lowercase.conf';
+
+ok($tf->start_proc == 0, "Starting lighttpd") or die();
+
+## check if lower-casing works
+
+$t->{REQUEST} = ( <<EOF
+GET /image.JPG HTTP/1.0
+EOF
+ );
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
+ok($tf->handle_http($t) == 0, 'uppercase access');
+
+$t->{REQUEST} = ( <<EOF
+GET /image.jpg HTTP/1.0
+EOF
+ );
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
+ok($tf->handle_http($t) == 0, 'lowercase access');
+
+## check that mod-auth works
+
+$t->{REQUEST} = ( <<EOF
+GET /image.JPG HTTP/1.0
+Host: lowercase-auth
+EOF
+ );
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 401 } ];
+ok($tf->handle_http($t) == 0, 'uppercase access');
+
+$t->{REQUEST} = ( <<EOF
+GET /image.jpg HTTP/1.0
+Host: lowercase-auth
+EOF
+ );
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 401 } ];
+ok($tf->handle_http($t) == 0, 'lowercase access');
+
+
+## check that mod-staticfile exclude works
+$t->{REQUEST} = ( <<EOF
+GET /image.JPG HTTP/1.0
+Host: lowercase-exclude
+EOF
+ );
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ];
+ok($tf->handle_http($t) == 0, 'upper case access to staticfile.exclude-extension');
+
+$t->{REQUEST} = ( <<EOF
+GET /image.jpg HTTP/1.0
+Host: lowercase-exclude
+EOF
+ );
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ];
+ok($tf->handle_http($t) == 0, 'lowercase access');
+
+
+## check that mod-access exclude works
+$t->{REQUEST} = ( <<EOF
+GET /image.JPG HTTP/1.0
+Host: lowercase-deny
+EOF
+ );
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ];
+ok($tf->handle_http($t) == 0, 'uppercase access to url.access-deny protected location');
+
+$t->{REQUEST} = ( <<EOF
+GET /image.jpg HTTP/1.0
+Host: lowercase-deny
+EOF
+ );
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ];
+ok($tf->handle_http($t) == 0, 'lowercase access');
+
+
+
+ok($tf->stop_proc == 0, "Stopping lighttpd");
+