Lite/RelyingParty/Discover/Service/Builder.pm

filter: Statementstmt 34.6% 18 / 52 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 11 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 50.0% 5 / 10 Podpod 0.0% 0 / 2 totaltotal 23.2% 23 / 99 CC 15 SCAR 36.7
CC
15
Cov
22%
build_service
90.0
__ANON__
20.0
build_services
12.0
CRAP 39.4
« Lite/RelyingParty/CheckID/Request.pm ↑ Summary Lite/Provider/Handler/CheckAuth.pm »
1 package OpenID::Lite::RelyingParty::Discover::Service::Builder;
2  
3 3 ▶use Any::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 3 ▶use List::MoreUtils qw(any);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use OpenID::Lite::RelyingParty::Discover::Service;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use OpenID::Lite::Constants::Namespace qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
8 SIGNON_2_0
9 SIGNON_1_1
10 SIGNON_1_0
11 SERVER_2_0
12 XRD_2_0
13 SPEC_1_0
14 3 );
15  
16 3 has 'claimed_identifier' => (
17 is => 'rw',
18 isa => 'Str',
19 required => 1,
20 );
21  
22 0 ▶sub build_services {
Subroutine build_services: not called CC=3 SCAR=24.8
Pod undocumented
23 0 my ( $self, $xrd ) = @_;
24 0 my @service_nodes = $xrd->findnodes(q{*[local-name()='Service']});
25 0 my @services;
26 0 for my $service_elem (@service_nodes) {
27 0 ▶ my $service = $self->build_service($service_elem)
Branch: 1 branch
BranchTrueFalseTotal
my $service = $self->build_service($service_elem) or next 0 0 0
28 or next;
29 0 push @services, $service;
30 }
31 0 return \@services;
32 }
33  
34 0 ▶sub build_service {
Subroutine build_service: not called CC=9 SCAR=45.0
Pod undocumented
35 0 my ( $self, $service_elem ) = @_;
36  
37 0 my @uri_nodes = $service_elem->findnodes(q{*[local-name()='URI']});
38  
39 # Schwartzian transform
40 0 my @uris = map { $_->[0] }
41 0 sort { $a->[1] <=> $b->[1] }
42 map {
43 0 ▶ [ $_->findvalue(q{text()}), $_->findvalue(q{@priority}) || 100 ]
Condition0%0/2
$_->findvalue('@priority') || 100
l!l
00
MC/DC0%0/1
$_->findvalue('@priority') || 100
$_->findvalue('@priority')
Truth table0%0/2
A
A= $_->findvalue('@priority')
Aresult
11
00
44 } @uri_nodes;
45  
46 #my @uris = map { $_->findvalue(q{text()}) }
47 # sort {
48 # ( $a->findvalue(q{@priority}) || 100 )
49 # <=> ( $b->findvalue(q{@priority}) || 100 )
50 # } @uri_nodes;
51  
52 0 my @type_nodes = $service_elem->findnodes(q{*[local-name()='Type']});
53 0 my @types = map { $_->findvalue(q{text()}) } @type_nodes;
54  
55 0 ▶ return unless @uris > 0 && @types > 0;
Branch: 1 branch
BranchTrueFalseTotal
unless @uris > 0 and @types > 0 0 0 0
Condition0%0/3
@uris > 0 and @types > 0
!ll&&!rl&&r
000
MC/DC0%0/2
@uris > 0 and @types > 0
@uris > 0 @types > 0
Truth table0%0/3
A and B
A= @uris > 0B= @types > 0
ABresult
0X0
100
111
56 return
57 unless (
58 0 ▶ any {
Subroutine __ANON__: not called CC=4 SCAR=30.0
59 0 ▶ $_ eq SERVER_2_0
Branch: 1 branch
BranchTrueFalseTotal
$_ eq "http://specs.openid.net/auth/2.0/server" or $_ eq "http://specs.openid.net/auth/2.0/signon" or $_ eq "http://openid.net/signon/1.1" or $_ eq "http://openid.net/signon/1.0" 0 0 0
Condition0%0/6
$_ eq "http://specs.openid.net/auth/2.0/server" or $_ eq "http://specs.openid.net/auth/2.0/signon" or $_ eq "http://openid.net/signon/1.1"
l!l&&r!l&&!r
000
$_ eq "http://specs.openid.net/auth/2.0/server" or $_ eq "http://specs.openid.net/auth/2.0/signon"
l!l&&r!l&&!r
000
MC/DC0%0/3
$_ eq "http://specs.openid.net/auth/2.0/server" or $_ eq "http://specs.openid.net/auth/2.0/signon" or $_ eq "http://openid.net/signon/1.1"
$_ eq "http://specs.openid.net/auth/2.0/server" $_ eq "http://specs.openid.net/auth/2.0/signon" $_ eq "http://openid.net/signon/1.1"
Truth table0%0/4
A or B or C
A= $_ eq "http://specs.openid.net/auth/2.0/server"B= $_ eq "http://specs.openid.net/auth/2.0/signon"C= $_ eq "http://openid.net/signon/1.1"
ABCresult
1XX1
01X1
0011
0000
60 || $_ eq SIGNON_2_0
61 || $_ eq SIGNON_1_1
62 || $_ eq SIGNON_1_0;
63 }
64 @types
65 0 ▶ );
Branch: 1 branch
BranchTrueFalseTotal
unless &any(sub { $_ eq "http://specs.openid.net/auth/2.0/server" or $_ eq "http://specs.openid.net/auth/2.0/signon" or $_ eq "http://openid.net/signon/1.1" or $_ eq "http://openid.net/signon/1.0"; } , @types) 0 0 0
66  
67 0 my $service = OpenID::Lite::RelyingParty::Discover::Service->new;
68 0 $service->add_uris(@uris);
69 0 $service->add_types(@types);
70  
71 0 ▶ unless ( $service->is_op_identifier ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($service->is_op_identifier) 0 0 0
72 0 $service->claimed_identifier( $self->claimed_identifier );
73 0 my $op_local_identifier;
74 0 my $xpath_template
75 = q{*[local-name()='%s' and namespace-uri()='%s']/text()};
76 0 ▶ if ( any { $_ eq SIGNON_2_0 } @types ) {
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if (&any(sub { $_ eq "http://specs.openid.net/auth/2.0/signon"; } , @types)) 0 0 0
77 0 $op_local_identifier
78 = $service_elem->findvalue( sprintf $xpath_template,
79 'LocalID', XRD_2_0 );
80 }
81 0 ▶ if ( any { $_ eq SIGNON_1_1 || $_ eq SIGNON_1_0 } @types ) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 2 branches
BranchTrueFalseTotal
if (&any(sub { $_ eq "http://openid.net/signon/1.1" or $_ eq "http://openid.net/signon/1.0"; } , @types)) 0 0 0
$_ eq "http://openid.net/signon/1.1" or $_ eq "http://openid.net/signon/1.0" 0 0 0
82 0 $op_local_identifier
83 = $service_elem->findvalue( sprintf $xpath_template,
84 'Delegate', SPEC_1_0 );
85 }
86  
87 0 ▶ $service->op_local_identifier($op_local_identifier)
Branch: 1 branch
BranchTrueFalseTotal
if $op_local_identifier 0 0 0
88 if $op_local_identifier;
89 }
90 0 return $service;
91 }
92  
93 3 ▶no Any::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
94 3 __PACKAGE__->meta->make_immutable;
95 3 1;
96  
« Lite/RelyingParty/CheckID/Request.pm ↑ Summary Lite/Provider/Handler/CheckAuth.pm »