summaryrefslogtreecommitdiff
path: root/tests/mod-scgi.t
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2017-01-04 11:38:46 -0500
committerGlenn Strauss <gstrauss@gluelogic.com>2017-01-31 14:36:15 -0500
commit4a68780e1b1d5388d2d67ab518d1d3c424b792d3 (patch)
tree8b34a6fe838022085ce3216d0dab942b2e9fd45e /tests/mod-scgi.t
parentd246656f5bf640d1c806fa1a4c28e7df1fc344da (diff)
downloadlighttpd-git-4a68780e1b1d5388d2d67ab518d1d3c424b792d3.tar.gz
[mod_scgi] tests/mod-scgi.t unit tests
(copied from tests/mod-fastcgi.t fcgi-responder tests)
Diffstat (limited to 'tests/mod-scgi.t')
-rwxr-xr-xtests/mod-scgi.t91
1 files changed, 91 insertions, 0 deletions
diff --git a/tests/mod-scgi.t b/tests/mod-scgi.t
new file mode 100755
index 00000000..684b012b
--- /dev/null
+++ b/tests/mod-scgi.t
@@ -0,0 +1,91 @@
+#!/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 Test::More tests => 10;
+use LightyTest;
+
+my $tf = LightyTest->new();
+my $t;
+
+SKIP: {
+ skip "no scgi-responder found", 11 unless -x $tf->{BASEDIR}."/tests/scgi-responder" || -x $tf->{BASEDIR}."/tests/scgi-responder.exe";
+
+ $tf->{CONFIGFILE} = 'scgi-responder.conf';
+ ok($tf->start_proc == 0, "Starting lighttpd with $tf->{CONFIGFILE}") or die();
+ $t->{REQUEST} = ( <<EOF
+GET /index.scgi?lf HTTP/1.0
+Host: www.example.org
+EOF
+ );
+ $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'test123' } ];
+ ok($tf->handle_http($t) == 0, 'line-ending \n\n');
+
+ $t->{REQUEST} = ( <<EOF
+GET /index.scgi?crlf HTTP/1.0
+Host: www.example.org
+EOF
+ );
+ $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'test123' } ];
+ ok($tf->handle_http($t) == 0, 'line-ending \r\n\r\n');
+
+ $t->{REQUEST} = ( <<EOF
+GET /index.scgi?slow-lf HTTP/1.0
+Host: www.example.org
+EOF
+ );
+ $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'test123' } ];
+ ok($tf->handle_http($t) == 0, 'line-ending \n + \n');
+
+ $t->{REQUEST} = ( <<EOF
+GET /index.scgi?slow-crlf HTTP/1.0
+Host: www.example.org
+EOF
+ );
+ $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'test123' } ];
+ ok($tf->handle_http($t) == 0, 'line-ending \r\n + \r\n');
+
+ $t->{REQUEST} = ( <<EOF
+GET /abc/def/ghi?path_info HTTP/1.0
+Host: wsgi.example.org
+EOF
+ );
+ $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/abc/def/ghi' } ];
+ ok($tf->handle_http($t) == 0, 'PATH_INFO (wsgi)');
+
+ $t->{REQUEST} = ( <<EOF
+GET /abc/def/ghi?script_name HTTP/1.0
+Host: wsgi.example.org
+EOF
+ );
+ $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '' } ];
+ ok($tf->handle_http($t) == 0, 'SCRIPT_NAME (wsgi)');
+
+
+ $t->{REQUEST} = ( <<EOF
+GET /index.scgi?die-at-end HTTP/1.0
+Host: www.example.org
+EOF
+ );
+ $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'test123' } ];
+ ok($tf->handle_http($t) == 0, 'killing scgi and wait for restart');
+
+ # (might take lighttpd 1 sec to detect backend exit)
+ select(undef, undef, undef, .9);
+ select(undef, undef, undef, .1) while (!$tf->listening_on(10000));
+ $t->{REQUEST} = ( <<EOF
+GET /index.scgi?crlf HTTP/1.0
+Host: www.example.org
+EOF
+ );
+ $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'test123' } ];
+ ok($tf->handle_http($t) == 0, 'regular response of after restart');
+
+
+ ok($tf->stop_proc == 0, "Stopping lighttpd");
+}