File: redirect.t

package info (click to toggle)
libapache2-mod-perl2 2.0.4-7%2Bsqueeze1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 9,896 kB
  • ctags: 3,820
  • sloc: perl: 56,663; ansic: 14,001; makefile: 93; sh: 38
file content (60 lines) | stat: -rw-r--r-- 1,388 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use strict;
use warnings FATAL => 'all';

use Apache::Test;
use Apache::TestUtil;
use Apache::TestRequest qw(GET_BODY HEAD);

use Apache::TestUtil qw(t_catfile_apache);

plan tests => 4, need [qw(mod_alias.c HTML::HeadParser)], need_lwp;

# need LWP to handle redirects
my $base_url = "/registry/redirect.pl";

{
    my $redirect_path = "/registry/basic.pl";
    my $url = "$base_url?$redirect_path";
    my $vars = Apache::Test::config()->{vars};
    my $script_file = t_catfile_apache $vars->{serverroot}, 'cgi-bin', 'basic.pl';

    ok t_cmp(
        GET_BODY($url),
        "ok $script_file",
        "test redirect: existing target",
       );
}

{
    my $redirect_path = "/registry/does_not_exists.pl";
    my $url = "$base_url?$redirect_path";
    t_client_log_error_is_expected();
    ok t_cmp(
        HEAD($url)->code,
        404,
        "test redirect: non-existing target",
       );
}

{
    local $Apache::TestRequest::RedirectOK = 0;

    my $base_url = "/registry/redirect-cookie.pl";
    my $redirect_path = "/registry/basic.pl";
    my $url = "$base_url?$redirect_path";

    my $response = HEAD $url;

    ok t_cmp(
        $response->code,
        302,
        "test Registry style redirect: status",
       );

    ok t_cmp(
        $response->header('Set-Cookie'),
        "mod_perl=ubercool; path=/",
        "test Registry style redirect: cookie",
       );
}