Annotation of embedaddon/lighttpd/tests/mod-cgi.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;
1.1.1.2 ! misho      11: use Test::More tests => 16;
1.1       misho      12: use LightyTest;
                     13: 
                     14: my $tf = LightyTest->new();
                     15: my $t;
                     16: 
                     17: ok($tf->start_proc == 0, "Starting lighttpd") or die();
                     18: 
                     19: # mod-cgi
                     20: #
                     21: $t->{REQUEST}  = ( <<EOF
                     22: GET /cgi.pl HTTP/1.0
                     23: EOF
                     24:  );
                     25: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
                     26: ok($tf->handle_http($t) == 0, 'perl via cgi');
                     27: 
                     28: $t->{REQUEST}  = ( <<EOF
                     29: GET /cgi.pl/foo HTTP/1.0
                     30: EOF
                     31:  );
                     32: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/cgi.pl' } ];
                     33: ok($tf->handle_http($t) == 0, 'perl via cgi + pathinfo');
                     34: 
                     35: $t->{REQUEST}  = ( <<EOF
1.1.1.2 ! misho      36: GET /cgi.pl?internal-redir HTTP/1.0
        !            37: EOF
        !            38:  );
        !            39: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
        !            40: ok($tf->handle_http($t) == 0, 'perl via cgi and internal redirect from CGI');
        !            41: 
        !            42: $t->{REQUEST}  = ( <<EOF
1.1       misho      43: GET /cgi-pathinfo.pl/foo HTTP/1.0
                     44: EOF
                     45:  );
                     46: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/foo' } ];
                     47: ok($tf->handle_http($t) == 0, 'perl via cgi + pathinfo');
                     48: 
                     49: $t->{REQUEST}  = ( <<EOF
                     50: GET /nph-status.pl?30 HTTP/1.0
                     51: EOF
                     52:  );
                     53: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
                     54: ok($tf->handle_http($t) == 0, 'NPH + perl, invalid status-code (#14)');
                     55: 
                     56: $t->{REQUEST}  = ( <<EOF
                     57: GET /nph-status.pl?304 HTTP/1.0
                     58: EOF
                     59:  );
                     60: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304 } ];
                     61: ok($tf->handle_http($t) == 0, 'NPH + perl, setting status-code (#1125)');
                     62: 
                     63: $t->{REQUEST}  = ( <<EOF
                     64: GET /nph-status.pl?200 HTTP/1.0
                     65: EOF
                     66:  );
                     67: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
                     68: ok($tf->handle_http($t) == 0, 'NPH + perl, setting status-code');
                     69: 
                     70: $t->{REQUEST} = ( <<EOF
                     71: GET /get-header.pl?GATEWAY_INTERFACE HTTP/1.0
                     72: EOF
                     73:  );
                     74: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'CGI/1.1' } ];
                     75: ok($tf->handle_http($t) == 0, 'cgi-env: GATEWAY_INTERFACE');
                     76: 
                     77: $t->{REQUEST} = ( <<EOF
                     78: GET /get-header.pl?QUERY_STRING HTTP/1.0
                     79: EOF
                     80:  );
                     81: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'QUERY_STRING' } ];
                     82: ok($tf->handle_http($t) == 0, 'cgi-env: QUERY_STRING');
                     83: 
                     84: $t->{REQUEST} = ( <<EOF
                     85: GET /get-header.pl?GATEWAY_INTERFACE HTTP/1.0
                     86: EOF
                     87:  );
                     88: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'CGI/1.1' } ];
                     89: ok($tf->handle_http($t) == 0, 'cgi-env: GATEWAY_INTERFACE');
                     90: 
                     91: $t->{REQUEST}  = ( <<EOF
                     92: GET /get-header.pl?HTTP_XX_YY123 HTTP/1.0
                     93: xx-yy123: foo
                     94: EOF
                     95:  );
                     96: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'foo' } ];
                     97: ok($tf->handle_http($t) == 0, 'cgi-env: quoting headers with numbers');
                     98: 
                     99: $t->{REQUEST}  = ( <<EOF
                    100: GET /get-header.pl?HTTP_HOST HTTP/1.0
                    101: Host: www.example.org
                    102: EOF
                    103:  );
1.1.1.2 ! misho     104: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'www.example.org', 'Content-Type' => 'text/plain' } ];
1.1       misho     105: ok($tf->handle_http($t) == 0, 'cgi-env: HTTP_HOST');
                    106: 
                    107: $t->{REQUEST}  = ( <<EOF
                    108: GET /get-header.pl?HTTP_HOST HTTP/1.1
                    109: Host: www.example.org
                    110: Connection: close
                    111: EOF
                    112:  );
                    113: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200, '+Content-Length' => '' } ];
                    114: ok($tf->handle_http($t) == 0, 'cgi-env: HTTP_HOST');
                    115: 
                    116: # broken header crash
                    117: $t->{REQUEST}  = ( <<EOF
                    118: GET /crlfcrash.pl HTTP/1.0
                    119: EOF
                    120:  );
                    121: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 302, 'Location' => 'http://www.example.org/' } ];
                    122: ok($tf->handle_http($t) == 0, 'broken header via perl cgi');
                    123: 
                    124: ok($tf->stop_proc == 0, "Stopping lighttpd");
                    125: 

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