ACME/Authorization.pm

filter: Statementstmt 100% 32 / 32 Branchbran 75.0% 3 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 3 totaltotal 88.0% 44 / 50 CC 5 SCAR 9.9
CC
5
Cov
95%
new
5.1
BEGIN
1.0
BEGIN
1.0
CRAP 2.7
« ACME/AccessorBase.pm ↑ Summary ACME/HTTP/Response.pm »
1 package Net::ACME::Authorization;
2  
3 =pod
4  
5 =encoding utf-8
6  
7 =head1 NAME
8  
9 Net::ACME::Authorization - fulfilled ACME authorization object
10  
11 =head1 SYNOPSIS
12  
13 use Net::ACME::Authorization ();
14  
15 my $authz = Net::ACME::Authorization->new(
16 status => 'valid', #or “invalid”
17 challenges => [ @list_of_challenge_objects ],
18 );
19  
20 my @challenge_objs = $authz->challenges();
21  
22 my $payload;
23 while (!$cert) {
24 if ($need_retry->is_time_to_poll()) {
25 $cert = $need_retry->poll();
26 }
27  
28 sleep 1;
29 }
30  
31 =cut
32  
33 #NOTE: For now, this assumes a domain name.
34 #Might be useful moving forward to separate out other types
35 #of authz as per ACME spec expansion. (As of April 2016 only
36 #domain names are handled.)
37  
38 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
40  
41 4 ▶use Call::Context ();
Subroutine BEGIN: called CC=1 SCAR=0.0
42  
43 4 ▶use Net::ACME::Utils ();
Subroutine BEGIN: called CC=1 SCAR=0.0
44 4 ▶use Net::ACME::X ();
Subroutine BEGIN: called CC=1 SCAR=0.0
45  
46 4 my $CHALLENGE_CLASS = 'Net::ACME::Challenge';
47  
48 sub new {
49 4 ▶ my ( $class, %opts ) = @_;
Subroutine new: called CC=5 SCAR=16.2
Pod undocumented
50  
51 my $self = {
52 _status => $opts{'status'} || die('Need “status”!'),
53 4 ▶ _challenges => $opts{'challenges'},
Condition50%1/2
$opts{'status'} || die("Need \342\200\234status\342\200\235!")
l!l
40
MC/DC0%0/1
$opts{'status'} || die("Need \342\200\234status\342\200\235!")
$opts{'status'}
Truth table50%1/2
A
A= $opts{'status'}
Aresult
11
00
54 };
55  
56 4 ▶ if ( $opts{'challenges'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"challenges"}) 4 0 4
57 4 for my $c ( 0 .. $#{ $opts{'challenges'} } ) {
58 4 my $challenge = $opts{'challenges'}[$c];
59  
60 4 ▶ if ( !Net::ACME::Utils::thing_isa($challenge, $CHALLENGE_CLASS) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (Net::ACME::Utils::thing_isa($challenge, $CHALLENGE_CLASS)) 1 3 4
61 1 die Net::ACME::X::create( 'InvalidParameter', "“challenges” index $c ($challenge) is not an instance of “$CHALLENGE_CLASS”!" );
62 }
63 }
64 }
65  
66 3 return bless $self, $class;
67 }
68  
69 sub status {
70 3 ▶ my ($self) = @_;
Subroutine status: called CC=1 SCAR=0.0
Pod undocumented
71 3 return $self->{'_status'};
72 }
73  
74 sub challenges {
75 4 ▶ my ($self) = @_;
Subroutine challenges: called CC=1 SCAR=0.0
Pod undocumented
76  
77 4 Call::Context::must_be_list();
78  
79 3 return @{ $self->{'_challenges'} };
80 }
81  
82 4 1;
« ACME/AccessorBase.pm ↑ Summary ACME/HTTP/Response.pm »