API/Role/Authentication.pm

filter: Statementstmt 100% 22 / 22 Branchbran 75.0% 6 / 8 Conditioncond 44.4% 4 / 9 MC/DCmcdc 16.6% 1 / 6 Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 76.0% 38 / 50 CC 9 SCAR 19.7
CC
9
Cov
82%
__ANON__
9.9
BEGIN
1.0
BEGIN
1.0
CRAP 7.2
↑ Summary API/Meta/Method/APIDeclare.pm »
1 package Net::HTTP::API::Role::Authentication;
2 4 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 $Net::HTTP::API::Role::Authentication::VERSION = '0.14';
4 }
5  
6 # ABSTRACT: Add authentication informations to request header
7  
8 4 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 4 has api_username => (
11 is => 'rw',
12 isa => 'Str',
13 predicate => 'has_api_username',
14 );
15  
16 4 has api_password => (
17 is => 'rw',
18 isa => 'Str',
19 predicate => 'has_api_password',
20 );
21  
22 # ugly :(
23 4 ▶after BUILDALL => sub {
Subroutine __ANON__: called CC=9 SCAR=23.0
24 4 my $self = shift;
25  
26 4 for (qw/api_username api_password/) {
27 8 my $predicate = 'has_' . $_;
28 8 my $value = $self->meta->get_api_option($_);
29 8 ▶ $self->$_($value) if $value && !$self->$predicate;
Branch: 1 branch
BranchTrueFalseTotal
if $value and not $self->$predicate 0 8 8
Condition33%1/3
$value and not $self->$predicate
!ll&&!rl&&r
800
MC/DC0%0/2
$value and not $self->$predicate
$value not $self->$predicate
Truth table33%1/3
A and not(B)
A= $valueB= not $self->$predicate
ABresult
0X0
100
111
30 }
31  
32 4 ▶ if ( $self->meta->get_api_option('authentication')
Branch: 1 branch
BranchTrueFalseTotal
if ($self->meta->get_api_option("authentication") or $self->meta->get_api_option("authentication_method")) 2 2 4
Condition66%2/3
$self->meta->get_api_option("authentication") or $self->meta->get_api_option("authentication_method")
l!l&&r!l&&!r
202
MC/DC50%1/2
$self->meta->get_api_option("authentication") or $self->meta->get_api_option("authentication_method")
$self->meta->get_api_option("authentication") $self->meta->get_api_option("authentication_method")
Truth table66%2/3
A or B
A= $self->meta->get_api_option("authentication")B= $self->meta->get_api_option("authentication_method")
ABresult
1X1
011
000
33 || $self->meta->get_api_option('authentication_method'))
34 {
35 2 my $auth_method = $self->meta->get_api_option('authentication_method');
36 2 ▶ if ($auth_method) {
Branch: 1 branch
BranchTrueFalseTotal
if ($auth_method) { } 1 1 2
37 $self->api_useragent->add_handler(
38 1 ▶ request_prepare => sub { $self->$auth_method(@_) });
Subroutine __ANON__: called CC=1 SCAR=0.0
39 }
40 else {
41 1 ▶ if ($self->has_api_username && $self->has_api_password) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_api_username and $self->has_api_password) 1 0 1
Condition33%1/3
$self->has_api_username and $self->has_api_password
!ll&&!rl&&r
001
MC/DC0%0/2
$self->has_api_username and $self->has_api_password
$self->has_api_username $self->has_api_password
Truth table33%1/3
A and B
A= $self->has_api_usernameB= $self->has_api_password
ABresult
0X0
100
111
42 $self->api_useragent->add_handler(
43 1 ▶ request_prepare => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
44 1 my $req = shift;
45 1 $req->headers->authorization_basic($self->api_username,
46 $self->api_password);
47 }
48 1 );
49 }
50 }
51 }
52 4 };
53  
54 4 1;
55  
56  
57 __END__
↑ Summary API/Meta/Method/APIDeclare.pm »