[config] config options to stream request/response (#949, #376)
[lighttpd.git] / tests / mod-userdir.t
blob52f9c32f1847cd36b7e55e04dc491edabb930c76
1 #!/usr/bin/env perl
2 BEGIN {
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;
9 use strict;
10 use IO::Socket;
11 use Test::More tests => 7;
12 use LightyTest;
14 my $tf = LightyTest->new();
15 my $t;
17 ok($tf->start_proc == 0, "Starting lighttpd") or die();
19 # get current user
21 $t->{REQUEST} = ( <<EOF
22 GET /~foobar/ HTTP/1.0
23 EOF
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
30 EOF
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
36 GET /~jan HTTP/1.0
37 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
43 GET /%7Ejan HTTP/1.0
44 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
50 GET /~jan HTTP/1.0
51 Host: www.example.org
52 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");