summaryrefslogtreecommitdiffstats
path: root/debian/perl-framework/t/modules/allowmethods.t
blob: 6e2e815dc2cb139f94ee1aab005be3e76aecad76 (plain)
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
use strict;
use warnings FATAL => 'all';

use Apache::Test;
use Apache::TestRequest;
use Apache::TestUtil;

my $r;
my $get = "Get";
my $head = "Head";
my $post = "Post";

##
## mod_allowmethods test
##
my @test_cases = (
    [ $get, $get, 200 ],
    [ $head, $get, 200 ],
    [ $post, $get, 405 ],
    [ $get, $head, 200 ],
    [ $head, $head, 200 ],
    [ $post, $head, 405 ],
    [ $get, $post, 405 ],
    [ $head, $post, 405 ],
    [ $post, $post, 200 ],
);

plan tests => (scalar @test_cases), have_module 'allowmethods';

foreach my $case (@test_cases) {
    my ($fct, $allowed, $rc) = @{$case};
    
    if ($fct eq $get) {
        $r = GET('/modules/allowmethods/' . $allowed . '/');
    }
    elsif ($fct eq $head) {
        $r = HEAD('/modules/allowmethods/' . $allowed . '/');
    }
    elsif ($fct eq $post) {
        $r = POST('/modules/allowmethods/' . $allowed . '/foo.txt');
    }

    ok t_cmp($r->code, $rc, $fct . " - When " . $allowed . " is allowed.");
}