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