Annotation of embedaddon/lighttpd/tests/core-404-handler.t, revision 1.1.1.1

1.1       misho       1: #!/usr/bin/env perl
                      2: #
                      3: # combinations we have to test:
                      4: # plain 404 case
                      5: # 404-handler -> static file (verify content)
                      6: # 404-handler -> fastcgi
                      7: #   returning 200
                      8: #   returning 302 + Location
                      9: #   returning 404
                     10: #   returning no status -> 200
                     11: #
                     12: BEGIN {
                     13:        # add current source dir to the include-path
                     14:        # we need this for make distcheck
                     15:        (my $srcdir = $0) =~ s,/[^/]+$,/,;
                     16:        unshift @INC, $srcdir;
                     17: }
                     18: 
                     19: use strict;
                     20: use IO::Socket;
                     21: use Test::More tests => 8;
                     22: use LightyTest;
                     23: 
                     24: my $tf = LightyTest->new();
                     25: my $t;
                     26: $tf->{CONFIGFILE} = '404-handler.conf';
                     27: 
                     28: ok($tf->start_proc == 0, "Starting lighttpd") or die();
                     29: 
                     30: $t->{REQUEST}  = ( <<EOF
                     31: GET /static/notfound HTTP/1.0
                     32: EOF
                     33:  );
                     34: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => "static not found\n" } ];
                     35: ok($tf->handle_http($t) == 0, '404 handler => static');
                     36: 
                     37: #
                     38: #
                     39: #
                     40: $t->{REQUEST}  = ( <<EOF
                     41: GET /dynamic/200/notfound HTTP/1.0
                     42: EOF
                     43:  );
                     44: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => "found here\n" } ];
                     45: ok($tf->handle_http($t) == 0, '404 handler => dynamic(200)');
                     46: 
                     47: $t->{REQUEST}  = ( <<EOF
                     48: GET /dynamic/302/notfound HTTP/1.0
                     49: EOF
                     50:  );
                     51: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 302, 'Location' => "http://www.example.org/" } ];
                     52: ok($tf->handle_http($t) == 0, '404 handler => dynamic(302)');
                     53: 
                     54: $t->{REQUEST}  = ( <<EOF
                     55: GET /dynamic/404/notfound HTTP/1.0
                     56: EOF
                     57:  );
                     58: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404, 'HTTP-Content' => "Not found here\n" } ];
                     59: ok($tf->handle_http($t) == 0, '404 handler => dynamic(404)');
                     60: 
                     61: $t->{REQUEST}  = ( <<EOF
                     62: GET /dynamic/nostatus/notfound HTTP/1.0
                     63: EOF
                     64:  );
                     65: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => "found here\n" } ];
                     66: ok($tf->handle_http($t) == 0, '404 handler => dynamic(nostatus)');
                     67: 
                     68: $t->{REQUEST}  = ( <<EOF
                     69: GET /send404.pl HTTP/1.0
                     70: EOF
                     71:  );
                     72: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404, 'HTTP-Content' => "send404\n" } ];
                     73: ok($tf->handle_http($t) == 0, '404 generated by CGI should stay 404');
                     74: 
                     75: ok($tf->stop_proc == 0, "Stopping lighttpd");
                     76: 

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