| 1 | package OpenID::Lite::Provider::Discover::Parser; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 2 | ▶ | use Any::Moose; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 2 | ▶ | use XML::LibXML; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 2 | ▶ | use OpenID::Lite::Constants::Namespace qw(RETURN_TO); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 2 | with 'OpenID::Lite::Role::ErrorHandler'; | |||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 0 | ▶ | sub parse { | ||||||||||||||||||
|
Subroutine
parse: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||
| 9 | 0 | my ( $self, $result ) = @_; | |||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 0 | my $parser = XML::LibXML->new; | |||||||||||||||||||
| 12 | 0 | my $doc; | |||||||||||||||||||
| 13 | 0 | eval { $doc = $parser->parse_string( $result->content ); }; | |||||||||||||||||||
| 14 | 0 | ▶ | if ($@) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 15 | 0 | return $self->ERROR( sprintf q{Failed to parse xrds "%s"}, $@ ); | |||||||||||||||||||
| 16 | } | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | my @xrd | ||||||||||||||||||||
| 19 | 0 | = $doc->findnodes(q{*[local-name()='XRDS']/*[local-name()='XRD']}); | |||||||||||||||||||
| 20 | 0 | ▶ | return $self->ERROR( q{XRD element not found} ) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 21 | unless @xrd > 0; | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 0 | my $xrd = $xrd[0]; | |||||||||||||||||||
| 24 | 0 | my @service_nodes = $xrd->findnodes(q{*[local-name()='Service']}); | |||||||||||||||||||
| 25 | 0 | for my $service_node ( @service_nodes ) { | |||||||||||||||||||
| 26 | 0 | my $urls = $self->_find_return_to($service_node); | |||||||||||||||||||
| 27 | 0 | ▶ | return $urls if $urls; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 28 | } | ||||||||||||||||||||
| 29 | 0 | return $self->ERROR(q{return_to not found.}); | |||||||||||||||||||
| 30 | } | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 0 | ▶ | sub _find_return_to { | ||||||||||||||||||
|
Subroutine
_find_return_to: not called CC=5 SCAR=34.0
| |||||||||||||||||||||
| 33 | 0 | my ( $self, $service_elem ) = @_; | |||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 0 | my @type_nodes = $service_elem->findnodes(q{*[local-name()='Type']}); | |||||||||||||||||||
| 36 | my @types = grep { | ||||||||||||||||||||
| 37 | 0 | my $t = $_->findvalue(q{text()}); | |||||||||||||||||||
| 38 | 0 | ▶ | return ($t && $t eq RETURN_TO) | ||||||||||||||||||
|
Condition0%0/3
$t && $t eq 'http://specs.openid.net/auth/2.0/return_to'
MC/DC0%0/2
$t && $t eq 'http://specs.openid.net/auth/2.0/return_to'
$t
$t eq 'http://specs.openid.net/auth/2.0/return_to'
Truth table0%0/3
A && B
A= $tB= $t eq 'http://specs.openid.net/auth/2.0/return_to'
| |||||||||||||||||||||
| 39 | } @type_nodes; | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 0 | ▶ | return unless @types > 0; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 0 | my @uri_nodes = $service_elem->findnodes(q{*[local-name()='URI']}); | |||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | # Schwartzian transform | ||||||||||||||||||||
| 46 | 0 | my @uris = map { $_->[0] } | |||||||||||||||||||
| 47 | 0 | sort { $a->[1] <=> $b->[1] } | |||||||||||||||||||
| 48 | map { | ||||||||||||||||||||
| 49 | 0 | ▶ | [ $_->findvalue(q{text()}), $_->findvalue(q{@priority}) || 100 ] | ||||||||||||||||||
|
Condition0%0/2
$_->findvalue('@priority') || 100
MC/DC0%0/1
$_->findvalue('@priority') || 100
$_->findvalue('@priority')
Truth table0%0/2
A
A= $_->findvalue('@priority')
| |||||||||||||||||||||
| 50 | } @uri_nodes; | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | #my @uris = map { $_->findvalue(q{text()}) } | ||||||||||||||||||||
| 53 | # sort { | ||||||||||||||||||||
| 54 | # ( $a->findvalue(q{@priority}) || 100 ) | ||||||||||||||||||||
| 55 | # <=> ( $b->findvalue(q{@priority}) || 100 ) | ||||||||||||||||||||
| 56 | # } @uri_nodes; | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | 0 | ▶ | return unless @uris > 0; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 59 | 0 | return \@uris; | |||||||||||||||||||
| 60 | } | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 2 | ▶ | no Any::Moose; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 63 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||
| 64 | 2 | 1; | |||||||||||||||||||
| 65 | |||||||||||||||||||||