Browse Source

[tests] able to run tests when built w/o pcre

perl test framework now runs most tests even when lighttpd has been
built without pcre support, though some tests which rely on regex
are skipped (tests/core-condition.t)
master
Glenn Strauss 3 months ago
parent
commit
7258624e51
  1. 20
      tests/condition.conf
  2. 17
      tests/core-condition.t
  3. 2
      tests/fastcgi-responder.conf
  4. 50
      tests/lighttpd.conf
  5. 6
      tests/proxy.conf
  6. 2
      tests/request.t
  7. 3
      tests/var-include-sub.conf

20
tests/condition.conf

@ -25,21 +25,21 @@ mimetype.assign = (
)
url.redirect = (
"^" => "/default",
"" => "/default",
)
$HTTP["host"] == "www.example.org" {
server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/"
server.name = "www.example.org"
url.redirect = (
"^" => "/match_1",
"" => "/match_1",
)
}
else $HTTP["host"] == "test1.example.org" {
server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/"
server.name = "test1.example.org"
url.redirect = (
"^" => "/match_2",
"" => "/match_2",
)
}
# comments
@ -47,7 +47,7 @@ else $HTTP["host"] == "test2.example.org" {
server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/"
server.name = "test2.example.org"
url.redirect = (
"^" => "/match_3",
"" => "/match_3",
)
}
@ -57,13 +57,13 @@ else $HTTP["host"] == "test3.example.org" {
server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/"
server.name = "test3.example.org"
url.redirect = (
"^" => "/match_4",
"" => "/match_4",
)
# comments
$HTTP["url"] == "/index.html" {
url.redirect = (
"^" => "/match_5",
"" => "/match_5",
)
}
}
@ -72,12 +72,12 @@ else $HTTP["host"] == "test4.example.org" {
server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/"
server.name = "test4.example.org"
url.redirect = (
"^" => "/match_6",
"" => "/match_6",
)
$HTTP["url"] =~ "^/subdir/" {
$HTTP["url"] =^ "/subdir/" {
url.redirect = (
"^" => "/match_7",
"" => "/match_7",
)
}
}
@ -86,7 +86,7 @@ else $HTTP["host"] == "test.example.org" {
server.name = "test.example.org"
var.myvar = "good"
var.one = 1
include "var-include-sub.conf"
include env.condition_include_file
}
$HTTP["url"] != "/show/other/server-tag" {

17
tests/core-condition.t

@ -8,10 +8,12 @@ BEGIN {
use strict;
use IO::Socket;
use Test::More tests => 25;
use Test::More tests => 26;
use LightyTest;
my $tf = LightyTest->new();
my $has_pcre = $tf->has_feature("PCRE support");
$ENV{condition_include_file} = $has_pcre ? "var-include-sub.conf" : "nonexistent-glob*";
my $t;
$ENV{"env_test"} = "good_env";
@ -19,6 +21,9 @@ $ENV{"env_test"} = "good_env";
$tf->{CONFIGFILE} = 'condition.conf';
ok($tf->start_proc == 0, "Starting lighttpd") or die();
SKIP: {
skip "skipping tests requiring PCRE", 24 unless $has_pcre;
$t->{REQUEST} = ( <<EOF
GET /index.html HTTP/1.0
Host: www.example.org
@ -88,6 +93,14 @@ $t->{REQUEST} = ( "GET /index.html HTTP/1.0\r\nHost: www.example.org\r\n" );
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => "/match_1" } ];
ok($tf->handle_http($t) == 0, 'basic test');
$t->{REQUEST} = ( <<EOF
GET /rewrite/all/some+test%3axxx%20with%20space HTTP/1.0
Host: test.example.org
EOF
);
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => '/some+test%3Axxx%20with%20space' } ];
ok($tf->handle_http($t) == 0, 'rewritten urls work with encoded path');
my $myvar = "good";
my $server_name = "test.example.org";
my $mystr = "string";
@ -122,4 +135,6 @@ EOF
ok($tf->handle_http($t) == 0, $test);
}
}
ok($tf->stop_proc == 0, "Stopping lighttpd");

2
tests/fastcgi-responder.conf

