ActionPack/Authorization/Basic.pm

filter: Statementstmt 100% 35 / 35 Branchbran 83.3% 5 / 6 Conditioncond 70.0% 7 / 10 MC/DCmcdc 50.0% 3 / 6 Subroutinesub 100% 11 / 11 Podpod 100% 6 / 6 totaltotal 90.5% 67 / 74 CC 8 SCAR 12.5
CC
8
Cov
92%
BUILDARGS
7.1
new_from_string
2.0
BEGIN
1.0
CRAP 3.5
« ActionPack/MediaTypeList.pm ↑ Summary ActionPack/AcceptLanguage.pm »
1 package HTTP::Headers::ActionPack::Authorization::Basic;
2 # ABSTRACT: The Basic Authorization Header
3  
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 our $VERSION = '0.10';
8  
9 3 ▶use Carp qw[ confess ];
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use MIME::Base64 qw[ encode_base64 decode_base64 ];
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 3 ▶use parent 'HTTP::Headers::ActionPack::Core::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 12 ▶sub BUILDARGS {
Subroutine BUILDARGS: called CC=7 SCAR=19.6
Pod documented
15 12 my $class = shift;
16 12 ▶ my $type = shift || confess "Must specify type";
Condition50%1/2
shift() || confess('Must specify type')
l!l
120
MC/DC0%0/1
shift() || confess('Must specify type')
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
17 12 ▶ my $credentials = shift || confess "Must provide credentials";
Condition50%1/2
shift() || confess('Must provide credentials')
l!l
120
MC/DC0%0/1
shift() || confess('Must provide credentials')
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
18  
19 12 ▶ if ( ref $credentials && ref $credentials eq 'HASH' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $credentials and ref $credentials eq 'HASH') { } 3 9 12
elsif (ref $credentials and ref $credentials eq 'ARRAY') { } 3 6 9
Condition100%3/3
ref $credentials and ref $credentials eq "HASH"
!ll&&!rl&&r
633
MC/DC100%2/2
ref $credentials and ref $credentials eq "HASH"
ref $credentials ref $credentials eq "HASH"
Truth table100%3/3
A and B
A= ref $credentialsB= ref $credentials eq "HASH"
ABresult
0X0
100
111
20 3 return +{ auth_type => $type, %$credentials };
21 }
22 ▶ elsif ( ref $credentials && ref $credentials eq 'ARRAY' ) {
Condition66%2/3
ref $credentials and ref $credentials eq "ARRAY"
!ll&&!rl&&r
603
MC/DC50%1/2
ref $credentials and ref $credentials eq "ARRAY"
ref $credentials ref $credentials eq "ARRAY"
Truth table66%2/3
A and B
A= ref $credentialsB= ref $credentials eq "ARRAY"
ABresult
0X0
100
111
23 3 my ($username, $password) = @$credentials;
24 3 return +{ auth_type => $type, username => $username, password => $password };
25 }
26 else {
27 6 my ($username, $password) = decode_base64( $credentials ) =~ /^([^:]+):(.*)$/;
28 6 return +{ auth_type => $type, username => $username, password => $password };
29 }
30 }
31  
32 3 ▶sub new_from_string {
Subroutine new_from_string: called CC=2 SCAR=7.0
Pod documented
33 3 my ($class, $header_string) = @_;
34 3 my ($type, $credentials) = split /\s/ => $header_string;
35 3 ▶ ($type eq 'Basic')
Branch: 1 branch
BranchTrueFalseTotal
$type eq "Basic" or confess("The type must be 'Basic', not '${type}'") 3 0 3
36 || confess "The type must be 'Basic', not '$type'";
37 3 $class->new( $type, $credentials );
38 }
39  
40 24 ▶sub auth_type { (shift)->{'auth_type'} }
Subroutine auth_type: called CC=1 SCAR=0.0
Pod documented
41 24 ▶sub username { (shift)->{'username'} }
Subroutine username: called CC=1 SCAR=0.0
Pod documented
42 24 ▶sub password { (shift)->{'password'} }
Subroutine password: called CC=1 SCAR=0.0
Pod documented
43  
44 12 ▶sub as_string {
Subroutine as_string: called CC=1 SCAR=0.0
Pod documented
45 12 my $self = shift;
46 12 join ' ' => $self->auth_type, encode_base64( (join ':' => $self->username, $self->password), '' )
47 }
48  
49 3 1;
50  
51 __END__
« ActionPack/MediaTypeList.pm ↑ Summary ActionPack/AcceptLanguage.pm »