File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / lighttpd / tests / mod-rewrite.t
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Wed Nov 2 10:35:00 2016 UTC (8 years ago) by misho
Branches: lighttpd, MAIN
CVS tags: v1_4_41p8, HEAD
lighttpd 1.4.41

    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 => 8;
   12: use LightyTest;
   13: 
   14: my $tf = LightyTest->new();
   15: my $t;
   16: my $php_child = -1;
   17: 
   18: SKIP: {
   19: 	skip "PHP already running on port 1026", 1 if $tf->listening_on(1026);
   20: 	skip "no php binary found", 1 unless $LightyTest::HAVE_PHP;
   21: 	ok(-1 != ($php_child = $tf->spawnfcgi($ENV{'PHP'}, 1026)), "Spawning php");
   22: }
   23: 
   24: SKIP: {
   25: 	skip "no PHP running on port 1026", 6 unless $tf->listening_on(1026);
   26: 
   27: 	ok($tf->start_proc == 0, "Starting lighttpd") or goto cleanup;
   28: 
   29: 	$t->{REQUEST}  = ( <<EOF
   30: GET /rewrite/foo HTTP/1.0
   31: Host: www.example.org
   32: EOF
   33:  );
   34: 	$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '' } ];
   35: 	ok($tf->handle_http($t) == 0, 'valid request');
   36:     
   37: 	$t->{REQUEST}  = ( <<EOF
   38: GET /rewrite/foo?a=b HTTP/1.0
   39: Host: www.example.org
   40: EOF
   41:  );
   42: 	$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'a=b' } ];
   43: 	ok($tf->handle_http($t) == 0, 'valid request');
   44: 
   45: 	$t->{REQUEST}  = ( <<EOF
   46: GET /rewrite/bar?a=b HTTP/1.0
   47: Host: www.example.org
   48: EOF
   49:  );
   50: 	$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'bar&a=b' } ];
   51: 	ok($tf->handle_http($t) == 0, 'valid request');
   52: 
   53: 	$t->{REQUEST}  = ( <<EOF
   54: GET /rewrite/nofile?a=b HTTP/1.0
   55: Host: www.example.org
   56: EOF
   57:  );
   58: 	$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'file=/rewrite/nofile&a=b' } ];
   59: 	ok($tf->handle_http($t) == 0, 'not existing file rewrite');
   60: 
   61: 	ok($tf->stop_proc == 0, "Stopping lighttpd");
   62: }
   63: 
   64: SKIP: {
   65: 	skip "PHP not started, cannot stop it", 1 unless $php_child != -1;
   66: 	ok(0 == $tf->endspawnfcgi($php_child), "Stopping php");
   67: }
   68: 
   69: 
   70: exit 0;
   71: 
   72: cleanup: ;
   73: 
   74: $tf->endspawnfcgi($php_child) if $php_child != -1;
   75: 
   76: die();

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>