Branch Coverage

blib/lib/Crypt/LE.pm
Criterion Covered Total %
branch 167 558 29.9


line true false branch
338 3 27 if exists $params{$key} and not ref $params{$key}
344 0 3 if ($self->{'server'}) { }
0 3 elsif ($self->{'dir'}) { }
0 3 elsif ($self->{'ca'}) { }
349 0 0 unless $self->{'dir'} =~ m[^https?://]i
356 3 0 if ($opts)
358 3 0 if ($opts->{'stage'}) { }
359 0 3 $self->{'live'} ? :
366 0 3 if $params{'logger'} and &blessed($params{'logger'})
386 1 3 unless $key
390 1 2 if $@
405 0 1 unless $pk
435 1 10 unless $csr
437 0 10 unless $bio
439 1 9 unless (&Net::SSLeay::BIO_write($bio, $csr) and $in = &Net::SSLeay::PEM_read_bio_X509_REQ($bio))
444 9 0 if ($cn)
446 9 0 if $cn and $cn =~ /^.*?\bCN=([^\s,]+).*$/
450 9 0 if ($i > -1)
452 9 0 if ($o)
455 9 0 if ($dec)
457 9 0 if ($ext->{'extnID'} and $ext->{'extnID'} eq "2.5.29.17")
469 9 0 if ($cn)
473 9 0 if ($san)
475 21 0 if ($ext->{'dNSName'}) { }
477 12 9 unless $seen{$cn}++
484 0 9 if ($san_broken)
487 9 0 if (@loaded_domains) { }
490 1 8 if (my $odd = $self->_verify_list(\@loaded_domains))
495 4 4 if (@list)
496 2 2 unless join(",", sort(@loaded_domains)) eq join(",", sort(@list))
519 1 13 unless @list
520 4 9 if (my $odd = $self->_verify_list(\@list))
524 3 6 unless $key
526 0 6 unless $csr
554 2 1 unless $key
579 0 0 unless ($email)
587 0 0 unless $email
603 1 8 unless @list
604 4 4 if (my $odd = $self->_verify_list(\@list))
623 0 0 unless defined $version and $version =~ /^\d+$/ and $version <= 2
653 0 3 if $self->_is_divisible($n)
661 0 3 if ($self->{'autodir'})
663 0 0 unless $status == 0
674 0 399 if $remainder->is_zero
696 24 7 $list ? :
1 31 ref $list eq 'ARRAY' ? :
701 42 7 unless m"[\s\[\{\(\<\@\>\)\}\]/\\:]" or /^[\d\.]+$/
702 9 21 @odd ? :
727 1 0 if (not $self->{'directory'} or $reload)
728 1 0 $self->{'dir'} ? :
729 0 1 if ($status == 200 and $content and ref $content eq 'HASH') { }
730 0 0 if ($content->{'newAccount'}) { }
0 0 elsif ($content->{'new-reg'}) { }
731 0 0 $self->version ? :
738 0 0 $self->version ? :
746 0 0 if $self->{'directory'} and $self->{'directory'}{'reg'}
748 0 0 unless ($self->{'nonce'})
749 0 0 if ($self->{'directory'}{'newNonce'}) { }
751 0 0 unless $self->{'nonce'}
792 0 0 if $self->{'email'}
794 0 0 if $self->{'location'}
796 0 0 if ($status == $self->_compat_response(409)) { }
0 0 elsif ($status == 201) { }
0 0 elsif ($status == 400 and $kid and $mac and $self->_pull_error($content) =~ /not awaiting/) { }
800 0 0 if ($status == $self->_compat_response(202)) { }
802 0 0 if ($self->version == 1 and $self->{'links'} and $self->{'links'}{'terms-of-service'} and !$content->{'agreement'} || $self->{'links'}{'terms-of-service'} ne $content->{'agreement'}) { }
803 0 0 $content->{'agreement'} ? :
816 0 0 if ($self->{'links'}{'terms-of-service'})
823 0 0 if ($self->{'directory'}{'reg'}) { }
831 0 0 if ($self->{'registration_info'} and ref $self->{'registration_info'} eq "HASH")
833 0 0 if ($self->{'registration_info'}{'contact'} and ref $self->{'registration_info'}{'contact'} eq "ARRAY" and @{$self->{'registration_info'}{'contact'};})
837 0 0 if (not $self->{'registration_id'} and $self->{'directory'}{'reg'} =~ m[/([^/]+)$])
840 0 0 if $self->{'registration_id'}
854 0 0 unless $self->tos_changed
856 0 0 $status == $self->_compat_response(202) ? :
870 0 0 unless $contacts and ref $contacts eq "ARRAY"
871 0 0 /^\w+:/ ? :
873 0 0 $status == $self->_compat_response(202) ? :
887 0 0 unless $self->{'domains'}
893 0 0 if ($self->version > 1) { }
894 0 0 unless ($self->{'authz'})
896 0 0 if ($status == 201 and $content->{'identifiers'} and $content->{'authorizations'}) { }
900 0 0 unless ($self->{'directory'}{'new-authz'})
913 0 0 if ($status == $self->_compat_response(201)) { }
915 0 0 unless $content->{'identifier'} and $content->{'identifier'}{'value'}
917 0 0 if $content->{'wildcard'}
919 0 0 unless ($challenge and ref $challenge eq "HASH" and $challenge->{'type'} and $challenge->{'url'} || $challenge->{'uri'} and $challenge->{'status'} || $content->{'status'})
926 0 0 unless ($challenge->{'token'} and $challenge->{'token'} =~ /$url_safe/)
930 0 0 if $challenge->{'status'} eq "valid"
935 0 0 if ($self->{'challenges'} and exists $self->{'challenges'}{$domain}) { }
950 0 0 if (%domains_failed) { }
954 0 0 @failed == $domains_requested ? :
961 0 0 unless (defined $self->{'domains'}{$domain})
966 0 0 $domains_requested ? :
1046 0 0 unless $self->{'domains'} and $self->{'challenges'}
1047 0 0 $cb && &blessed($cb) ? :
1050 0 0 unless $cb and ref $cb eq 'CODE' || $mod_callback && $cb->can($handler)
1051 0 0 if $params and ref $params ne "HASH"
1055 0 0 unless (defined $self->{'domains'}{$domain} and not $self->{'domains'}{$domain})
1056 0 0 $self->{'domains'}{$domain} ? :
1059 0 0 unless ($self->{'challenges'}{$domain} and $self->{'challenges'}{$domain}{$type})
1073 0 0 $mod_callback ? :
1075 0 0 if ($@ or not $rv) { }
1076 0 0 $@ ? :
1083 0 0 if (@domains_failed) { }
1085 0 0 $domains_accepted ? :
1089 0 0 $domains_accepted ? :
1176 0 0 unless $self->{'domains'} and $self->{'challenges'}
1177 0 0 unless $self->{'active_challenges'}
1178 0 0 $cb && &blessed($cb) ? :
1181 0 0 if ($cb)
1182 0 0 unless $cb and ref $cb eq 'CODE' || $mod_callback && $cb->can($handler)
1183 0 0 if $params and ref $params ne "HASH"
1188 0 0 unless (defined $self->{'domains'}{$domain} and not $self->{'domains'}{$domain})
1189 0 0 $self->{'domains'}{$domain} ? :
1192 0 0 unless ($self->{'active_challenges'}{$domain})
1201 0 0 if ($status == $expected_status)
1203 0 0 if ($content->{'uri'})
1205 0 0 $self->version > 1 ? :
1207 0 0 if ($status == $expected_status and $content and $content->{'status'})
1208 0 0 if ($content->{'status'} =~ /^(?:in)?valid$/)
1209 0 0 if ($content->{'status'} eq "valid")
1217 0 0 if ($cb)
1229 0 0 $mod_callback ? :
1231 0 0 if ($@ or not $rv)
1233 0 0 $@ ? :
1234 0 0 if $validated
1238 0 0 if ($validated) { }
1242 0 0 unless $cb_reset
1246 0 0 if (@domains_failed) { }
1248 0 0 $domains_verified ? :
1252 0 0 $domains_verified ? :
1265 0 0 unless $self->{'csr'}
1270 0 0 unless ($self->{'finalize'})
1272 0 0 $status == 403 ? :
0 0 unless $status == 201
1273 0 0 if (ref $content eq "HASH" and $content->{'identifiers'} and $content->{'authorizations'})
1278 0 0 if ($self->{'finalize'})
1281 0 0 if (ref $content eq "HASH" and $content->{'status'} and $content->{'status'} eq "processing")
1286 0 0 if ($status == 200 and $content and $content->{'status'}) { }
1287 0 0 if ($content->{'status'} eq 'valid') { }
0 0 elsif ($content->{'status'} eq 'invalid') { }
0 0 elsif ($content->{'status'} eq 'pending') { }
1288 0 0 if ($content->{'certificate'}) { }
1291 0 0 if $self->version > 1
1293 0 0 unless $status == 200
1296 0 0 if ($content =~ /(\n\-+END CERTIFICATE\-+)[\s\r\n]+(.+)/s)
1316 0 0 unless $ready
1320 0 0 $self->{'links'} && $self->{'links'}{'up'} ? :
1321 0 0 $self->{'issuer_url'} ? :
1334 0 0 unless $self->{'alternatives'}
1340 0 0 if $self->version > 1
1342 0 0 unless $status == 200
1344 0 0 if ($content =~ /(\n\-+END CERTIFICATE\-+)[\s\r\n]+(.+)/s) { }
1364 0 0 if $self->issuer
1365 0 0 unless $self->{'issuer_url'}
1367 0 0 if ($status == 200)
1386 0 0 unless $crt
1390 0 0 if ($status == 200) { }
0 0 elsif ($status == 409) { }
1415 0 0 $self->{'links'} && $self->{'links'}{'terms-of-service'} ? :
1486 0 0 if ($self->{'alternative_certificates'} and defined $idx and $idx < @{$self->{'alternative_certificates'};})
1500 0 0 if ($self->{'alternative_certificates'})
1557 0 2 unless $self->{'failed_domains'} and @{$self->{'failed_domains'};}
1558 1 1 unless $all
1561 1 1 if ($proc)
1566 1 0 @rv ? :
1577 0 1 unless $self->{'domains'} and %{$self->{'domains'};}
1579 1 0 @list ? :
1600 0 2 unless $ca
1601 1 1 $$cas{lc $ca} ? :
1612 0 2 unless $ca
1614 1 1 $Crypt::LE::cas->{$ca} && $Crypt::LE::cas->{$ca}{'stage'} ? :
1632 0 2 if $params and ref $params eq "HASH"
1633 0 2 if (not $res or $timeout and !($timeout =~ /^\d+/) || $timeout < 1) { }
2 0 elsif (ref $res or not $res =~ m[^\w+://]i) { }
1638 2 0 if (ref $res) { }
1640 0 2 unless $bio and &Net::SSLeay::BIO_write($bio, $$res)
1643 0 0 unless $bio
1645 0 2 if ($load_error) { }
1648 1 1 unless ($cert)
1666 0 0 unless $response->{'success'}
1679 0 3 unless $pem
1680 3 0 if $pem =~ /(?:^|\s+)-+BEGIN[^-]*-+\s+(.*?)\s+-+END/s
1693 3 0 $der && $type ? :
1708 1 0 unless $pkcs12_available
1709 0 0 unless $pass
1714 0 0 if $@ and $@ =~ /Usage/
1715 0 0 if $@
1737 2 0 if ($self->{'error'})
1739 0 2 ref $self->{'error'} ? :
0 2 $err ? :
1752 0 10 unless $type =~ /^\d+$/ and $type <= 1
1753 8 2 if ($type == 0) { }
2 0 elsif ($type == 1) { }
1755 2 6 if $attr < 2048 or $attr % 1024
1757 1 1 unless $attr and $attr ne "default"
1758 0 2 unless defined &Net::SSLeay::EC_KEY_generate_key
1760 4 4 if ($key) { }
1762 0 4 unless $bio
1763 0 4 unless &Net::SSLeay::BIO_write($bio, $key)
1766 0 4 unless $pk
1769 0 4 unless $pk
1772 2 2 $type == 0 ? :
1774 1 3 if $@
1775 1 0 $@ ? :
1 3 unless $gen
1776 2 1 $type == 0 ? :
1784 0 6 unless $domains and !$ref || $ref eq 'ARRAY'
1785 0 6 if $attrib and ref $attrib ne "HASH"
1787 0 6 unless $req
1788 0 6 unless &Net::SSLeay::X509_REQ_set_pubkey($req, $pk)
1789 6 0 $ref ? :
1790 6 0 unless $attrib and $attrib->{'CN'} || $attrib->{'commonName'}
1792 0 6 unless &Net::SSLeay::P_X509_REQ_add_extensions($req, &Net::SSLeay::NID_subject_alt_name, $list)
1794 0 6 unless $n
1797 0 30 unless &Net::SSLeay::X509_NAME_add_entry_by_txt($n, $key, scalar MBSTRING_UTF8(), scalar &encode_utf8($attrib->{$key}))
1799 0 6 unless &Net::SSLeay::X509_REQ_set_subject_name($req, $n)
1802 6 0 unless (&Net::SSLeay::X509_REQ_get_version($req))
1803 0 6 unless &Net::SSLeay::X509_REQ_set_version($req, 0)
1806 0 6 unless $md and &Net::SSLeay::X509_REQ_sign($req, $pk, $md)
1814 6 16 if $data{'r'}
1815 14 8 if $data{'b'}
1816 8 14 if $data{'k'}
1817 1 21 wantarray ? :
1824 0 6 if length($val) % 2
1835 0 1 unless ($url)
1837 0 0 wantarray ? :
1844 0 1 if (defined $payload or $method eq 'post') { }
1846 0 0 defined $payload ? :
1850 0 1 $resp->{'headers'}{'content-type'} && $resp->{'headers'}{'content-type'} =~ m[^application/(?:problem\+)?json] ? :
1851 1 0 $slurp ? :
1852 0 1 if $resp->{'headers'}{'replay-nonce'}
1854 0 1 unless ($slurp)
1858 0 0 if ($@)
1862 0 1 $resp->{'headers'}{'link'} ? :
1863 0 1 $resp->{'headers'}{'location'} ? :
1864 0 1 if ($resp->{'headers'}{'retry-after'} and $resp->{'headers'}{'retry-after'} =~ /^(\d+)$/)
1868 1 0 wantarray ? :
1881 0 0 if $self->{'try'} and ++$try == $self->{'try'}
1888 0 3 unless $self->{'key_params'}
1899 0 0 unless defined $obj
1900 0 0 ref $obj ? :
1903 0 0 if ($url and $self->version > 1)
1904 0 0 if ($self->{'directory'}{'reg'} and not $opts->{'jwk'})
1910 0 0 if ($opts->{'kid'} and $opts->{'mac'})
1923 0 0 ref $obj ? :
1933 0 0 unless $links
1935 0 0 ref $links eq 'ARRAY' ? :
1936 0 0 unless $link and $link =~ /^<([^>]+)>;rel="([^"]+)"$/i
1937 0 0 if ($2 eq 'alternate') { }
1949 0 0 unless $content
1951 0 0 if (my $name = $compat->{$_})
1959 0 0 $self->version == 2 ? :
1964 0 0 if not $req or $self->version == 1 or not $req->{'resource'}
1965 0 0 unless my $res = delete $req->{'resource'}
1966 0 0 if ($res eq 'new-reg' or $res eq 'reg') { }
0 0 elsif ($res eq 'new-cert') { }
1978 0 0 unless $data and $data->{'domain'}
1988 55 0 unless $self->{'debug'}
1990 0 0 if (not ref $_) { }
0 0 elsif ($self->{'debug'} > 1) { }
1991 0 0 $self->{'logger'} ? :
1993 0 0 $self->{'logger'} ? :
2001 20 25 if ($code == 0) { }
2004 0 25 if (ref $data eq 'HASH' and $data->{'error'}) { }
2010 45 0 if $data
2017 0 2 if ($err and ref $err eq "HASH")
2018 0 0 if $err->{'error'} and $err->{'error'}{'detail'}
2019 0 0 if $err->{'detail'}
2026 0 0 unless $self->{'loaded_domains'}
2036 0 18 unless $file
2037 4 14 unless (ref $file)
2039 4 0 if (defined $fh)
2047 14 0 ref $file eq 'SCALAR' ? :
2053 1 0 unless (defined $_[5] and $_[5])
2059 1 0 unless ($@)
2062 1 0 unless $$exp and $s > $$exp
2071 2 1 !$content || $content =~ /^\-+BEGIN/ ? :