@ -25,7 +25,7 @@ $HTTP["host"] == "auth.example.org" {
server.name = "auth.example.org"
$HTTP["url"] =~ "\.php$" {
$HTTP["url"] =$ ".php" {
auth.backend.htpasswd.userfile = env.SRCDIR + "/tmp/lighttpd/lighttpd.htpasswd"
auth.backend = "htpasswd"
auth.require = (

50
tests/lighttpd.conf

@ -94,11 +94,6 @@ extforward.forwarder = (
"127.0.30.1" => "trust",
)
url.access-deny = (
"~",
".inc",
)
expire.url = (
"/expire/access" => "access 2 hours",
"/expire/modification" => "access plus 1 seconds 2 minutes",
@ -123,7 +118,7 @@ else {
simple-vhost.default-host = "www.example.org"
}
$HTTP["host"] =~ "bug255\.example\.org$" {
$HTTP["host"] == "bug255.example.org" {
$HTTP["remoteip"] == "127.0.0.1" {
url.access-deny = (
"",
@ -131,7 +126,12 @@ $HTTP["host"] =~ "bug255\.example\.org$" {
}
}
$HTTP["referer"] !~ "^($|http://referer\.example\.org)" {
#$HTTP["referer"] !~ "^($|http://referer\.example\.org)" {
$HTTP["referer"] =^ "http://referer.example.org" {
}
else $HTTP["referer"] == "" {
}
else {
url.access-deny = (
".jpg",
)
@ -139,14 +139,19 @@ $HTTP["referer"] !~ "^($|http://referer\.example\.org)" {
# deny access for all image stealers
$HTTP["host"] == "referer.example.org" {
$HTTP["referer"] !~ "^($|http://referer\.example\.org)" {
#$HTTP["referer"] !~ "^($|http://referer\.example\.org)" {
$HTTP["referer"] =^ "http://referer.example.org" {
}
else $HTTP["referer"] == "" {
}
else {
url.access-deny = (
".png",
)
}
}
$HTTP["cookie"] =~ "empty-ref" {
$HTTP["cookie"] =~ "^empty-ref$" {
$HTTP["referer"] == "" {
url.access-deny = (
"",
@ -154,20 +159,15 @@ $HTTP["cookie"] =~ "empty-ref" {
}
}
$HTTP["host"] =~ "allow\.example\.org$" {
url.access-allow = ( ".txt" ) # allow takes precedence over deny
url.access-deny = ( ".txt" )
}
$HTTP["host"] == "cgi.example.org" {
cgi.x-sendfile = "enable"
}
$HTTP["host"] == "errors.example.org" {
$HTTP["url"] =~ "^/static/" {
$HTTP["url"] =^ "/static/" {
server.error-handler-404 = "/404.html"
}
else $HTTP["url"] =~ "^/dynamic/redirect_status/" {
else $HTTP["url"] =^ "/dynamic/redirect_status/" {
server.error-handler = "/404.pl"
}
else {
@ -203,7 +203,11 @@ $HTTP["host"] == "lowercase-auth" {
)
}
$HTTP["host"] =~ "^deflate(?:-cache)?\.example\.org$" {
deflate.allowed-encodings = (
"gzip",
"deflate",
)
$HTTP["host"] == "deflate.example.org" {
$HTTP["url"] == "/index.txt" {
# (force Content-Type for test; do not copy)
setenv.set-response-header = (
@ -214,13 +218,13 @@ $HTTP["host"] =~ "^deflate(?:-cache)?\.example\.org$" {
"text/plain",
"text/html",
)
deflate.allowed-encodings = (
"gzip",
"deflate",
}
$HTTP["host"] == "deflate-cache.example.org" {
deflate.mimetypes = (
"text/plain",
"text/html",
)
$HTTP["host"] == "deflate-cache.example.org" {
deflate.cache-dir = env.SRCDIR + "/tmp/lighttpd/cache/compress/"
}
deflate.cache-dir = env.SRCDIR + "/tmp/lighttpd/cache/compress/"
}
$HTTP["host"] =~ "^auth-" {

6
tests/proxy.conf

@ -10,7 +10,6 @@ server.tag = "Proxy"
server.compat-module-load = "disable"
server.modules = (
"mod_rewrite",
"mod_proxy",
"mod_accesslog",
)
@ -24,7 +23,6 @@ proxy.server = ( "" => (
"port" => env.EPHEMERAL_PORT,
),
))
url.rewrite = (
"^/rewrite/all(/.*)$" => "/cgi.pl?$1",
proxy.header = (
"map-urlpath" => ( "/rewrite/all" => "/cgi.pl?" )
)

2
tests/request.t

@ -1510,7 +1510,7 @@ Accept-Encoding: bzip2, gzip, deflate
Host: deflate-cache.example.org
EOF
);
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', 'Content-Encoding' => 'gzip', 'Content-Type' => "text/plain; charset=utf-8" } ];
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', 'Content-Encoding' => 'gzip', 'Content-Type' => "text/plain" } ];
ok($tf->handle_http($t) == 0, 'bzip2 requested but disabled');

3
tests/var-include-sub.conf

@ -1,5 +1,5 @@
# file to be included
$HTTP["host"] =~ "^" + server.name + "$" {
$HTTP["host"] == server.name {
url.redirect = (
"^/include$" => "/good_include",
"^/concat$" => "/good_" + "concat",
@ -11,6 +11,7 @@ $HTTP["host"] =~ "^" + server.name + "$" {
"^/number1$" => "/good_number" + one,
"^/number2$" => one + "/good_number",
"^/env$" => "/" + env.env_test,
"^/rewrite/all(/.*)$" => "$1",
)
num = 1

Loading…
Cancel
Save