X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fwrap-cgi.t;h=8317345bcf1dc909df804f0a2f0a97214c488997;hb=5c7bf47d5c832018fc615638efbddcbf97b6e19a;hp=8e01df7f6d8e0112e709d821ea51ffaadf8cb3f0;hpb=8903042ec15fa19c666a6cbbc6c56597f6d90f3f;p=catagits%2FCatalyst-Controller-WrapCGI.git diff --git a/t/wrap-cgi.t b/t/wrap-cgi.t index 8e01df7..8317345 100644 --- a/t/wrap-cgi.t +++ b/t/wrap-cgi.t @@ -6,7 +6,7 @@ use warnings; use FindBin '$Bin'; use lib "$Bin/lib"; -use Test::More tests => 4; +use Test::More tests => 7; use Catalyst::Test 'TestApp'; use HTTP::Request::Common; @@ -18,13 +18,51 @@ my $response = request POST '/cgi-bin/test.cgi', [ is($response->content, 'foo:bar bar:baz', 'POST to CGI'); +$response = request POST '/cgi-bin/test.cgi', [ + foo => 'bar', + bar => 'baz', +], User_Agent => 'perl/5', Content_Type => 'form-data'; + +is($response->content, 'foo:bar bar:baz', 'POST to CGI (form-data)'); + +$response = request POST '/cgi-bin/test.cgi', + Content => [ + foo => 1, + bar => 2, + baz => [ + undef, + 'baz', + 'Some-Header' => 'blah', + 'Content-Type' => 'text/plain', + Content => 3 + ], + quux => [ undef, quux => Content => 4 ], + ], + User_Agent => 'perl/5', + Content_Type => 'form-data'; + +is($response->content, 'foo:1 bar:2 baz:3 quux:4', 'POST with file upload'); + $response = request '/cgi-bin/test_pathinfo.cgi/path/%2Finfo'; -is($response->content, '/path/%2Finfo', 'PATH_INFO is correct'); +is($response->content, '/path//info', 'PATH_INFO is correct'); $response = request '/cgi-bin/test_filepathinfo.cgi/path/%2Finfo'; -is($response->content, '/test_filepath_info/path/%2Finfo', - 'FILEPATH_INFO is correct (maybe)'); +is($response->content, '/test_filepath_info/path//info', + 'FILEPATH_INFO is correct'); -$response = request '/cgi-bin/test_scriptname.cgi/foo/bar'; -is($response->content, '/cgi-bin/test_scriptname.cgi', +$response = request '/cgi-bin/mtfnpy/test_scriptname.cgi/foo/bar'; +is($response->content, '/cgi-bin/mtfnpy/test_scriptname.cgi', 'SCRIPT_NAME is correct'); + +SKIP: { + require Catalyst; + + skip 'no $c->req->remote_user', 1 + if $Catalyst::VERSION < 5.80005; + + $ENV{REMOTE_USER} = 'TEST_USER'; + $response = request( '/cgi-bin/test_remote_user.cgi', + { extra_env => { REMOTE_USER => 'TEST_USER' } }, + ); + is($response->content, 'TEST_USER', 'REMOTE_USER was passed'); +}