diff options
Diffstat (limited to 'tests/core-condition.t')
-rwxr-xr-x | tests/core-condition.t | 88 |
1 files changed, 1 insertions, 87 deletions
diff --git a/tests/core-condition.t b/tests/core-condition.t index 53b69c5e..40647041 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 => 21; +use Test::More tests => 10; use LightyTest; my $tf = LightyTest->new(); @@ -80,89 +80,3 @@ $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Serve ok($tf->handle_http($t) == 0, 'condition: handle if before else branches #2'); ok($tf->stop_proc == 0, "Stopping lighttpd"); - -$tf->{CONFIGFILE} = 'lighttpd.conf'; -ok($tf->start_proc == 0, "Starting lighttpd") or die(); - -$t->{REQUEST} = ( <<EOF -GET /nofile.png HTTP/1.0 -Host: referer.example.org -EOF - ); -$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ]; -ok($tf->handle_http($t) == 0, 'condition: Referer - no referer'); - -$t->{REQUEST} = ( <<EOF -GET /nofile.png HTTP/1.0 -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 -GET /image.jpg HTTP/1.0 -Host: www.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'); - -$t->{REQUEST} = ( <<EOF -GET /nofile HTTP/1.1 -Host: bug255.example.org - -GET /nofile HTTP/1.1 -Host: bug255.example.org -Connection: close -EOF - ); -$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 403 }, { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 403 } ]; -ok($tf->handle_http($t) == 0, 'remote ip cache (#255)'); - -$t->{REQUEST} = ( <<EOF -GET /empty-ref.noref HTTP/1.0 -Cookie: empty-ref -EOF - ); -$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ]; -ok($tf->handle_http($t) == 0, 'condition: $HTTP["referer"] == "" and Referer is no set'); - -$t->{REQUEST} = ( <<EOF -GET /empty-ref.noref HTTP/1.0 -Cookie: empty-ref -Referer: -EOF - ); -$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ]; -ok($tf->handle_http($t) == 0, 'condition: $HTTP["referer"] == "" and Referer is empty'); - -$t->{REQUEST} = ( <<EOF -GET /empty-ref.noref HTTP/1.0 -Cookie: empty-ref -Referer: foobar -EOF - ); -$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ]; -ok($tf->handle_http($t) == 0, 'condition: $HTTP["referer"] == "" and Referer: foobar'); - -ok($tf->stop_proc == 0, "Stopping lighttpd"); |