DRI/Protocol/EPP/Extensions/CAT/DefensiveRegistration.pm

filter: Statementstmt 7.4% 16 / 214 Branchbran 0.0% 0 / 146 Conditioncond 0.0% 0 / 81 MC/DCmcdc 0.0% 0 / 42 Subroutinesub 22.7% 5 / 22 Podpod 0.0% 0 / 17 totaltotal 4.0% 21 / 522 CC 107 SCAR 53.9
CC
107
Cov
4%
info_parse
506.0
update
462.0
build_trademark
182.0
CRAP 220.1
« DRI/Data/Contact/BE.pm ↑ Summary DRI/Transport/Socket.pm »
1 ## Domain Registry Interface, .CAT Defensive Registration EPP extension commands
2 ##
3 ## Copyright (c) 2006-2010,2013-2016,2018 Patrick Mevzek <netdri@dotandco.com>. All rights reserved.
4 ##
5 ## This file is part of Net::DRI
6 ##
7 ## Net::DRI is free software; you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation; either version 2 of the License, or
10 ## (at your option) any later version.
11 ##
12 ## See the LICENSE file that comes with this distribution for more details.
13 ####################################################################################################
14  
15 package Net::DRI::Protocol::EPP::Extensions::CAT::DefensiveRegistration;
16  
17 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use Net::DRI::Protocol::EPP::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 =pod
25  
26 =head1 NAME
27  
28 Net::DRI::Protocol::EPP::Extensions::CAT::DefensiveRegistration - .CAT EPP Defensive Registration extension commands for Net::DRI
29  
30 =head1 DESCRIPTION
31  
32 Please see the README file for details.
33  
34 =head1 SUPPORT
35  
36 For now, support questions should be sent to:
37  
38 E<lt>netdri@dotandco.comE<gt>
39  
40 Please also see the SUPPORT file in the distribution.
41  
42 =head1 SEE ALSO
43  
44 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
45  
46 =head1 AUTHOR
47  
48 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
49  
50 =head1 COPYRIGHT
51  
52 Copyright (c) 2006-2010,2013-2016,2018 Patrick Mevzek <netdri@dotandco.com>.
53 All rights reserved.
54  
55 This program is free software; you can redistribute it and/or modify
56 it under the terms of the GNU General Public License as published by
57 the Free Software Foundation; either version 2 of the License, or
58 (at your option) any later version.
59  
60 See the LICENSE file that comes with this distribution for more details.
61  
62 =cut
63  
64 ####################################################################################################
65  
66 sub register_commands
67 {
68 0 ▶ my ($class,$version)=@_;
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
69 0 my %tmp1=( create => [ \&create ],
70 check => [ \&check, \&check_parse ],
71 info => [ \&info, \&info_parse ],
72 delete => [ \&delete ],
73 update => [ \&update ],
74 renew => [ \&renew ],
75 );
76  
77 0 $tmp1{check_multi}=$tmp1{check};
78
79 0 return { 'defreg' => \%tmp1 };
80 }
81  
82 sub build_command
83 {
84 0 ▶ my ($epp,$command,$id)=@_;
Subroutine build_command: not called CC=7 SCAR=40.3
Pod undocumented
85 0 my $mes=$epp->message();
86  
87 0 my @id;
88 0 ▶ foreach my $n ( grep { defined } (ref($id) eq 'ARRAY')? @$id : ($id))
Branch: 1 branch
BranchTrueFalseTotal
ref $id eq 'ARRAY' ? : 0 0 0
89 {
90 0 ▶ Net::DRI::Exception->die(1,'protocol/EPP',10,'Invalid defensive registration id '.$n) unless ($n && !ref($n) && Net::DRI::Util::xml_is_token($n,3,16));
Branch: 1 branch
BranchTrueFalseTotal
unless $n and not ref $n and Net::DRI::Util::xml_is_token($n, 3, 16) 0 0 0
Condition0%0/6
$n and not ref $n and Net::DRI::Util::xml_is_token($n, 3, 16)
!ll&&!rl&&r
000
$n and not ref $n
!ll&&!rl&&r
000
MC/DC0%0/3
$n and not ref $n and Net::DRI::Util::xml_is_token($n, 3, 16)
$n not ref $n Net::DRI::Util::xml_is_token($n, 3, 16)
Truth table0%0/4
A and not(B) and C
A= $nB= not ref $nC= Net::DRI::Util::xml_is_token($n, 3, 16)
ABCresult
0XX0
10X0
1100
1111
91 0 push @id,$n;
92 }
93  
94 0 ▶ Net::DRI::Exception->die(1,'protocol/EPP',2,'Defensive registration id needed') unless @id;
Branch: 1 branch
BranchTrueFalseTotal
unless @id 0 0 0
95  
96 0 $mes->command([$command,'defreg:'.$command, $mes->nsattrs('defreg')]);
97 0 return map { ['defreg:id',$_] } @id;
98 }
99  
100 sub build_pattern
101 {
102 0 ▶ my ($d)=@_;
Subroutine build_pattern: not called CC=4 SCAR=30.0
Pod undocumented
103 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('pattern is mandatory') unless (defined($d) && $d);
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
104 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('pattern must be a XML token between 1 and 63 chars long') unless Net::DRI::Util::xml_is_token($d,1,63);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($d, 1, 63) 0 0 0
105 0 return ['defreg:pattern',$d];
106 }
107  
108 sub build_contact
109 {
110 0 ▶ my ($d,$type)=@_;
Subroutine build_contact: not called CC=6 SCAR=37.4
Pod undocumented
111 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters($type.' contact is mandatory') unless (defined($d) && $d);
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
112 0 ▶ $d=$d->srid() if Net::DRI::Util::isa_contact($d,'Net::DRI::Data::Contact::CAT');
Branch: 1 branch
BranchTrueFalseTotal
if Net::DRI::Util::isa_contact($d, "Net::DRI::Data::Contact::CAT") 0 0 0
113 0 ▶ Net::DRI::Exception->die(1,'protocol/EPP',10,"Invalid $type contact id: $d") unless Net::DRI::Util::xml_is_token($d,3,16);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($d, 3, 16) 0 0 0
114 0 ▶ return ($type eq 'registrant')? ['defreg:registrant',$d] : ['defreg:contact',$d,{type => $type}];
Branch: 1 branch
BranchTrueFalseTotal
$type eq 'registrant' ? : 0 0 0
115 }
116  
117 sub build_contact_noregistrant
118 {
119 0 ▶ my $cs=shift;
Subroutine build_contact_noregistrant: not called CC=3 SCAR=24.8
Pod undocumented
120 0 my @d;
121 0 foreach my $t (sort($cs->types()))
122 {
123 0 ▶ next if ($t eq 'registrant');
Branch: 1 branch
BranchTrueFalseTotal
if $t eq "registrant" 0 0 0
124 0 my @o=$cs->get($t);
125 0 push @d,map { ['defreg:contact',$_->srid(),{'type'=>$t}] } @o;
126 }
127 0 return @d;
128 }
129  
130 sub build_authinfo
131 {
132 0 ▶ my ($d)=@_;
Subroutine build_authinfo: not called CC=7 SCAR=40.3
Pod undocumented
133 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('auth info is mandatory') unless (defined($d) && (ref($d) eq 'HASH') && exists($d->{pw}) && $d->{pw});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $d and ref $d eq "HASH" and exists $d->{"pw"} and $d->{"pw"} 0 0 0
Condition0%0/9
defined $d and ref $d eq "HASH" and exists $d->{"pw"} and $d->{"pw"}
!ll&&!rl&&r
000
defined $d and ref $d eq "HASH" and exists $d->{"pw"}
!ll&&!rl&&r
000
defined $d and ref $d eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/4
defined $d and ref $d eq "HASH" and exists $d->{"pw"} and $d->{"pw"}
defined $d ref $d eq "HASH" exists $d->{"pw"} $d->{"pw"}
Truth table0%0/5
A and B and C and D
A= defined $dB= ref $d eq "HASH"C= exists $d->{"pw"}D= $d->{"pw"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
134 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('auth pw must be a XML normalized string') unless Net::DRI::Util::xml_is_normalizedstring($d->{pw});
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_normalizedstring($d->{"pw"}) 0 0 0
135 0 ▶ return ['defreg:authInfo',['defreg:pw',$d->{pw},exists($d->{roid})? { 'roid' => $d->{roid} } : undef]];
Branch: 1 branch
BranchTrueFalseTotal
exists $d->{'roid'} ? : 0 0 0
136 }
137  
138 sub build_maintainer
139 {
140 0 ▶ my ($d)=@_;
Subroutine build_maintainer: not called CC=4 SCAR=30.0
Pod undocumented
141 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('maintainer is mandatory') unless (defined($d) && $d);
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
142 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('maintainer must be an XML token up to 128 chars long') unless Net::DRI::Util::xml_is_token($d,undef,128);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($d, undef, 128) 0 0 0
143 0 return ['defreg:maintainer',$d];
144 }
145  
146 sub build_trademark
147 {
148 0 ▶ my ($d)=@_;
Subroutine build_trademark: not called CC=13 SCAR=52.0
Pod undocumented
149 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('trademark is mandatory') unless (defined $d && ref $d eq 'HASH' && keys %$d);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $d and ref $d eq "HASH" and keys %$d 0 0 0
Condition0%0/6
defined $d and ref $d eq "HASH" and keys %$d
!ll&&!rl&&r
000
defined $d and ref $d eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/3
defined $d and ref $d eq "HASH" and keys %$d
defined $d ref $d eq "HASH" keys %$d
Truth table0%0/4
A and B and C
A= defined $dB= ref $d eq "HASH"C= keys %$d
ABCresult
0XX0
10X0
1100
1111
150 0 my %t=%$d;
151 0 my @n;
152 0 ▶ if (exists($t{name}))
Branch: 1 branch
BranchTrueFalseTotal
if (exists $t{"name"}) 0 0 0
153 {
154 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('trademark name must be an XML token at least one char long') unless Net::DRI::Util::xml_is_token($t{name},1);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($t{"name"}, 1) 0 0 0
155 0 push @n,['defreg:name',$t{name}];
156 }
157 0 ▶ if (exists($t{issue_date}))
Branch: 1 branch
BranchTrueFalseTotal
if (exists $t{"issue_date"}) 0 0 0
158 {
159 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('trademark issueDate must be a valid DateTime object') unless Net::DRI::Util::check_isa($t{issue_date},'DateTime');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::check_isa($t{"issue_date"}, "DateTime") 0 0 0
160 0 push @n,['defreg:issueDate',$t{issue_date}->strftime('%Y-%m-%d')];
161 }
162 0 ▶ if (exists($t{country}))
Branch: 1 branch
BranchTrueFalseTotal
if (exists $t{"country"}) 0 0 0
163 {
164 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('trademark country must be a valid country code') unless ($t{country} && exists($Net::DRI::Util::CCA2{uc($t{country})}));
Branch: 1 branch
BranchTrueFalseTotal
unless $t{"country"} and exists $Net::DRI::Util::CCA2{uc $t{"country"}} 0 0 0
Condition0%0/3
$t{"country"} and exists $Net::DRI::Util::CCA2{uc $t{"country"}}
!ll&&!rl&&r
000
MC/DC0%0/2
$t{"country"} and exists $Net::DRI::Util::CCA2{uc $t{"country"}}
$t{"country"} exists $Net::DRI::Util::CCA2{uc $t{"country"}}
Truth table0%0/3
A and B
A= $t{"country"}B= exists $Net::DRI::Util::CCA2{uc $t{"country"}}
ABresult
0X0
100
111
165 0 push @n,['defreg:country',$t{country}];
166 }
167 0 ▶ if (exists($t{number}))
Branch: 1 branch
BranchTrueFalseTotal
if (exists $t{"number"}) 0 0 0
168 {
169 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('trademark number must be an XML token at least one chat long') unless Net::DRI::Util::xml_is_token($t{number},1);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($t{"number"}, 1) 0 0 0
170 0 push @n,['defreg:number',$t{number}];
171 }
172 0 return ['defreg:trademark',@n];
173 }
174  
175 sub build_period
176 {
177 0 ▶ my $p=Net::DRI::Protocol::EPP::Util::build_period(shift);
Subroutine build_period: not called CC=1 SCAR=6.9
Pod undocumented
178 0 $p->[0]='defreg:period';
179 0 return $p;
180 }
181  
182 ####################################################################################################
183 ########### Query commands
184  
185 sub check
186 {
187 0 ▶ my ($epp,@id)=@_;
Subroutine check: not called CC=1 SCAR=6.9
Pod undocumented
188 0 my @d=build_command($epp,'check',\@id);
189 0 $epp->message->command_body(\@d);
190 0 return;
191 }
192  
193 sub check_parse
194 {
195 0 ▶ my ($po,$otype,$oaction,$oname,$rinfo)=@_;
Subroutine check_parse: not called CC=7 SCAR=40.3
Pod undocumented
196 0 my $mes=$po->message();
197 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
198  
199 0 my $chkdata=$mes->get_response('defreg', 'chkData');
200 0 ▶ return unless defined $chkdata;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $chkdata 0 0 0
201  
202 0 my $ns=$mes->ns('defreg');
203 0 foreach my $cd ($chkdata->getChildrenByTagNameNS($ns,'cd'))
204 {
205 0 my $id;
206 0 foreach my $el (Net::DRI::Util::xml_list_children($cd))
207 {
208 0 my ($n,$c)=@$el;
209 0 ▶ if ($n eq 'id')
Branch: 2 branches
BranchTrueFalseTotal
if ($n eq 'id') { } 0 0 0
elsif ($n eq 'reason') { } 0 0 0
210 {
211 0 $id=$c->textContent();
212 0 $rinfo->{defreg}->{$id}->{action}='check';
213 0 $rinfo->{defreg}->{$id}->{exist}=1-Net::DRI::Util::xml_parse_boolean($c->getAttribute('avail'));
214 } elsif ($n eq 'reason')
215 {
216 0 $rinfo->{defreg}->{$id}->{exist_reason}=$c->textContent();
217 }
218 }
219 }
220 0 return;
221 }
222  
223 sub info
224 {
225 0 ▶ my ($epp,$id,$rd)=@_;
Subroutine info: not called CC=2 SCAR=17.9
Pod undocumented
226 0 my @d=build_command($epp,'info',$id);
227 0 ▶ push @d,build_authinfo($rd->{auth}) if Net::DRI::Util::has_auth($rd);
Branch: 1 branch
BranchTrueFalseTotal
if Net::DRI::Util::has_auth($rd) 0 0 0
228 0 $epp->message->command_body(\@d);
229 0 return;
230 }
231  
232 sub info_parse
233 {
234 0 ▶ my ($po,$otype,$oaction,$oname,$rinfo)=@_;
Subroutine info_parse: not called CC=22 SCAR=62.3
Pod undocumented
235 0 my $mes=$po->message();
236 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
237  
238 0 my $infdata=$mes->get_response('defreg', 'infData');
239 0 ▶ return unless defined $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $infdata 0 0 0
240  
241 0 my $ns=$mes->ns('defreg');
242 0 my (@s,%t);
243 0 my $cs=$po->create_local_object('contactset');
244 0 my %ccache;
245 0 foreach my $el (Net::DRI::Util::xml_list_children($infdata))
246 {
247 0 my ($name,$c)=@$el;
248 0 ▶ if ($name eq 'id')
Branch: 11 branches
BranchTrueFalseTotal
if ($name eq 'id') { } 0 0 0
elsif ($name eq 'roid') { } 0 0 0
elsif ($name eq 'pattern') { } 0 0 0
elsif ($name eq 'status') { } 0 0 0
elsif ($name eq 'registrant') { } 0 0 0
elsif ($name eq 'contact') { } 0 0 0
elsif ($name =~ /^(clID|crID|upID)$/) { } 0 0 0
elsif ($name =~ /^(crDate|upDate|exDate)$/) { } 0 0 0
elsif ($name eq 'authInfo') { } 0 0 0
elsif ($name eq 'maintainer') { } 0 0 0
elsif ($name eq 'trademark') { } 0 0 0
249 {
250 0 $oname=$c->textContent();
251 0 $rinfo->{defreg}->{$oname}->{id}=$oname;
252 } elsif ($name eq 'roid')
253 {
254 0 $rinfo->{defreg}->{$oname}->{roid}=$c->textContent();
255 } elsif ($name eq 'pattern')
256 {
257 0 $rinfo->{defreg}->{$oname}->{pattern}=$c->textContent();
258 } elsif ($name eq 'status')
259 {
260 0 push @s,Net::DRI::Protocol::EPP::Util::parse_node_status($c);
261 } elsif ($name eq 'registrant')
262 {
263 0 my $id=$c->textContent();
264 0 ▶ $ccache{$id}=$po->create_local_object('contact')->srid($id) unless exists $ccache{$id};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $ccache{$id} 0 0 0
265 0 $cs->set($ccache{$id},'registrant');
266 } elsif ($name eq 'contact')
267 {
268 0 my $id=$c->textContent();
269 0 ▶ $ccache{$id}=$po->create_local_object('contact')->srid($id) unless exists $ccache{$id};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $ccache{$id} 0 0 0
270 0 $cs->add($ccache{$id},$c->getAttribute('type'));
271 } elsif ($name=~m/^(clID|crID|upID)$/)
272 {
273 0 $rinfo->{defreg}->{$oname}->{$1}=$c->textContent();
274 } elsif ($name=~m/^(crDate|upDate|exDate)$/)
275 {
276 0 $rinfo->{defreg}->{$oname}->{$1}=$po->parse_iso8601($c->textContent());
277 } elsif ($name eq 'authInfo')
278 {
279 0 $rinfo->{defreg}->{$oname}->{auth}={ pw => Net::DRI::Util::xml_child_content($c,$ns,'pw') };
280 } elsif ($name eq 'maintainer')
281 {
282 0 $rinfo->{defreg}->{$oname}->{maintainer}=$c->textContent();
283 } elsif ($name eq 'trademark')
284 {
285 0 foreach my $sel (Net::DRI::Util::xml_list_children($c))
286 {
287 0 my ($name2,$cc)=@$sel;
288 0 ▶ if ($name2 eq 'name')
Branch: 4 branches
BranchTrueFalseTotal
if ($name2 eq 'name') { } 0 0 0
elsif ($name2 eq 'issueDate') { } 0 0 0
elsif ($name2 eq 'country') { } 0 0 0
elsif ($name2 eq 'number') { } 0 0 0
289 {
290 0 $t{name}=$cc->textContent();
291 } elsif ($name2 eq 'issueDate')
292 {
293 0 $t{issue_date}=$po->parse_iso8601($cc->textContent());
294 } elsif ($name2 eq 'country')
295 {
296 0 $t{country}=$cc->textContent();
297 } elsif ($name2 eq 'number')
298 {
299 0 $t{number}=$cc->textContent();
300 }
301 }
302 }
303 }
304  
305 0 $rinfo->{defreg}->{$oname}->{action}='info';
306 0 $rinfo->{defreg}->{$oname}->{exist}=1;
307 0 $rinfo->{defreg}->{$oname}->{contact}=$cs;
308 0 $rinfo->{defreg}->{$oname}->{status}=$po->create_local_object('status')->add(@s);
309 0 $rinfo->{defreg}->{$oname}->{trademark}=\%t;
310 0 return;
311 }
312  
313 ####################################################################################################
314 ############ Transform commands
315  
316 sub create
317 {
318 0 ▶ my ($epp,$id,$ri)=@_;
Subroutine create: not called CC=11 SCAR=48.8
Pod undocumented
319 0 my @d=build_command($epp,'create',$id);
320  
321 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('A ref hash with all info must be provided alongside the id') unless (defined $ri && ref $ri eq 'HASH' && keys %$ri);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ri and ref $ri eq "HASH" and keys %$ri 0 0 0
Condition0%0/6
defined $ri and ref $ri eq "HASH" and keys %$ri
!ll&&!rl&&r
000
defined $ri and ref $ri eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/3
defined $ri and ref $ri eq "HASH" and keys %$ri
defined $ri ref $ri eq "HASH" keys %$ri
Truth table0%0/4
A and B and C
A= defined $riB= ref $ri eq "HASH"C= keys %$ri
ABCresult
0XX0
10X0
1100
1111
322  
323 ## Period, OPTIONAL
324 0 ▶ if (exists($ri->{duration}))
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ri->{"duration"}) 0 0 0
325 {
326 0 my $period=$ri->{duration};
327 0 Net::DRI::Util::check_isa($period,'DateTime::Duration');
328 0 push @d,build_period($period);
329 }
330  
331 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('pattern must be an XML token between 1 and 63 chars long') unless (exists($ri->{pattern}) && $ri->{pattern} && Net::DRI::Util::xml_is_token($ri->{pattern},1,63));
Branch: 1 branch
BranchTrueFalseTotal
unless exists $ri->{"pattern"} and $ri->{"pattern"} and Net::DRI::Util::xml_is_token($ri->{"pattern"}, 1, 63) 0 0 0
Condition0%0/6
exists $ri->{"pattern"} and $ri->{"pattern"} and Net::DRI::Util::xml_is_token($ri->{"pattern"}, 1, 63)
!ll&&!rl&&r
000
exists $ri->{"pattern"} and $ri->{"pattern"}
!ll&&!rl&&r
000
MC/DC0%0/3
exists $ri->{"pattern"} and $ri->{"pattern"} and Net::DRI::Util::xml_is_token($ri->{"pattern"}, 1, 63)
exists $ri->{"pattern"} $ri->{"pattern"} Net::DRI::Util::xml_is_token($ri->{"pattern"}, 1, 63)
Truth table0%0/4
A and B and C
A= exists $ri->{"pattern"}B= $ri->{"pattern"}C= Net::DRI::Util::xml_is_token($ri->{"pattern"}, 1, 63)
ABCresult
0XX0
10X0
1100
1111
332 0 push @d,['defreg:pattern',$ri->{pattern}];
333 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('a valid contactset object must be given in contact attribute') unless Net::DRI::Util::has_contact($ri);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_contact($ri) 0 0 0
334 0 my $cs=$ri->{contact};
335 0 push @d,build_contact($cs->get('registrant'),'registrant');
336 0 push @d,build_contact($cs->get('billing'),'billing');
337 0 push @d,build_contact($cs->get('admin'),'admin');
338 0 push @d,build_authinfo($ri->{auth});
339 0 ▶ push @d,build_maintainer($ri->{maintainer}) if (exists($ri->{maintainer})); ## optional
Branch: 1 branch
BranchTrueFalseTotal
if exists $ri->{"maintainer"} 0 0 0
340 0 my $tmp=build_trademark($ri->{trademark});
341 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('trademark must be a ref hash with 4 keys: name, issue_date, country, number') unless (@$tmp==5);
Branch: 1 branch
BranchTrueFalseTotal
unless @$tmp == 5 0 0 0
342 0 push @d,$tmp;
343 0 $epp->message->command_body(\@d);
344 0 return;
345 }
346  
347 sub delete ## no critic (Subroutines::ProhibitBuiltinHomonyms)
348 {
349 0 ▶ my ($epp,$id)=@_;
Subroutine delete: not called CC=1 SCAR=6.9
Pod undocumented
350 0 my @d=build_command($epp,'delete',$id);
351 0 $epp->message->command_body(\@d);
352 0 return;
353 }
354  
355 sub renew
356 {
357 0 ▶ my ($epp,$id,$rd)=@_;
Subroutine renew: not called CC=12 SCAR=50.5
Pod undocumented
358 0 ▶ my $period=(defined($rd) && (ref($rd) eq 'HASH') && exists($rd->{duration}))? $rd->{duration} : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $rd && ref $rd eq 'HASH' && exists $rd->{'duration'} ? : 0 0 0
Condition0%0/6
defined $rd and ref $rd eq "HASH" and exists $rd->{"duration"}
!ll&&!rl&&r
000
defined $rd and ref $rd eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/3
defined $rd and ref $rd eq "HASH" and exists $rd->{"duration"}
defined $rd ref $rd eq "HASH" exists $rd->{"duration"}
Truth table0%0/4
A and B and C
A= defined $rdB= ref $rd eq "HASH"C= exists $rd->{"duration"}
ABCresult
0XX0
10X0
1100
1111
359 0 ▶ my $curexp=(defined($rd) && (ref($rd) eq 'HASH') && exists($rd->{current_expiration}))? $rd->{current_expiration} : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $rd && ref $rd eq 'HASH' && exists $rd->{'current_expiration'} ? : 0 0 0
Condition0%0/6
defined $rd and ref $rd eq "HASH" and exists $rd->{"current_expiration"}
!ll&&!rl&&r
000
defined $rd and ref $rd eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/3
defined $rd and ref $rd eq "HASH" and exists $rd->{"current_expiration"}
defined $rd ref $rd eq "HASH" exists $rd->{"current_expiration"}
Truth table0%0/4
A and B and C
A= defined $rdB= ref $rd eq "HASH"C= exists $rd->{"current_expiration"}
ABCresult
0XX0
10X0
1100
1111
360 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('current expiration year') unless defined($curexp);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $curexp 0 0 0
361 0 ▶ $curexp=$curexp->set_time_zone('UTC')->strftime('%Y-%m-%d') if (ref $curexp && Net::DRI::Util::is_class($curexp,'DateTime'));
Branch: 1 branch
BranchTrueFalseTotal
if ref $curexp and Net::DRI::Util::is_class($curexp, "DateTime") 0 0 0
Condition0%0/3
ref $curexp and Net::DRI::Util::is_class($curexp, "DateTime")
!ll&&!rl&&r
000
MC/DC0%0/2
ref $curexp and Net::DRI::Util::is_class($curexp, "DateTime")
ref $curexp Net::DRI::Util::is_class($curexp, "DateTime")
Truth table0%0/3
A and B
A= ref $curexpB= Net::DRI::Util::is_class($curexp, "DateTime")
ABresult
0X0
100
111
362 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('current expiration year must be YYYY-MM-DD') unless $curexp=~m/^\d{4}-\d{2}-\d{2}$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $curexp =~ /^\d{4}-\d{2}-\d{2}$/ 0 0 0
363  
364 0 my @d=build_command($epp,'renew',$id);
365 0 push @d,['defreg:curExpDate',$curexp];
366 0 ▶ if (defined($period))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $period) 0 0 0
367 {
368 0 Net::DRI::Util::check_isa($period,'DateTime::Duration');
369 0 push @d,build_period($period);
370 }
371  
372 0 $epp->message->command_body(\@d);
373 0 return;
374 }
375  
376 sub update
377 {
378 0 ▶ my ($epp,$id,$todo)=@_;
Subroutine update: not called CC=21 SCAR=61.4
Pod undocumented
379 0 my $mes=$epp->message();
380  
381 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
382  
383 0 ▶ if ((grep { ! /^(?:add|del)$/ } $todo->types('status')) ||
Branch: 1 branch
BranchTrueFalseTotal
if (grep {not /^(?:add|del)$/;} $todo->types("status") or grep {not /^(?:add|del)$/;} $todo->types("contact") or grep {not /^set$/;} $todo->types("registrant") or grep {not /^set$/;} $todo->types("auth") or grep {not /^set$/;} $todo->types("maintainer") or grep {not /^set$/;} $todo->types("trademark")) 0 0 0
Condition0%0/15
grep {not /^(?:add|del)$/;} $todo->types("status") or grep {not /^(?:add|del)$/;} $todo->types("contact") or grep {not /^set$/;} $todo->types("registrant") or grep {not /^set$/;} $todo->types("auth") or grep {not /^set$/;} $todo->types("maintainer") or grep {not /^set$/;} $todo->types("trademark")
l!l&&r!l&&!r
000
grep {not /^(?:add|del)$/;} $todo->types("status") or grep {not /^(?:add|del)$/;} $todo->types("contact") or grep {not /^set$/;} $todo->types("registrant") or grep {not /^set$/;} $todo->types("auth") or grep {not /^set$/;} $todo->types("maintainer")
l!l&&r!l&&!r
000
grep {not /^(?:add|del)$/;} $todo->types("status") or grep {not /^(?:add|del)$/;} $todo->types("contact") or grep {not /^set$/;} $todo->types("registrant") or grep {not /^set$/;} $todo->types("auth")
l!l&&r!l&&!r
000
grep {not /^(?:add|del)$/;} $todo->types("status") or grep {not /^(?:add|del)$/;} $todo->types("contact") or grep {not /^set$/;} $todo->types("registrant")
l!l&&r!l&&!r
000
grep {not /^(?:add|del)$/;} $todo->types("status") or grep {not /^(?:add|del)$/;} $todo->types("contact")
l!l&&r!l&&!r
000
MC/DC0%0/6
grep {not /^(?:add|del)$/;} $todo->types("status") or grep {not /^(?:add|del)$/;} $todo->types("contact") or grep {not /^set$/;} $todo->types("registrant") or grep {not /^set$/;} $todo->types("auth") or grep {not /^set$/;} $todo->types("maintainer") or grep {not /^set$/;} $todo->types("trademark")
grep {not /^(?:add|del)$/;} $todo->types("status") grep {not /^(?:add|del)$/;} $todo->types("contact") grep {not /^set$/;} $todo->types("registrant") grep {not /^set$/;} $todo->types("auth") grep {not /^set$/;} $todo->types("maintainer") grep {not /^set$/;} $todo->types("trademark")
Truth table0%0/7
A or B or C or D or E or F
A= grep {not /^(?:add|del)$/;} $todo->types("status")B= grep {not /^(?:add|del)$/;} $todo->types("contact")C= grep {not /^set$/;} $todo->types("registrant")D= grep {not /^set$/;} $todo->types("auth")E= grep {not /^set$/;} $todo->types("maintainer")F= grep {not /^set$/;} $todo->types("trademark")
ABCDEFresult
1XXXXX1
01XXXX1
001XXX1
0001XX1
00001X1
0000011
0000000
384 0 (grep { ! /^(?:add|del)$/ } $todo->types('contact')) ||
385 0 (grep { ! /^set$/ } $todo->types('registrant')) ||
386 0 (grep { ! /^set$/ } $todo->types('auth')) ||
387 0 (grep { ! /^set$/ } $todo->types('maintainer')) ||
388 0 (grep { ! /^set$/ } $todo->types('trademark'))
389 )
390 {
391 0 Net::DRI::Exception->die(0,'protocol/EPP',11,'Only status/contact add/del or registrant/authinfo/maintainer/trademark set available for defreg');
392 }
393  
394 0 my @d=build_command($epp,'update',$id);
395  
396 0 my $sadd=$todo->add('status');
397 0 my $sdel=$todo->del('status');
398 0 my $cadd=$todo->add('contact');
399 0 my $cdel=$todo->del('contact');
400 0 my (@add,@del);
401  
402 0 ▶ push @add,build_contact_noregistrant($cadd) if $cadd;
Branch: 1 branch
BranchTrueFalseTotal
if $cadd 0 0 0
403 0 ▶ push @add,$sadd->build_xml('defreg:status') if $sadd;
Branch: 1 branch
BranchTrueFalseTotal
if $sadd 0 0 0
404 0 ▶ push @del,build_contact_noregistrant($cdel) if $cdel;
Branch: 1 branch
BranchTrueFalseTotal
if $cdel 0 0 0
405 0 ▶ push @del,$sdel->build_xml('defreg:status') if $sdel;
Branch: 1 branch
BranchTrueFalseTotal
if $sdel 0 0 0
406  
407 0 ▶ push @d,['defreg:add',@add] if @add;
Branch: 1 branch
BranchTrueFalseTotal
if @add 0 0 0
408 0 ▶ push @d,['defreg:rem',@del] if @del;
Branch: 1 branch
BranchTrueFalseTotal
if @del 0 0 0
409  
410 0 my (@chg,$chg);
411  
412 0 $chg=$todo->set('registrant');
413 0 ▶ push @chg,['defreg:registrant',$chg->srid()] if Net::DRI::Util::isa_contact($chg,'Net::DRI::Data::Contact::CAT');
Branch: 1 branch
BranchTrueFalseTotal
if Net::DRI::Util::isa_contact($chg, "Net::DRI::Data::Contact::CAT") 0 0 0
414 0 $chg=$todo->set('auth');
415 0 ▶ push @chg,build_authinfo($chg) if ($chg && ref($chg));
Branch: 1 branch
BranchTrueFalseTotal
if $chg and ref $chg 0 0 0
Condition0%0/3
$chg and ref $chg
!ll&&!rl&&r
000
MC/DC0%0/2
$chg and ref $chg
$chg ref $chg
Truth table0%0/3
A and B
A= $chgB= ref $chg
ABresult
0X0
100
111
416 0 $chg=$todo->set('maintainer');
417 0 ▶ push @chg,build_maintainer($chg) if $chg;
Branch: 1 branch
BranchTrueFalseTotal
if $chg 0 0 0
418 0 $chg=$todo->set('trademark');
419 0 ▶ push @chg,build_trademark($chg) if ($chg && ref($chg));
Branch: 1 branch
BranchTrueFalseTotal
if $chg and ref $chg 0 0 0
Condition0%0/3
$chg and ref $chg
!ll&&!rl&&r
000
MC/DC0%0/2
$chg and ref $chg
$chg ref $chg
Truth table0%0/3
A and B
A= $chgB= ref $chg
ABresult
0X0
100
111
420  
421 0 ▶ push @d,['defreg:chg',@chg] if @chg;
Branch: 1 branch
BranchTrueFalseTotal
if @chg 0 0 0
422 0 $mes->command_body(\@d);
423 0 return;
424 }
425  
426 ####################################################################################################
427 1 1;
« DRI/Data/Contact/BE.pm ↑ Summary DRI/Transport/Socket.pm »