Project

General

Profile

mod-evhost_tests.patch

Testcases for 1.4.x - admin, 2007-05-28 14:58

View differences:

mod-evhost.t (revision 0)
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 => 7;
12
use LightyTest;
13

  
14
my $tf = LightyTest->new();
15
$tf->{CONFIGFILE} = 'mod-evhost.conf';
16
my $t;
17

  
18
ok($tf->start_proc == 0, "Starting lighttpd") or die();
19

  
20
# test for correct config
21
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
22
$t->{REQUEST}  = ( <<EOF
23
GET /index.html HTTP/1.0
24
Host: evhost1.example.org
25
EOF
26
 );
27
ok($tf->handle_http($t) == 0, 'correct pattern using dot notation');
28

  
29
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
30
$t->{REQUEST}  = ( <<EOF
31
GET /index.html HTTP/1.0
32
Host: evhost2.example.org
33
EOF
34
 );
35
ok($tf->handle_http($t) == 0, 'correct pattern not using dot notation');
36

  
37
# test for broken config
38
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ];
39
$t->{REQUEST}  = ( <<EOF
40
GET /index.html HTTP/1.0
41
Host: evhost3.example.org
42
EOF
43
 );
44
ok($tf->handle_http($t) == 0, 'broken pattern 1');
45

  
46
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ];
47
$t->{REQUEST}  = ( <<EOF
48
GET /index.html HTTP/1.0
49
Host: evhost4.example.org
50
EOF
51
 );
52
ok($tf->handle_http($t) == 0, 'broken pattern 2');
53

  
54
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ];
55
$t->{REQUEST}  = ( <<EOF
56
GET /index.html HTTP/1.0
57
Host: evhost5.example.org
58
EOF
59
 );
60
ok($tf->handle_http($t) == 0, 'broken pattern 3');
61

  
62
ok($tf->stop_proc == 0, "Stopping lighttpd");
63

  
mod-evhost.conf (revision 0)
1
server.document-root         = env.SRCDIR + "/tmp/lighttpd/servers/evhost"
2
server.pid-file              = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid"
3

  
4
## bind to port (default: 80)
5
server.port                 = 2048
6

  
7
## bind to localhost (default: all interfaces)
8
server.bind                = "localhost"
9
server.errorlog            = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
10
server.name                = "www.example.org"
11
server.tag                 = "Proxy"
12

  
13
server.dir-listing          = "enable"
14

  
15
#server.event-handler        = "linux-sysepoll"
16
#server.event-handler        = "linux-rtsig"
17

  
18
#server.modules.path         = ""
19
server.modules              = (
20
				"mod_rewrite",
21
				"mod_setenv",
22
			        "mod_access",
23
				"mod_auth",
24
#				"mod_httptls",
25
				"mod_status",
26
				"mod_expire",
27
				"mod_simple_vhost",
28
				"mod_redirect",
29
				"mod_evhost",
30
#				"mod_localizer",
31
#				"mod_fastcgi",
32
#				"mod_proxy",
33
				"mod_cgi",
34
				"mod_compress",
35
				"mod_userdir",
36
				"mod_accesslog" )
37

  
38
server.indexfiles           = ( "index.php", "index.html",
39
                                "index.htm", "default.htm" )
40

  
41

  
42
######################## MODULE CONFIG ############################
43

  
44

  
45
accesslog.filename          = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.access.log"
46

  
47
mimetype.assign             = ( ".png"  => "image/png",
48
                                ".jpg"  => "image/jpeg",
49
                                ".jpeg" => "image/jpeg",
50
                                ".gif"  => "image/gif",
51
                                ".html" => "text/html",
52
                                ".htm"  => "text/html",
53
                                ".pdf"  => "application/pdf",
54
                                ".swf"  => "application/x-shockwave-flash",
55
                                ".spl"  => "application/futuresplash",
56
                                ".txt"  => "text/plain",
57
                                ".tar.gz" =>   "application/x-tgz",
58
                                ".tgz"  => "application/x-tgz",
59
                                ".gz"   => "application/x-gzip",
60
				".c"    => "text/plain",
61
				".conf" => "text/plain" )
