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=c604487a46c6e315094cefdef0281f9f12fe3d18;hb=62b6b631cf9141ffd9ae02e4b87c182b080b335a;hp=dd768f4570ef6322bc5b4ef24e648199057697c5;hpb=ee1ea13fb9f1694f769e4bf41366178079e16c06;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 dd768f4..c604487 100644 --- a/t/aggregate/unit_core_engine_cgi-prepare_path.t +++ b/t/aggregate/unit_core_engine_cgi-prepare_path.t @@ -50,6 +50,69 @@ use Catalyst::Engine::CGI; 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/'; +} + +{ + my $r = get_req ( + PATH_INFO => '/auth/login', + SCRIPT_NAME => '/tx', + REQUEST_URI => '/login', + ); + is ''.$r->path, 'auth/login'; + is ''.$r->uri, 'http://www.foo.com/tx/auth/login'; + is ''.$r->base, 'http://www.foo.com/tx/'; +} + +# test req->base and c->uri_for work correctly after an internally redirected request +# (i.e. REDIRECT_URL set) when the PATH_INFO contains a regex +{ + my $path = '/engine/request/uri/Rx(here)'; + my $r = get_req ( + SCRIPT_NAME => '/', + PATH_INFO => $path, + REQUEST_URI => $path, + REDIRECT_URL => $path, + ); + + is $r->path, 'engine/request/uri/Rx(here)', 'URI contains correct path'; + is $r->base, 'http://www.foo.com/', 'Base is correct'; +} + + # FIXME - Test proxy logic # - Test query string # - Test non standard port numbers