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