Login/Discover.pm

filter: Statementstmt 100% 31 / 31 Branchbran 50.0% 5 / 10 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 82.6% 43 / 52 CC 7 SCAR 10.8
CC
7
Cov
84%
perform_discovery
4.2
_get_xrds_location
3.1
_get
2.0
CRAP 2.9
« Login/Extension.pm ↑ Summary Login/Types.pm »
1 package OpenID::Login::Discover;
2 {
3 4 $OpenID::Login::Discover::VERSION = '0.1.2';
4 }
5  
6 # ABSTRACT: Find an endpoint for generic OpenID identifiers
7  
8 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 4 has claimed_id => (
11 is => 'rw',
12 isa => 'Str',
13 required => 1,
14 );
15  
16 4 has ua => (
17 is => 'rw',
18 isa => 'LWP::UserAgent',
19 required => 1,
20 );
21  
22  
23 5 ▶sub perform_discovery {
Subroutine perform_discovery: called CC=4 SCAR=14.5
Pod documented
24 5 my $self = shift;
25  
26 5 my $claimed_id = $self->claimed_id;
27 5 ▶ my $server = $self->_get_xrds_location($claimed_id) || $self->claimed_id;
Condition33%1/3
$self->_get_xrds_location($claimed_id) || $self->claimed_id
l!l&&r!l&&!r
500
MC/DC0%0/2
$self->_get_xrds_location($claimed_id) || $self->claimed_id
$self->_get_xrds_location($claimed_id) $self->claimed_id
Truth table33%1/3
A || B
A= $self->_get_xrds_location($claimed_id)B= $self->claimed_id
ABresult
1X1
011
000
28 5 my $open_id_endpoint;
29 5 ▶ if ($server) {
Branch: 1 branch
BranchTrueFalseTotal
if ($server) 5 0 5
30 5 my $xrds = $self->_get($server)->decoded_content;
31 5 ▶ if ( $xrds =~ m{<URI>([^<>]+)</URI>} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($xrds =~ m[<URI>([^<>]+)</URI>]) 5 0 5
32 5 $open_id_endpoint = $1;
33 }
34 }
35  
36 5 return $open_id_endpoint;
37 }
38  
39 10 ▶sub _get {
Subroutine _get: called CC=2 SCAR=7.0
40 10 my ( $self, $url ) = @_;
41  
42 10 my $ua = $self->ua;
43 10 my $res = $ua->get($url);
44 10 ▶ $res->is_success or return;
Branch: 1 branch
BranchTrueFalseTotal
$res->is_success or return 10 0 10
45 10 $res;
46 }
47  
48 5 ▶sub _get_xrds_location {
Subroutine _get_xrds_location: called CC=3 SCAR=11.3
49 5 my ( $self, $entry_point ) = @_;
50  
51 5 my $res = $self->_get( $entry_point, Accept => 'application/xrds+xml' );
52 5 ▶ return unless $res;
Branch: 1 branch
BranchTrueFalseTotal
unless $res 0 5 5
53 5 ▶ my $xrds_location = $res->header('X-XRDS-Location') or return;
Branch: 1 branch
BranchTrueFalseTotal
my $xrds_location = $res->header("X-XRDS-Location") or return 5 0 5
54 5 return $xrds_location;
55 }
56  
57 4 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
58 4 __PACKAGE__->meta->make_immutable;
59 4 1;
60  
61  
62  
63 =pod
64  
65 =head1 NAME
66  
67 OpenID::Login::Discover - Find an endpoint for generic OpenID identifiers
68  
69 =head1 VERSION
70  
71 version 0.1.2
72  
73 =head1 METHODS
74  
75 =head2 perform_discovery
76  
77 Performs OpenID endpoint discovery for generic OpenID indentifiers
78  
79 =head1 AUTHOR
80  
81 Holger Eiboeck <realholgi@cpan.org>
82  
83 =head1 COPYRIGHT AND LICENSE
84  
85 This software is copyright (c) 2013 by Holger Eiboeck.
86  
87 This is free software; you can redistribute it and/or modify it under
88 the same terms as the Perl 5 programming language system itself.
89  
90 =cut
91  
92  
93 __END__
« Login/Extension.pm ↑ Summary Login/Types.pm »