From b6d6b82b70fcdaf7f79916857db394dbad9d8c51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Thu, 17 Jan 2008 09:50:17 +0000 Subject: [PATCH] - add test for extforward module git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2044 152afb58-edef-0310-8abb-c4023f1b3aa9 --- tests/docroot/www/ip.pl | 5 +++++ tests/mod-extforward.conf | 30 ++++++++++++++++++++++++++++ tests/mod-extforward.t | 41 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100755 tests/docroot/www/ip.pl create mode 100644 tests/mod-extforward.conf create mode 100755 tests/mod-extforward.t diff --git a/tests/docroot/www/ip.pl b/tests/docroot/www/ip.pl new file mode 100755 index 00000000..b86cfb5a --- /dev/null +++ b/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; diff --git a/tests/mod-extforward.conf b/tests/mod-extforward.conf new file mode 100644 index 00000000..e4e0b185 --- /dev/null +++ b/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", +) diff --git a/tests/mod-extforward.t b/tests/mod-extforward.t new file mode 100755 index 00000000..ff3a1934 --- /dev/null +++ b/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} = ( <{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} = ( <{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");