1#!/usr/bin/env perl 2BEGIN { 3 # add current source dir to the include-path 4 # we need this for make distcheck 5 (my $srcdir = $0) =~ s,/[^/]+$,/,; 6 unshift @INC, $srcdir; 7} 8 9use strict; 10use IO::Socket; 11use Test::More tests => 5; 12use LightyTest; 13 14my $tf = LightyTest->new(); 15my $t; 16 17ok($tf->start_proc == 0, "Starting lighttpd") or die(); 18 19# get current user 20 21$t->{REQUEST} = ( <<EOF 22GET /~foobar/ HTTP/1.0 23EOF 24 ); 25$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ]; 26ok($tf->handle_http($t) == 0, 'valid user'); 27 28$t->{REQUEST} = ( <<EOF 29GET /~jan HTTP/1.0 30EOF 31 ); 32$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => 'http://'.$tf->{HOSTNAME}.':'.$tf->{PORT}.'/~jan/' } ]; 33ok($tf->handle_http($t) == 0, 'valid user + redirect'); 34 35$t->{REQUEST} = ( <<EOF 36GET /~jan HTTP/1.0 37Host: www.example.org 38EOF 39 ); 40$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => 'http://www.example.org/~jan/' } ]; 41ok($tf->handle_http($t) == 0, 'valid user + redirect'); 42 43ok($tf->stop_proc == 0, "Stopping lighttpd"); 44 45