4 use RT::Test tests => 13;
6 my $r = $HTML::Mason::Commands::r = bless {}, 'R';
7 my $m = $HTML::Mason::Commands::m = bless {}, 'M';
10 CanonicalizeRedirectURLs => 0,
11 WebDomain => 'localhost',
15 is( RT->Config->Get('WebBaseURL'), 'http://localhost' );
16 is( RT->Config->Get('WebURL'), 'http://localhost/' );
19 'http://localhost/Ticket/', 'http://localhost/Ticket/',
20 { SERVER_NAME => 'localhost', SERVER_PORT => 80 },
23 '/Ticket/', 'http://localhost/Ticket/',
24 { SERVER_NAME => 'localhost', SERVER_PORT => 80 },
27 'http://localhost/Ticket/', 'http://example.com/Ticket/',
28 { SERVER_NAME => 'example.com', SERVER_PORT => 80 },
32 CanonicalizeRedirectURLs => 0,
33 WebDomain => 'localhost',
37 is( RT->Config->Get('WebBaseURL'), 'https://localhost' );
38 is( RT->Config->Get('WebURL'), 'https://localhost/' );
41 'https://localhost/Ticket/', 'https://localhost/Ticket/',
42 { SERVER_NAME => 'localhost', SERVER_PORT => 443, HTTPS => 'on' },
45 '/Ticket/', 'https://localhost/Ticket/',
46 { SERVER_NAME => 'localhost', SERVER_PORT => 443, HTTPS => 'on' },
49 'https://localhost/Ticket/', 'http://localhost/Ticket/',
50 { SERVER_NAME => 'localhost', SERVER_PORT => 80 },
53 '/Ticket/', 'http://localhost/Ticket/',
54 { SERVER_NAME => 'localhost', SERVER_PORT => 80 },
57 'https://localhost/Ticket/', 'http://example.com/Ticket/',
58 { SERVER_NAME => 'example.com', SERVER_PORT => 80 },
61 'https://localhost/Ticket/', 'https://example.com/Ticket/',
62 { SERVER_NAME => 'example.com', SERVER_PORT => 443, HTTPS => 'on' },
67 while ( my ($k, $v) = each %values ) {
68 RT->Config->Set( $k => $v );
71 unless ( $values{'WebBaseURL'} ) {
72 my $port = RT->Config->Get('WebPort');
75 ($port == 443? 'https': 'http') .'://'
76 . RT->Config->Get('WebDomain')
77 . ($port != 80 && $port != 443? ":$port" : '')
80 unless ( $values{'WebURL'} ) {
82 WebURL => RT->Config->Get('WebBaseURL') . RT->Config->Get('WebPath') . "/"
88 my ($to, $expected, $env, $details) = @_;
91 while ( my ($k, $v) = each %{ $env || {} } ) {
94 RT::Interface::Web::Redirect( $to );
95 is($m->redirect, $expected, $details || "correct for '$to'");
102 sub redirect { $_[0]{'last'} = $_[1] if @_ > 1; return $_[0]{'last'} }