[tests] remove FastCGI test dependency on PHP
parent
89a3987ce7
commit
b598bb53f9
|
@ -1653,7 +1653,6 @@ AC_CONFIG_FILES([\
|
|||
tests/docroot/123/Makefile \
|
||||
tests/docroot/Makefile \
|
||||
tests/docroot/www/expire/Makefile \
|
||||
tests/docroot/www/go/Makefile \
|
||||
tests/docroot/www/indexfile/Makefile \
|
||||
tests/docroot/www/Makefile \
|
||||
tests/Makefile \
|
||||
|
|
|
@ -36,7 +36,6 @@ sub find_program {
|
|||
}
|
||||
|
||||
BEGIN {
|
||||
our $HAVE_PHP = find_program('PHP', 'php-cgi');
|
||||
our $HAVE_PERL = find_program('PERL', 'perl');
|
||||
if (!$HAVE_PERL) {
|
||||
die "Couldn't find path to perl, but it obviously seems to be running";
|
||||
|
|
|
@ -21,7 +21,6 @@ CONFS=\
|
|||
core-request.t \
|
||||
core-response.t \
|
||||
core-var-include.t \
|
||||
fastcgi-10.conf \
|
||||
fastcgi-responder.conf \
|
||||
LightyTest.pm \
|
||||
lowercase.conf \
|
||||
|
|
|
@ -46,21 +46,20 @@ To run a specific config
|
|||
repo=$PWD # from root of src repository
|
||||
cd tests/
|
||||
./prepare.sh
|
||||
PERL=/usr/bin/perl PHP=/usr/bin/php-cgi SRCDIR=$repo/tests \
|
||||
PERL=/usr/bin/perl SRCDIR=$repo/tests \
|
||||
$repo/src/lighttpd -D -f lighttpd.conf -m $repo/src/.libs
|
||||
|
||||
The PERL, PHP, and SRCDIR environment variables are set by LightyTest.pm
|
||||
when 'make check' is run. PERL and PHP can be set to paths to perl and php,
|
||||
e.g. export PERL=/usr/bin/perl PHP=/usr/bin/php-cgi
|
||||
e.g. export PERL=/usr/bin/perl
|
||||
|
||||
To run a specific config under gdb
|
||||
repo=$PWD # from root of src repository
|
||||
cd tests/
|
||||
./prepare.sh
|
||||
PERL=/usr/bin/perl PHP=/usr/bin/php-cgi SRCDIR=$repo/tests repo=$repo \
|
||||
gdb $repo/src/lighttpd
|
||||
PERL=/usr/bin/perl SRCDIR=$repo/tests \
|
||||
gdb --args $repo/src/lighttpd -D -f lighttpd.conf -m $repo/src/.libs
|
||||
|
||||
(gdb) set args -D -f lighttpd.conf -m $repo/src/.libs
|
||||
(gdb) start
|
||||
(gdb) ...
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
EXTRA_DIST=100.txt 12345.html 12345.txt dummyfile.bla phpinfo.php
|
||||
EXTRA_DIST=100.txt 12345.html 12345.txt dummyfile.bla
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
<?php phpinfo(); ?>
|
|
@ -2,27 +2,20 @@ EXTRA_DIST=\
|
|||
404.html \
|
||||
404.pl \
|
||||
cgi-pathinfo.pl \
|
||||
cgi.php \
|
||||
cgi.pl \
|
||||
crlfcrash.pl \
|
||||
exec-date.shtml \
|
||||
get-env.php \
|
||||
get-header.pl \
|
||||
get-post-len.pl \
|
||||
get-server-env.php \
|
||||
index.html \
|
||||
index.txt \
|
||||
ip.pl \
|
||||
nph-status.pl \
|
||||
phpinfo.php \
|
||||
prefix.fcgi \
|
||||
redirect.php \
|
||||
send404.pl \
|
||||
sendfile.php \
|
||||
ssi-include.shtml \
|
||||
ssi-include.txt \
|
||||
ssi.shtml
|
||||
SUBDIRS=\
|
||||
expire \
|
||||
go \
|
||||
indexfile
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
|
||||
#ob_start(/*"ob_gzhandler"*/);
|
||||
print "12345<br />\n";
|
||||
#phpinfo();
|
||||
#header("Content-Length: ".ob_get_length());
|
||||
#ob_end_flush();
|
||||
|
||||
?>
|
|
@ -5,6 +5,33 @@ if ($ENV{"QUERY_STRING"} eq "internal-redir") {
|
|||
exit 0;
|
||||
}
|
||||
|
||||
if ($ENV{"QUERY_STRING"} eq "external-redir") {
|
||||
print "Location: http://www.example.org:2048/\r\n\r\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
# X-Sendfile
|
||||
if ($ENV{"QUERY_STRING"} eq "xsendfile") {
|
||||
# urlencode path for CGI header
|
||||
# (including urlencode ',' if in path, for X-Sendfile2 w/ FastCGI (not CGI))
|
||||
# (This implementation is not minimal encoding;
|
||||
# encode everything that is not alphanumeric, '.' '_', '-', '/')
|
||||
require Cwd;
|
||||
my $path = Cwd::getcwd() . "/index.txt";
|
||||
$path =~ s#([^\w./-])#"%".unpack("H2",$1)#eg;
|
||||
|
||||
print "Status: 200\r\n";
|
||||
print "X-Sendfile: $path\r\n\r\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
# env
|
||||
if ($ENV{"QUERY_STRING"} =~ /^env=(\w+)/) {
|
||||
print "Status: 200\r\n\r\n$ENV{$1}";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
# default
|
||||
print "Content-Type: text/html\r\n\r\n";
|
||||
|
||||
print $ENV{"SCRIPT_NAME"};
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
<?php
|
||||
$env = $_GET["env"];
|
||||
print isset($_ENV[$env]) ? $_ENV[$env] : '';
|
||||
?>
|
|
@ -1,3 +0,0 @@
|
|||
<?php
|
||||
print $_SERVER[$_GET["env"]];
|
||||
?>
|
|
@ -1 +0,0 @@
|
|||
EXTRA_DIST=cgi.php
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
|
||||
#ob_start(/*"ob_gzhandler"*/);
|
||||
print "12345<br />\n";
|
||||
#phpinfo();
|
||||
#header("Content-Length: ".ob_get_length());
|
||||
#ob_end_flush();
|
||||
|
||||
?>
|
|
@ -1 +1 @@
|
|||
EXTRA_DIST=index.php return-404.php query_string.pl
|
||||
EXTRA_DIST=index.pl query_string.pl
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
<?php print $_SERVER["PHP_SELF"]; ?>
|
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
if ($ENV{REDIRECT_STATUS}) {
|
||||
print "Status: $ENV{REDIRECT_STATUS}\r\n\r\n$ENV{SCRIPT_NAME}";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
print "Status: 200\r\n\r\n";
|
|
@ -1,5 +0,0 @@
|
|||
<?php
|
||||
header("Status: 404");
|
||||
|
||||
print $_SERVER["PHP_SELF"];
|
||||
?>
|
|
@ -1 +0,0 @@
|
|||
<?php phpinfo(); ?>
|
|
@ -1,3 +1 @@
|
|||
<?php
|
||||
echo $_SERVER[$_GET["var"]];
|
||||
?>
|
||||
# (file exists for mod-fastcgi.t test case)
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
<?php
|
||||
|
||||
header('Location: http://www.example.org:2048/');
|
||||
?>
|
|
@ -1,13 +0,0 @@
|
|||
<?php
|
||||
|
||||
function pathencode($path) {
|
||||
return str_replace(',', '%2c', urlencode($path));
|
||||
}
|
||||
|
||||
$val = "X-Sendfile2: " . pathencode(getcwd() . "/index.txt") . " " . $_GET["range"];
|
||||
|
||||
if (isset($_GET["range2"])) $val .= ", " . pathencode(getcwd() . "/index.txt") . " " . $_GET["range2"];
|
||||
|
||||
header($val);
|
||||
|
||||
?>
|
|
@ -1,67 +0,0 @@
|
|||
server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/"
|
||||
|
||||
## 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.breakagelog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log"
|
||||
server.name = "www.example.org"
|
||||
server.tag = "Apache 1.3.29"
|
||||
|
||||
server.modules = (
|
||||
"mod_auth",
|
||||
"mod_authn_file",
|
||||
"mod_fastcgi",
|
||||
"mod_accesslog",
|
||||
)
|
||||
|
||||
index-file.names = (
|
||||
"index.php",
|
||||
"index.html",
|
||||
)
|
||||
|
||||
accesslog.filename = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.access.log"
|
||||
|
||||
fastcgi.debug = 0
|
||||
fastcgi.server = (
|
||||
".php" => ( (
|
||||
"host" => "127.0.0.1",
|
||||
"port" => 1026,
|
||||
"bin-path" => env.PHP,
|
||||
"bin-copy-environment" => ( "PATH", "SHELL", "USER", ),
|
||||
"allow-x-send-file" => "enable",
|
||||
) ),
|
||||
"/prefix.fcgi" => ( (
|
||||
"host" => "127.0.0.1",
|
||||
"port" => 1026,
|
||||
"bin-path" => env.PHP,
|
||||
"bin-copy-environment" => ( "PATH", "SHELL", "USER", ),
|
||||
) ),
|
||||
)
|
||||
|
||||
server.error-handler-404 = "/indexfile/return-404.php"
|
||||
|
||||
$HTTP["host"] == "zzz.example.org" {
|
||||
server.name = "zzz.example.org"
|
||||
}
|
||||
|
||||
$HTTP["host"] == "auth.example.org" {
|
||||
server.name = "auth.example.org"
|
||||
auth.backend.htpasswd.userfile = env.SRCDIR + "/tmp/lighttpd/lighttpd.htpasswd"
|
||||
auth.backend = "htpasswd"
|
||||
auth.require = (
|
||||
"" => (
|
||||
"method" => "basic",
|
||||
"realm" => "download archiv",
|
||||
"require" => "valid-user",
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
$HTTP["host"] == "www.example.org" {
|
||||
$HTTP["url"] == "/go/" {
|
||||
index-file.names = ( "cgi.php" )
|
||||
}
|
||||
}
|
|
@ -15,69 +15,95 @@ server.name = "www.example.org"
|
|||
server.tag = "Apache 1.3.29"
|
||||
|
||||
server.modules = (
|
||||
"mod_auth",
|
||||
"mod_authn_file",
|
||||
"mod_fastcgi",
|
||||
"mod_accesslog",
|
||||
)
|
||||
|
||||
index-file.names = (
|
||||
"index.php",
|
||||
"index.html",
|
||||
)
|
||||
|
||||
accesslog.filename = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.access.log"
|
||||
|
||||
$HTTP["host"] == "auth.example.org" {
|
||||
|
||||
fastcgi.debug = 0
|
||||
fastcgi.server = (
|
||||
server.name = "auth.example.org"
|
||||
|
||||
$HTTP["url"] =~ "\.php$" {
|
||||
auth.backend.htpasswd.userfile = env.SRCDIR + "/tmp/lighttpd/lighttpd.htpasswd"
|
||||
auth.backend = "htpasswd"
|
||||
auth.require = (
|
||||
"" => (
|
||||
"method" => "basic",
|
||||
"realm" => "download archiv",
|
||||
"require" => "valid-user",
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
fastcgi.debug = 0
|
||||
fastcgi.server = (
|
||||
"/" => (
|
||||
"grisu-auth" => (
|
||||
"host" => "127.0.0.1",
|
||||
"port" => 20000,
|
||||
"port" => 10000,
|
||||
"bin-path" => env.SRCDIR + "/fcgi-responder",
|
||||
"mode" => "authorizer",
|
||||
"bin-copy-environment" => ( "PATH", "SHELL", "USER", ),
|
||||
"check-local" => "disable",
|
||||
"max-procs" => 1,
|
||||
"mode" => "authorizer",
|
||||
),
|
||||
"grisu-resp" => (
|
||||
"host" => "127.0.0.1",
|
||||
"port" => 10000,
|
||||
"bin-path" => env.SRCDIR + "/fcgi-responder",
|
||||
"bin-copy-environment" => ( "PATH", "SHELL", "USER", ),
|
||||
"check-local" => "disable",
|
||||
"max-procs" => 1,
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
fastcgi.debug = 0
|
||||
fastcgi.server = (
|
||||
fastcgi.debug = 0
|
||||
fastcgi.server = (
|
||||
".php" => ( (
|
||||
"host" => "127.0.0.1",
|
||||
"port" => 10000,
|
||||
"bin-path" => env.SRCDIR + "/fcgi-responder",
|
||||
"bin-copy-environment" => ( "PATH", "SHELL", "USER", ),
|
||||
"check-local" => "disable",
|
||||
"max-procs" => 1,
|
||||
) ),
|
||||
"/prefix.fcgi" => ( (
|
||||
"host" => "127.0.0.1",
|
||||
"port" => 10000,
|
||||
"bin-path" => env.SRCDIR + "/fcgi-responder",
|
||||
"max-procs" => 1,
|
||||
) ),
|
||||
".fcgi" => (
|
||||
"grisu" => (
|
||||
"host" => "127.0.0.1",
|
||||
"port" => 10000,
|
||||
"bin-path" => env.SRCDIR + "/fcgi-responder",
|
||||
"bin-copy-environment" => ( "PATH", "SHELL", "USER", ),
|
||||
"check-local" => "disable",
|
||||
"max-procs" => 1,
|
||||
"min-procs" => 1,
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
$HTTP["host"] == "zzz.example.org" {
|
||||
server.name = "zzz.example.org"
|
||||
}
|
||||
|
||||
$HTTP["host"] == "wsgi.example.org" {
|
||||
fastcgi.server = (
|
||||
"/" => ( (
|
||||
"host" => "127.0.0.1", "port" => 10000,
|
||||
"fix-root-scriptname" => "enable",
|
||||
"check-local" => "disable",
|
||||
"host" => "127.0.0.1",
|
||||
"port" => 10000,
|
||||
"bin-path" => env.SRCDIR + "/fcgi-responder",
|
||||
"bin-copy-environment" => ( "PATH", "SHELL", "USER", ),
|
||||
"check-local" => "disable",
|
||||
"fix-root-scriptname" => "enable",
|
||||
"max-procs" => 1,
|
||||
) ),
|
||||
)
|
||||
|
|
|
@ -198,10 +198,6 @@ fcgi_process_params (FILE * const stream, int req_id, int role, unsigned char *
|
|||
|
||||
if (NULL == p)
|
||||
cdata = NULL;
|
||||
else if (9 == len && 0 == memcmp(p, "path_info", 9))
|
||||
cdata = fcgi_getenv(r, rlen, "PATH_INFO", 9, &len);
|
||||
else if (11 == len && 0 == memcmp(p, "script_name", 11))
|
||||
cdata = fcgi_getenv(r, rlen, "SCRIPT_NAME", 11, &len);
|
||||
else if (len > 4 && 0 == memcmp(p, "env=", 4))
|
||||
cdata = fcgi_getenv(r, rlen, p+4, len-4, &len);
|
||||
else if (8 == len && 0 == memcmp(p, "auth-var", 8))
|
||||
|
|
|
@ -172,3 +172,9 @@ $HTTP["host"] == "etag.example.org" {
|
|||
static-file.etags = "disable"
|
||||
deflate.filetype = ()
|
||||
}
|
||||
|
||||
$HTTP["host"] == "cgi.example.org" {
|
||||
index-file.names = ( "nonexistent.txt", "index.pl" )
|
||||
server.error-handler-404 = "/indexfile/index.pl"
|
||||
cgi.x-sendfile = "enable"
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ BEGIN {
|
|||
|
||||
use strict;
|
||||
use IO::Socket;
|
||||
use Test::More tests => 16;
|
||||
use Test::More tests => 24;
|
||||
use LightyTest;
|
||||
|
||||
my $tf = LightyTest->new();
|
||||
|
@ -25,6 +25,17 @@ EOF
|
|||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
|
||||
ok($tf->handle_http($t) == 0, 'perl via cgi');
|
||||
|
||||
if ($^O ne "cygwin") {
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /cgi.pl%20%20%20 HTTP/1.0
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ];
|
||||
ok($tf->handle_http($t) == 0, 'No source retrieval');
|
||||
} else {
|
||||
ok(1, 'No source retrieval; skipped on cygwin; see response.c');
|
||||
}
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /cgi.pl/foo HTTP/1.0
|
||||
EOF
|
||||
|
@ -39,6 +50,30 @@ EOF
|
|||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
|
||||
ok($tf->handle_http($t) == 0, 'perl via cgi and internal redirect from CGI');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /cgi.pl?xsendfile HTTP/1.0
|
||||
Host: cgi.example.org
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'Content-Length' => 4348 } ];
|
||||
ok($tf->handle_http($t) == 0, 'X-Sendfile');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /cgi.pl?external-redir HTTP/1.0
|
||||
Host: www.example.org
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 302, 'Location' => 'http://www.example.org:2048/' } ];
|
||||
ok($tf->handle_http($t) == 0, 'Status + Location via FastCGI');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /cgi.pl/?external-redir HTTP/1.0
|
||||
Host: www.example.org
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 302, 'Location' => 'http://www.example.org:2048/' } ];
|
||||
ok($tf->handle_http($t) == 0, 'Trailing slash as path-info (#1989: workaround broken operating systems)');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /cgi-pathinfo.pl/foo HTTP/1.0
|
||||
EOF
|
||||
|
@ -82,11 +117,25 @@ $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-
|
|||
ok($tf->handle_http($t) == 0, 'cgi-env: QUERY_STRING');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /get-header.pl?GATEWAY_INTERFACE HTTP/1.0
|
||||
GET /get-header.pl?SCRIPT_NAME HTTP/1.0
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'CGI/1.1' } ];
|
||||
ok($tf->handle_http($t) == 0, 'cgi-env: GATEWAY_INTERFACE');
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/get-header.pl' } ];
|
||||
ok($tf->handle_http($t) == 0, 'cgi-env: SCRIPT_NAME');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /get-header.pl/path/info?SCRIPT_NAME HTTP/1.0
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/get-header.pl' } ];
|
||||
ok($tf->handle_http($t) == 0, 'cgi-env: SCRIPT_NAME w/ PATH_INFO');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /get-header.pl/path/info?PATH_INFO HTTP/1.0
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/path/info' } ];
|
||||
ok($tf->handle_http($t) == 0, 'cgi-env: PATH_INFO');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /get-header.pl?HTTP_XX_YY123 HTTP/1.0
|
||||
|
@ -121,5 +170,23 @@ EOF
|
|||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 302, 'Location' => 'http://www.example.org/' } ];
|
||||
ok($tf->handle_http($t) == 0, 'broken header via perl cgi');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /indexfile/ HTTP/1.0
|
||||
Host: cgi.example.org
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/indexfile/index.pl' } ];
|
||||
ok($tf->handle_http($t) == 0, 'index-file handling, Bug #3, Bug #6');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
POST /indexfile/abc HTTP/1.0
|
||||
Host: cgi.example.org
|
||||
Content-Length: 0
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404, 'HTTP-Content' => '/indexfile/index.pl' } ];
|
||||
ok($tf->handle_http($t) == 0, 'server.error-handler-404, Bug #12');
|
||||
|
||||
|
||||
ok($tf->stop_proc == 0, "Stopping lighttpd");
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ BEGIN {
|
|||
}
|
||||
|
||||
use strict;
|
||||
use Test::More tests => 44;
|
||||
use Test::More tests => 24;
|
||||
use LightyTest;
|
||||
|
||||
my $tf = LightyTest->new();
|
||||
|
@ -15,10 +15,41 @@ my $tf = LightyTest->new();
|
|||
my $t;
|
||||
|
||||
SKIP: {
|
||||
skip "no php binary found", 29 unless $LightyTest::HAVE_PHP;
|
||||
skip "no fcgi-responder found", 24
|
||||
unless ( -x $tf->{BASEDIR}."/tests/fcgi-responder"
|
||||
|| -x $tf->{BASEDIR}."/tests/fcgi-responder.exe");
|
||||
|
||||
$tf->{CONFIGFILE} = 'fastcgi-10.conf';
|
||||
ok($tf->start_proc == 0, "Starting lighttpd") or goto cleanup;
|
||||
$tf->{CONFIGFILE} = 'fastcgi-responder.conf';
|
||||
ok($tf->start_proc == 0, "Starting lighttpd with $tf->{CONFIGFILE}") or die();
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /prefix.fcgi-nonexistent HTTP/1.0
|
||||
Host: www.example.org
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ];
|
||||
ok($tf->handle_http($t) == 0, 'file not found');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /prefix.fcgi?env=SCRIPT_NAME HTTP/1.0
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/prefix.fcgi' } ];
|
||||
ok($tf->handle_http($t) == 0, 'SCRIPT_NAME');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /prefix.fcgi/foo/bar?env=SCRIPT_NAME HTTP/1.0
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/prefix.fcgi' } ];
|
||||
ok($tf->handle_http($t) == 0, 'SCRIPT_NAME w/ PATH_INFO');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /prefix.fcgi/foo/bar?env=PATH_INFO HTTP/1.0
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/foo/bar' } ];
|
||||
ok($tf->handle_http($t) == 0, 'PATH_INFO');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /phpinfo.php HTTP/1.0
|
||||
|
@ -29,151 +60,20 @@ EOF
|
|||
ok($tf->handle_http($t) == 0, 'valid request');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /phpinfofoobar.php HTTP/1.0
|
||||
Host: www.example.org
|
||||
GET /get-server-env.php?env=USER HTTP/1.0
|
||||
Host: bin-env.example.org
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ];
|
||||
ok($tf->handle_http($t) == 0, 'file not found');
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 , 'HTTP-Content' => $ENV{USER} } ];
|
||||
ok($tf->handle_http($t) == 0, 'FastCGI + bin-copy-environment');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /go/ HTTP/1.0
|
||||
Host: www.example.org
|
||||
GET /get-server-env.php?env=MAIL HTTP/1.0
|
||||
Host: bin-env.example.org
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
|
||||
ok($tf->handle_http($t) == 0, 'index-file handling');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /redirect.php HTTP/1.0
|
||||
Host: www.example.org
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 302, 'Location' => 'http://www.example.org:2048/' } ];
|
||||
ok($tf->handle_http($t) == 0, 'Status + Location via FastCGI');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /redirect.php/ HTTP/1.0
|
||||
Host: www.example.org
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 302, 'Location' => 'http://www.example.org:2048/' } ];
|
||||
ok($tf->handle_http($t) == 0, 'Trailing slash as path-info (#1989: workaround broken operating systems)');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /get-server-env.php?env=PHP_SELF HTTP/1.0
|
||||
Host: www.example.org
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
|
||||
ok($tf->handle_http($t) == 0, '$_SERVER["PHP_SELF"]');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /get-server-env.php/foo?env=SCRIPT_NAME HTTP/1.0
|
||||
Host: www.example.org
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/get-server-env.php' } ];
|
||||
ok($tf->handle_http($t) == 0, '$_SERVER["SCRIPT_NAME"]');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /get-server-env.php/foo?env=PATH_INFO HTTP/1.0
|
||||
Host: www.example.org
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/foo' } ];
|
||||
ok($tf->handle_http($t) == 0, '$_SERVER["PATH_INFO"]');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /get-server-env.php?env=SERVER_NAME HTTP/1.0
|
||||
Host: www.example.org
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'www.example.org' } ];
|
||||
ok($tf->handle_http($t) == 0, 'SERVER_NAME');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /get-server-env.php?env=SERVER_NAME HTTP/1.0
|
||||
Host: foo.example.org
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'www.example.org' } ];
|
||||
ok($tf->handle_http($t) == 0, 'SERVER_NAME');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /get-server-env.php?env=SERVER_NAME HTTP/1.0
|
||||
Host: vvv.example.org
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'www.example.org' } ];
|
||||
ok($tf->handle_http($t) == 0, 'SERVER_NAME');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /cgi.php/abc HTTP/1.0
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
|
||||
ok($tf->handle_http($t) == 0, 'PATHINFO');
|
||||
|
||||
if ($^O ne "cygwin") {
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /cgi.php%20%20%20 HTTP/1.0
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ];
|
||||
ok($tf->handle_http($t) == 0, 'No source retrieval');
|
||||
} else {
|
||||
ok(1, 'No source retrieval; skipped on cygwin; see response.c');
|
||||
}
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /www/abc/def HTTP/1.0
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ];
|
||||
ok($tf->handle_http($t) == 0, 'PATHINFO on a directory');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /indexfile/ HTTP/1.0
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/indexfile/index.php' } ];
|
||||
ok($tf->handle_http($t) == 0, 'PHP_SELF + Indexfile, Bug #3');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /prefix.fcgi?var=SCRIPT_NAME HTTP/1.0
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/prefix.fcgi' } ];
|
||||
ok($tf->handle_http($t) == 0, 'PATH_INFO, check-local off');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /prefix.fcgi/foo/bar?var=SCRIPT_NAME HTTP/1.0
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/prefix.fcgi' } ];
|
||||
ok($tf->handle_http($t) == 0, 'PATH_INFO, check-local off');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /prefix.fcgi/foo/bar?var=PATH_INFO HTTP/1.0
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/foo/bar' } ];
|
||||
ok($tf->handle_http($t) == 0, 'PATH_INFO, check-local off');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /sendfile.php?range=0- HTTP/1.0
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'Content-Length' => 4348 } ];
|
||||
ok($tf->handle_http($t) == 0, 'X-Sendfile2');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /sendfile.php?range=0-4&range2=5- HTTP/1.0
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'Content-Length' => 4348 } ];
|
||||
ok($tf->handle_http($t) == 0, 'X-Sendfile2');
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 , 'HTTP-Content' => '' } ];
|
||||
ok($tf->handle_http($t) == 0, 'FastCGI + bin-copy-environment');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /get-server-env.php?env=REMOTE_USER HTTP/1.0
|
||||
|
@ -193,58 +93,6 @@ EOF
|
|||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'Basic' } ];
|
||||
ok($tf->handle_http($t) == 0, '$_SERVER["AUTH_TYPE"]');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /indexfile/ HTTP/1.0
|
||||
Host: www.example.org
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/indexfile/index.php' } ];
|
||||
ok($tf->handle_http($t) == 0, 'Bug #6');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
POST /indexfile/abc HTTP/1.0
|
||||
Host: www.example.org
|
||||
Content-Length: 0
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404, 'HTTP-Content' => '/indexfile/return-404.php' } ];
|
||||
ok($tf->handle_http($t) == 0, 'Bug #12');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /indexfile/index.php HTTP/1.0
|
||||
Host: bin-env.example.org
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
|
||||
ok($tf->handle_http($t) == 0, 'FastCGI + local spawning');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
HEAD /indexfile/index.php HTTP/1.0
|
||||
Host: bin-env.example.org
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '-Content-Length' => '0' } ];
|
||||
# Of course a valid content-length != 0 would be ok, but we assume for now that such one is not generated.
|
||||
ok($tf->handle_http($t) == 0, 'Check for buggy content length with HEAD');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /get-env.php?env=MAIL HTTP/1.0
|
||||
Host: bin-env.example.org
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 , 'HTTP-Content' => '' } ];
|
||||
ok($tf->handle_http($t) == 0, 'FastCGI + bin-copy-environment');
|
||||
|
||||
ok($tf->stop_proc == 0, "Stopping lighttpd");
|
||||
}
|
||||
|
||||
SKIP: {
|
||||
skip "no fcgi-responder found", 15
|
||||
unless ( -x $tf->{BASEDIR}."/tests/fcgi-responder"
|
||||
|| -x $tf->{BASEDIR}."/tests/fcgi-responder.exe");
|
||||
|
||||
$tf->{CONFIGFILE} = 'fastcgi-responder.conf';
|
||||
ok($tf->start_proc == 0, "Starting lighttpd with $tf->{CONFIGFILE}") or die();
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /index.html?auth-ok HTTP/1.0
|
||||
Host: auth.example.org
|
||||
|
@ -318,7 +166,7 @@ EOF
|
|||
ok($tf->handle_http($t) == 0, 'line-ending \r\n + \r\n');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /abc/def/ghi?path_info HTTP/1.0
|
||||
GET /abc/def/ghi?env=PATH_INFO HTTP/1.0
|
||||
Host: wsgi.example.org
|
||||
EOF
|
||||
);
|
||||
|
@ -326,7 +174,7 @@ EOF
|
|||
ok($tf->handle_http($t) == 0, 'PATH_INFO (wsgi)');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /abc/def/ghi?script_name HTTP/1.0
|
||||
GET /abc/def/ghi?env=SCRIPT_NAME HTTP/1.0
|
||||
Host: wsgi.example.org
|
||||
EOF
|
||||
);
|
||||
|
@ -358,9 +206,3 @@ EOF
|
|||
|
||||
ok($tf->stop_proc == 0, "Stopping lighttpd");
|
||||
}
|
||||
|
||||
exit 0;
|
||||
|
||||
cleanup: ;
|
||||
|
||||
die();
|
||||
|
|
|
@ -51,7 +51,7 @@ EOF
|
|||
ok($tf->handle_http($t) == 0, 'line-ending \r\n + \r\n');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /abc/def/ghi?path_info HTTP/1.0
|
||||
GET /abc/def/ghi?env=PATH_INFO HTTP/1.0
|
||||
Host: wsgi.example.org
|
||||
EOF
|
||||
);
|
||||
|
@ -59,7 +59,7 @@ EOF
|
|||
ok($tf->handle_http($t) == 0, 'PATH_INFO (wsgi)');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /abc/def/ghi?script_name HTTP/1.0
|
||||
GET /abc/def/ghi?env=SCRIPT_NAME HTTP/1.0
|
||||
Host: wsgi.example.org
|
||||
EOF
|
||||
);
|
||||
|
|
|
@ -16,34 +16,29 @@ tmpdir="${top_builddir}/tests/tmp/lighttpd"
|
|||
|
||||
# create test-framework
|
||||
rm -rf "${tmpdir}"
|
||||
mkdir -p "${tmpdir}/servers/www.example.org/pages/"
|
||||
mkdir -p "${tmpdir}/servers/www.example.org/pages/dummydir/"
|
||||
mkdir -p "${tmpdir}/servers/www.example.org/pages/~test ä_/"
|
||||
mkdir -p "${tmpdir}/servers/www.example.org/pages/go/"
|
||||
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/a.example.org/pages/a/"
|
||||
mkdir -p "${tmpdir}/servers/b.example.org/pages/b/"
|
||||
mkdir -p "${tmpdir}/logs/"
|
||||
mkdir -p "${tmpdir}/cache/"
|
||||
mkdir -p "${tmpdir}/cache/compress/"
|
||||
mkdir -p "${tmpdir}/servers/www.example.org/pages/" \
|
||||
"${tmpdir}/servers/www.example.org/pages/dummydir/" \
|
||||
"${tmpdir}/servers/www.example.org/pages/~test ä_/" \
|
||||
"${tmpdir}/servers/www.example.org/pages/expire/" \
|
||||
"${tmpdir}/servers/www.example.org/pages/indexfile/" \
|
||||
"${tmpdir}/servers/123.example.org/pages/" \
|
||||
"${tmpdir}/servers/a.example.org/pages/a/" \
|
||||
"${tmpdir}/servers/b.example.org/pages/b/" \
|
||||
"${tmpdir}/logs/" \
|
||||
"${tmpdir}/cache/" \
|
||||
"${tmpdir}/cache/compress/"
|
||||
|
||||
# copy everything into the right places
|
||||
cp "${srcdir}/docroot/www/"*.html \
|
||||
"${srcdir}/docroot/www/"*.php \
|
||||
"${srcdir}/docroot/www/"*.pl \
|
||||
"${srcdir}/docroot/www/"*.fcgi \
|
||||
"${srcdir}/docroot/www/"*.shtml \
|
||||
"${srcdir}/docroot/www/"*.txt \
|
||||
"${tmpdir}/servers/www.example.org/pages/"
|
||||
cp "${srcdir}/docroot/www/go/"*.php "${tmpdir}/servers/www.example.org/pages/go/"
|
||||
cp "${srcdir}/docroot/www/expire/"*.txt "${tmpdir}/servers/www.example.org/pages/expire/"
|
||||
cp "${srcdir}/docroot/www/indexfile/"*.php "${tmpdir}/servers/www.example.org/pages/indexfile/"
|
||||
cp "${srcdir}/docroot/www/indexfile/"*.pl "${tmpdir}/servers/www.example.org/pages/indexfile/"
|
||||
cp "${srcdir}/docroot/123/"*.txt \
|
||||
"${srcdir}/docroot/123/"*.html \
|
||||
"${srcdir}/docroot/123/"*.php \
|
||||
"${srcdir}/docroot/123/"*.bla \
|
||||
"${tmpdir}/servers/123.example.org/pages/"
|
||||
cp "${srcdir}/lighttpd.user" "${tmpdir}/"
|
||||
|
@ -57,5 +52,6 @@ touch "${tmpdir}/servers/www.example.org/pages/image.jpg" \
|
|||
echo "12345" > "${tmpdir}/servers/123.example.org/pages/range.pdf"
|
||||
|
||||
printf "%-40s" "preparing infrastructure"
|
||||
[ -z "$MAKELEVEL" ] && echo
|
||||
|
||||
exit 0
|
||||
|
|
|
@ -8,7 +8,7 @@ BEGIN {
|
|||
|
||||
use strict;
|
||||
use IO::Socket;
|
||||
use Test::More tests => 52;
|
||||
use Test::More tests => 53;
|
||||
use LightyTest;
|
||||
|
||||
my $tf = LightyTest->new();
|
||||
|
@ -524,6 +524,13 @@ EOF
|
|||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ];
|
||||
ok($tf->handle_http($t) == 0, 'static file with forbidden pathinfo');
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /www/abc/def HTTP/1.0
|
||||
EOF
|
||||
);
|
||||
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ];
|
||||
ok($tf->handle_http($t) == 0, 'pathinfo on a directory');
|
||||
|
||||
|
||||
$t->{REQUEST} = ( <<EOF
|
||||
GET /12345.txt HTTP/1.1
|
||||
|
|
|
@ -193,10 +193,8 @@ scgi_process (const int fd)
|
|||
|
||||
if (NULL == p)
|
||||
cdata = NULL;
|
||||
else if (0 == strcmp(p, "path_info"))
|
||||
cdata = scgi_getenv(r, rlen, "PATH_INFO");
|
||||
else if (0 == strcmp(p, "script_name"))
|
||||
cdata = scgi_getenv(r, rlen, "SCRIPT_NAME");
|
||||
else if (0 == strncmp(p, "env=", 4))
|
||||
cdata = scgi_getenv(r, rlen, p+4);
|
||||
else
|
||||
cdata = "test123";
|
||||
|
||||
|
|
Loading…
Reference in New Issue