Browse Source

- add test for extforward module

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2044 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.19
Elan Ruusamäe 15 years ago
parent
commit
b6d6b82b70
  1. 5
      tests/docroot/www/ip.pl
  2. 30
      tests/mod-extforward.conf
  3. 41
      tests/mod-extforward.t

5
tests/docroot/www/ip.pl

@ -0,0 +1,5 @@
#!/usr/bin/perl
print "Content-Type: text/html\r\n\r\n";
print $ENV{'REMOTE_ADDR'};
0;

30
tests/mod-extforward.conf

@ -0,0 +1,30 @@
debug.log-request-handling = "enable"
debug.log-response-header = "enable"
debug.log-request-header = "enable"
server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/"
server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid"
## bind to port (default: 80)
server.port = 2048
## bind to localhost (default: all interfaces)
server.bind = "localhost"
server.errorlog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
server.name = "www.example.org"
server.tag = "Apache 1.3.29"
server.modules = (
"mod_cgi",
"mod_extforward"
)
######################## MODULE CONFIG ############################
mimetype.assign = ( ".html" => "text/html" )
cgi.assign = (".pl" => "/usr/bin/perl" )
extforward.forwarder = (
"127.0.0.1" => "trust",
)

41
tests/mod-extforward.t

@ -0,0 +1,41 @@
#!/usr/bin/env perl
BEGIN {
# add current source dir to the include-path
# we need this for make distcheck
(my $srcdir = $0) =~ s,/[^/]+$,/,;
unshift @INC, $srcdir;
}
use strict;
use IO::Socket;
use Test::More tests => 2;
use LightyTest;
my $tf = LightyTest->new();
my $t;
$tf->{CONFIGFILE} = 'mod-extforward.conf';
ok($tf->start_proc == 0, "Starting lighttpd") or die();
## check if If-Modified-Since, If-None-Match works
$t->{REQUEST} = ( <<EOF
GET /ip.pl HTTP/1.0
Host: www.example.org
X-Forwarded-For: 127.0.10.1
EOF
);
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '127.0.10.1' } ];
ok($tf->handle_http($t) == 0, 'expect 127.0.10.1');
$t->{REQUEST} = ( <<EOF
GET /ip.pl HTTP/1.0
Host: www.example.org
X-Forwarded-For: 127.0.10.1, 127.0.20.1
EOF
);
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '127.0.20.1' } ];
ok($tf->handle_http($t) == 0, 'expect 127.0.20.1');
ok($tf->stop_proc == 0, "Stopping lighttpd");
Loading…
Cancel
Save