ActionPack/Authorization/Basic.pm

filter: Statementstmt 100% 37 / 37 Branchbran 83.3% 5 / 6 Conditioncond 58.3% 7 / 12 MC/DCmcdc 37.5% 3 / 8 Subroutinesub 100% 12 / 12 Podpod 100% 6 / 6 totaltotal 86.4% 70 / 81 CC 8 SCAR 12.4
CC
8
Cov
89%
BUILDARGS
7.4
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 4 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 $HTTP::Headers::ActionPack::Authorization::Basic::AUTHORITY = 'cpan:STEVAN';
4 }
5 {
6 4 $HTTP::Headers::ActionPack::Authorization::Basic::VERSION = '0.09';
7 }
8 # ABSTRACT: The Basic Authorization Header
9  
10 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 4 ▶use Carp qw[ confess ];
Subroutine BEGIN: called CC=1 SCAR=0.0
14 4 ▶use MIME::Base64 qw[ encode_base64 decode_base64 ];
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 4 ▶use parent 'HTTP::Headers::ActionPack::Core::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 12 ▶sub BUILDARGS {
Subroutine BUILDARGS: called CC=7 SCAR=20.0
Pod documented
19 12 my $class = shift;
20 12 ▶ my $type = shift || confess "Must specify type";
Condition33%1/3
shift() || confess('Must specify type')
l!l&&r!l&&!r
1200
MC/DC0%0/2
shift() || confess('Must specify type')
shift() confess('Must specify type')
Truth table33%1/3
A || B
A= shift()B= confess('Must specify type')
ABresult
1X1
011
000
21 12 ▶ my $credentials = shift || confess "Must provide credentials";
Condition33%1/3
shift() || confess('Must provide credentials')
l!l&&r!l&&!r
1200
MC/DC0%0/2
shift() || confess('Must provide credentials')
shift() confess('Must provide credentials')
Truth table33%1/3
A || B
A= shift()B= confess('Must provide credentials')
ABresult
1X1
011
000
22  
23 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
24 3 return +{ auth_type => $type, %$credentials };
25 }
26 ▶ 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
27 3 my ($username, $password) = @$credentials;
28 3 return +{ auth_type => $type, username => $username, password => $password };
29 }
30 else {
31 6 my ($username, $password) = split ':' => decode_base64( $credentials );
32 6 return +{ auth_type => $type, username => $username, password => $password };
33 }
34 }
35  
36 3 ▶sub new_from_string {
Subroutine new_from_string: called CC=2 SCAR=7.0
Pod documented
37 3 my ($class, $header_string) = @_;
38 3 my ($type, $credentials) = split /\s/ => $header_string;
39 3 ▶ ($type eq 'Basic')
Branch: 1 branch
BranchTrueFalseTotal
$type eq "Basic" or confess("The type must be 'Basic', not '${type}'") 3 0 3
40 || confess "The type must be 'Basic', not '$type'";
41 3 $class->new( $type, $credentials );
42 }
43  
44 24 ▶sub auth_type { (shift)->{'auth_type'} }
Subroutine auth_type: called CC=1 SCAR=0.0
Pod documented
45 24 ▶sub username { (shift)->{'username'} }
Subroutine username: called CC=1 SCAR=0.0
Pod documented
46 24 ▶sub password { (shift)->{'password'} }
Subroutine password: called CC=1 SCAR=0.0
Pod documented
47  
48 12 ▶sub as_string {
Subroutine as_string: called CC=1 SCAR=0.0
Pod documented
49 12 my $self = shift;
50 12 join ' ' => $self->auth_type, encode_base64( (join ':' => $self->username, $self->password), '' )
51 }
52  
53 4 1;
54  
55 __END__
« ActionPack/MediaTypeList.pm ↑ Summary ActionPack/AcceptLanguage.pm »