summaryrefslogtreecommitdiff
path: root/tests/core-condition.t
diff options
context:
space:
mode:
authorJan Kneschke <jan@kneschke.de>2005-09-16 12:44:29 +0000
committerJan Kneschke <jan@kneschke.de>2005-09-16 12:44:29 +0000
commite2cf5d3094d5fe655bb03d477bfcff25dfd2e453 (patch)
tree4c0d0e9853a4e03128d8753d3b14cd44d57506fe /tests/core-condition.t
parentbe5f187d0ff76716befd069396e5f234293eb5af (diff)
downloadlighttpd-git-e2cf5d3094d5fe655bb03d477bfcff25dfd2e453.tar.gz
tests for htpasswd + md5 and referer matching in conditionals
git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@711 152afb58-edef-0310-8abb-c4023f1b3aa9
Diffstat (limited to 'tests/core-condition.t')
-rwxr-xr-xtests/core-condition.t42
1 files changed, 36 insertions, 6 deletions
diff --git a/tests/core-condition.t b/tests/core-condition.t
index f685bd36..3e7e8ad9 100755
--- a/tests/core-condition.t
+++ b/tests/core-condition.t
@@ -8,7 +8,7 @@ BEGIN {
use strict;
use IO::Socket;
-use Test::More tests => 11;
+use Test::More tests => 14;
use LightyTest;
my $tf = LightyTest->new();
@@ -56,7 +56,7 @@ ok($tf->start_proc == 0, "Starting lighttpd") or die();
$t->{REQUEST} = ( <<EOF
GET /nofile.png HTTP/1.0
-Host: www.example.org
+Host: referer.example.org
EOF
);
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ];
@@ -64,21 +64,51 @@ ok($tf->handle_http($t) == 0, 'condition: Referer - no referer');
$t->{REQUEST} = ( <<EOF
GET /nofile.png HTTP/1.0
-Host: www.example.org
-Referer: http://www.example.org/
+Host: referer.example.org
+Referer: http://referer.example.org/
EOF
);
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ];
ok($tf->handle_http($t) == 0, 'condition: Referer - referer matches regex');
-$t->{REQUEST} = ( <<EOF
+TODO: {
+ local $TODO = "referer matching in conditionals";
+ $t->{REQUEST} = ( <<EOF
GET /nofile.png HTTP/1.0
+Host: referer.example.org
+Referer: http://evil-referer.example.org/
+EOF
+ );
+ $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ];
+ ok($tf->handle_http($t) == 0, 'condition: Referer - referer doesn\'t match');
+}
+
+$t->{REQUEST} = ( <<EOF
+GET /image.jpg HTTP/1.0
Host: www.example.org
-Referer: http://123.example.org/
+EOF
+ );
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
+ok($tf->handle_http($t) == 0, 'condition: Referer - no referer');
+
+$t->{REQUEST} = ( <<EOF
+GET /image.jpg HTTP/1.0
+Host: www.example.org
+Referer: http://referer.example.org/
+EOF
+ );
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
+ok($tf->handle_http($t) == 0, 'condition: Referer - referer matches regex');
+
+$t->{REQUEST} = ( <<EOF
+GET /image.jpg HTTP/1.0
+Host: www.example.org
+Referer: http://evil-referer.example.org/
EOF
);
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ];
ok($tf->handle_http($t) == 0, 'condition: Referer - referer doesn\'t match');
+
ok($tf->stop_proc == 0, "Stopping lighttpd");