DRI/Protocol/EPP/Extensions/DNSBE/Domain.pm

filter: Statementstmt 15.1% 22 / 145 Branchbran 0.0% 0 / 52 Conditioncond 0.0% 0 / 30 MC/DCmcdc 0.0% 0 / 17 Subroutinesub 33.3% 7 / 21 Podpod 0.0% 0 / 14 totaltotal 10.3% 29 / 279 CC 38 SCAR 43.9
CC
38
Cov
10%
add_transfer
240.0
add_nsgroup
72.0
update
42.0
CRAP 80.9
« DRI/Transport/HTTP/XMLRPCLite.pm ↑ Summary DRI/Protocol/RRI/Message.pm »
1 ## Domain Registry Interface, DNSBE Domain EPP extension commands
2 ## (based on Registration_guidelines_v4_7_2-Part_4-epp.pdf)
3 ##
4 ## Copyright (c) 2006-2010,2013,2016,2018 Patrick Mevzek <netdri@dotandco.com>. All rights reserved.
5 ## (c) 2013 Michael Holloway <michael@thedarkwinter.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::EPP::Extensions::DNSBE::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 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶use Net::DRI::Data::Hosts;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 1 ▶use Net::DRI::Protocol::EPP::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 =pod
30  
31 =head1 NAME
32  
33 Net::DRI::Protocol::EPP::Extensions::DNSBE::Domain - DNSBE EPP Domain extension commands for Net::DRI
34  
35 =head1 DESCRIPTION
36  
37 Please see the README file for details.
38  
39 =head1 SUPPORT
40  
41 For now, support questions should be sent to:
42  
43 E<lt>netdri@dotandco.comE<gt>
44  
45 Please also see the SUPPORT file in the distribution.
46  
47 =head1 SEE ALSO
48  
49 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
50  
51 =head1 AUTHOR
52  
53 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
54  
55 =head1 COPYRIGHT
56  
57 Copyright (c) 2006-2010,2013,2016,2018 Patrick Mevzek <netdri@dotandco.com>.
58 (c) 2013 Michael Holloway <michael@thedarkwinter.com>.
59 All rights reserved.
60  
61 This program is free software; you can redistribute it and/or modify
62 it under the terms of the GNU General Public License as published by
63 the Free Software Foundation; either version 2 of the License, or
64 (at your option) any later version.
65  
66 See the LICENSE file that comes with this distribution for more details.
67  
68 =cut
69  
70 ####################################################################################################
71  
72 sub register_commands
73 {
74 0 ▶ my ($class,$version)=@_;
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
75 0 my %tmp=(
76 create => [ \&create, undef ],
77 update => [ \&update, undef ],
78 info => [ undef, \&info_parse ],
79 delete => [ \&delete, undef ],
80 transfer_request => [ \&transfer_request, undef ],
81 undelete => [ \&undelete, undef ],
82 transferq_request => [ \&transferq_request, undef ],
83 trade => [ \&trade, undef ],
84 reactivate => [ \&reactivate, undef ],
85 request_authcode => [ \&request_authcode, undef ],
86 );
87  
88 0 return { 'domain' => \%tmp };
89 }
90  
91 ####################################################################################################
92  
93 sub create
94 {
95 0 ▶ my ($epp,$domain,$rd)=@_;
Subroutine create: not called CC=4 SCAR=30.0
Pod undocumented
96  
97 ## Registrant contact is mandatory (optional in EPP), already added in Core, we just verify here
98 Net::DRI::Exception->die(0,'protocol/EPP',11,'Registrant contact is mandatory in domain_create')
99 0 ▶ unless (Net::DRI::Util::has_contact($rd) && $rd->{contact}->get('registrant')->srid());
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_contact($rd) and $rd->{"contact"}->get("registrant")->srid 0 0 0
Condition0%0/3
Net::DRI::Util::has_contact($rd) and $rd->{"contact"}->get("registrant")->srid
!ll&&!rl&&r
000
MC/DC0%0/2
Net::DRI::Util::has_contact($rd) and $rd->{"contact"}->get("registrant")->srid
Net::DRI::Util::has_contact($rd) $rd->{"contact"}->get("registrant")->srid
Truth table0%0/3
A and B
A= Net::DRI::Util::has_contact($rd)B= $rd->{"contact"}->get("registrant")->srid
ABresult
0X0
100
111
100  
101 0 ▶ return unless exists($rd->{nsgroup});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $rd->{"nsgroup"} 0 0 0
102 0 my @n=add_nsgroup($rd->{nsgroup});
103  
104 0 my $mes=$epp->message();
105 0 my $eid=$mes->command_extension_register('dnsbe', 'ext');
106 0 $mes->command_extension($eid,['dnsbe:create',['dnsbe:domain',@n]]);
107 0 return;
108 }
109  
110 sub update
111 {
112 0 ▶ my ($epp,$domain,$todo)=@_;
Subroutine update: not called CC=6 SCAR=37.4
Pod undocumented
113  
114 0 ▶ if (grep { ! /^(?:add|del)$/ } $todo->types('nsgroup'))
Branch: 1 branch
BranchTrueFalseTotal
if (grep {not /^(?:add|del)$/;} $todo->types("nsgroup")) 0 0 0
115 {
116 0 Net::DRI::Exception->die(0,'protocol/EPP',11,'Only nsgroup add/del available for domain');
117 }
118  
119 0 my $nsgadd=$todo->add('nsgroup');
120 0 my $nsgdel=$todo->del('nsgroup');
121 0 ▶ return unless ($nsgadd || $nsgdel);
Branch: 1 branch
BranchTrueFalseTotal
unless $nsgadd or $nsgdel 0 0 0
Condition0%0/3
$nsgadd or $nsgdel
l!l&&r!l&&!r
000
MC/DC0%0/2
$nsgadd or $nsgdel
$nsgadd $nsgdel
Truth table0%0/3
A or B
A= $nsgaddB= $nsgdel
ABresult
1X1
011
000
122  
123 0 my @n;
124 0 ▶ push @n,['dnsbe:add',add_nsgroup($nsgadd)] if $nsgadd;
Branch: 1 branch
BranchTrueFalseTotal
if $nsgadd 0 0 0
125 0 ▶ push @n,['dnsbe:rem',add_nsgroup($nsgdel)] if $nsgdel;
Branch: 1 branch
BranchTrueFalseTotal
if $nsgdel 0 0 0
126  
127 0 my $mes=$epp->message();
128 0 my $eid=$mes->command_extension_register('dnsbe', 'ext');
129 0 $mes->command_extension($eid,['dnsbe:update',['dnsbe:domain',@n]]);
130 0 return;
131 }
132  
133 ## This is not written in the PDF document, but it should probably be there, like for .EU
134 sub info_parse
135 {
136 0 ▶ my ($po,$otype,$oaction,$oname,$rinfo)=@_;
Subroutine info_parse: not called CC=4 SCAR=30.0
Pod undocumented
137 0 my $mes=$po->message();
138 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
139  
140 0 my $infdata=$mes->get_extension('dnsbe','infData');
141 0 ▶ return unless $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless $infdata 0 0 0
142  
143 0 my @c;
144 0 foreach my $el ($infdata->getChildrenByTagNameNS($mes->ns('dnsbe'),'nsgroup'))
145 {
146 0 push @c,Net::DRI::Data::Hosts->new()->name($el->getFirstChild()->getData());
147 }
148  
149 0 $rinfo->{domain}->{$oname}->{nsgroup}=\@c;
150 0 return;
151 }
152  
153 sub delete ## no critic (Subroutines::ProhibitBuiltinHomonyms)
154 {
155 0 ▶ my ($epp,$domain,$rd)=@_;
Subroutine delete: not called CC=3 SCAR=24.8
Pod undocumented
156  
157 0 ▶ return unless (exists($rd->{deleteDate}) && $rd->{deleteDate});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $rd->{"deleteDate"} and $rd->{"deleteDate"} 0 0 0
Condition0%0/3
exists $rd->{"deleteDate"} and $rd->{"deleteDate"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $rd->{"deleteDate"} and $rd->{"deleteDate"}
exists $rd->{"deleteDate"} $rd->{"deleteDate"}
Truth table0%0/3
A and B
A= exists $rd->{"deleteDate"}B= $rd->{"deleteDate"}
ABresult
0X0
100
111
158  
159 0 Net::DRI::Util::check_isa($rd->{deleteDate},'DateTime');
160  
161 0 my $mes=$epp->message();
162 0 my $eid=$mes->command_extension_register('dnsbe', 'ext');
163 0 my @n=('dnsbe:delete',['dnsbe:domain',['dnsbe:deleteDate',$rd->{deleteDate}->set_time_zone('UTC')->strftime("%Y-%m-%dT%T.%NZ")]]);
164 0 $mes->command_extension($eid,\@n);
165 0 return;
166 }
167  
168 sub transfer_request
169 {
170 0 ▶ my ($epp,$domain,$rd)=@_;
Subroutine transfer_request: not called CC=1 SCAR=6.9
Pod undocumented
171 0 my $mes=$epp->message();
172  
173 0 my @n=add_transfer($epp,$mes,$domain,$rd);
174 0 my $eid=$mes->command_extension_register('dnsbe', 'ext');
175 0 $mes->command_extension($eid,['dnsbe:transfer',['dnsbe:domain',@n]]);
176 0 return;
177 }
178  
179 sub add_transfer
180 {
181 0 ▶ my ($epp,$mes,$domain,$rd)=@_;
Subroutine add_transfer: not called CC=15 SCAR=54.8
Pod undocumented
182  
183 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('registrant and billing are mandatory') unless (Net::DRI::Util::has_contact($rd) && $rd->{contact}->has_type('registrant') && $rd->{contact}->has_type('billing'));
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_contact($rd) and $rd->{"contact"}->has_type("registrant") and $rd->{"contact"}->has_type("billing") 0 0 0
Condition0%0/6
Net::DRI::Util::has_contact($rd) and $rd->{"contact"}->has_type("registrant") and $rd->{"contact"}->has_type("billing")
!ll&&!rl&&r
000
Net::DRI::Util::has_contact($rd) and $rd->{"contact"}->has_type("registrant")
!ll&&!rl&&r
000
MC/DC0%0/3
Net::DRI::Util::has_contact($rd) and $rd->{"contact"}->has_type("registrant") and $rd->{"contact"}->has_type("billing")
Net::DRI::Util::has_contact($rd) $rd->{"contact"}->has_type("registrant") $rd->{"contact"}->has_type("billing")
Truth table0%0/4
A and B and C
A= Net::DRI::Util::has_contact($rd)B= $rd->{"contact"}->has_type("registrant")C= $rd->{"contact"}->has_type("billing")
ABCresult
0XX0
10X0
1100
1111
184  
185 0 my $cs=$rd->{contact};
186 0 my @n;
187  
188 0 my $creg=$cs->get('registrant');
189 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('registrant must be a contact object or #AUTO#') unless (Net::DRI::Util::isa_contact($creg,'Net::DRI::Data::Contact::BE') || (!ref($creg) && ($creg eq '#AUTO#')));
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::isa_contact($creg, "Net::DRI::Data::Contact::BE") or not ref $creg and $creg eq "#AUTO#" 0 0 0
Condition0%0/6
Net::DRI::Util::isa_contact($creg, "Net::DRI::Data::Contact::BE") or not ref $creg and $creg eq "#AUTO#"
l!l&&r!l&&!r
000
not ref $creg and $creg eq "#AUTO#"
!ll&&!rl&&r
000
MC/DC0%0/3
Net::DRI::Util::isa_contact($creg, "Net::DRI::Data::Contact::BE") or not ref $creg and $creg eq "#AUTO#"
Net::DRI::Util::isa_contact($creg, "Net::DRI::Data::Contact::BE") not ref $creg $creg eq "#AUTO#"
Truth table0%0/4
A or not(B) and C
A= Net::DRI::Util::isa_contact($creg, "Net::DRI::Data::Contact::BE")B= not ref $cregC= $creg eq "#AUTO#"
ABCresult
1XX1
0111
00X0
0100
190 0 ▶ push @n,['dnsbe:registrant',ref($creg)? $creg->srid() : '#AUTO#' ];
Branch: 1 branch
BranchTrueFalseTotal
ref $creg ? : 0 0 0
191  
192 0 ▶ if (exists($rd->{trDate}))
Branch: 1 branch
BranchTrueFalseTotal
if (exists $rd->{"trDate"}) 0 0 0
193 {
194 0 Net::DRI::Util::check_isa($rd->{trDate},'DateTime');
195 0 push @n,['dnsbe:trDate',$rd->{trDate}->set_time_zone('UTC')->strftime('%Y-%m-%dT%T.%NZ')];
196 }
197  
198 0 my $cbill=$cs->get('billing');
199 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('billing must be a contact object') unless Net::DRI::Util::isa_contact($cbill,'Net::DRI::Data::Contact::BE');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::isa_contact($cbill, "Net::DRI::Data::Contact::BE") 0 0 0
200 0 push @n,['dnsbe:billing',$cbill->srid()];
201  
202 0 ▶ push @n,add_contact('accmgr',$cs,1) if $cs->has_type('accmgr');
Branch: 1 branch
BranchTrueFalseTotal
if $cs->has_type("accmgr") 0 0 0
203 0 ▶ push @n,add_contact('tech',$cs,9) if $cs->has_type('tech');
Branch: 1 branch
BranchTrueFalseTotal
if $cs->has_type("tech") 0 0 0
204 0 ▶ push @n,add_contact('onsite',$cs,5) if $cs->has_type('onsite');
Branch: 1 branch
BranchTrueFalseTotal
if $cs->has_type("onsite") 0 0 0
205  
206 0 ▶ if (Net::DRI::Util::has_ns($rd))
Branch: 1 branch
BranchTrueFalseTotal
if (Net::DRI::Util::has_ns($rd)) 0 0 0
207 {
208 0 my $n=Net::DRI::Protocol::EPP::Util::build_ns($epp,$rd->{ns},$domain,'dnsbe');
209 0 my @ns=$mes->nsattrs('domain');
210 0 push @$n,{'xmlns:domain'=>shift(@ns)};
211 0 push @n,$n;
212 }
213  
214 0 ▶ push @n,add_nsgroup($rd->{nsgroup}) if (exists($rd->{nsgroup}));
Branch: 1 branch
BranchTrueFalseTotal
if exists $rd->{"nsgroup"} 0 0 0
215 0 return @n;
216 }
217  
218 sub add_nsgroup
219 {
220 0 ▶ my ($nsg)=@_;
Subroutine add_nsgroup: not called CC=8 SCAR=42.8
Pod undocumented
221 0 ▶ return unless (defined($nsg) && $nsg);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $nsg and $nsg 0 0 0
Condition0%0/3
defined $nsg and $nsg
!ll&&!rl&&r
000
MC/DC0%0/2
defined $nsg and $nsg
defined $nsg $nsg
Truth table0%0/3
A and B
A= defined $nsgB= $nsg
ABresult
0X0
100
111
222 0 ▶ my @a=grep { defined($_) && $_ && !ref($_) && Net::DRI::Util::xml_is_normalizedstring($_,1,100) } map { Net::DRI::Util::isa_hosts($_)? $_->name() : $_ } (ref($nsg) eq 'ARRAY')? @$nsg : ($nsg);
Branch: 3 branches
BranchTrueFalseTotal
defined $_ and $_ and not ref $_ and Net::DRI::Util::xml_is_normalizedstring($_, 1, 100) 0 0 0
Net::DRI::Util::isa_hosts($_) ? : 0 0 0
ref $nsg eq 'ARRAY' ? : 0 0 0
Condition0%0/6
defined $_ and $_ and not ref $_
!ll&&!rl&&r
000
defined $_ and $_
!ll&&!rl&&r
000
MC/DC0%0/3
defined $_ and $_ and not ref $_
defined $_ $_ not ref $_
Truth table0%0/4
A and B and not(C)
A= defined $_B= $_C= not ref $_
ABCresult
0XX0
10X0
1100
1111
223 0 return map { ['dnsbe:nsgroup',$_] } grep {defined} @a[0..8];
224 }
225  
226 sub add_contact
227 {
228 0 ▶ my ($type,$cs,$max)=@_;
Subroutine add_contact: not called CC=1 SCAR=6.9
Pod undocumented
229 0 $max--;
230 0 my @r=grep { Net::DRI::Util::isa_contact($_,'Net::DRI::Data::Contact::BE') } ($cs->get($type));
231 0 return map { ['dnsbe:'.$type,$_->srid()] } grep {defined} @r[0..$max];
232 }
233  
234 sub undelete
235 {
236 0 ▶ my ($epp,$domain)=@_;
Subroutine undelete: not called CC=1 SCAR=6.9
Pod undocumented
237 0 my $mes=$epp->message();
238 0 my @d=Net::DRI::Protocol::EPP::Util::domain_build_command($mes,'undelete',$domain);
239 0 $mes->command_body(\@d);
240 0 return;
241 }
242  
243 sub transferq_request
244 {
245 0 ▶ my ($epp,$domain,$rd)=@_;
Subroutine transferq_request: not called CC=3 SCAR=24.8
Pod undocumented
246 0 my $mes=$epp->message();
247 0 my @d=Net::DRI::Protocol::EPP::Util::domain_build_command($mes,['transferq',{'op'=>'request'}],$domain);
248  
249 0 ▶ Carp::croak('Key "period" should be key "duration"') if Net::DRI::Util::has_key($rd,'period');
Branch: 1 branch
BranchTrueFalseTotal
if Net::DRI::Util::has_key($rd, "period") 0 0 0
250 0 ▶ push @d,Net::DRI::Protocol::EPP::Util::build_period($rd->{period}) if Net::DRI::Util::has_duration($rd);
Branch: 1 branch
BranchTrueFalseTotal
if Net::DRI::Util::has_duration($rd) 0 0 0
251 0 $mes->command_body(\@d);
252  
253 0 my @n=add_transfer($epp,$mes,$domain,$rd);
254 0 my $eid=$mes->command_extension_register('dnsbe', 'ext');
255 0 $mes->command_extension($eid,['dnsbe:transferq',['dnsbe:domain',@n]]);
256 0 return;
257 }
258  
259 sub trade
260 {
261 0 ▶ my ($epp,$domain,$rd)=@_;
Subroutine trade: not called CC=1 SCAR=6.9
Pod undocumented
262 0 my $mes=$epp->message();
263 0 my @d=Net::DRI::Protocol::EPP::Util::domain_build_command($mes,['trade',{'op'=>'request'}],$domain);
264 0 $mes->command_body(\@d);
265  
266 0 my @n=add_transfer($epp,$mes,$domain,$rd);
267 0 my $eid=$mes->command_extension_register('dnsbe', 'ext');
268 0 $mes->command_extension($eid,['dnsbe:trade',['dnsbe:domain',@n]]);
269 0 return;
270 }
271  
272 sub reactivate
273 {
274 0 ▶ my ($epp,$domain)=@_;
Subroutine reactivate: not called CC=1 SCAR=6.9
Pod undocumented
275 0 my $mes=$epp->message();
276 0 my @d=Net::DRI::Protocol::EPP::Util::domain_build_command($mes,'reactivate',$domain);
277 0 $mes->command_body(\@d);
278 0 return;
279 }
280  
281 sub request_authcode
282 {
283 0 ▶ my ($epp,$domain,$rd)=@_;
Subroutine request_authcode: not called CC=2 SCAR=17.9
Pod undocumented
284 0 my $mes=$epp->message();
285 0 my $eid=$mes->command_extension_register('dnsbe', 'ext');
286 0 my @d;
287 0 push @d,['dnsbe:domainName',$domain];
288 0 ▶ push @d,['dnsbe:url',$rd->{'url'}] if $rd->{'url'};
Branch: 1 branch
BranchTrueFalseTotal
if $rd->{"url"} 0 0 0
289 0 $mes->command_extension($eid,['dnsbe:command',['dnsbe:requestAuthCode',@d],['dnsbe:clTRID',$mes->cltrid()]]);
290 # missing TRID
291 0 return;
292 }
293  
294 ####################################################################################################
295 1 1;
« DRI/Transport/HTTP/XMLRPCLite.pm ↑ Summary DRI/Protocol/RRI/Message.pm »