Feature #1194 » mod-evhost_tests.patch
mod-evhost.t (revision 0) | ||
---|---|---|
#!/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 => 7;
|
||
use LightyTest;
|
||
my $tf = LightyTest->new();
|
||
$tf->{CONFIGFILE} = 'mod-evhost.conf';
|
||
my $t;
|
||
ok($tf->start_proc == 0, "Starting lighttpd") or die();
|
||
# test for correct config
|
||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
|
||
$t->{REQUEST} = ( <<EOF
|
||
GET /index.html HTTP/1.0
|
||
Host: evhost1.example.org
|
||
EOF
|
||
);
|
||
ok($tf->handle_http($t) == 0, 'correct pattern using dot notation');
|
||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
|
||
$t->{REQUEST} = ( <<EOF
|
||
GET /index.html HTTP/1.0
|
||
Host: evhost2.example.org
|
||
EOF
|
||
);
|
||
ok($tf->handle_http($t) == 0, 'correct pattern not using dot notation');
|
||
# test for broken config
|
||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ];
|
||
$t->{REQUEST} = ( <<EOF
|
||
GET /index.html HTTP/1.0
|
||
Host: evhost3.example.org
|
||
EOF
|
||
);
|
||
ok($tf->handle_http($t) == 0, 'broken pattern 1');
|
||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ];
|
||
$t->{REQUEST} = ( <<EOF
|
||
GET /index.html HTTP/1.0
|
||
Host: evhost4.example.org
|
||
EOF
|
||
);
|
||
ok($tf->handle_http($t) == 0, 'broken pattern 2');
|
||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ];
|
||
$t->{REQUEST} = ( <<EOF
|
||
GET /index.html HTTP/1.0
|
||
Host: evhost5.example.org
|
||
EOF
|
||
);
|
||
ok($tf->handle_http($t) == 0, 'broken pattern 3');
|
||
ok($tf->stop_proc == 0, "Stopping lighttpd");
|
||
mod-evhost.conf (revision 0) | ||
---|---|---|
server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/evhost"
|
||
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 = "Proxy"
|
||
server.dir-listing = "enable"
|
||
#server.event-handler = "linux-sysepoll"
|
||
#server.event-handler = "linux-rtsig"
|
||
#server.modules.path = ""
|
||
server.modules = (
|
||
"mod_rewrite",
|
||
"mod_setenv",
|
||
"mod_access",
|
||
"mod_auth",
|
||
# "mod_httptls",
|
||
"mod_status",
|
||
"mod_expire",
|
||
"mod_simple_vhost",
|
||
"mod_redirect",
|
||
"mod_evhost",
|
||
# "mod_localizer",
|
||
# "mod_fastcgi",
|
||
# "mod_proxy",
|
||
"mod_cgi",
|
||
"mod_compress",
|
||
"mod_userdir",
|
||
"mod_accesslog" )
|
||
server.indexfiles = ( "index.php", "index.html",
|
||
"index.htm", "default.htm" )
|
||
######################## MODULE CONFIG ############################
|
||
accesslog.filename = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.access.log"
|
||
mimetype.assign = ( ".png" => "image/png",
|
||
".jpg" => "image/jpeg",
|
||
".jpeg" => "image/jpeg",
|
||
".gif" => "image/gif",
|
||
".html" => "text/html",
|
||
".htm" => "text/html",
|
||
".pdf" => "application/pdf",
|
||
".swf" => "application/x-shockwave-flash",
|
||
".spl" => "application/futuresplash",
|
||
".txt" => "text/plain",
|
||
".tar.gz" => "application/x-tgz",
|
||
".tgz" => "application/x-tgz",
|
||
".gz" => "application/x-gzip",
|
||
".c" => "text/plain",
|
||
".conf" => "text/plain" )
|
||
compress.cache-dir = env.SRCDIR + "/tmp/lighttpd/cache/compress/"
|
||
compress.filetype = ("text/plain", "text/html")
|
||
cgi.assign = ( ".pl" => "/usr/bin/perl",
|
||
".cgi" => "/usr/bin/perl",
|
||
".py" => "/usr/bin/python" )
|
||
userdir.include-user = ( "jan" )
|
||
userdir.path = "/"
|
||
ssl.engine = "disable"
|
||
ssl.pemfile = "server.pem"
|
||
url.access-deny = ( "~", ".inc")
|
||
url.redirect = ( "^/redirect/$" => "http://localhost:2048/" )
|
||
url.rewrite = ( "^/rewrite/foo($|\?.+)" => "/indexfile/rewrite.php$1",
|
||
"^/rewrite/bar(?:$|\?(.+))" => "/indexfile/rewrite.php?bar&$1" )
|
||
expire.url = ( "/expire/access" => "access 2 hours",
|
||
"/expire/modification" => "access plus 1 seconds 2 minutes")
|
||
#cache.cache-dir = "/home/weigon/wwwroot/cache/"
|
||
#### status module
|
||
status.status-url = "/server-status"
|
||
status.config-url = "/server-config"
|
||
#### mod-evhost
|
||
$HTTP["host"] =~ "evhost1.example.org" {
|
||
evhost.path-pattern = env.SRCDIR + "/tmp/lighttpd/servers/evhost/%3.1/%3.2/%3/pages/"
|
||
}
|
||
else $HTTP["host"] =~ "evhost2.example.org" {
|
||
evhost.path-pattern = env.SRCDIR + "/tmp/lighttpd/servers/evhost/%3/pages/"
|
||
}
|
||
else $HTTP["host"] =~ "evhost3.example.org" {
|
||
evhost.path-pattern = env.SRCDIR + "/tmp/lighttpd/servers/evhost/%3.0/pages/"
|
||
}
|
||
else $HTTP["host"] =~ "evhost4.example.org" {
|
||
evhost.path-pattern = env.SRCDIR + "/tmp/lighttpd/servers/evhost/%3.\1/pages/"
|
||
}
|
||
else $HTTP["host"] =~ "evhost5.example.org" {
|
||
evhost.path-pattern = env.SRCDIR + "/tmp/lighttpd/servers/evhost/%3.\1/pages/"
|
||
}
|
||
else $HTTP["host"] =~ "evhost.example.org" {
|
||
url.access-deny = ("")
|
||
}
|
||
prepare.sh (working copy) | ||
---|---|---|
mkdir -p $tmpdir/servers/www.example.org/pages/expire/
|
||
mkdir -p $tmpdir/servers/www.example.org/pages/indexfile/
|
||
mkdir -p $tmpdir/servers/123.example.org/pages/
|
||
mkdir -p $tmpdir/servers/evhost/e/v/evhost1/pages
|
||
mkdir -p $tmpdir/servers/evhost/evhost2/pages
|
||
mkdir -p $tmpdir/logs/
|
||
mkdir -p $tmpdir/cache/
|
||
mkdir -p $tmpdir/cache/compress/
|
||
... | ... | |
touch $tmpdir/servers/www.example.org/pages/image.jpg \
|
||
$tmpdir/servers/www.example.org/pages/image.JPG \
|
||
$tmpdir/servers/www.example.org/pages/Foo.txt \
|
||
$tmpdir/servers/www.example.org/pages/a
|
||
$tmpdir/servers/www.example.org/pages/a \
|
||
$tmpdir/servers/evhost/e/v/evhost1/pages/index.html \
|
||
$tmpdir/servers/evhost/evhost2/pages/index.html
|
||
echo "12345" > $tmpdir/servers/www.example.org/pages/range.pdf
|
||
printf "%-40s" "preparing infrastructure"
|
- « Previous
- 1
- 2
- 3
- Next »