->req->remote_user support, new release
[catagits/Catalyst-Controller-WrapCGI.git] / t / wrap-cgi.t
CommitLineData
457c1d76 1#!perl
2
3use strict;
4use warnings;
5
6use FindBin '$Bin';
7use lib "$Bin/lib";
8
b9548267 9use Test::More tests => 7;
457c1d76 10
11use Catalyst::Test 'TestApp';
12use HTTP::Request::Common;
13
14my $response = request POST '/cgi-bin/test.cgi', [
15 foo => 'bar',
16 bar => 'baz'
17];
18
19is($response->content, 'foo:bar bar:baz', 'POST to CGI');
0d83c5de 20
a032b7f8 21$response = request POST '/cgi-bin/test.cgi', [
22 foo => 'bar',
23 bar => 'baz',
24], 'Content-Type' => 'form-data';
25
26is($response->content, 'foo:bar bar:baz', 'POST to CGI (form-data)');
27
d5bb451f 28$response = request POST '/cgi-bin/test.cgi',
29 Content => [
16db0bfc 30 foo => 1,
31 bar => 2,
32 baz => [
33 undef,
34 'baz',
35 'Some-Header' => 'blah',
36 'Content-Type' => 'text/plain',
37 Content => 3
38 ],
01c35d4e 39 quux => [ undef, quux => Content => 4 ],
d5bb451f 40 ],
41 'Content-Type' => 'form-data';
42
01c35d4e 43is($response->content, 'foo:1 bar:2 baz:3 quux:4', 'POST with file upload');
d5bb451f 44
f410f043 45$response = request '/cgi-bin/test_pathinfo.cgi/path/%2Finfo';
8903042e 46is($response->content, '/path/%2Finfo', 'PATH_INFO is correct');
0d83c5de 47
f410f043 48$response = request '/cgi-bin/test_filepathinfo.cgi/path/%2Finfo';
8903042e 49is($response->content, '/test_filepath_info/path/%2Finfo',
f410f043 50 'FILEPATH_INFO is correct (maybe)');
51
17a050f8 52$response = request '/cgi-bin/mtfnpy/test_scriptname.cgi/foo/bar';
53is($response->content, '/cgi-bin/mtfnpy/test_scriptname.cgi',
f410f043 54 'SCRIPT_NAME is correct');
b9548267 55
56$ENV{REMOTE_USER} = 'TEST_USER';
57$response = request '/cgi-bin/test_remote_user.cgi';
58is($response->content, 'TEST_USER', 'REMOTE_USER was passed');