File Coverage

blib/lib/Net/ACME2/Error.pm
Criterion Covered Total %
statement 51 51 100.0
branch 6 6 100.0
condition 4 5 80.0
subroutine 13 13 100.0
pod 4 4 100.0
total 78 79 98.7


line stmt bran cond sub pod time code
1             package Net::ACME2::Error;
2              
3             =encoding utf-8
4              
5             =head1 NAME
6              
7             Net::ACME2::Error - error parsing logic for ACME
8              
9             =head1 SYNOPSIS
10              
11             use Net::ACME2::Error;
12              
13             my $err = Net::ACME2::Error->new( { type => '..', .. } );
14              
15             =head1 DESCRIPTION
16              
17             This simple module interfaces with ACME2 “error” objects,
18             which are described in the ACME protocol specification.
19              
20             =head1 NOTES
21              
22             ACME’s errors are basically just HTTP API problem detail documents,
23             which are described in more detail at L.
24              
25             =cut
26              
27 6     6   84109 use strict;
  6         19  
  6         155  
28 6     6   27 use warnings;
  6         8  
  6         143  
29              
30 6     6   510 use parent qw( Net::ACME2::AccessorBase );
  6         354  
  6         27  
31              
32 6     6   1819 use Call::Context ();
  6         1326  
  6         179  
33              
34             my $URN_PREFIX = 'urn:ietf:params:acme:error:';
35              
36 6         697 use constant _ACCESSORS => qw(
37             detail
38             instance
39             status
40             title
41             type
42 6     6   31 );
  6         9  
43              
44             #cf. https://ietf-wg-acme.github.io/acme/#errors
45 6         2202 use constant _TYPE_DESCRIPTION => {
46             badCSR => 'The CSR is unacceptable (e.g., due to a short key)',
47             badNonce => 'The client sent an unacceptable anti-replay nonce',
48             badSignatureAlgorithm => 'The JWS was signed with an algorithm the server does not support',
49             invalidContact => 'A contact URL for an account was invalid',
50             unsupportedContact => 'A contact URL for an account used an unsupported protocol scheme',
51             accountDoesNotExist => 'The request specified an account that does not exist',
52             malformed => 'The request message was malformed',
53             rateLimited => 'The request exceeds a rate limit',
54             rejectedIdentifier => 'The server will not issue for the identifier',
55             serverInternal => 'The server experienced an internal error',
56             unauthorized => 'The client lacks sufficient authorization',
57             unsupportedIdentifier => 'Identifier is not supported, but may be in the future',
58             userActionRequired => 'Visit the “instance” URL and take actions specified there',
59             badRevocationReason => 'The revocation reason provided is not allowed by the server',
60             dns => 'There was a problem with a DNS query',
61              
62             connection => 'The server could not connect to a validation target',
63             dnssec => 'The server could not validate a DNSSEC signed domain',
64             caa => 'CAA records forbid the CA from issuing',
65             tls => 'The server received a TLS error during validation',
66             incorrectResponse => 'Response received didn’t match the challenge’s requirements',
67 6     6   37 };
  6         9  
