3 # add current source dir to the include-path
4 # we need this for make distcheck
5 (my $srcdir = $0) =~ s
,/[^/]+$,/,;
11 use Test
::More tests
=> 7;
14 my $tf = LightyTest
->new();
17 ok
($tf->start_proc == 0, "Starting lighttpd") or die();
21 $t->{REQUEST
} = ( <<EOF
22 GET /~foobar/ HTTP/1.0
25 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ];
26 ok
($tf->handle_http($t) == 0, 'valid user');
28 $t->{REQUEST
} = ( <<EOF
29 GET /%7Efoobar/ HTTP/1.0
32 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ];
33 ok
($tf->handle_http($t) == 0, 'valid user with url-encoded ~ as %7E');
35 $t->{REQUEST
} = ( <<EOF
39 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => 'http://'.$tf->{HOSTNAME
}.':'.$tf->{PORT
}.'/~jan/' } ];
40 ok
($tf->handle_http($t) == 0, 'valid user + redirect');
42 $t->{REQUEST
} = ( <<EOF
46 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => 'http://'.$tf->{HOSTNAME
}.':'.$tf->{PORT
}.'/~jan/' } ];
47 ok
($tf->handle_http($t) == 0, 'valid user with url encoded ~ as %7E + redirect');
49 $t->{REQUEST
} = ( <<EOF
54 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => 'http://www.example.org/~jan/' } ];
55 ok
($tf->handle_http($t) == 0, 'valid user + redirect');
57 ok
($tf->stop_proc == 0, "Stopping lighttpd");