62

  
63
compress.cache-dir          = env.SRCDIR + "/tmp/lighttpd/cache/compress/"
64
compress.filetype           = ("text/plain", "text/html")
65

  
66
cgi.assign                  = ( ".pl"  => "/usr/bin/perl",
67
                                ".cgi" => "/usr/bin/perl",
68
				".py"  => "/usr/bin/python" )
69

  
70
userdir.include-user = ( "jan" )
71
userdir.path = "/"
72

  
73
ssl.engine                  = "disable"
74
ssl.pemfile                 = "server.pem"
75

  
76

  
77
url.access-deny             = ( "~", ".inc")
78

  
79
url.redirect                = ( "^/redirect/$" => "http://localhost:2048/" )
80

  
81
url.rewrite		    = ( "^/rewrite/foo($|\?.+)" => "/indexfile/rewrite.php$1",
82
				"^/rewrite/bar(?:$|\?(.+))" => "/indexfile/rewrite.php?bar&$1" )
83

  
84
expire.url                  = ( "/expire/access" => "access 2 hours",
85
				"/expire/modification" => "access plus 1 seconds 2 minutes")
86

  
87
#cache.cache-dir             = "/home/weigon/wwwroot/cache/"
88

  
89
#### status module
90
status.status-url           = "/server-status"
91
status.config-url           = "/server-config"
92

  
93
#### mod-evhost
94
$HTTP["host"] =~ "evhost1.example.org" {
95
  evhost.path-pattern = env.SRCDIR + "/tmp/lighttpd/servers/evhost/%3.1/%3.2/%3/pages/"
96
}
97

  
98
else $HTTP["host"] =~ "evhost2.example.org" {
99
  evhost.path-pattern = env.SRCDIR + "/tmp/lighttpd/servers/evhost/%3/pages/"
100
}
101

  
102
else $HTTP["host"] =~ "evhost3.example.org" {
103
  evhost.path-pattern = env.SRCDIR + "/tmp/lighttpd/servers/evhost/%3.0/pages/"
104
}
105

  
106
else $HTTP["host"] =~ "evhost4.example.org" {
107
  evhost.path-pattern = env.SRCDIR + "/tmp/lighttpd/servers/evhost/%3.\1/pages/"
108
}
109

  
110
else $HTTP["host"] =~ "evhost5.example.org" {
111
  evhost.path-pattern = env.SRCDIR + "/tmp/lighttpd/servers/evhost/%3.\1/pages/"
112
}
113
else $HTTP["host"] =~ "evhost.example.org" {
114
  url.access-deny = ("")
115
}
116

  
117

  
prepare.sh (working copy)
18 18
mkdir -p $tmpdir/servers/www.example.org/pages/expire/
19 19
mkdir -p $tmpdir/servers/www.example.org/pages/indexfile/
20 20
mkdir -p $tmpdir/servers/123.example.org/pages/
21
mkdir -p $tmpdir/servers/evhost/e/v/evhost1/pages
22
mkdir -p $tmpdir/servers/evhost/evhost2/pages
21 23
mkdir -p $tmpdir/logs/
22 24
mkdir -p $tmpdir/cache/
23 25
mkdir -p $tmpdir/cache/compress/
......
42 44
touch $tmpdir/servers/www.example.org/pages/image.jpg \
43 45
      $tmpdir/servers/www.example.org/pages/image.JPG \
44 46
      $tmpdir/servers/www.example.org/pages/Foo.txt \
45
      $tmpdir/servers/www.example.org/pages/a
47
      $tmpdir/servers/www.example.org/pages/a \
48
      $tmpdir/servers/evhost/e/v/evhost1/pages/index.html \
49
      $tmpdir/servers/evhost/evhost2/pages/index.html 
50

  
46 51
echo "12345" > $tmpdir/servers/www.example.org/pages/range.pdf
47 52

  
48 53
printf "%-40s" "preparing infrastructure"