Lite/RelyingParty/Discover/Fetcher/Yadis.pm

filter: Statementstmt 76.9% 30 / 39 Branchbran 37.5% 3 / 8 Conditioncond 33.3% 3 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 1 totaltotal 61.9% 44 / 71 CC 8 SCAR 17.5
CC
8
Cov
64%
fetch
12.0
_extract_location
2.3
_extract_location_from_header
2.3
CRAP 5.8
« Lite/Util/XRI.pm ↑ Summary Lite/RelyingParty/Discover/Method/URL.pm »
1 package OpenID::Lite::RelyingParty::Discover::Fetcher::Yadis;
2  
3 3 ▶use Any::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 with 'OpenID::Lite::Role::AgentHandler';
5 3 with 'OpenID::Lite::Role::ErrorHandler';
6  
7 3 ▶use OpenID::Lite::RelyingParty::Discover::Fetcher::Yadis::HTMLExtractor;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use OpenID::Lite::RelyingParty::Discover::FetchResult;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 use OpenID::Lite::Constants::Yadis
10 3 ▶ qw(XRDS_HEADER YADIS_HEADER XRDS_CONTENT_TYPE);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶sub fetch {
Subroutine fetch: called CC=6 SCAR=24.9
Pod undocumented
13 1 my ( $self, $uri ) = @_;
14  
15 1 my $res = $self->agent->get( $uri, 'Accept' => XRDS_CONTENT_TYPE );
16 1 ▶ return $self->ERROR( sprintf q{Failed Yadis discovery on "%s"}, $uri )
Branch: 1 branch
BranchTrueFalseTotal
unless $res->is_success 0 1 1
17 unless $res->is_success;
18  
19 1 my $result = OpenID::Lite::RelyingParty::Discover::FetchResult->new;
20 1 $result->normalized_identifier($uri);
21  
22 1 my $content_type = $res->header('Content-Type');
23 1 my $xrds_type = quotemeta XRDS_CONTENT_TYPE;
24 1 ▶ if ( $content_type && $content_type =~ /^$xrds_type/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($content_type and $content_type =~ /^$xrds_type/i) { } 0 1 1
Condition33%1/3
$content_type and $content_type =~ /^$xrds_type/i
!ll&&!rl&&r
010
MC/DC0%0/2
$content_type and $content_type =~ /^$xrds_type/i
$content_type $content_type =~ /^$xrds_type/i
Truth table33%1/3
A and B
A= $content_typeB= $content_type =~ /^$xrds_type/i
ABresult
0X0
100
111
25 0 $result->content_type( lc $content_type );
26 0 $result->final_url( $res->base->as_string );
27 0 $result->content( $res->content );
28 }
29 else {
30  
31 1 ▶ my $yadis_location = $self->_extract_location($res)
Branch: 1 branch
BranchTrueFalseTotal
my $yadis_location = $self->_extract_location($res) or return $self->ERROR(sprintf('Failed Yadis discovery for url "%s"', $uri)) 0 1 1
32 or return $self->ERROR(
33 sprintf q{Failed Yadis discovery for url "%s"}, $uri );
34  
35 0 $res = $self->agent->get($yadis_location);
36 0 ▶ return $self->ERROR( sprintf q{Failed Yadis discovery for url "%s"},
Branch: 1 branch
BranchTrueFalseTotal
unless $res->is_success 0 0 0
37 $yadis_location )
38 unless $res->is_success;
39  
40 0 $result->content_type( lc $res->header('Content-Type') );
41 0 $result->final_url( $res->base->as_string );
42 0 $result->content( $res->content );
43 }
44 0 return $result;
45 }
46  
47 1 ▶sub _extract_location {
Subroutine _extract_location: called CC=2 SCAR=8.1
48 1 my ( $self, $res ) = @_;
49 1 ▶ return $self->_extract_location_from_header($res)
Condition33%1/3
$self->_extract_location_from_header($res) || $self->_extract_location_from_html($res->content)
l!l&&r!l&&!r
001
MC/DC0%0/2
$self->_extract_location_from_header($res) || $self->_extract_location_from_html($res->content)
$self->_extract_location_from_header($res) $self->_extract_location_from_html($res->content)
Truth table33%1/3
A || B
A= $self->_extract_location_from_header($res)B= $self->_extract_location_from_html($res->content)
ABresult
1X1
011
000
50 || $self->_extract_location_from_html( $res->content );
51 }
52  
53 1 ▶sub _extract_location_from_header {
Subroutine _extract_location_from_header: called CC=2 SCAR=8.1
54 1 my ( $self, $res ) = @_;
55 1 ▶ return $res->header(XRDS_HEADER)
Condition33%1/3
$res->header('X-XRDS-Location') || $res->header('X-Yadis-Location')
l!l&&r!l&&!r
001
MC/DC0%0/2
$res->header('X-XRDS-Location') || $res->header('X-Yadis-Location')
$res->header('X-XRDS-Location') $res->header('X-Yadis-Location')
Truth table33%1/3
A || B
A= $res->header('X-XRDS-Location')B= $res->header('X-Yadis-Location')
ABresult
1X1
011
000
56 || $res->header(YADIS_HEADER);
57 }
58  
59 1 ▶sub _extract_location_from_html {
Subroutine _extract_location_from_html: called CC=1 SCAR=0.0
60 1 my ( $self, $content ) = @_;
61 return
62 1 OpenID::Lite::RelyingParty::Discover::Fetcher::Yadis::HTMLExtractor->extract($content);
63 }
64  
65 3 1;
66  
« Lite/Util/XRI.pm ↑ Summary Lite/RelyingParty/Discover/Method/URL.pm »