Commit | Line | Data |
21a20b7e |
1 | #!perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use FindBin '$Bin'; |
7 | use lib "$Bin/lib"; |
8 | |
d5ba2ab2 |
9 | use Test::More; |
21a20b7e |
10 | use Catalyst::Test 'TestCGIBin'; |
11 | use HTTP::Request::Common; |
12 | |
46a4350c |
13 | # this should be ignored |
14 | $ENV{MOD_PERL} = "mod_perl/2.0"; |
15 | |
9cc2dd4c |
16 | my $response = request POST '/my-bin/path/test.pl', [ |
21a20b7e |
17 | foo => 'bar', |
18 | bar => 'baz' |
19 | ]; |
20 | |
21 | is($response->content, 'foo:bar bar:baz', 'POST to Perl CGI File'); |
22 | |
06d193b4 |
23 | $response = request '/my-bin/path/test.pl?foo=bar&bar=baz'; |
24 | |
25 | is($response->content, 'foo:bar bar:baz', |
26 | 'Perl CGI File invoked with query params'); |
27 | |
bdb35995 |
28 | $response = request POST '/my-bin/exit.pl', [ |
29 | name => 'world', |
30 | ]; |
31 | |
32 | is($response->content, 'hello world', 'POST to Perl CGI with exit()'); |
33 | |
34 | $response = request POST '/my-bin/exit.pl', [ |
35 | name => 'world', |
36 | exit => 17, |
37 | ]; |
38 | |
39 | is($response->code, 500, 'POST to Perl CGI with nonzero exit()'); |
40 | |
21a20b7e |
41 | $response = request POST '/cgihandler/mtfnpy', [ |
42 | foo => 'bar', |
43 | bar => 'baz' |
44 | ]; |
45 | |
46 | is($response->content, 'foo:bar bar:baz', |
47 | 'POST to Perl CGI File through a forward via cgi_action'); |
48 | |
63096ad1 |
49 | $response = request '/my-bin/path/testdata.pl'; |
fbaba9dd |
50 | is($response->content, "testing\n", |
51 | 'scripts with __DATA__ sections work'); |
52 | |
f410f043 |
53 | $response = request '/my-bin/pathinfo.pl/path/info'; |
54 | is($response->content, '/path/info', |
55 | 'PATH_INFO works'); |
56 | |
d5ba2ab2 |
57 | my %orig_sig = %SIG; |
58 | |
59 | ok request '/my-bin/sigs.pl'; |
60 | |
61 | is_deeply \%SIG, \%orig_sig, '%SIG is preserved'; |
62 | |
21a20b7e |
63 | SKIP: { |
64 | skip "Can't run shell scripts on non-*nix", 1 |
65 | if $^O eq 'MSWin32' || $^O eq 'VMS'; |
66 | |
5709e6bd |
67 | # for some reason the +x is not preserved in the dist |
68 | system "chmod +x $Bin/lib/TestCGIBin/root/cgi-bin/test.sh"; |
69 | |
9cc2dd4c |
70 | is(get('/my-bin/test.sh'), "Hello!\n", 'Non-Perl CGI File'); |
21a20b7e |
71 | } |
d5ba2ab2 |
72 | |
73 | done_testing; |