blib/lib/Sledge/Authorizer/BasicAuth.pm

filter: Statementstmt 54.5% 18 / 33 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 71.4% 5 / 7 Podpod 0.0% 0 / 2 totaltotal 42.5% 23 / 54 CC 5 SCAR 26.6
CC
5
Cov
43%
basic_auth
30.0
show_error_page
2.0
BEGIN
1.0
CRAP 14.3
↑ Summary
1 package Sledge::Authorizer::BasicAuth;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use base qw(Sledge::Authorizer Class::Data::Inheritable);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our $VERSION = '0.07';
8  
9 1 ▶use MIME::Base64 qw//;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 __PACKAGE__->mk_classdata('error_template');
12 1 __PACKAGE__->mk_classdata(realm => 'Authorization Required');
13  
14 0 ▶sub basic_auth {
Subroutine basic_auth: not called CC=5 SCAR=34.0
Pod undocumented
15 0 my $self = shift;
16 0 my $page = shift;
17  
18 0 ▶ my $auth_header = $page->r->header_in('Authorization') || '';
Condition0%0/2
$page->r->header_in('Authorization') || ''
l!l
00
MC/DC0%0/1
$page->r->header_in('Authorization') || ''
$page->r->header_in('Authorization')
Truth table0%0/2
A
A= $page->r->header_in('Authorization')
Aresult
11
00
19 0 ▶ if ($auth_header =~ /^Basic (.+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($auth_header =~ /^Basic (.+)$/) 0 0 0
20 0 my ($user, $pass) = split q{:}, MIME::Base64::decode_base64($1);
21 0 ▶ if (defined $user and defined $pass) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $user and defined $pass) 0 0 0
Condition0%0/3
defined $user and defined $pass
!ll&&!rl&&r
000
MC/DC0%0/2
defined $user and defined $pass
defined $user defined $pass
Truth table0%0/3
A and B
A= defined $userB= defined $pass
ABresult
0X0
100
111
22 0 return ($user, $pass);
23 }
24 }
25 0 return $self->show_error_page($page);
26 }
27  
28 0 ▶sub show_error_page {
Subroutine show_error_page: not called CC=1 SCAR=6.9
Pod undocumented
29 0 my $self = shift;
30 0 my $page = shift;
31  
32 0 $page->load_template($self->error_template);
33  
34 0 my $realm = $self->realm;
35 0 $page->r->header_out('WWW-Authenticate' => qq{Basic realm="$realm"});
36 0 $page->r->status(401);
37  
38 0 $page->output_content;
39 }
40  
41 1 1;
42 __END__
↑ Summary