line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
35
|
|
2
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
629
|
use Test::More; |
|
1
|
|
|
|
|
14531
|
|
|
1
|
|
|
|
|
7
|
|
5
|
1
|
|
|
1
|
|
707
|
use Plack::Test; |
|
1
|
|
|
|
|
1124
|
|
|
1
|
|
|
|
|
50
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
BEGIN { |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
377
|
use Dancer2; |
|
1
|
|
|
|
|
293400
|
|
|
1
|
|
|
|
|
6
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
5
|
set session => undef; # explicit |
12
|
1
|
|
|
|
|
21364
|
set plugins => { |
13
|
|
|
|
|
|
|
'HTTP::Auth::Extensible' => { |
14
|
|
|
|
|
|
|
realms => { |
15
|
|
|
|
|
|
|
some_realm => { |
16
|
|
|
|
|
|
|
scheme => "Basic", |
17
|
|
|
|
|
|
|
provider => "Config", |
18
|
|
|
|
|
|
|
users => [ |
19
|
|
|
|
|
|
|
{ user => "dave", |
20
|
|
|
|
|
|
|
pass => "beer", |
21
|
|
|
|
|
|
|
name => "David Precious", |
22
|
|
|
|
|
|
|
roles => [ |
23
|
|
|
|
|
|
|
'BeerDrinker', |
24
|
|
|
|
|
|
|
'VodkaDrinker', |
25
|
|
|
|
|
|
|
], |
26
|
|
|
|
|
|
|
}, |
27
|
|
|
|
|
|
|
] |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
}; |
32
|
1
|
|
|
|
|
100
|
set logger => "file"; |
33
|
1
|
|
|
|
|
8894
|
set log => "core"; |
34
|
1
|
|
|
|
|
195
|
set show_errors => 1; |
35
|
1
|
|
|
|
|
59
|
set serializer => "YAML"; |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
1
|
|
53517
|
use Dancer2::Plugin::HTTP::Auth::Extensible; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
38
|
1
|
|
|
1
|
|
36
|
no warnings 'uninitialized'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
220
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
get '/auth_http_realm' => http_requires_authentication sub { |
41
|
1
|
|
|
|
|
4
|
my $variable = http_realm; |
42
|
1
|
50
|
|
|
|
5
|
return qq|variable got: | unless defined $variable; |
43
|
1
|
|
|
|
|
9
|
return qq|variable got: '$variable'|; |
44
|
1
|
|
|
|
|
14540
|
}; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
get '/http_realm' => sub { |
47
|
1
|
|
|
|
|
4290
|
my $variable = http_realm; |
48
|
1
|
50
|
|
|
|
14
|
return qq|variable got: | unless defined $variable; |
49
|
0
|
|
|
|
|
0
|
return qq|variable got: '$variable'|; |
50
|
1
|
|
|
|
|
3679
|
}; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
put '/auth_http_realm' => http_requires_authentication sub { |
53
|
1
|
|
|
|
|
3
|
http_realm(params->{new}); |
54
|
1
|
|
|
|
|
6
|
my $variable = http_realm; |
55
|
1
|
50
|
|
|
|
7
|
return qq|variable set: | unless defined $variable; |
56
|
1
|
|
|
|
|
6
|
return qq|variable set: '$variable'|; |
57
|
1
|
|
|
|
|
634
|
}; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
put '/http_realm' => sub { |
60
|
1
|
|
|
|
|
3757
|
http_realm(params->{new}); |
61
|
1
|
|
|
|
|
6
|
my $variable = http_realm; |
62
|
1
|
50
|
|
|
|
7
|
return qq|variable set: | unless defined $variable; |
63
|
1
|
|
|
|
|
39
|
return qq|variable set: '$variable'|; |
64
|
1
|
|
|
|
|
344
|
}; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
} # BEGIN |
67
|
|
|
|
|
|
|
|
68
|
1
|
|
|
|
|
9
|
my $app = Dancer2->runner->psgi_app; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
{ |
71
|
1
|
|
|
|
|
3839
|
is ( |
|
1
|
|
|
|
|
8
|
|
72
|
|
|
|
|
|
|
ref $app, |
73
|
|
|
|
|
|
|
'CODE', |
74
|
|
|
|
|
|
|
'Got app' |
75
|
|
|
|
|
|
|
); |
76
|
|
|
|
|
|
|
}; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
test_psgi $app, sub { |
79
|
1
|
|
|
1
|
|
5517
|
my $cb = shift; |
80
|
1
|
|
|
|
|
6
|
my $req = HTTP::Request->new( GET => '/auth_http_realm'); |
81
|
1
|
|
|
|
|
3243
|
$req->authorization_basic ( 'dave', 'beer'); |
82
|
1
|
|
|
|
|
118
|
my $res = $cb->( $req ); |
83
|
1
|
|
|
|
|
7301
|
like ( |
84
|
|
|
|
|
|
|
$res->content, |
85
|
|
|
|
|
|
|
qr|variable got: '.*'|, |
86
|
|
|
|
|
|
|
'get http_realm authenticated' |
87
|
|
|
|
|
|
|
); |
88
|
1
|
|
|
|
|
764
|
}; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
test_psgi $app, sub { |
91
|
1
|
|
|
1
|
|
90
|
my $cb = shift; |
92
|
1
|
|
|
|
|
7
|
my $req = HTTP::Request->new( GET => '/http_realm'); |
93
|
1
|
|
|
|
|
100
|
$req->authorization_basic ( 'dave', 'beer'); |
94
|
1
|
|
|
|
|
56
|
my $res = $cb->( $req ); |
95
|
1
|
|
|
|
|
2628
|
like ( |
96
|
|
|
|
|
|
|
$res->content, |
97
|
|
|
|
|
|
|
qr|variable got: |, |
98
|
|
|
|
|
|
|
'get http_realm' |
99
|
|
|
|
|
|
|
); |
100
|
1
|
|
|
|
|
599
|
}; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
test_psgi $app, sub { |
103
|
1
|
|
|
1
|
|
95
|
my $cb = shift; |
104
|
1
|
|
|
|
|
7
|
my $req = HTTP::Request->new( PUT => '/auth_http_realm'); |
105
|
1
|
|
|
|
|
82
|
$req->authorization_basic ( 'dave', 'beer'); |
106
|
1
|
|
|
|
|
55
|
$req->uri->query_form( new => 'NEW'); |
107
|
1
|
|
|
|
|
107
|
my $res = $cb->( $req ); |
108
|
1
|
|
|
|
|
2544
|
like ( |
109
|
|
|
|
|
|
|
$res->content, |
110
|
|
|
|
|
|
|
qr|variable set: 'NEW'|, |
111
|
|
|
|
|
|
|
'put http_realm authenticated' |
112
|
|
|
|
|
|
|
); |
113
|
1
|
|
|
|
|
471
|
}; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
test_psgi $app, sub { |
116
|
1
|
|
|
1
|
|
90
|
my $cb = shift; |
117
|
1
|
|
|
|
|
7
|
my $req = HTTP::Request->new( PUT => '/http_realm'); |
118
|
1
|
|
|
|
|
78
|
$req->authorization_basic ( 'dave', 'beer'); |
119
|
1
|
|
|
|
|
49
|
$req->uri->query_form( new => 'NEW'); |
120
|
1
|
|
|
|
|
56
|
my $res = $cb->( $req ); |
121
|
1
|
|
|
|
|
2584
|
like ( |
122
|
|
|
|
|
|
|
$res->content, |
123
|
|
|
|
|
|
|
qr|variable set: 'NEW'|, |
124
|
|
|
|
|
|
|
'put http_realm' |
125
|
|
|
|
|
|
|
); |
126
|
1
|
|
|
|
|
428
|
}; |
127
|
|
|
|
|
|
|
|
128
|
1
|
|
|
|
|
407
|
done_testing(); |