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

filter: Statementstmt 16.7% 22 / 131 Branchbran 0.0% 0 / 50 Conditioncond 0.0% 0 / 33 MC/DCmcdc 0.0% 0 / 18 Subroutinesub 33.3% 7 / 21 Podpod 0.0% 0 / 14 totaltotal 10.8% 29 / 267 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-2019 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-2019 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 0 ▶{
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
74 0 my ($class,$version)=@_;
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 0 ▶{
Subroutine create: not called CC=4 SCAR=30.0
Pod undocumented
95 0 my ($epp,$domain,$rd)=@_;
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 $epp->message()->command_extension('dnsbe', ['ext', ['create', ['domain', @n]]]);
105 0 return;
106 }
107  
108 sub update
109 0 ▶{
Subroutine update: not called CC=6 SCAR=37.4
Pod undocumented
110 0 my ($epp,$domain,$todo)=@_;
111  
112 0 ▶ if (grep { ! /^(?:add|del)$/ } $todo->types('nsgroup'))
Branch: 1 branch
BranchTrueFalseTotal
if (grep {not /^(?:add|del)$/;} $todo->types("nsgroup")) 0 0 0
113 {
114 0 Net::DRI::Exception->die(0,'protocol/EPP',11,'Only nsgroup add/del available for domain');
115 }
116  
117 0 my $nsgadd=$todo->add('nsgroup');
118 0 my $nsgdel=$todo->del('nsgroup');
119 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
120  
121 0 my @n;
122 0 ▶ push @n,['dnsbe:add',add_nsgroup($nsgadd)] if $nsgadd;
Branch: 1 branch
BranchTrueFalseTotal
if $nsgadd 0 0 0
123 0 ▶ push @n,['dnsbe:rem',add_nsgroup($nsgdel)] if $nsgdel;
Branch: 1 branch
BranchTrueFalseTotal
if $nsgdel 0 0 0
124  
125 0 $epp->message()->command_extension('dnsbe', ['ext', ['update', ['domain', @n]]]);
126 0 return;
127 }
128  
129 ## This is not written in the PDF document, but it should probably be there, like for .EU
130 sub info_parse
131 0 ▶{
Subroutine info_parse: not called CC=4 SCAR=30.0
Pod undocumented
132 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
133 0 my $mes=$po->message();
134 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
135  
136 0 my $infdata=$mes->get_extension('dnsbe','infData');
137 0 ▶ return unless $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless $infdata 0 0 0
138  
139 0 my @c;
140 0 foreach my $el ($infdata->getChildrenByTagNameNS($mes->ns('dnsbe'),'nsgroup'))
141 {
142 0 push @c,Net::DRI::Data::Hosts->new()->name($el->getFirstChild()->getData());
143 }
144  
145 0 $rinfo->{domain}->{$oname}->{nsgroup}=\@c;
146 0 return;
147 }
148  
149 sub delete ## no critic (Subroutines::ProhibitBuiltinHomonyms)
150 0 ▶{
Subroutine delete: not called CC=3 SCAR=24.8
Pod undocumented
151 0 my ($epp,$domain,$rd)=@_;
152  
153 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
154  
155 0 Net::DRI::Util::check_isa($rd->{deleteDate},'DateTime');
156  
157 0 $epp->message()->command_extension('dnsbe', ['ext', ['delete', ['domain', ['deleteDate', $rd->{deleteDate}->set_time_zone('UTC')->strftime("%Y-%m-%dT%T.%NZ")]]]]);
158 0 return;
159 }
160  
161 sub transfer_request
162 0 ▶{
Subroutine transfer_request: not called CC=1 SCAR=6.9
Pod undocumented
163 0 my ($epp,$domain,$rd)=@_;
164 0 my $mes = $epp->message();
165  
166 0 $mes->command_extension('dnsbe', ['ext', ['transfer', ['domain', add_transfer($epp, $mes, $domain, $rd)]]]);
167 0 return;
168 }
169  
170 sub add_transfer
171 0 ▶{
Subroutine add_transfer: not called CC=15 SCAR=54.8
Pod undocumented
172 0 my ($epp,$mes,$domain,$rd)=@_;
173  
174 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
175  
176 0 my $cs=$rd->{contact};
177 0 my @n;
178  
179 0 my $creg=$cs->get('registrant');
180 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
181 0 ▶ push @n,['dnsbe:registrant',ref($creg)? $creg->srid() : '#AUTO#' ];
Branch: 1 branch
BranchTrueFalseTotal
ref $creg ? : 0 0 0
182  
183 0 ▶ if (exists($rd->{trDate}))
Branch: 1 branch
BranchTrueFalseTotal
if (exists $rd->{"trDate"}) 0 0 0
184 {
185 0 Net::DRI::Util::check_isa($rd->{trDate},'DateTime');
186 0 push @n,['dnsbe:trDate',$rd->{trDate}->set_time_zone('UTC')->strftime('%Y-%m-%dT%T.%NZ')];
187 }
188  
189 0 my $cbill=$cs->get('billing');
190 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
191 0 push @n,['dnsbe:billing',$cbill->srid()];
192  
193 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
194 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
195 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
196  
197 0 ▶ if (Net::DRI::Util::has_ns($rd))
Branch: 1 branch
BranchTrueFalseTotal
if (Net::DRI::Util::has_ns($rd)) 0 0 0
198 {
199 0 my $n=Net::DRI::Protocol::EPP::Util::build_ns($epp,$rd->{ns},$domain,'dnsbe');
200 0 my @ns=$mes->nsattrs('domain');
201 0 push @$n,{'xmlns:domain'=>shift(@ns)};
202 0 push @n,$n;
203 }
204  
205 0 ▶ push @n,add_nsgroup($rd->{nsgroup}) if (exists($rd->{nsgroup}));
Branch: 1 branch
BranchTrueFalseTotal
if exists $rd->{"nsgroup"} 0 0 0
206 0 return @n;
207 }
208  
209 sub add_nsgroup
210 0 ▶{
Subroutine add_nsgroup: not called CC=8 SCAR=42.8
Pod undocumented
211 0 my ($nsg)=@_;
212 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
213 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: 2 branches
BranchTrueFalseTotal
Net::DRI::Util::isa_hosts($_) ? : 0 0 0
ref $nsg eq 'ARRAY' ? : 0 0 0
Condition0%0/9
defined $_ && $_ && !ref($_) && Net::DRI::Util::xml_is_normalizedstring($_, 1, 100)
!ll&&!rl&&r
000
defined $_ and $_ and not ref $_
!ll&&!rl&&r
000
defined $_ and $_
!ll&&!rl&&r
000
MC/DC0%0/4
defined $_ && $_ && !ref($_) && Net::DRI::Util::xml_is_normalizedstring($_, 1, 100)
defined $_ $_ not ref $_ Net::DRI::Util::xml_is_normalizedstring($_, 1, 100)
Truth table0%0/5
A and B and not(C) && D
A= defined $_B= $_C= not ref $_D= Net::DRI::Util::xml_is_normalizedstring($_, 1, 100)
ABCDresult
0XXX0
10XX0
110X0
11100
11111
214 0 return map { ['dnsbe:nsgroup',$_] } grep {defined} @a[0..8];
215 }
216  
217 sub add_contact
218 0 ▶{
Subroutine add_contact: not called CC=1 SCAR=6.9
Pod undocumented
219 0 my ($type,$cs,$max)=@_;
220 0 $max--;
221 0 my @r=grep { Net::DRI::Util::isa_contact($_,'Net::DRI::Data::Contact::BE') } ($cs->get($type));
222 0 return map { ['dnsbe:'.$type,$_->srid()] } grep {defined} @r[0..$max];
223 }
224  
225 sub undelete
226 0 ▶{
Subroutine undelete: not called CC=1 SCAR=6.9
Pod undocumented
227 0 my ($epp,$domain)=@_;
228 0 my $mes=$epp->message();
229 0 my @d=Net::DRI::Protocol::EPP::Util::domain_build_command($mes,'undelete',$domain);
230 0 $mes->command_body(\@d);
231 0 return;
232 }
233  
234 sub transferq_request
235 0 ▶{
Subroutine transferq_request: not called CC=3 SCAR=24.8
Pod undocumented
236 0 my ($epp,$domain,$rd)=@_;
237 0 my $mes=$epp->message();
238 0 my @d=Net::DRI::Protocol::EPP::Util::domain_build_command($mes,['transferq',{'op'=>'request'}],$domain);
239  
240 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
241 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
242 0 $mes->command_body(\@d);
243  
244 0 $mes->command_extension('dnsbe', ['ext', ['transferq', ['domain', add_transfer($epp, $mes, $domain, $rd)]]]);
245 0 return;
246 }
247  
248 sub trade
249 0 ▶{
Subroutine trade: not called CC=1 SCAR=6.9
Pod undocumented
250 0 my ($epp,$domain,$rd)=@_;
251 0 my $mes=$epp->message();
252 0 my @d=Net::DRI::Protocol::EPP::Util::domain_build_command($mes,['trade',{'op'=>'request'}],$domain);
253 0 $mes->command_body(\@d);
254 0 $mes->command_extension('dnsbe', ['ext', ['trade', ['domain', add_transfer($epp, $mes, $domain, $rd)]]]);
255  
256 0 return;
257 }
258  
259 sub reactivate
260 0 ▶{
Subroutine reactivate: not called CC=1 SCAR=6.9
Pod undocumented
261 0 my ($epp,$domain)=@_;
262 0 my $mes=$epp->message();
263 0 my @d=Net::DRI::Protocol::EPP::Util::domain_build_command($mes,'reactivate',$domain);
264 0 $mes->command_body(\@d);
265 0 return;
266 }
267  
268 sub request_authcode
269 0 ▶{
Subroutine request_authcode: not called CC=2 SCAR=17.9
Pod undocumented
270 0 my ($epp,$domain,$rd)=@_;
271 0 my $mes = $epp->message();
272  
273 0 my @d;
274 0 push @d,['dnsbe:domainName',$domain];
275 0 ▶ push @d,['dnsbe:url',$rd->{'url'}] if $rd->{'url'};
Branch: 1 branch
BranchTrueFalseTotal
if $rd->{"url"} 0 0 0
276 0 $mes->command_extension('dnsbe', ['ext', ['command', ['requestAuthCode', @d], ['clTRID', $mes->cltrid()]]]);
277 # missing TRID
278 0 return;
279 }
280  
281 ####################################################################################################
282 1 1;
« DRI/Transport/HTTP/XMLRPCLite.pm ↑ Summary DRI/Protocol/RRI/Message.pm »