| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
1
|
|
|
1
|
|
3
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
30
|
|
|
2
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
18
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
574
|
use Test::More; |
|
|
1
|
|
|
|
|
13194
|
|
|
|
1
|
|
|
|
|
7
|
|
|
5
|
1
|
|
|
1
|
|
641
|
use Plack::Test; |
|
|
1
|
|
|
|
|
1046
|
|
|
|
1
|
|
|
|
|
48
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
BEGIN { |
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
375
|
use Dancer2; |
|
|
1
|
|
|
|
|
291934
|
|
|
|
1
|
|
|
|
|
6
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
5
|
set session => undef; # explicit |
|
12
|
1
|
|
|
|
|
21277
|
set plugins => { |
|
13
|
|
|
|
|
|
|
'HTTP::Auth::Extensible' => { |
|
14
|
|
|
|
|
|
|
default_realm => "realm_one", |
|
15
|
|
|
|
|
|
|
realms => { |
|
16
|
|
|
|
|
|
|
realm_one => { |
|
17
|
|
|
|
|
|
|
scheme => "Basic", |
|
18
|
|
|
|
|
|
|
provider => "Config", |
|
19
|
|
|
|
|
|
|
users => [ |
|
20
|
|
|
|
|
|
|
{ user => "dave", |
|
21
|
|
|
|
|
|
|
pass => "beer", |
|
22
|
|
|
|
|
|
|
name => "David Precious", |
|
23
|
|
|
|
|
|
|
roles => [ 'BeerDrinker', 'Motorcyclist' ], |
|
24
|
|
|
|
|
|
|
}, |
|
25
|
|
|
|
|
|
|
{ user => "bob", |
|
26
|
|
|
|
|
|
|
pass => "cider", |
|
27
|
|
|
|
|
|
|
name => "Bob Smith", |
|
28
|
|
|
|
|
|
|
roles => [ 'Ciderdrinker' ], |
|
29
|
|
|
|
|
|
|
}, |
|
30
|
|
|
|
|
|
|
] |
|
31
|
|
|
|
|
|
|
}, |
|
32
|
|
|
|
|
|
|
realm_two => { |
|
33
|
|
|
|
|
|
|
scheme => "Basic", |
|
34
|
|
|
|
|
|
|
provider => "Config", |
|
35
|
|
|
|
|
|
|
users => [ |
|
36
|
|
|
|
|
|
|
{ user => "burt", |
|
37
|
|
|
|
|
|
|
pass => "bacharach", |
|
38
|
|
|
|
|
|
|
}, |
|
39
|
|
|
|
|
|
|
{ user => "hashedpassword", |
|
40
|
|
|
|
|
|
|
pass => "{SSHA}+2u1HpOU7ak6iBR6JlpICpAUvSpA/zBM", |
|
41
|
|
|
|
|
|
|
}, |
|
42
|
|
|
|
|
|
|
] |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
}; |
|
47
|
1
|
|
|
|
|
99
|
set logger => "file"; |
|
48
|
|
|
|
|
|
|
# set log => "core"; |
|
49
|
1
|
|
|
|
|
8677
|
set show_errors => 1; |
|
50
|
1
|
|
|
|
|
83
|
set serializer => "YAML"; |
|
51
|
|
|
|
|
|
|
|
|
52
|
1
|
|
|
1
|
|
54906
|
use Dancer2::Plugin::HTTP::Auth::Extensible; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
4
|
|
|
53
|
1
|
|
|
1
|
|
42
|
no warnings 'uninitialized'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
119
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
get '/realm_one' => http_requires_authentication 'realm_one' => sub { |
|
56
|
0
|
|
|
|
|
0
|
"Welcome to realm_one" |
|
57
|
1
|
|
|
|
|
14228
|
}; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
get '/realm_two' => http_requires_authentication 'realm_two' => sub { |
|
60
|
0
|
|
|
|
|
0
|
"Welcome to realm_two" |
|
61
|
1
|
|
|
|
|
4176
|
}; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
get '/realm_bad' => http_requires_authentication 'realm_bad' => sub { |
|
64
|
0
|
|
|
|
|
0
|
"Welcome to realm_bad" # we are not suposed to get here |
|
65
|
1
|
|
|
|
|
653
|
}; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
get '/realm' => http_requires_authentication sub { |
|
68
|
0
|
|
|
|
|
|
"Welcome to realm_one, the default" |
|
69
|
1
|
|
|
|
|
637
|
}; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
} # BEGIN |
|
72
|
|
|
|
|
|
|
|
|
73
|
1
|
|
|
|
|
15
|
my $app = Dancer2->runner->psgi_app; |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
{ |
|
76
|
1
|
|
|
|
|
3822
|
is ( |
|
|
1
|
|
|
|
|
7
|
|
|
77
|
|
|
|
|
|
|
ref $app, |
|
78
|
|
|
|
|
|
|
'CODE', |
|
79
|
|
|
|
|
|
|
'Got app' |
|
80
|
|
|
|
|
|
|
); |
|
81
|
|
|
|
|
|
|
}; |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
test_psgi $app, sub { |
|
84
|
1
|
|
|
1
|
|
5751
|
my $cb = shift; |
|
85
|
1
|
|
|
|
|
7
|
my $req = HTTP::Request->new( GET => '/realm'); |
|
86
|
1
|
|
|
|
|
3411
|
my $res = $cb->( $req ); |
|
87
|
1
|
|
|
|
|
6849
|
is ( |
|
88
|
|
|
|
|
|
|
$res->code, |
|
89
|
|
|
|
|
|
|
401, |
|
90
|
|
|
|
|
|
|
'Status 401: Unauthorized for realm_one, the default' |
|
91
|
|
|
|
|
|
|
); |
|
92
|
1
|
|
|
|
|
313
|
is ( |
|
93
|
|
|
|
|
|
|
$res->headers->header('WWW-Authenticate'), |
|
94
|
|
|
|
|
|
|
'Basic realm="realm_one"', |
|
95
|
|
|
|
|
|
|
'HTTP-field: WWW-Authentication for realm_one, the default' |
|
96
|
|
|
|
|
|
|
); |
|
97
|
1
|
|
|
|
|
340
|
}; |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
test_psgi $app, sub { |
|
100
|
1
|
|
|
1
|
|
89
|
my $cb = shift; |
|
101
|
1
|
|
|
|
|
7
|
my $req = HTTP::Request->new( GET => '/realm_one'); |
|
102
|
1
|
|
|
|
|
98
|
my $res = $cb->( $req ); |
|
103
|
1
|
|
|
|
|
2897
|
is ( |
|
104
|
|
|
|
|
|
|
$res->code, |
|
105
|
|
|
|
|
|
|
401, |
|
106
|
|
|
|
|
|
|
'Status 401: Unauthorized for realm_one' |
|
107
|
|
|
|
|
|
|
); |
|
108
|
1
|
|
|
|
|
303
|
is ( |
|
109
|
|
|
|
|
|
|
$res->headers->header('WWW-Authenticate'), |
|
110
|
|
|
|
|
|
|
'Basic realm="realm_one"', |
|
111
|
|
|
|
|
|
|
'HTTP-field: WWW-Authentication for realm_one' |
|
112
|
|
|
|
|
|
|
); |
|
113
|
1
|
|
|
|
|
232
|
}; |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
test_psgi $app, sub { |
|
116
|
1
|
|
|
1
|
|
98
|
my $cb = shift; |
|
117
|
1
|
|
|
|
|
8
|
my $req = HTTP::Request->new( GET => '/realm_two'); |
|
118
|
1
|
|
|
|
|
111
|
my $res = $cb->( $req ); |
|
119
|
1
|
|
|
|
|
2513
|
is ( |
|
120
|
|
|
|
|
|
|
$res->code, |
|
121
|
|
|
|
|
|
|
401, |
|
122
|
|
|
|
|
|
|
'Status 401: Unauthorized for realm_two' |
|
123
|
|
|
|
|
|
|
); |
|
124
|
1
|
|
|
|
|
290
|
is ( |
|
125
|
|
|
|
|
|
|
$res->headers->header('WWW-Authenticate'), |
|
126
|
|
|
|
|
|
|
'Basic realm="realm_two"', |
|
127
|
|
|
|
|
|
|
'HTTP-field: WWW-Authentication for realm_two' |
|
128
|
|
|
|
|
|
|
); |
|
129
|
1
|
|
|
|
|
254
|
}; |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
test_psgi $app, sub { |
|
132
|
1
|
|
|
1
|
|
178
|
my $cb = shift; |
|
133
|
1
|
|
|
|
|
11
|
my $req = HTTP::Request->new( GET => '/realm_bad'); |
|
134
|
1
|
|
|
|
|
120
|
my $res = $cb->( $req ); |
|
135
|
1
|
|
|
|
|
24037
|
is ( |
|
136
|
|
|
|
|
|
|
$res->code, |
|
137
|
|
|
|
|
|
|
500, |
|
138
|
|
|
|
|
|
|
'Status 500: realm does not exist' |
|
139
|
|
|
|
|
|
|
); |
|
140
|
1
|
|
|
|
|
290
|
like ( |
|
141
|
|
|
|
|
|
|
$res->content, |
|
142
|
|
|
|
|
|
|
qr{required realm does not exist: 'realm_bad'}, |
|
143
|
|
|
|
|
|
|
'Prompt 500: realm does not exist' |
|
144
|
|
|
|
|
|
|
); |
|
145
|
1
|
|
|
|
|
205
|
}; |
|
146
|
|
|
|
|
|
|
|
|
147
|
1
|
|
|
|
|
249
|
done_testing(); |