Lite/RelyingParty/Discover/Parser/XRI.pm

filter: Statementstmt 32.0% 16 / 50 Branchbran 0.0% 0 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 4 / 7 Podpod 0.0% 0 / 1 totaltotal 26.3% 20 / 76 CC 12 SCAR 33.6
CC
12
Cov
24%
parse
42.0
_validate_canonical_id
42.0
_get_canonical_id
6.0
CRAP 28.9
« Lite/Provider/Handler/CheckAuth.pm ↑ Summary Lite/Provider/Discover/Parser.pm »
1 package OpenID::Lite::RelyingParty::Discover::Parser::XRI;
2  
3 2 ▶use Any::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 with 'OpenID::Lite::Role::Parser';
5 2 with 'OpenID::Lite::Role::ErrorHandler';
6  
7 2 ▶use OpenID::Lite::Util::XRI;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use OpenID::Lite::RelyingParty::Discover::Service::Builder;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 0 ▶sub parse {
Subroutine parse: not called CC=6 SCAR=37.4
Pod undocumented
11 0 my ( $self, $result ) = @_;
12  
13 0 my $identifier = $result->normalized_identifier;
14 0 my $doc = $result->xrds;
15  
16 my @xrd
17 0 = $doc->findnodes(q{*[local-name()='XRDS']/*[local-name()='XRD']});
18 0 ▶ return $self->ERROR( sprintf q{XRD element not found for iname "%s".},
Branch: 1 branch
BranchTrueFalseTotal
unless @xrd > 0 0 0 0
19 $identifier )
20 unless @xrd > 0;
21  
22 0 @xrd = reverse @xrd;
23 0 my $last_xrd = shift @xrd;
24  
25 0 ▶ my $canonical_id = $self->_get_canonical_id($last_xrd)
Branch: 1 branch
BranchTrueFalseTotal
my $canonical_id = $self->_get_canonical_id($last_xrd) or return $self->ERROR(sprintf('No CanonicalID found for XRI "%s".', $identifier)) 0 0 0
26 or return $self->ERROR( sprintf q{No CanonicalID found for XRI "%s".},
27 $identifier );
28  
29 0 ▶ $self->_validate_canonical_id( \@xrd, $canonical_id, $identifier )
Branch: 1 branch
BranchTrueFalseTotal
$self->_validate_canonical_id(\@xrd, $canonical_id, $identifier) or return $self->ERROR(sprintf('Invalid XRDS for XRI "%s".', $identifier)) 0 0 0
30 or return $self->ERROR( sprintf q{Invalid XRDS for XRI "%s".},
31 $identifier );
32  
33 0 my $builder = OpenID::Lite::RelyingParty::Discover::Service::Builder->new(
34 claimed_identifier => $canonical_id, );
35  
36 0 my $services = $builder->build_services($last_xrd);
37 0 $_->display_identifier($identifier) for @$services;
38 0 ▶ return $self->ERROR(q{No service found.}) unless @$services > 0;
Branch: 1 branch
BranchTrueFalseTotal
unless @$services > 0 0 0 0
39 0 return $services;
40 }
41  
42 0 ▶sub _validate_canonical_id {
Subroutine _validate_canonical_id: not called CC=6 SCAR=37.4
43 0 my ( $self, $xrd_list, $canonical_id, $iname ) = @_;
44 0 my $child_id = lc $canonical_id;
45 0 for my $xrd ( @$xrd_list ) {
46 0 my $parent_sought = substr($child_id, rindex($child_id, '!'));
47 0 my @cids = $xrd->findnodes(q{*[local-name()='CanonicalID']});
48 0 ▶ return 0 unless @cids > 0;
Branch: 1 branch
BranchTrueFalseTotal
unless @cids > 0 0 0 0
49 0 my $cid = $cids[0];
50 0 my $parent
51 = OpenID::Lite::Util::XRI->make_xri( $cid->findvalue(q{text()}) );
52 0 ▶ return 0 unless $parent;
Branch: 1 branch
BranchTrueFalseTotal
unless $parent 0 0 0
53 0 ▶ return 0 if ($parent_sought ne lc $parent);
Branch: 1 branch
BranchTrueFalseTotal
if $parent_sought ne lc $parent 0 0 0
54 0 $child_id = $parent_sought;
55 }
56  
57 0 my $root = OpenID::Lite::Util::XRI->root_authority($iname);
58 0 ▶ return 0 unless
Branch: 1 branch
BranchTrueFalseTotal
unless "OpenID::Lite::Util::XRI"->provider_is_authoritative($root, $child_id) 0 0 0
59 OpenID::Lite::Util::XRI->provider_is_authoritative($root, $child_id);
60 0 1;
61 }
62  
63 0 ▶sub _get_canonical_id {
Subroutine _get_canonical_id: not called CC=2 SCAR=17.9
64 0 my ( $self, $xrd ) = @_;
65  
66 0 my @cids = $xrd->findnodes(q{*[local-name()='CanonicalID']});
67 0 ▶ return unless @cids > 0;
Branch: 1 branch
BranchTrueFalseTotal
unless @cids > 0 0 0 0
68  
69 0 my $cid = $cids[0];
70 0 my $canonical_id
71 = OpenID::Lite::Util::XRI->make_xri( $cid->findvalue(q{text()}) );
72  
73 0 return $canonical_id;
74 }
75  
76 2 ▶no Any::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
77 2 __PACKAGE__->meta->make_immutable;
78 2 1;
79  
« Lite/Provider/Handler/CheckAuth.pm ↑ Summary Lite/Provider/Discover/Parser.pm »