Annotation of embedaddon/lighttpd/tests/mod-extforward.t, revision 1.1
1.1 ! misho 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;
! 7: }
! 8:
! 9: use strict;
! 10: use IO::Socket;
! 11: use Test::More tests => 5;
! 12: use LightyTest;
! 13:
! 14: my $tf = LightyTest->new();
! 15: my $t;
! 16:
! 17: $tf->{CONFIGFILE} = 'mod-extforward.conf';
! 18:
! 19: ok($tf->start_proc == 0, "Starting lighttpd") or die();
! 20:
! 21: $t->{REQUEST} = ( <<EOF
! 22: GET /ip.pl HTTP/1.0
! 23: Host: www.example.org
! 24: X-Forwarded-For: 127.0.10.1
! 25: EOF
! 26: );
! 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');
! 29:
! 30: $t->{REQUEST} = ( <<EOF
! 31: GET /ip.pl HTTP/1.0
! 32: Host: www.example.org
! 33: X-Forwarded-For: 127.0.10.1, 127.0.20.1
! 34: EOF
! 35: );
! 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');
! 38:
! 39: $t->{REQUEST} = ( <<EOF
! 40: GET /ip.pl HTTP/1.0
! 41: Host: www.example.org
! 42: X-Forwarded-For: 127.0.10.1, 127.0.20.1, 127.0.30.1
! 43: EOF
! 44: );
! 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');
! 47:
! 48: ok($tf->stop_proc == 0, "Stopping lighttpd");
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>