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