Branch Coverage

blib/lib/Zonemaster/Backend/RPCAPI.pm
Criterion Covered Total %
branch 57 106 53.7


line true false branch
34 2 0 if ($params and $params->{'db'}) { }
37 0 2 if $@
40 0 2 if $@
46 0 0 if $@
49 0 0 if $@
69 0 0 unless @adresses
80 0 0 if $dn_syntax->{'status'} eq 'nok'
92 0 0 if ($ds_p)
96 0 0 unless $ds->type eq 'DS'
110 0 65 unless (defined $dn)
114 8 57 if ($dn =~ /[^[:ascii:]]+/u)
115 0 8 if (&Zonemaster::LDNS::has_idn()) { }
117 0 0 if ($@)
141 4 53 if (@res != 0)
158 0 161 unless grep {$_ eq $k;} @allowed_params_keys
161 30 1 if (defined $syntax_input->{'nameservers'} and @{$syntax_input->{'nameservers'};})
164 0 102 unless $k eq 'ns' or $k eq 'ip'
169 6 25 if (defined $syntax_input->{'ds_info'} and @{$syntax_input->{'ds_info'};})
172 0 4 unless $k eq 'algorithm' or $k eq 'digest' or $k eq 'digtype' or $k eq 'keytag'
177 2 29 if (defined $syntax_input->{'advanced'})
179 0 2 unless $syntax_input->{'advanced'} eq JSON::PP::false() or $syntax_input->{'advanced'} eq JSON::PP::true()
182 31 0 if (defined $syntax_input->{'ipv4'})
187 0 0 unless $syntax_input->{'ipv4'} eq JSON::PP::false() or $syntax_input->{'ipv4'} eq JSON::PP::true() or $syntax_input->{'ipv4'} eq '1' or $syntax_input->{'ipv4'} eq '0'
190 31 0 if (defined $syntax_input->{'ipv6'})
195 0 0 unless $syntax_input->{'ipv6'} eq JSON::PP::false() or $syntax_input->{'ipv6'} eq JSON::PP::true() or $syntax_input->{'ipv6'} eq '1' or $syntax_input->{'ipv6'} eq '0'
198 2 29 if (defined $syntax_input->{'profile'})
202 0 0 unless $syntax_input->{'profile'} eq 'default_profile' or $syntax_input->{'profile'} eq 'test_profile_1' or $syntax_input->{'profile'} eq 'test_profile_2'
207 6 25 if $dn_syntax->{'status'} eq 'nok'
209 24 1 if (defined $syntax_input->{'nameservers'} and @{$syntax_input->{'nameservers'};})
212 6 28 if $ns_syntax->{'status'} eq 'nok'
217 2 24 unless not $ns_ip->{'ip'} or &ip_is_ipv4($ns_ip->{'ip'}) or &ip_is_ipv6($ns_ip->{'ip'})
225 1 5 if $ds_digest->{'algorithm'} =~ /\D/u
237 2 3 if length $ds_digest->{'digest'} != 96 and length $ds_digest->{'digest'} != 64 and length $ds_digest->{'digest'} != 40 or $ds_digest->{'digest'} =~ /[^A-Fa-f0-9]/u
248 0 0 if ($params->{'user_ip'} and 'Zonemaster::Backend::Config'->Maxmind_ISP_DB_File and 'Zonemaster::Backend::Config'->Maxmind_City_DB_File)
253 0 0 if ($ip->iptype eq 'PUBLIC') { }
279 2 0 unless not $params->{'domain'} or $params->{'domain'} eq '.'
281 0 2 unless $syntax_result and $syntax_result->{'status'} eq 'ok'
283 0 2 unless $params->{'domain'}
285 0 2 if ($params->{'config'})
287 0 0 unless 'Zonemaster::Backend::Config'->GetCustomConfigParameter('ZONEMASTER', $params->{'config'})
328 2 0 if $translator
334 35 258 if ($test_res->{'module'} eq 'NAMESERVER') { }
3 271 elsif ($test_res->{'module'} eq 'SYSTEM' and $test_res->{'tag'} eq 'POLICY_DISABLED' and $test_res->{'args'}{'name'} eq 'Example') { }
335 17 18 $test_res->{'args'}{'ns'} ? :
350 16 274 if ($test_res->{'module'} eq 'SYSTEM')
351 3 13 if ($res->{'message'} =~ /policy\.json/u) { }
3 10 elsif ($res->{'message'} =~ /config\.json/u) { }
354 0 3 if $policy =~ m[some/other/policy/path]u
360 0 3 if $config =~ m[some/other/configuration/path]u
387 0 1 if (defined $remote_ip) { }
388 0 0 if $remote_ip eq '::1' or $remote_ip eq '127.0.0.1'
394 1 0 if ($allow)
395 1 0 if $self->{'db'}->add_api_user($p->{'username'}, $p->{'api_key'}) eq '1'