[tests] skip mod-secdownload HMAC-SHA1,HMAC-SHA256
[lighttpd.git] / tests / mod-proxy.t
blob50cd1424582b66a0d74f12285245ff09e31c59ed
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;
9 use strict;
10 use IO::Socket;
11 use Test::More tests => 7;
12 use LightyTest;
14 my $tf_real = LightyTest->new();
15 my $tf_proxy = LightyTest->new();
17 my $t;
19 ## we need two procs
20 ## 1. the real webserver
21 ## 2. the proxy server
23 $tf_real->{PORT} = 2048;
24 $tf_real->{CONFIGFILE} = 'lighttpd.conf';
26 $tf_proxy->{PORT} = 2050;
27 $tf_proxy->{CONFIGFILE} = 'proxy.conf';
29 ok($tf_real->start_proc == 0, "Starting lighttpd") or goto cleanup;
31 ok($tf_proxy->start_proc == 0, "Starting lighttpd as proxy") or goto cleanup;
33 $t->{REQUEST} = ( <<EOF
34 GET /index.html HTTP/1.0
35 Host: www.example.org
36 EOF
38 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
39 ok($tf_proxy->handle_http($t) == 0, 'valid request');
41 $t->{REQUEST} = ( <<EOF
42 GET /index.html HTTP/1.0
43 Host: www.example.org
44 EOF
46 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'Server' => 'Apache 1.3.29' } ];
47 ok($tf_proxy->handle_http($t) == 0, 'drop Server from real server');
49 $t->{REQUEST} = ( <<EOF
50 GET /rewrite/all/some+test%3axxx%20with%20space HTTP/1.0
51 Host: www.example.org
52 EOF
54 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/some+test%3Axxx%20with%20space' } ];
55 ok($tf_proxy->handle_http($t) == 0, 'rewrited urls work with encoded path');
57 ok($tf_proxy->stop_proc == 0, "Stopping lighttpd proxy");
59 ok($tf_real->stop_proc == 0, "Stopping lighttpd");
61 exit 0;
63 cleanup:
65 $tf_real->stop_proc;
66 $tf_proxy->stop_proc;
68 die();