Annotation of embedaddon/lighttpd/tests/mod-proxy.t, revision 1.1.1.2
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 => 9;
12: use LightyTest;
13:
14: my $tf_real = LightyTest->new();
15: my $tf_proxy = LightyTest->new();
16:
17: my $t;
18: my $php_child = -1;
19:
20: SKIP: {
21: skip "PHP already running on port 1026", 1 if $tf_real->listening_on(1026);
1.1.1.2 ! misho 22: skip "no php binary found", 1 unless $LightyTest::HAVE_PHP;
! 23: ok(-1 != ($php_child = $tf_real->spawnfcgi($ENV{'PHP'}, 1026)), "Spawning php");
1.1 misho 24: }
25:
26: ## we need two procs
27: ## 1. the real webserver
28: ## 2. the proxy server
29:
30: $tf_real->{PORT} = 2048;
31: $tf_real->{CONFIGFILE} = 'lighttpd.conf';
32:
33: $tf_proxy->{PORT} = 2050;
34: $tf_proxy->{CONFIGFILE} = 'proxy.conf';
35:
36: ok($tf_real->start_proc == 0, "Starting lighttpd") or goto cleanup;
37:
38: ok($tf_proxy->start_proc == 0, "Starting lighttpd as proxy") or goto cleanup;
39:
40: $t->{REQUEST} = ( <<EOF
41: GET /index.html HTTP/1.0
42: Host: www.example.org
43: EOF
44: );
45: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
46: ok($tf_proxy->handle_http($t) == 0, 'valid request');
47:
48: $t->{REQUEST} = ( <<EOF
49: GET /index.html HTTP/1.0
50: Host: www.example.org
51: EOF
52: );
53: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'Server' => 'Apache 1.3.29' } ];
54: ok($tf_proxy->handle_http($t) == 0, 'drop Server from real server');
55:
56: SKIP: {
57: skip "no PHP running on port 1026", 1 unless $tf_real->listening_on(1026);
58: $t->{REQUEST} = ( <<EOF
59: GET /rewrite/all/some+test%3axxx%20with%20space HTTP/1.0
60: Host: www.example.org
61: EOF
62: );
63: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/some+test%3axxx%20with%20space' } ];
64: ok($tf_proxy->handle_http($t) == 0, 'rewrited urls work with encoded path');
65: }
66:
67: ok($tf_proxy->stop_proc == 0, "Stopping lighttpd proxy");
68:
69: ok($tf_real->stop_proc == 0, "Stopping lighttpd");
70:
71: SKIP: {
72: skip "PHP not started, cannot stop it", 1 unless $php_child != -1;
73: ok(0 == $tf_real->endspawnfcgi($php_child), "Stopping php");
74: $php_child = -1;
75: }
76:
77: exit 0;
78:
79: cleanup:
80:
81: $tf_real->endspawnfcgi($php_child) if $php_child != -1;
82: $tf_real->stop_proc;
83: $tf_proxy->stop_proc;
84:
85: die();
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>