~ubuntu-branches/ubuntu/trusty/libapache-authenhook-perl/trusty-proposed

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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
use strict;
use warnings FATAL => 'all';

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

# Basic auth tests

plan tests => 12, (need_lwp &&
                   need_module('mod_auth_basic'));

my $url = '/basic/index.html';

my $response = GET $url;
ok $response->code == 401;

# bad pass
$response = GET $url, username => 'user1', password => 'foo';
ok t_cmp($response->code,
         401,
         "GET $url, username => 'user1', password => 'foo'");

# authenticated in the first provider
$response = GET $url, username => 'user1', password => 'basic1';
ok t_cmp($response->code,
         200,
         "GET $url, username => 'user1', password => 'basic1'");

# declined in the first provider
$response = GET $url, username => 'user2', password => 'basic2';
ok t_cmp($response->code,
         401,
         "GET $url, username => 'user2', password => 'basic2'");

# bad pass
$response = GET $url, username => 'user3', password => 'foo';
ok t_cmp($response->code,
         401,
         "GET $url, username => 'user3', password => 'foo'");

# authenticated in the second provider
$response = GET $url, username => 'user3', password => 'basic3';
ok t_cmp($response->code,
         200,
         "GET $url, username => 'user3', password => 'basic3'");

# declined in the second provider
$response = GET $url, username => 'user4', password => 'basic4';
ok t_cmp($response->code,
         401,
         "GET $url, username => 'user4', password => 'basic4'");

# bad pass
$response = GET $url, username => 'user5', password => 'foo';
skip(! need_module('mod_authn_file'),
     ok t_cmp($response->code,
              401,
              "GET $url, username => 'user5', password => 'foo'")
    );

# authenticated in the file provider
$response = GET $url, username => 'user5', password => 'basic5';
skip(! have_module('mod_authn_file'),
     ok t_cmp($response->code,
              200,
              "GET $url, username => 'user5', password => 'basic5'")
    );

# non-existent anywhere
$response = GET $url, username => 'user6', password => 'basic6';
ok t_cmp($response->code,
         401,
         "GET $url, username => 'user6', password => 'basic6'");