Commit | Line | Data |
5dbf12d1 |
1 | use strict; |
2 | use warnings; |
3 | use Test::More; |
4 | use FindBin qw/$Bin/; |
5 | use lib "$Bin/../lib"; |
6 | use TestApp; |
7 | use Catalyst::Engine::CGI; |
8 | |
eb3abf96 |
9 | # mod_rewrite to app root for non / based app |
5dbf12d1 |
10 | { |
eb3abf96 |
11 | my $r = get_req ( |
5dbf12d1 |
12 | REDIRECT_URL => '/comics/', |
5dbf12d1 |
13 | SCRIPT_NAME => '/comics/dispatch.cgi', |
14 | REQUEST_URI => '/comics/', |
15 | ); |
eb3abf96 |
16 | is ''.$r->uri, 'http://www.foo.com/comics/'; |
17 | is ''.$r->base, 'http://www.foo.com/comics/'; |
18 | } |
19 | |
20 | # mod_rewrite to sub path under app root for non / based app |
21 | { |
22 | my $r = get_req ( |
23 | PATH_INFO => '/foo/bar.gif', |
24 | REDIRECT_URL => '/comics/foo/bar.gif', |
25 | SCRIPT_NAME => '/comics/dispatch.cgi', |
26 | REQUEST_URI => '/comics/foo/bar.gif', |
27 | ); |
28 | is ''.$r->uri, 'http://www.foo.com/comics/foo/bar.gif'; |
29 | is ''.$r->base, 'http://www.foo.com/comics/'; |
30 | } |
31 | |
32 | # Standard CGI hit for non / based app |
33 | { |
34 | my $r = get_req ( |
35 | PATH_INFO => '/static/css/blueprint/screen.css', |
36 | SCRIPT_NAME => '/~bobtfish/Gitalist/script/gitalist.cgi', |
37 | REQUEST_URI => '/~bobtfish/Gitalist/script/gitalist.cgi/static/css/blueprint/screen.css', |
38 | ); |
39 | is ''.$r->uri, 'http://www.foo.com/~bobtfish/Gitalist/script/gitalist.cgi/static/css/blueprint/screen.css'; |
40 | is ''.$r->base, 'http://www.foo.com/~bobtfish/Gitalist/script/gitalist.cgi/'; |
41 | } |
53f4422a |
42 | # / %2F %252F escaping case. |
43 | { |
44 | my $r = get_req ( |
45 | PATH_INFO => '/%2F/%2F', |
46 | SCRIPT_NAME => '/~bobtfish/Gitalist/script/gitalist.cgi', |
47 | REQUEST_URI => '/~bobtfish/Gitalist/script/gitalist.cgi/%252F/%252F', |
48 | ); |
49 | is ''.$r->uri, 'http://www.foo.com/~bobtfish/Gitalist/script/gitalist.cgi/%252F/%252F'; |
50 | is ''.$r->base, 'http://www.foo.com/~bobtfish/Gitalist/script/gitalist.cgi/'; |
51 | } |
eb3abf96 |
52 | |
53 | # FIXME - Test proxy logic |
eb3abf96 |
54 | # - Test query string |
55 | # - Test non standard port numbers |
56 | # - Test // in PATH_INFO |
57 | # - Test scheme (secure request on port 80) |
58 | |
59 | sub get_req { |
ee1ea13f |
60 | my %template = ( |
61 | HTTP_HOST => 'www.foo.com', |
62 | PATH_INFO => '/', |
63 | ); |
64 | |
eb3abf96 |
65 | local %ENV = (%template, @_); |
ee1ea13f |
66 | |
5dbf12d1 |
67 | my $i = TestApp->new; |
68 | $i->engine(Catalyst::Engine::CGI->new); |
69 | $i->engine->prepare_path($i); |
eb3abf96 |
70 | return $i->req; |
5dbf12d1 |
71 | } |
72 | |
73 | done_testing; |
74 | |