All working now
[catagits/Catalyst-TraitFor-Request-ProxyBase.git] / t / live-test.t
CommitLineData
1640822e 1#!/usr/bin/env perl
2
3use strict;
4use warnings;
cbca054e 5use HTTP::Request::Common;
6use Test::More tests => 9;
1640822e 7
8# setup library path
9use FindBin qw($Bin);
10use lib "$Bin/lib";
11
044d8723 12use TestApp;
1640822e 13
14# a live test against TestApp, the test application
044d8723 15use Catalyst::Test 'TestApp';
16
cbca054e 17sub req_with_base {
18 my $base = shift;
19
f03ff44b 20 my ($res, $c) = ctx_request(GET('http://localhost/',
21 'X-Request-Base' => $base ));
cbca054e 22 return $c;
23}
24
25is(req_with_base('http://localhost/')->res->body, 'http://localhost/');
26is(req_with_base('https://localhost/')->res->body, 'https://localhost/');
27ok req_with_base('https://localhost/')->req->secure;
28
29is(req_with_base('https://example.com:445/')->res->body,
30 'https://example.com:445/');
31is(req_with_base('http://example.com:443/')->res->body,
32 'http://example.com:443/');
33is(req_with_base('https://example.com:445/some/path')->res->body,
34 'https://example.com:445/some/path/');
35is(req_with_base('https://example.com:445/some/path/')->res->body,
36 'https://example.com:445/some/path/');
37
38ok req_with_base('https://example.com:80/')->req->secure;
39ok !req_with_base('http://example.com:443/')->req->secure;
1640822e 40