From 91472ab7681b26f36b813f3b245c0e98f91b4c3f Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Tue, 6 Jul 2021 22:58:13 -0400 Subject: [tests] t/test_mod_staticfile move some tests from tests/request.t to src/t/test_mod_staticfile.c --- tests/request.t | 56 ++------------------------------------------------------ 1 file changed, 2 insertions(+), 54 deletions(-) (limited to 'tests/request.t') diff --git a/tests/request.t b/tests/request.t index ea8852d6..f2264486 100755 --- a/tests/request.t +++ b/tests/request.t @@ -8,7 +8,7 @@ BEGIN { use strict; use IO::Socket; -use Test::More tests => 52; +use Test::More tests => 44; use LightyTest; my $tf = LightyTest->new(); @@ -18,13 +18,6 @@ ok($tf->start_proc == 0, "Starting lighttpd") or die(); ## Basic Request-Handling -$t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ]; -ok($tf->handle_http($t) == 0, 'file not found'); - $t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/html' } ]; ok($tf->handle_http($t) == 0, 'GET, content == 12345, mimetype text/html'); -$t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'application/octet-stream' } ]; -ok($tf->handle_http($t) == 0, 'GET, content == 12345, mimetype application/octet-stream'); - $t->{REQUEST} = ( <handle_http($t) == 0, 'OPTIONS for RTSP'); my $nextyr = (gmtime(time()))[5] + 1900 + 1; -$t->{REQUEST} = ( "GET / HTTP/1.0\r\nIf-Modified-Since: \r\n\r\n" ); -$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; -ok($tf->handle_http($t) == 0, 'empty If-Modified-Since'); - -$t->{REQUEST} = ( "GET / HTTP/1.0\r\nIf-Modified-Since: foobar\r\n\r\n" ); -$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; -ok($tf->handle_http($t) == 0, 'broken If-Modified-Since'); - -$t->{REQUEST} = ( "GET / HTTP/1.0\r\nIf-Modified-Since: this string is too long to be a valid timestamp\r\n\r\n" ); -$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; -ok($tf->handle_http($t) == 0, 'broken If-Modified-Since'); - - $t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304, 'Content-Type' => 'text/html' } ]; -ok($tf->handle_http($t) == 0, 'If-Modified-Since'); - -$t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304, '-Content-Length' => '' } ]; +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304, '-Content-Length' => '', 'Content-Type' => 'text/html' } ]; ok($tf->handle_http($t) == 0, 'Status 304 has no Content-Length (#1002)'); $t->{REQUEST} = ( <{SLOWREQUEST} = 1; ok($tf->handle_http($t) == 0, 'GET, slow \\r\\n\\r\\n (#2105)'); undef $t->{SLOWREQUEST}; -print "\nPathinfo for static files\n"; -$t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'Content-Type' => 'image/jpeg' } ]; -ok($tf->handle_http($t) == 0, 'static file accepting pathinfo by default'); - -$t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ]; -ok($tf->handle_http($t) == 0, 'static file with forbidden pathinfo'); - $t->{REQUEST} = ( <