DRI/Protocol/RRI/Domain.pm

filter: Statementstmt 6.5% 22 / 335 Branchbran 0.0% 0 / 186 Conditioncond 0.0% 0 / 75 MC/DCmcdc 0.0% 0 / 44 Subroutinesub 23.3% 7 / 30 Podpod 0.0% 0 / 23 totaltotal 4.1% 29 / 693 CC 131 SCAR 50.2
CC
131
Cov
4%
info_parse
342.0
update
306.0
parse_ns
210.0
CRAP 150.7
« DRI/Protocol/BookMyName/WS/Domain.pm ↑ Summary DRI/Protocol/EPP/Extensions/BR/Domain.pm »
1 ## Domain Registry Interface, RRI Domain commands (DENIC-11)
2 ##
3 ## Copyright (c) 2007,2008 Tonnerre Lombard <tonnerre.lombard@sygroup.ch>. All rights reserved.
4 ## (c) 2012,2013 Michael Holloway <michael@thedarkwinter.com>. All rights reserved.
5 ## (c) 2018 Patrick Mevzek <netdri@dotandco.com>. All rights reserved.
6 ##
7 ## This file is part of Net::DRI
8 ##
9 ## Net::DRI is free software; you can redistribute it and/or modify
10 ## it under the terms of the GNU General Public License as published by
11 ## the Free Software Foundation; either version 2 of the License, or
12 ## (at your option) any later version.
13 ##
14 ## See the LICENSE file that comes with this distribution for more details.
15 ####################################################################################################
16  
17 package Net::DRI::Protocol::RRI::Domain;
18  
19 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 ##use IDNA::Punycode;
23 1 ▶use DateTime::Format::ISO8601 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 1 ▶use Net::DRI::Data::Hosts;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 1 ▶use Net::DRI::Data::ContactSet;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 =pod
31  
32 =head1 NAME
33  
34 Net::DRI::Protocol::RRI::Domain - RRI Domain commands (DENIC-11) for Net::DRI
35  
36 =head1 DESCRIPTION
37  
38 Please see the README file for details.
39  
40 =head1 SUPPORT
41  
42 For now, support questions should be sent to:
43  
44 E<lt>tonnerre.lombard@sygroup.chE<gt>
45  
46 Please also see the SUPPORT file in the distribution.
47  
48 =head1 SEE ALSO
49  
50 E<lt>http://oss.bsdprojects.net/projects/netdri/E<gt>
51  
52 =head1 AUTHOR
53  
54 Tonnerre Lombard, E<lt>tonnerre.lombard@sygroup.chE<gt>
55  
56 =head1 COPYRIGHT
57  
58 Copyright (c) 2007,2008 Tonnerre Lombard <tonnerre.lombard@sygroup.ch>.
59 (c) 2012,2013 Michael Holloway <michael@thedarkwinter.com>.
60 (c) 2018 Patrick Mevzek <netdri@dotandco.com>. All rights reserved.
61 All rights reserved.
62  
63 This program is free software; you can redistribute it and/or modify
64 it under the terms of the GNU General Public License as published by
65 the Free Software Foundation; either version 2 of the License, or
66 (at your option) any later version.
67  
68 See the LICENSE file that comes with this distribution for more details.
69  
70 =cut
71  
72 ####################################################################################################
73  
74 sub register_commands
75 0 ▶{
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
76 0 my ($class,$version)=@_;
77 0 my %tmp=(
78 check => [ \&check, \&check_parse ],
79 info => [ \&info, \&info_parse ],
80 transfer_query => [ \&transfer_query, \&transfer_parse ],
81 create => [ \&create, \&create_parse ],
82 delete => [ \&delete ],
83 transfer_request => [ \&transfer_request ],
84 transfer_answer => [ \&transfer_answer ],
85 trade => [ \&trade ],
86 update => [ \&update],
87 transit => [ \&transit],
88 migrate_descr => [ \&migrate_descr],
89 create_authinfo => [ \&create_authinfo],
90 delete_authinfo => [ \&delete_authinfo],
91 );
92  
93 0 return { 'domain' => \%tmp };
94 }
95  
96 sub build_command
97 0 ▶{
Subroutine build_command: not called CC=10 SCAR=47.0
Pod undocumented
98 0 my ($msg, $command, $domain, $domainattr, $dns) = @_;
99 0 ▶ my @dom = (ref($domain))? @$domain : ($domain);
Branch: 1 branch
BranchTrueFalseTotal
ref $domain ? : 0 0 0
100 0 ▶ Net::DRI::Exception->die(1,'protocol/RRI', 2, 'Domain name needed')
Branch: 1 branch
BranchTrueFalseTotal
unless @dom 0 0 0
101 unless @dom;
102 0 foreach my $d (@dom)
103 {
104 0 ▶ Net::DRI::Exception->die(1, 'protocol/RRI', 2, 'Domain name needed')
Branch: 1 branch
BranchTrueFalseTotal
unless defined $d and $d 0 0 0
Condition0%0/3
defined $d and $d
!ll&&!rl&&r
000
MC/DC0%0/2
defined $d and $d
defined $d $d
Truth table0%0/3
A and B
A= defined $dB= $d
ABresult
0X0
100
111
105 unless defined($d) && $d;
106 0 ▶ Net::DRI::Exception->die(1, 'protocol/RRI', 10, 'Invalid domain name: ' . $d)
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::is_hostname($d) 0 0 0
107 unless Net::DRI::Util::is_hostname($d);
108 }
109  
110 0 ▶ my $tcommand = (ref($command)) ? $command->[0] : $command;
Branch: 1 branch
BranchTrueFalseTotal
ref $command ? : 0 0 0
111 0 ▶ $msg->command(['domain', $tcommand, $dns // $msg->ns('domain'), $domainattr]);
Condition0%0/3
$dns // $msg->ns("domain")
l!l&&r!l&&!r
000
MC/DC0%0/2
$dns // $msg->ns("domain")
$dns $msg->ns("domain")
Truth table0%0/3
A // B
A= $dnsB= $msg->ns("domain")
ABresult
1X1
011
000
112  
113 0 my @d;
114  
115 0 foreach my $domain (@dom)
116 {
117 ##my $ace = join('.', map { decode_punycode($_) } split(/\./, $domain));
118 0 push @d, ['domain:handle', $domain];
119 0 push @d, ['domain:ace', $domain];
120 }
121 0 return @d;
122 }
123  
124 ####################################################################################################
125 ########### Query commands
126  
127 sub check
128 0 ▶{
Subroutine check: not called CC=1 SCAR=6.9
Pod undocumented
129 0 my ($rri, $domain, $rd)=@_;
130 0 my $mes = $rri->message();
131 0 my @d = build_command($mes, 'check', $domain);
132 0 $mes->command_body(\@d);
133 0 $mes->cltrid(undef);
134 0 return;
135 }
136  
137  
138 sub check_parse
139 0 ▶{
Subroutine check_parse: not called CC=6 SCAR=37.4
Pod undocumented
140 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
141 0 my $mes = $po->message();
142 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
143  
144 0 my $ns = $mes->ns('domain');
145 0 my $chkdata = $mes->get_content('checkData', $ns);
146 0 ▶ return unless $chkdata;
Branch: 1 branch
BranchTrueFalseTotal
unless $chkdata 0 0 0
147 0 my @d = $chkdata->getElementsByTagNameNS($ns, 'handle');
148 0 my @s = $chkdata->getElementsByTagNameNS($ns, 'status');
149 0 ▶ return unless (@d && @s);
Branch: 1 branch
BranchTrueFalseTotal
unless @d and @s 0 0 0
Condition0%0/3
@d and @s
!ll&&!rl&&r
000
MC/DC0%0/2
@d and @s
@d @s
Truth table0%0/3
A and B
A= @dB= @s
ABresult
0X0
100
111
150  
151 0 my $dom = $d[0]->getFirstChild()->getData();
152 0 $rinfo->{domain}->{$dom}->{action} = 'check';
153 0 ▶ $rinfo->{domain}->{$dom}->{exist} = ($s[0]->getFirstChild()->getData() eq 'free')? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$s[0]->getFirstChild->getData eq 'free' ? : 0 0 0
154 0 return;
155 }
156  
157 sub info
158 0 ▶{
Subroutine info: not called CC=3 SCAR=24.8
Pod undocumented
159 0 my ($rri, $domain, $rd)=@_;
160 0 my $mes = $rri->message();
161 0 ▶ my $wp = (defined($rd->{'withProvider'} && $rd->{'withProvider'})) ? 'true' : 'false';
Branch: 1 branch
BranchTrueFalseTotal
defined($rd->{'withProvider'} && $rd->{'withProvider'}) ? : 0 0 0
Condition0%0/3
$rd->{'withProvider'} && $rd->{'withProvider'}
!ll&&!rl&&r
000
MC/DC0%0/2
$rd->{'withProvider'} && $rd->{'withProvider'}
$rd->{'withProvider'} $rd->{'withProvider'}
Truth table0%0/3
A && B
A= $rd->{'withProvider'}B= $rd->{'withProvider'}
ABresult
0X0
100
111
162 0 my @d = build_command($mes, 'info', $domain,
163 {recursive => 'false', withProvider => $wp});
164 0 $mes->command_body(\@d);
165 0 $mes->cltrid(undef);
166 0 return;
167 }
168  
169 sub info_parse
170 0 ▶{
Subroutine info_parse: not called CC=18 SCAR=58.3
Pod undocumented
171 0 my ($po, $otype, $oaction, $oname, $rinfo) = @_;
172 0 my $mes = $po->message();
173 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
174 0 my $infdata = $mes->get_content('infoData', $mes->ns('domain'));
175 0 ▶ return unless $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless $infdata 0 0 0
176 0 my $cs = Net::DRI::Data::ContactSet->new();
177 0 my $ns = Net::DRI::Data::Hosts->new();
178 0 my $c = $infdata->getFirstChild();
179  
180 0 ▶ while ($c)
Branch: 1 branch
BranchTrueFalseTotal
if ($c) 0 0 0
181 {
182 0 ▶ next unless ($c->nodeType() == 1); ## only for element nodes
Branch: 1 branch
BranchTrueFalseTotal
unless $c->nodeType == 1 0 0 0
183 0 ▶ my $name = $c->localname() || $c->nodeName();
Condition0%0/3
$c->localname || $c->nodeName
l!l&&r!l&&!r
000
MC/DC0%0/2
$c->localname || $c->nodeName
$c->localname $c->nodeName
Truth table0%0/3
A || B
A= $c->localnameB= $c->nodeName
ABresult
1X1
011
000
184 0 ▶ next unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 0 0
185  
186 0 ▶ if ($name eq 'handle')
Branch: 7 branches
BranchTrueFalseTotal
if ($name eq 'handle') { } 0 0 0
elsif ($name eq 'status') { } 0 0 0
elsif ($name eq 'contact') { } 0 0 0
elsif ($name eq 'dnsentry') { } 0 0 0
elsif ($name eq 'regAccId') { } 0 0 0
elsif ($name eq 'changed') { } 0 0 0
elsif ($name eq 'chprovData') { } 0 0 0
187 {
188 0 $oname = lc($c->getFirstChild()->getData());
189 0 $rinfo->{domain}->{$oname}->{action} = 'info';
190 0 $rinfo->{domain}->{$oname}->{exist} = 1;
191 }
192 elsif ($name eq 'status')
193 {
194 0 my $val = $c->getFirstChild()->getData();
195 0 ▶ $rinfo->{domain}->{$oname}->{exist} = ($val eq 'connect')? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$val eq 'connect' ? : 0 0 0
196 }
197 elsif ($name eq 'contact')
198 {
199 0 my $role = $c->getAttribute('role');
200 0 my %rmap = ('holder' => 'registrant', 'admin-c' => 'admin',
201 'tech-c' => 'tech', 'zone-c' => 'zone');
202 0 my @hndl_tags = $c->getElementsByTagNameNS($mes->ns('contact'),'handle');
203 0 my $hndl_tag = $hndl_tags[0];
204 0 ▶ $role = $rmap{$role} if (defined($rmap{$role}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $rmap{$role} 0 0 0
205 0 ▶ $cs->add($po->create_local_object('contact')->srid($hndl_tag->getFirstChild()->getData()), $role)
Branch: 1 branch
BranchTrueFalseTotal
if defined $hndl_tag and defined $hndl_tag->getFirstChild 0 0 0
Condition0%0/3
defined $hndl_tag and defined $hndl_tag->getFirstChild
!ll&&!rl&&r
000
MC/DC0%0/2
defined $hndl_tag and defined $hndl_tag->getFirstChild
defined $hndl_tag defined $hndl_tag->getFirstChild
Truth table0%0/3
A and B
A= defined $hndl_tagB= defined $hndl_tag->getFirstChild
ABresult
0X0
100
111
206 if (defined($hndl_tag) && defined($hndl_tag->getFirstChild()));
207 }
208 elsif ($name eq 'dnsentry')
209 {
210 0 $ns->add(parse_ns($mes,$c));
211 }
212 elsif ($name eq 'regAccId')
213 {
214 $rinfo->{domain}->{$oname}->{clID} =
215 $rinfo->{domain}->{$oname}->{crID} =
216 0 $rinfo->{domain}->{$oname}->{upID} = $c->getFirstChild()->getData();
217 }
218 elsif ($name eq 'changed')
219 {
220 $rinfo->{domain}->{$oname}->{crDate} =
221 $rinfo->{domain}->{$oname}->{upDate} =
222 0 DateTime::Format::ISO8601->new()->
223 parse_datetime($c->getFirstChild()->getData());
224 }
225 elsif ($name eq 'chprovData')
226 {
227 # FIXME: Implement this one as well
228 }
229 0 } continue { $c = $c->getNextSibling(); }
230  
231 0 $rinfo->{domain}->{$oname}->{contact} = $cs;
232 0 $rinfo->{domain}->{$oname}->{status} = $po->create_local_object('status');
233 0 $rinfo->{domain}->{$oname}->{ns} = $ns;
234 0 return;
235 }
236  
237 sub parse_ns
238 0 ▶{
Subroutine parse_ns: not called CC=14 SCAR=53.5
Pod undocumented
239 0 my $mes = shift;
240 0 my $node = shift;
241 0 my $n = $node->getFirstChild();
242 0 my $hostname = '';
243 0 my @ip4 = ();
244 0 my @ip6 = ();
245  
246 0 ▶ while ($n)
Branch: 1 branch
BranchTrueFalseTotal
if ($n) 0 0 0
247 {
248 0 ▶ next unless ($n->nodeType() == 1); ## only for element nodes
Branch: 1 branch
BranchTrueFalseTotal
unless $n->nodeType == 1 0 0 0
249 0 ▶ my $name = $n->localname() || $n->nodeName();
Condition0%0/3
$n->localname || $n->nodeName
l!l&&r!l&&!r
000
MC/DC0%0/2
$n->localname || $n->nodeName
$n->localname $n->nodeName
Truth table0%0/3
A || B
A= $n->localnameB= $n->nodeName
ABresult
1X1
011
000
250 0 ▶ next unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 0 0
251  
252 0 ▶ if ($name eq 'rdata')
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "rdata") 0 0 0
253 {
254 0 my $nn = $n->getFirstChild();
255 0 ▶ while ($nn)
Branch: 1 branch
BranchTrueFalseTotal
if ($nn) 0 0 0
256 {
257 0 ▶ next unless ($nn->nodeType() == 1); ## only for element nodes
Branch: 1 branch
BranchTrueFalseTotal
unless $nn->nodeType == 1 0 0 0
258 0 ▶ my $name2 = $nn->localname() || $nn->nodeName();
Condition0%0/3
$nn->localname || $nn->nodeName
l!l&&r!l&&!r
000
MC/DC0%0/2
$nn->localname || $nn->nodeName
$nn->localname $nn->nodeName
Truth table0%0/3
A || B
A= $nn->localnameB= $nn->nodeName
ABresult
1X1
011
000
259 0 ▶ next unless $name2;
Branch: 1 branch
BranchTrueFalseTotal
unless $name2 0 0 0
260 0 ▶ if ($name2 eq 'nameserver')
Branch: 2 branches
BranchTrueFalseTotal
if ($name2 eq 'nameserver') { } 0 0 0
elsif ($name2 eq 'address') { } 0 0 0
261 {
262 0 $hostname = $nn->getFirstChild()->getData();
263 0 ▶ $hostname =~ s/\.$// if ($hostname =~ /\.$/);
Branch: 1 branch
BranchTrueFalseTotal
if $hostname =~ /\.$/ 0 0 0
264 }
265 elsif ($name2 eq 'address')
266 {
267 0 my $ip = $nn->getFirstChild()->getData();
268 0 ▶ if ($ip=~m/:/)
Branch: 1 branch
BranchTrueFalseTotal
if ($ip =~ /:/) { } 0 0 0
269 {
270 0 push @ip6, $ip;
271 }
272 else
273 {
274 0 push @ip4, $ip;
275 }
276 }
277 0 } continue { $nn = $nn->getNextSibling(); }
278 }
279 0 } continue { $n = $n->getNextSibling(); }
280  
281 0 return ($hostname, \@ip4, \@ip6);
282 }
283  
284 sub transfer_query
285 0 ▶{
Subroutine transfer_query: not called CC=1 SCAR=6.9
Pod undocumented
286 0 my ($rri, $domain, $rd)=@_;
287 0 my $mes = $rri->message();
288 0 my @d = build_command($mes, 'info', $domain,
289 {recursive => 'true', withProvider => 'false'});
290 0 $mes->command_body(\@d);
291 0 return;
292 }
293  
294 sub transfer_parse
295 0 ▶{
Subroutine transfer_parse: not called CC=13 SCAR=52.0
Pod undocumented
296 0 my ($po, $otype, $oaction, $oname, $rinfo) = @_;
297 0 my $mes = $po->message();
298 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
299  
300 0 my $ns = $mes->ns('domain');
301 0 my $infodata = $mes->get_content('infoData', $ns);
302 0 ▶ return unless $infodata;
Branch: 1 branch
BranchTrueFalseTotal
unless $infodata 0 0 0
303 0 my $namedata = ($infodata->getElementsByTagNameNS($ns, 'handle'))[0];
304 0 ▶ return unless $namedata;
Branch: 1 branch
BranchTrueFalseTotal
unless $namedata 0 0 0
305 0 my $trndata = ($infodata->getElementsByTagNameNS($ns, 'chprovData'))[0];
306 0 ▶ return unless $trndata;
Branch: 1 branch
BranchTrueFalseTotal
unless $trndata 0 0 0
307  
308 0 $oname = lc($namedata->getFirstChild()->getData());
309 0 $rinfo->{domain}->{$oname}->{action} = 'transfer';
310 0 $rinfo->{domain}->{$oname}->{exist} = 1;
311 0 $rinfo->{domain}->{$oname}->{trStatus} = undef;
312  
313 0 my $c = $trndata->getFirstChild();
314 0 ▶ while ($c)
Branch: 1 branch
BranchTrueFalseTotal
if ($c) 0 0 0
315 {
316 0 ▶ next unless ($c->nodeType() == 1); ## only for element nodes
Branch: 1 branch
BranchTrueFalseTotal
unless $c->nodeType == 1 0 0 0
317 0 ▶ my $name = $c->localname() || $c->nodeName();
Condition0%0/3
$c->localname || $c->nodeName
l!l&&r!l&&!r
000
MC/DC0%0/2
$c->localname || $c->nodeName
$c->localname $c->nodeName
Truth table0%0/3
A || B
A= $c->localnameB= $c->nodeName
ABresult
1X1
011
000
318 0 ▶ next unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 0 0
319  
320 0 ▶ if ($name eq 'chprovTo')
Branch: 3 branches
BranchTrueFalseTotal
if ($name eq 'chprovTo') { } 0 0 0
elsif ($name eq 'chprovStatus') { } 0 0 0
elsif ($name =~ /^(chprovStart|chprovReminder|chprovEnd)$/) { } 0 0 0
321 {
322 0 $rinfo->{domain}->{$oname}->{reID} = $c->getFirstChild()->getData();
323 }
324 elsif ($name eq 'chprovStatus')
325 {
326 0 my %stmap = (ACTIVE => 'pending', REMINDED => 'pending');
327 0 my $val = $c->getFirstChild()->getData();
328 $rinfo->{domain}->{$oname}->{trStatus} =
329 0 ▶ (defined($stmap{$val}) ? $stmap{$val} : $val);
Branch: 1 branch
BranchTrueFalseTotal
defined $stmap{$val} ? : 0 0 0
330 }
331 elsif ($name =~ m/^(chprovStart|chprovReminder|chprovEnd)$/)
332 {
333 0 my %tmmap = (chprovStart => 'reDate', chprovReminder => 'acDate',
334 chprovEnd => 'exDate');
335 0 $rinfo->{domain}->{$oname}->{$tmmap{$1}} = DateTime::Format::ISO8601->
336 new()->parse_datetime($c->getFirstChild()->getData());
337 }
338 0 } continue { $c = $c->getNextSibling(); }
339 0 return;
340 }
341  
342 ############ Transform commands
343  
344 sub create
345 0 ▶{
Subroutine create: not called CC=13 SCAR=52.0
Pod undocumented
346 0 my ($rri, $domain, $rd) = @_;
347 0 my $mes = $rri->message();
348 0 my %ns = map { $_ => $mes->ns($_) } qw(domain dnsentry xsi);
349 0 my @d = build_command($mes, 'create', $domain, undef, \%ns);
350
351 0 my $def = $rri->default_parameters();
352 0 ▶ if ($def && (ref($def) eq 'HASH') && exists($def->{domain_create}) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($def and ref $def eq "HASH" and exists $def->{"domain_create"} and ref $def->{"domain_create"} eq "HASH") 0 0 0
Condition0%0/9
$def and ref $def eq "HASH" and exists $def->{"domain_create"} and ref $def->{"domain_create"} eq "HASH"
!ll&&!rl&&r
000
$def and ref $def eq "HASH" and exists $def->{"domain_create"}
!ll&&!rl&&r
000
$def and ref $def eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/4
$def and ref $def eq "HASH" and exists $def->{"domain_create"} and ref $def->{"domain_create"} eq "HASH"
$def ref $def eq "HASH" exists $def->{"domain_create"} ref $def->{"domain_create"} eq "HASH"
Truth table0%0/5
A and B and C and D
A= $defB= ref $def eq "HASH"C= exists $def->{"domain_create"}D= ref $def->{"domain_create"} eq "HASH"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
353 (ref($def->{domain_create}) eq 'HASH'))
354 {
355 0 ▶ $rd = {} unless ($rd && (ref($rd) eq 'HASH') && keys(%$rd));
Branch: 1 branch
BranchTrueFalseTotal
unless $rd and ref $rd eq "HASH" and keys %$rd 0 0 0
Condition0%0/6
$rd and ref $rd eq "HASH" and keys %$rd
!ll&&!rl&&r
000
$rd and ref $rd eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/3
$rd and ref $rd eq "HASH" and keys %$rd
$rd ref $rd eq "HASH" keys %$rd
Truth table0%0/4
A and B and C
A= $rdB= ref $rd eq "HASH"C= keys %$rd
ABCresult
0XX0
10X0
1100
1111
356 0 ▶ while (my ($k, $v) = each(%{$def->{domain_create}}))
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$$def{"domain_create"};}) 0 0 0
357 {
358 0 ▶ next if exists($rd->{$k});
Branch: 1 branch
BranchTrueFalseTotal
if exists $rd->{$k} 0 0 0
359 0 $rd->{$k} = $v;
360 }
361 }
362  
363 ## Contacts, all OPTIONAL
364 0 ▶ push @d,build_contact($rd->{contact}) if Net::DRI::Util::has_contact($rd);
Branch: 1 branch
BranchTrueFalseTotal
if Net::DRI::Util::has_contact($rd) 0 0 0
365  
366 ## Nameservers, OPTIONAL
367 0 ▶ push @d,build_ns($rri,$rd->{ns},$domain) if Net::DRI::Util::has_ns($rd);
Branch: 1 branch
BranchTrueFalseTotal
if Net::DRI::Util::has_ns($rd) 0 0 0
368  
369 0 ▶ push @d,build_secdns($rd->{secdns},$domain) if $rd->{secdns};
Branch: 1 branch
BranchTrueFalseTotal
if $rd->{"secdns"} 0 0 0
370  
371 0 $mes->command_body(\@d);
372 0 return;
373 }
374  
375 sub build_contact
376 0 ▶{
Subroutine build_contact: not called CC=3 SCAR=24.8
Pod undocumented
377 0 my $cs = shift;
378 0 my @d;
379  
380 0 my %trans = ('registrant' => 'holder', 'admin' => 'admin-c',
381 'tech' => 'tech-c', 'zone' => 'zone-c');
382  
383 # All nonstandard contacts go into the extension section
384 0 foreach my $t (sort($cs->types()))
385 {
386 0 my @o = $cs->get($t);
387 0 ▶ my $c = (defined($trans{$t}) ? $trans{$t} : $t);
Branch: 1 branch
BranchTrueFalseTotal
defined $trans{$t} ? : 0 0 0
388 0 push @d, map { ['domain:contact', $_->srid(), {'role' => $c}] } @o;
389 }
390 0 return @d;
391 }
392  
393 sub build_ns
394 0 ▶{
Subroutine build_ns: not called CC=3 SCAR=24.8
Pod undocumented
395 0 my ($rri,$ns,$domain,$xmlns)=@_;
396 0 my @d;
397  
398 0 foreach my $i (1..$ns->count())
399 {
400 0 my ($n, $v4, $v6) = $ns->get_details($i);
401 0 my @h = map { ['dnsentry:address', $_] } (@{$v4}, @{$v6});
402 0 push @d, ['dnsentry:dnsentry', {'xsi:type' => 'dnsentry:NS'},
403 ['dnsentry:owner', $domain . '.'],
404 ['dnsentry:rdata', ['dnsentry:nameserver', $n . '.' ], @h ] ];
405 }
406 0 ▶ $xmlns='dnsentry' unless defined($xmlns);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $xmlns 0 0 0
407 0 return @d;
408 }
409  
410 sub build_secdns
411 0 ▶{
Subroutine build_secdns: not called CC=8 SCAR=42.8
Pod undocumented
412 0 my ($secdns,$domain)=@_;
413 0 ▶ return unless $secdns;
Branch: 1 branch
BranchTrueFalseTotal
unless $secdns 0 0 0
414 0 my @d;
415 0 foreach my $s (@{$secdns}) {
416 0 ▶ next unless $s->{key_flags};
Branch: 1 branch
BranchTrueFalseTotal
unless $s->{"key_flags"} 0 0 0
417 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('key_flags mut be a 16-bit unsigned integer: '.$s->{key_flags}) unless Net::DRI::Util::verify_ushort($s->{key_flags});
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::verify_ushort($s->{"key_flags"}) 0 0 0
418 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('key_protocol must be an unsigned byte: '.$s->{key_protocol}) unless Net::DRI::Util::verify_ubyte($s->{key_protocol});
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::verify_ubyte($s->{"key_protocol"}) 0 0 0
419 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('key_alg must be an unsigned byte: '.$s->{key_alg}) unless Net::DRI::Util::verify_ubyte($s->{key_alg});
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::verify_ubyte($s->{"key_alg"}) 0 0 0
420 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('key_pubKey must be a non empty base64 string: '.$s->{key_pubKey}) unless Net::DRI::Util::verify_base64($s->{key_pubKey},1);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::verify_base64($s->{"key_pubKey"}, 1) 0 0 0
421 push @d, ['dnsentry:dnsentry', {'xsi:type' => 'dnsentry:DNSKEY'},
422 ['dnsentry:owner', $domain . '.'],
423 ['dnsentry:rdata',
424 ['dnsentry:flags', $s->{'key_flags'}],
425 ['dnsentry:protocol', $s->{'key_protocol'}],
426 ['dnsentry:algorithm', $s->{'key_alg'}],
427 0 ['dnsentry:publicKey', $s->{'key_pubKey'}] ] ];
428 }
429 0 return @d;
430 }
431  
432 sub create_parse
433 0 ▶{
Subroutine create_parse: not called CC=9 SCAR=45.0
Pod undocumented
434 0 my ($po, $otype, $oaction, $oname, $rinfo) = @_;
435 0 my $mes = $po->message();
436 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
437  
438 0 my $credata = $mes->get_content('creData', $mes->ns('domain'));
439 0 ▶ return unless $credata;
Branch: 1 branch
BranchTrueFalseTotal
unless $credata 0 0 0
440  
441 0 my $c = $credata->getFirstChild();
442 0 ▶ while ($c)
Branch: 1 branch
BranchTrueFalseTotal
if ($c) 0 0 0
443 {
444 0 ▶ next unless ($c->nodeType() == 1); ## only for element nodes
Branch: 1 branch
BranchTrueFalseTotal
unless $c->nodeType == 1 0 0 0
445 0 ▶ my $name = $c->localname() || $c->nodeName();
Condition0%0/3
$c->localname || $c->nodeName
l!l&&r!l&&!r
000
MC/DC0%0/2
$c->localname || $c->nodeName
$c->localname $c->nodeName
Truth table0%0/3
A || B
A= $c->localnameB= $c->nodeName
ABresult
1X1
011
000
446 0 ▶ next unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 0 0
447  
448 0 ▶ if ($name eq 'name')
Branch: 2 branches
BranchTrueFalseTotal
if ($name eq 'name') { } 0 0 0
elsif ($name =~ /^(crDate|exDate)$/) { } 0 0 0
449 {
450 0 $oname = lc($c->getFirstChild()->getData());
451 0 $rinfo->{domain}->{$oname}->{action} = 'create';
452 0 $rinfo->{domain}->{$oname}->{exist} = 1;
453 }
454 elsif ($name =~ m/^(crDate|exDate)$/)
455 {
456 0 $rinfo->{domain}->{$oname}->{$1} = DateTime::Format::ISO8601->new()->
457 parse_datetime($c->getFirstChild()->getData());
458 }
459 0 } continue { $c = $c->getNextSibling(); }
460 0 return;
461 }
462  
463 sub delete ## no critic (Subroutines::ProhibitBuiltinHomonyms)
464 0 ▶{
Subroutine delete: not called CC=3 SCAR=24.8
Pod undocumented
465 0 my ($rri, $domain, $rd) = @_;
466 0 my $mes = $rri->message();
467 0 my @d = build_command($mes, 'delete', $domain);
468  
469 ## Holder contact
470 0 ▶ if (Net::DRI::Util::has_contact($rd))
Branch: 1 branch
BranchTrueFalseTotal
if (Net::DRI::Util::has_contact($rd)) 0 0 0
471 {
472 0 my $ocs = $rd->{contact};
473 0 my $cs = Net::DRI::Data::ContactSet->new();
474 0 foreach my $c ($ocs->get('registrant'))
475 {
476 0 $cs->add($c, 'registrant');
477 }
478  
479 0 push @d, build_contact($cs);
480 }
481  
482 0 $mes->command_body(\@d);
483 0 return;
484 }
485  
486 sub transfer_request
487 0 ▶{
Subroutine transfer_request: not called CC=4 SCAR=30.0
Pod undocumented
488 0 my ($rri, $domain, $rd) = @_;
489 0 my $mes = $rri->message();
490 0 my %ns = map { $_ => $mes->ns($_) } qw(domain dnsentry xsi);
491 0 my @d = build_command($mes, 'chprov', $domain, undef, \%ns);
492  
493 ## Contacts, all OPTIONAL
494 0 ▶ push @d,build_contact($rd->{contact}) if Net::DRI::Util::has_contact($rd);
Branch: 1 branch
BranchTrueFalseTotal
if Net::DRI::Util::has_contact($rd) 0 0 0
495  
496 ## Nameservers, OPTIONAL
497 0 ▶ push @d, build_ns($rri, $rd->{ns}, $domain) if Net::DRI::Util::has_ns($rd);
Branch: 1 branch
BranchTrueFalseTotal
if Net::DRI::Util::has_ns($rd) 0 0 0
498  
499 0 ▶ push @d, ['domain:authInfo',$rd->{auth}->{pw}] if $rd->{auth};
Branch: 1 branch
BranchTrueFalseTotal
if $rd->{"auth"} 0 0 0
500  
501 0 $mes->command_body(\@d);
502 0 return;
503 }
504  
505 sub transfer_answer
506 0 ▶{
Subroutine transfer_answer: not called CC=3 SCAR=24.8
Pod undocumented
507 0 my ($rri, $domain, $rd) = @_;
508 0 my $mes = $rri->message();
509 0 ▶ my @d = build_command($mes, (Net::DRI::Util::has_key($rd,'approve') && $rd->{approve}) ?
Branch: 1 branch
BranchTrueFalseTotal
Net::DRI::Util::has_key($rd, 'approve') && $rd->{'approve'} ? : 0 0 0
Condition0%0/3
Net::DRI::Util::has_key($rd, "approve") and $rd->{"approve"}
!ll&&!rl&&r
000
MC/DC0%0/2
Net::DRI::Util::has_key($rd, "approve") and $rd->{"approve"}
Net::DRI::Util::has_key($rd, "approve") $rd->{"approve"}
Truth table0%0/3
A and B
A= Net::DRI::Util::has_key($rd, "approve")B= $rd->{"approve"}
ABresult
0X0
100
111
510 'chprovAck' : 'chprovNack', $domain);
511 0 $mes->command_body(\@d);
512 0 return;
513 }
514  
515 sub trade
516 0 ▶{
Subroutine trade: not called CC=12 SCAR=50.5
Pod undocumented
517 0 my ($rri, $domain, $rd) = @_;
518 0 my $mes = $rri->message();
519 0 my %ns = map { $_ => $mes->ns($_) } qw(domain dnsentry xsi);
520 0 my @d = build_command($mes, 'chholder', $domain, undef, \%ns);
521  
522 0 my $def = $rri->default_parameters();
523 0 ▶ if ($def && (ref($def) eq 'HASH') && exists($def->{domain_create}) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($def and ref $def eq "HASH" and exists $def->{"domain_create"} and ref $def->{"domain_create"} eq "HASH") 0 0 0
Condition0%0/9
$def and ref $def eq "HASH" and exists $def->{"domain_create"} and ref $def->{"domain_create"} eq "HASH"
!ll&&!rl&&r
000
$def and ref $def eq "HASH" and exists $def->{"domain_create"}
!ll&&!rl&&r
000
$def and ref $def eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/4
$def and ref $def eq "HASH" and exists $def->{"domain_create"} and ref $def->{"domain_create"} eq "HASH"
$def ref $def eq "HASH" exists $def->{"domain_create"} ref $def->{"domain_create"} eq "HASH"
Truth table0%0/5
A and B and C and D
A= $defB= ref $def eq "HASH"C= exists $def->{"domain_create"}D= ref $def->{"domain_create"} eq "HASH"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
524 (ref($def->{domain_create}) eq 'HASH'))
525 {
526 0 ▶ $rd = {} unless ($rd && (ref($rd) eq 'HASH') && keys(%$rd));
Branch: 1 branch
BranchTrueFalseTotal
unless $rd and ref $rd eq "HASH" and keys %$rd 0 0 0
Condition0%0/6
$rd and ref $rd eq "HASH" and keys %$rd
!ll&&!rl&&r
000
$rd and ref $rd eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/3
$rd and ref $rd eq "HASH" and keys %$rd
$rd ref $rd eq "HASH" keys %$rd
Truth table0%0/4
A and B and C
A= $rdB= ref $rd eq "HASH"C= keys %$rd
ABCresult
0XX0
10X0
1100
1111
527 0 ▶ while (my ($k, $v) = each(%{$def->{domain_create}}))
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$$def{"domain_create"};}) 0 0 0
528 {
529 0 ▶ next if exists($rd->{$k});
Branch: 1 branch
BranchTrueFalseTotal
if exists $rd->{$k} 0 0 0
530 0 $rd->{$k} = $v;
531 }
532 }
533  
534 ## Contacts, all OPTIONAL
535 0 ▶ push @d,build_contact($rd->{contact}) if Net::DRI::Util::has_contact($rd);
Branch: 1 branch
BranchTrueFalseTotal
if Net::DRI::Util::has_contact($rd) 0 0 0
536  
537 ## Nameservers, OPTIONAL
538 0 ▶ push @d, build_ns($rri, $rd->{ns}, $domain) if Net::DRI::Util::has_ns($rd);
Branch: 1 branch
BranchTrueFalseTotal
if Net::DRI::Util::has_ns($rd) 0 0 0
539  
540 0 $mes->command_body(\@d);
541 0 return;
542 }
543  
544 0 ▶sub transit {
Subroutine transit: not called CC=3 SCAR=24.8
Pod undocumented
545 0 my ($rri, $domain, $rd) = @_;
546 0 my $mes = $rri->message();
547 0 ▶ my $disconnect = ( exists($rd->{disconnect}) && $rd->{disconnect} eq 'true' ) ? { disconnect => 'true'} : undef;
Branch: 1 branch
BranchTrueFalseTotal
exists $rd->{'disconnect'} && $rd->{'disconnect'} eq 'true' ? : 0 0 0
Condition0%0/3
exists $rd->{"disconnect"} and $rd->{"disconnect"} eq "true"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $rd->{"disconnect"} and $rd->{"disconnect"} eq "true"
exists $rd->{"disconnect"} $rd->{"disconnect"} eq "true"
Truth table0%0/3
A and B
A= exists $rd->{"disconnect"}B= $rd->{"disconnect"} eq "true"
ABresult
0X0
100
111
548 0 my %ns = map { $_ => $mes->ns($_) } qw(domain dnsentry xsi);
549 0 my @d = build_command($mes, 'transit', $domain, $disconnect, \%ns);
550  
551 0 $mes->command_body(\@d);
552 0 return;
553 }
554  
555 0 ▶sub migrate_descr {
Subroutine migrate_descr: not called CC=2 SCAR=17.9
Pod undocumented
556 0 my ($rri, $domain, $rd) = @_;
557 0 my $mes = $rri->message();
558 0 my %ns = map { $_ => $mes->ns($_) } qw(domain dnsentry xsi);
559 0 my @d = build_command($mes, 'migrate-descr', $domain, undef, \%ns);
560  
561 ## Contacts, Holder is required
562 0 ▶ push @d,build_contact($rd->{contact}) if Net::DRI::Util::has_contact($rd);
Branch: 1 branch
BranchTrueFalseTotal
if Net::DRI::Util::has_contact($rd) 0 0 0
563  
564 0 $mes->command_body(\@d);
565 0 return;
566 }
567  
568 0 ▶sub create_authinfo {
Subroutine create_authinfo: not called CC=5 SCAR=34.0
Pod undocumented
569 0 my ($rri, $domain, $rd) = @_;
570 0 my $mes = $rri->message();
571 0 my %ns = map { $_ => $mes->ns($_) } qw(domain dnsentry xsi);
572 0 ▶ my $hash = exists($rd->{'authinfohash'}) ? { hash => $rd->{'authinfohash'}} : undef;
Branch: 1 branch
BranchTrueFalseTotal
exists $rd->{'authinfohash'} ? : 0 0 0
573 0 ▶ $hash->{'expire'} = $rd->{'authinfoexpire'} if ($hash && exists($rd->{'authinfoexpire'}));
Branch: 1 branch
BranchTrueFalseTotal
if $hash and exists $rd->{"authinfoexpire"} 0 0 0
Condition0%0/3
$hash and exists $rd->{"authinfoexpire"}
!ll&&!rl&&r
000
MC/DC0%0/2
$hash and exists $rd->{"authinfoexpire"}
$hash exists $rd->{"authinfoexpire"}
Truth table0%0/3
A and B
A= $hashB= exists $rd->{"authinfoexpire"}
ABresult
0X0
100
111
574 0 ▶ my $cmd = ($hash) ? 'createAuthInfo1' : 'createAuthInfo2';
Branch: 1 branch
BranchTrueFalseTotal
$hash ? : 0 0 0
575 0 my @d = build_command($mes, $cmd, $domain, $hash, \%ns);
576 0 $mes->command_body(\@d);
577 0 return;
578 }
579  
580 0 ▶sub delete_authinfo {
Subroutine delete_authinfo: not called CC=1 SCAR=6.9
Pod undocumented
581 0 my ($rri, $domain, $rd) = @_;
582 0 my $mes = $rri->message();
583 0 my %ns = map { $_ => $mes->ns($_) } qw(domain dnsentry xsi);
584 0 my @d = build_command($mes, 'deleteAuthInfo1', $domain, undef, \%ns);
585 0 $mes->command_body(\@d);
586 0 return;
587 }
588  
589 sub update
590 0 ▶{
Subroutine update: not called CC=17 SCAR=57.2
Pod undocumented
591 0 my ($rri, $domain, $todo, $rd)=@_;
592 0 my $mes = $rri->message();
593 0 my %ns = map { $_ => $mes->ns($_) } qw(domain dnsentry xsi);
594 0 my $ns = $rd->{ns};
595 0 my $cs = $rd->{contact};
596  
597 0 ▶ Net::DRI::Exception::usererr_invalid_parameters($todo.' must be a Net::DRI::Data::Changes object') unless Net::DRI::Util::isa_changes($todo);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::isa_changes($todo) 0 0 0
598  
599 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Must specify contact set and name servers with update command (or use the proper API)') unless (Net::DRI::Util::isa_contactset($cs) && Net::DRI::Util::isa_hosts($ns));
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::isa_contactset($cs) and Net::DRI::Util::isa_hosts($ns) 0 0 0
Condition0%0/3
Net::DRI::Util::isa_contactset($cs) and Net::DRI::Util::isa_hosts($ns)
!ll&&!rl&&r
000
MC/DC0%0/2
Net::DRI::Util::isa_contactset($cs) and Net::DRI::Util::isa_hosts($ns)
Net::DRI::Util::isa_contactset($cs) Net::DRI::Util::isa_hosts($ns)
Truth table0%0/3
A and B
A= Net::DRI::Util::isa_contactset($cs)B= Net::DRI::Util::isa_hosts($ns)
ABresult
0X0
100
111
600  
601 0 ▶ if ((grep { ! /^(?:add|del)$/ } $todo->types('ns')) ||
Branch: 1 branch
BranchTrueFalseTotal
if (grep {not /^(?:add|del)$/;} $todo->types("ns") or grep {not /^(?:add|del)$/;} $todo->types("contact")) 0 0 0
Condition0%0/3
grep {not /^(?:add|del)$/;} $todo->types("ns") or grep {not /^(?:add|del)$/;} $todo->types("contact")
l!l&&r!l&&!r
000
MC/DC0%0/2
grep {not /^(?:add|del)$/;} $todo->types("ns") or grep {not /^(?:add|del)$/;} $todo->types("contact")
grep {not /^(?:add|del)$/;} $todo->types("ns") grep {not /^(?:add|del)$/;} $todo->types("contact")
Truth table0%0/3
A or B
A= grep {not /^(?:add|del)$/;} $todo->types("ns")B= grep {not /^(?:add|del)$/;} $todo->types("contact")
ABresult
1X1
011
000
602 0 (grep { ! /^(?:add|del)$/ } $todo->types('contact')))
603 {
604 0 Net::DRI::Exception->die(0, 'protocol/RRI', 11, 'Only ns/status/contact add/del or registrant/authinfo set available for domain');
605 }
606  
607 0 my @d = build_command($mes, 'update', $domain, undef, \%ns);
608  
609 0 my $nsadd = $todo->add('ns');
610 0 my $nsdel = $todo->del('ns');
611 0 my $cadd = $todo->add('contact');
612 0 my $cdel = $todo->del('contact');
613  
614 0 ▶ if (defined($nsadd)) { foreach my $hostname ($nsadd->get_names())
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nsadd) 0 0 0
615 {
616 0 $ns->add($nsadd->get_details($hostname));
617 } }
618  
619 0 ▶ if (defined($nsdel))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nsdel) 0 0 0
620 {
621 0 my $newns =Net::DRI::Data::Hosts->new();
622  
623 0 foreach my $hostname ($ns->get_names())
624 {
625 0 ▶ if (!grep { $_ eq $hostname } $nsdel->get_names())
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {$_ eq $hostname;} $nsdel->get_names) 0 0 0
626 {
627 0 $newns->add($ns->get_details($hostname));
628 }
629 }
630  
631 0 $ns = $newns;
632 }
633  
634 0 ▶ if (defined($cadd)) { foreach my $type ($cadd->types()) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cadd) 0 0 0
635 0 foreach my $c ($cadd->get($type))
636 {
637 0 $cs->add($c, $type);
638 }
639 } }
640  
641 0 ▶ if (defined($cdel)) { foreach my $type ($cdel->types()) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cdel) 0 0 0
642 0 foreach my $c ($cdel->get($type))
643 {
644 0 $cs->del($c, $type);
645 }
646 } }
647  
648 0 push @d, build_contact($cs);
649 0 push @d, build_ns($rri, $ns, $domain);
650  
651 0 $mes->command_body(\@d);
652 0 return;
653 }
654  
655 ####################################################################################################
656 1 1;
« DRI/Protocol/BookMyName/WS/Domain.pm ↑ Summary DRI/Protocol/EPP/Extensions/BR/Domain.pm »