68              
69             =head1 ACCESSORS
70              
71             =over
72              
73             =item * C
74              
75             =item * C
76              
77             =item * C
78              
79             =item * C </td> </tr> <tr> <td class="h" > <a name="80">80</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="81">81</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> =item * C<type> - defaults to C<about:blank> </td> </tr> <tr> <td class="h" > <a name="82">82</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="83">83</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> =item * C<description> - text description of the C<type> </td> </tr> <tr> <td class="h" > <a name="84">84</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="85">85</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> =item * C<subproblems> - list of subproblem objects </td> </tr> <tr> <td class="h" > <a name="86">86</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="87">87</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> =item * C<to_string> - human-readable description of the error </td> </tr> <tr> <td class="h" > <a name="88">88</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> (including subproblems) </td> </tr> <tr> <td class="h" > <a name="89">89</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="90">90</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> =back </td> </tr> <tr> <td class="h" > <a name="91">91</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="92">92</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> =cut </td> </tr> <tr> <td class="h" > <a name="93">93</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="94">94</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub type { </td> </tr> <tr> <td class="h" > <a name="95">95</a> </td> <td class="c3" > 21 </td> <td >   </td> <td >   </td> <td class="c3" > <a href="blib-lib-Net-ACME2-Error-pm--subroutine.html#95-1"> 21 </a> </td> <td class="c3" > <a href="blib-lib-Net-ACME2-Error-pm--subroutine.html#95-1"> 1 </a> </td> <td > 59 </td> <td class="s"> my ($self) = @_; </td> </tr> <tr> <td class="h" > <a name="96">96</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="97">97</a> </td> <td class="c3" > 21 </td> <td >   </td> <td class="c3" > <a href="blib-lib-Net-ACME2-Error-pm--condition.html#97-1"> 100 </a> </td> <td >   </td> <td >   </td> <td > 79 </td> <td class="s"> return $self->SUPER::type() || 'about:blank'; </td> </tr> <tr> <td class="h" > <a name="98">98</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="99">99</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="100">100</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub description { </td> </tr> <tr> <td class="h" > <a name="101">101</a> </td> <td class="c3" > 10 </td> <td >   </td> <td >   </td> <td class="c3" > <a href="blib-lib-Net-ACME2-Error-pm--subroutine.html#101-1"> 10 </a> </td> <td class="c3" > <a href="blib-lib-Net-ACME2-Error-pm--subroutine.html#101-1"> 1 </a> </td> <td > 15 </td> <td class="s"> my ($self) = @_; </td> </tr> <tr> <td class="h" > <a name="102">102</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="103">103</a> </td> <td class="c3" > 10 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 17 </td> <td class="s"> my $type = $self->type(); </td> </tr> <tr> <td class="h" > <a name="104">104</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="105">105</a> </td> <td class="c3" > 10 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 50 </td> <td class="s"> $type =~ s<\A$URN_PREFIX><>; </td> </tr> <tr> <td class="h" > <a name="106">106</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="107">107</a> </td> <td class="c3" > 10 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 26 </td> <td class="s"> return _TYPE_DESCRIPTION()->{$type}; </td> </tr> <tr> <td class="h" > <a name="108">108</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="109">109</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="110">110</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub subproblems { </td> </tr> <tr> <td class="h" > <a name="111">111</a> </td> <td class="c3" > 11 </td> <td >   </td> <td >   </td> <td class="c3" > <a href="blib-lib-Net-ACME2-Error-pm--subroutine.html#111-1"> 11 </a> </td> <td class="c3" > <a href="blib-lib-Net-ACME2-Error-pm--subroutine.html#111-1"> 1 </a> </td> <td > 17 </td> <td class="s"> my ($self) = @_; </td> </tr> <tr> <td class="h" > <a name="112">112</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="113">113</a> </td> <td class="c3" > 11 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 30 </td> <td class="s"> Call::Context::must_be_list(); </td> </tr> <tr> <td class="h" > <a name="114">114</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="115">115</a> </td> <td class="c3" > 11 </td> <td class="c3" > <a href="blib-lib-Net-ACME2-Error-pm--branch.html#115-1"> 100 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 118 </td> <td class="s"> my $subs_ar = $self->{'_subproblems'} or return; </td> </tr> <tr> <td class="h" > <a name="116">116</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="117">117</a> </td> <td class="c3" > 3 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 7 </td> <td class="s"> return map { Net::ACME2::Error::Subproblem->new(%$_) } @$subs_ar; </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 6 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 27 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="118">118</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="119">119</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="120">120</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub to_string { </td> </tr> <tr> <td class="h" > <a name="121">121</a> </td> <td class="c3" > 10 </td> <td >   </td> <td >   </td> <td class="c3" > <a href="blib-lib-Net-ACME2-Error-pm--subroutine.html#121-1"> 10 </a> </td> <td class="c3" > <a href="blib-lib-Net-ACME2-Error-pm--subroutine.html#121-1"> 1 </a> </td> <td > 38 </td> <td class="s"> my ($self) = @_; </td> </tr> <tr> <td class="h" > <a name="122">122</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="123">123</a> </td> <td class="c3" > 10 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 46 </td> <td class="s"> my $str = join( q< >, grep { defined } $self->status(), $self->type() ); </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 20 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 49 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="124">124</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="125">125</a> </td> <td class="c3" > 10 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 24 </td> <td class="s"> for my $attribute ( qw( title description detail instance ) ) { </td> </tr> <tr> <td class="h" > <a name="126">126</a> </td> <td class="c3" > 40 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 149 </td> <td class="s"> my $value = $self->$attribute(); </td> </tr> <tr> <td class="h" > <a name="127">127</a> </td> <td class="c3" > 40 </td> <td class="c3" > <a href="blib-lib-Net-ACME2-Error-pm--branch.html#127-1"> 100 </a> </td> <td class="c0" > <a href="blib-lib-Net-ACME2-Error-pm--condition.html#127-1"> 66 </a> </td> <td >   </td> <td >   </td> <td > 116 </td> <td class="s"> if ( defined $value && length $value ) { </td> </tr> <tr> <td class="h" > <a name="128">128</a> </td> <td class="c3" > 6 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 19 </td> <td class="s"> $str .= " ($value)"; </td> </tr> <tr> <td class="h" > <a name="129">129</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="130">130</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="131">131</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="132">132</a> </td> <td class="c3" > 10 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 23 </td> <td class="s"> my @subs = $self->subproblems(); </td> </tr> <tr> <td class="h" > <a name="133">133</a> </td> <td class="c3" > 10 </td> <td class="c3" > <a href="blib-lib-Net-ACME2-Error-pm--branch.html#133-1"> 100 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 23 </td> <td class="s"> if (@subs) { </td> </tr> <tr> <td class="h" > <a name="134">134</a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 6 </td> <td class="s"> $str .= ' (' . join(', ', map { $_->to_string() } @subs) . ')'; </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 4 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 10 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="135">135</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="136">136</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="137">137</a> </td> <td class="c3" > 10 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 59 </td> <td class="s"> return $str; </td> </tr> <tr> <td class="h" > <a name="138">138</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="139">139</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="140">140</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> #---------------------------------------------------------------------- </td> </tr> <tr> <td class="h" > <a name="141">141</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="142">142</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> package Net::ACME2::Error::Subproblem; </td> </tr> <tr> <td class="h" > <a name="143">143</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="144">144</a> </td> <td class="c3" > 6 </td> <td >   </td> <td >   </td> <td class="c3" > <a href="blib-lib-Net-ACME2-Error-pm--subroutine.html#144-1"> 6 </a> </td> <td >   </td> <td > 39 </td> <td class="s"> use parent qw( Net::ACME2::Error ); </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 6 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 10 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 6 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 27 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="145">145</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="146">146</a> </td> <td class="c3" > 6 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 832 </td> <td class="s"> use constant _ACCESSORS => ( </td> </tr> <tr> <td class="h" > <a name="147">147</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> __PACKAGE__->SUPER::_ACCESSORS(), </td> </tr> <tr> <td class="h" > <a name="148">148</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> 'identifier', </td> </tr> <tr> <td class="h" > <a name="149">149</a> </td> <td class="c3" > 6 </td> <td >   </td> <td >   </td> <td class="c3" > <a href="blib-lib-Net-ACME2-Error-pm--subroutine.html#149-1"> 6 </a> </td> <td >   </td> <td > 413 </td> <td class="s"> ); </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 6 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 12 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="150">150</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="151">151</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub to_string { </td> </tr> <tr> <td class="h" > <a name="152">152</a> </td> <td class="c3" > 6 </td> <td >   </td> <td >   </td> <td class="c3" > <a href="blib-lib-Net-ACME2-Error-pm--subroutine.html#152-1"> 6 </a> </td> <td >   </td> <td > 7308 </td> <td class="s"> my ($self) = @_; </td> </tr> <tr> <td class="h" > <a name="153">153</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="154">154</a> </td> <td class="c3" > 6 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 12 </td> <td class="s"> my $identifier_str = join('/', @{ $self->identifier() }{'type', 'value'}); </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 6 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 28 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="155">155</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="156">156</a> </td> <td class="c3" > 6 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 21 </td> <td class="s"> return "$identifier_str: " . $self->SUPER::to_string(); </td> </tr> <tr> <td class="h" > <a name="157">157</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="158">158</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="159">159</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> 1; </td> </tr> </table> </body> </html>