Added more documentation and tests
[catagits/HTTP-Request-AsCGI.git] / t / 05env.t
CommitLineData
6f5fb9a7 1#!perl
2
9c216915 3use Test::More tests => 12;
6f5fb9a7 4
5use strict;
6use warnings;
7
6f5fb9a7 8use HTTP::Request;
9use HTTP::Request::AsCGI;
10
ca38286c 11my $r = HTTP::Request->new( GET => 'http://www.host.com/cgi-bin/script.cgi/my/path/?a=1&b=2', [ 'X-Test' => 'Test' ] );
9c216915 12 $r->authorization_basic( 'chansen', 'xxx' );
13
14my $c = HTTP::Request::AsCGI->new(
15 environment => { SCRIPT_NAME => '/cgi-bin/script.cgi' },
16 request => $r,
17 stdout => undef
18);
6f5fb9a7 19
20$c->setup;
21
22is( $ENV{GATEWAY_INTERFACE}, 'CGI/1.1', 'GATEWAY_INTERFACE' );
23is( $ENV{HTTP_HOST}, 'www.host.com:80', 'HTTP_HOST' );
30efa07d 24is( $ENV{HTTP_X_TEST}, 'Test', 'HTTP_X_TEST' );
090cc060 25is( $ENV{PATH_INFO}, '/my/path/', 'PATH_INFO' );
6f5fb9a7 26is( $ENV{QUERY_STRING}, 'a=1&b=2', 'QUERY_STRING' );
9c216915 27is( $ENV{AUTH_TYPE}, 'Basic', 'AUTH_TYPE' );
28is( $ENV{REMOTE_USER}, 'chansen', 'REMOTE_USER' );
ca38286c 29is( $ENV{SCRIPT_NAME}, '/cgi-bin/script.cgi', 'SCRIPT_NAME' );
6f5fb9a7 30is( $ENV{REQUEST_METHOD}, 'GET', 'REQUEST_METHOD' );
31is( $ENV{SERVER_NAME}, 'www.host.com', 'SERVER_NAME' );
32is( $ENV{SERVER_PORT}, '80', 'SERVER_PORT' );
33
34$c->restore;
35
36is( $ENV{GATEWAY_INTERFACE}, undef, 'No CGI env after restore' );