[mod_evhost] mod-evhost.t tests (#1194)
(thx Daniel-Brandt) x-ref: "Partial matching in mod_evhost patterns" https://redmine.lighttpd.net/issues/1194personal/stbuehler/mod-csrf
parent
a3bba43b30
commit
75040e9988
@ -0,0 +1,47 @@
|
||||
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.name = "www.example.org"
|
||||
server.tag = "Proxy"
|
||||
server.errorlog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
|
||||
server.breakagelog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log"
|
||||
accesslog.filename = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.access.log"
|
||||
|
||||
server.modules = (
|
||||
"mod_evhost",
|
||||
"mod_accesslog" )
|
||||
|
||||
server.indexfiles = ( "index.html" )
|
||||
|
||||
|
||||
######################## MODULE 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 = ("")
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
#!/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");
|
||||
|
Loading…
Reference in New Issue