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
=> 6;
14 my $tf = LightyTest
->new();
17 $tf->{CONFIGFILE
} = 'mod-extforward.conf';
19 ok
($tf->start_proc == 0, "Starting lighttpd") or die();
21 $t->{REQUEST
} = ( <<EOF
24 X-Forwarded-For: 127.0.10.1
27 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '127.0.10.1' } ];
28 ok
($tf->handle_http($t) == 0, 'expect 127.0.10.1, from single ip');
30 $t->{REQUEST
} = ( <<EOF
33 X-Forwarded-For: 127.0.10.1, 127.0.20.1
36 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '127.0.20.1' } ];
37 ok
($tf->handle_http($t) == 0, 'expect 127.0.20.1, from two ips');
39 $t->{REQUEST
} = ( <<EOF
42 X-Forwarded-For: 127.0.10.1, 127.0.20.1, 127.0.30.1
45 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '127.0.20.1' } ];
46 ok
($tf->handle_http($t) == 0, 'expect 127.0.20.1, from chained proxies');
48 $t->{REQUEST
} = ( <<EOF
51 Forwarded: for=127.0.10.1, for=127.0.20.1;proto=https, for=127.0.30.1;proto=http
54 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '127.0.20.1' } ];
55 ok
($tf->handle_http($t) == 0, 'expect 127.0.20.1, from chained proxies');
57 ok
($tf->stop_proc == 0, "Stopping lighttpd");