X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Faggregate%2Funit_core_engine_cgi-prepare_path.t;h=76bad625cf893f65e8165117405f3a561399fe1d;hb=439bc59c795c896db3b43daaff4e10c3f9741b1a;hp=0c874e56e465181227bdb61c238a0f2cb34ec41c;hpb=eb3abf9698d6eb550497284482f36a315e856091;p=catagits%2FCatalyst-Runtime.git diff --git a/t/aggregate/unit_core_engine_cgi-prepare_path.t b/t/aggregate/unit_core_engine_cgi-prepare_path.t index 0c874e5..76bad62 100644 --- a/t/aggregate/unit_core_engine_cgi-prepare_path.t +++ b/t/aggregate/unit_core_engine_cgi-prepare_path.t @@ -6,11 +6,6 @@ use lib "$Bin/../lib"; use TestApp; use Catalyst::Engine::CGI; -my %template = ( - HTTP_HOST => 'www.foo.com', - PATH_INFO => '/', -); - # mod_rewrite to app root for non / based app { my $r = get_req ( @@ -44,16 +39,70 @@ my %template = ( is ''.$r->uri, 'http://www.foo.com/~bobtfish/Gitalist/script/gitalist.cgi/static/css/blueprint/screen.css'; is ''.$r->base, 'http://www.foo.com/~bobtfish/Gitalist/script/gitalist.cgi/'; } +# / %2F %252F escaping case. +{ + my $r = get_req ( + PATH_INFO => '/%2F/%2F', + SCRIPT_NAME => '/~bobtfish/Gitalist/script/gitalist.cgi', + REQUEST_URI => '/~bobtfish/Gitalist/script/gitalist.cgi/%252F/%252F', + ); + is ''.$r->uri, 'http://www.foo.com/~bobtfish/Gitalist/script/gitalist.cgi/%252F/%252F'; + is ''.$r->base, 'http://www.foo.com/~bobtfish/Gitalist/script/gitalist.cgi/'; +} + +# Using rewrite rules to ask for a sub-path in your app. +# E.g. RewriteRule ^(.*)$ /path/to/fastcgi/domainprofi.fcgi/iframeredirect$1 [L,NS] +{ + my $r = get_req ( + PATH_INFO => '/iframeredirect/info', + SCRIPT_NAME => '', + REQUEST_URI => '/info', + ); + is ''.$r->uri, 'http://www.foo.com/iframeredirect/info'; + is ''.$r->base, 'http://www.foo.com/'; +} + +# nginx example from espent with path /"foo" +{ + my $r = get_req ( + PATH_INFO => '"foo"', + SCRIPT_NAME => '/', + REQUEST_URI => '/%22foo%22', + ); + is ''.$r->path, '%22foo%22'; + is ''.$r->uri, 'http://www.foo.com/%22foo%22'; + is ''.$r->base, 'http://www.foo.com/'; +} + +# nginx example from espent with path /"foo" and the app based at /oslobilder +{ + my $r = get_req ( + PATH_INFO => 'oslobilder/"foo"', + SCRIPT_NAME => '/oslobilder/', + REQUEST_URI => '/oslobilder/%22foo%22', + ); + is ''.$r->path, '%22foo%22'; + is ''.$r->uri, 'http://www.foo.com/oslobilder/%22foo%22'; + is ''.$r->base, 'http://www.foo.com/oslobilder/'; +} + + + # FIXME - Test proxy logic -# - Test encoding/escaping # - Test query string # - Test non standard port numbers # - Test // in PATH_INFO # - Test scheme (secure request on port 80) sub get_req { + my %template = ( + HTTP_HOST => 'www.foo.com', + PATH_INFO => '/', + ); + local %ENV = (%template, @_); + my $i = TestApp->new; $i->engine(Catalyst::Engine::CGI->new); $i->engine->prepare_path($i);