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

filter: Statementstmt 10.0% 16 / 159 Branchbran 0.0% 0 / 64 Conditioncond 0.0% 0 / 26 MC/DCmcdc 0.0% 0 / 15 Subroutinesub 20.0% 5 / 25 Podpod 0.0% 0 / 20 totaltotal 6.8% 21 / 309 CC 46 SCAR 37.8
CC
46
Cov
6%
check_parse
132.0
parse_trade_recover
72.0
verify_contacts
42.0
CRAP 43.9
« DRI/Protocol/OVH/WS/Domain.pm ↑ Summary DRI/Protocol/EPP/Extensions/ARNES/Contact.pm »
1 ## Domain Registry Interface, AFNIC EPP Domain extensions
2 ##
3 ## Copyright (c) 2008-2010,2012,2013,2016,2018-2019 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::AFNIC::Domain;
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 1 ▶use feature 'state';
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 =pod
25  
26 =head1 NAME
27  
28 Net::DRI::Protocol::EPP::Extensions::AFNIC::Domain - AFNIC (.FR/.RE/.TF/.WF/.PM/.YT) EPP Domain extensions 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) 2008-2010,2012,2013,2016,2018-2019 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 0 ▶{
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
68 0 my ($class,$version)=@_;
69 0 state $rops = { domain => {
70 create => [ \&create, undef ],
71 update => [ \&update, undef ],
72 transfer_request => [ \&transfer_request, undef ],
73 trade_request => [ \&trade_request, \&trade_parse ],
74 trade_query => [ \&trade_query, \&trade_parse ],
75 trade_cancel => [ \&trade_cancel, undef ],
76 recover_request => [ \&recover_request, \&recover_parse],
77 check => [ undef, \&check_parse],
78 check_multi => [ undef, \&check_parse],
79 info => [ undef, \&info_parse],
80 }
81 };
82  
83 0 return $rops;
84 }
85  
86 ####################################################################################################
87  
88 sub build_domain
89 0 ▶{
Subroutine build_domain: not called CC=4 SCAR=30.0
Pod undocumented
90 0 my ($domain)=@_;
91 0 ▶ Net::DRI::Exception->die(1,'protocol/EPP',2,'Domain name needed') unless defined($domain) && $domain;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $domain and $domain 0 0 0
Condition0%0/3
defined $domain and $domain
!ll&&!rl&&r
000
MC/DC0%0/2
defined $domain and $domain
defined $domain $domain
Truth table0%0/3
A and B
A= defined $domainB= $domain
ABresult
0X0
100
111
92 0 ▶ Net::DRI::Exception->die(1,'protocol/EPP',10,'Invalid domain name: '.$domain) unless Net::DRI::Util::is_hostname($domain);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::is_hostname($domain) 0 0 0
93 0 return ['frnic:name',$domain];
94 }
95  
96 sub build_registrant
97 0 ▶{
Subroutine build_registrant: not called CC=5 SCAR=34.0
Pod undocumented
98 0 my ($rd)=@_;
99 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('AFNIC needs contacts for domain operations') unless Net::DRI::Util::has_contact($rd);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_contact($rd) 0 0 0
100 0 my @t=$rd->{contact}->get('registrant');
101 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('AFNIC needs one contact of type registrant') unless (@t==1 && Net::DRI::Util::isa_contact($t[0],'Net::DRI::Data::Contact::AFNIC'));
Branch: 1 branch
BranchTrueFalseTotal
unless @t == 1 and Net::DRI::Util::isa_contact($t[0], "Net::DRI::Data::Contact::AFNIC") 0 0 0
Condition0%0/3
@t == 1 and Net::DRI::Util::isa_contact($t[0], "Net::DRI::Data::Contact::AFNIC")
!ll&&!rl&&r
000
MC/DC0%0/2
@t == 1 and Net::DRI::Util::isa_contact($t[0], "Net::DRI::Data::Contact::AFNIC")
@t == 1 Net::DRI::Util::isa_contact($t[0], "Net::DRI::Data::Contact::AFNIC")
Truth table0%0/3
A and B
A= @t == 1B= Net::DRI::Util::isa_contact($t[0], "Net::DRI::Data::Contact::AFNIC")
ABresult
0X0
100
111
102 0 $t[0]->validate_registrant();
103 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Registrant contact must have an id') unless length $t[0]->srid();
Branch: 1 branch
BranchTrueFalseTotal
unless length $t[0]->srid 0 0 0
104 0 return ['frnic:registrant',$t[0]->srid()];
105 }
106  
107 sub build_cltrid
108 0 ▶{
Subroutine build_cltrid: not called CC=1 SCAR=6.9
Pod undocumented
109 0 my ($mes)=@_;
110 0 return (['frnic:clTRID',$mes->cltrid()]);
111 }
112  
113 sub verify_contacts
114 0 ▶{
Subroutine verify_contacts: not called CC=6 SCAR=37.4
Pod undocumented
115 0 my $rd=shift;
116 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('AFNIC needs contacts for domain operations') unless Net::DRI::Util::has_contact($rd);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_contact($rd) 0 0 0
117 0 my @t=$rd->{contact}->get('admin');
118 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('AFNIC needs one contact of type admin, and only one') unless (@t==1 && Net::DRI::Util::isa_contact($t[0],'Net::DRI::Data::Contact::AFNIC'));
Branch: 1 branch
BranchTrueFalseTotal
unless @t == 1 and Net::DRI::Util::isa_contact($t[0], "Net::DRI::Data::Contact::AFNIC") 0 0 0
Condition0%0/3
@t == 1 and Net::DRI::Util::isa_contact($t[0], "Net::DRI::Data::Contact::AFNIC")
!ll&&!rl&&r
000
MC/DC0%0/2
@t == 1 and Net::DRI::Util::isa_contact($t[0], "Net::DRI::Data::Contact::AFNIC")
@t == 1 Net::DRI::Util::isa_contact($t[0], "Net::DRI::Data::Contact::AFNIC")
Truth table0%0/3
A and B
A= @t == 1B= Net::DRI::Util::isa_contact($t[0], "Net::DRI::Data::Contact::AFNIC")
ABresult
0X0
100
111
119 0 @t=grep { Net::DRI::Util::isa_contact($_,'Net::DRI::Data::Contact::AFNIC') } $rd->{contact}->get('tech');
120 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('AFNIC needs one to three contacts of type tech') unless (@t >= 1 && @t <= 3);
Branch: 1 branch
BranchTrueFalseTotal
unless @t >= 1 and @t <= 3 0 0 0
Condition0%0/3
@t >= 1 and @t <= 3
!ll&&!rl&&r
000
MC/DC0%0/2
@t >= 1 and @t <= 3
@t >= 1 @t <= 3
Truth table0%0/3
A and B
A= @t >= 1B= @t <= 3
ABresult
0X0
100
111
121 0 return;
122 }
123  
124 sub build_contacts
125 0 ▶{
Subroutine build_contacts: not called CC=1 SCAR=6.9
Pod undocumented
126 0 my ($rd)=@_;
127 0 my $cs=$rd->{contact};
128 0 my @n;
129 0 push @n,['frnic:contact',{type => 'admin'},$cs->get('admin')->srid()]; ## only one admin allowed
130 0 push @n,map { ['frnic:contact',{type => 'tech'},$_->srid()] } $cs->get('tech'); ## 1 to 3 allowed
131 0 return @n;
132 }
133  
134 sub build_authinfo
135 0 ▶{
Subroutine build_authinfo: not called CC=4 SCAR=30.0
Pod undocumented
136 0 my ($mes, $rd, $what)=@_;
137 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('authInfo is mandatory for a "'.$what.'"') unless (Net::DRI::Util::has_auth($rd) && exists($rd->{auth}->{pw}) && $rd->{auth}->{pw});
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_auth($rd) and exists $rd->{"auth"}{"pw"} and $rd->{"auth"}{"pw"} 0 0 0
Condition0%0/6
Net::DRI::Util::has_auth($rd) and exists $rd->{"auth"}{"pw"} and $rd->{"auth"}{"pw"}
!ll&&!rl&&r
000
Net::DRI::Util::has_auth($rd) and exists $rd->{"auth"}{"pw"}
!ll&&!rl&&r
000
MC/DC0%0/3
Net::DRI::Util::has_auth($rd) and exists $rd->{"auth"}{"pw"} and $rd->{"auth"}{"pw"}
Net::DRI::Util::has_auth($rd) exists $rd->{"auth"}{"pw"} $rd->{"auth"}{"pw"}
Truth table0%0/4
A and B and C
A= Net::DRI::Util::has_auth($rd)B= exists $rd->{"auth"}{"pw"}C= $rd->{"auth"}{"pw"}
ABCresult
0XX0
10X0
1100
1111
138 0 return ['frnic:authInfo',['domain:pw',{'xmlns:domain'=>$mes->ns('domain')},$rd->{auth}->{pw}]];
139 }
140  
141 sub create
142 0 ▶{
Subroutine create: not called CC=1 SCAR=6.9
Pod undocumented
143 0 my ($epp,$domain,$rd)=@_;
144 0 my $mes=$epp->message();
145  
146 ## We just make sure that we have all contact data
147 0 verify_contacts($rd);
148 0 build_registrant($rd);
149 0 return;
150 }
151  
152 sub update
153 0 ▶{
Subroutine update: not called CC=6 SCAR=37.4
Pod undocumented
154 0 my ($epp,$domain,$todo)=@_;
155 0 my $mes=$epp->message();
156  
157 ## We just verify that if we do a redemption, we only use op=request, because RFC3915 allows also op=report
158 0 my $rgp=$todo->set('rgp');
159 0 ▶ return unless (defined($rgp) && $rgp && (ref($rgp) eq 'HASH'));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $rgp and $rgp and ref $rgp eq "HASH" 0 0 0
Condition0%0/6
defined $rgp and $rgp and ref $rgp eq "HASH"
!ll&&!rl&&r
000
defined $rgp and $rgp
!ll&&!rl&&r
000
MC/DC0%0/3
defined $rgp and $rgp and ref $rgp eq "HASH"
defined $rgp $rgp ref $rgp eq "HASH"
Truth table0%0/4
A and B and C
A= defined $rgpB= $rgpC= ref $rgp eq "HASH"
ABCresult
0XX0
10X0
1100
1111
160 0 ▶ my $op=$rgp->{op} || '';
Condition0%0/2
$rgp->{'op'} || ''
l!l
00
MC/DC0%0/1
$rgp->{'op'} || ''
$rgp->{'op'}
Truth table0%0/2
A
A= $rgp->{'op'}
Aresult
11
00
161 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('RGP op can only be request for AFNIC') unless ($op eq 'request');
Branch: 1 branch
BranchTrueFalseTotal
unless $op eq "request" 0 0 0
162 0 return;
163 }
164  
165 sub add_keepds
166 0 ▶{
Subroutine add_keepds: not called CC=3 SCAR=24.8
Pod undocumented
167 0 my ($op,$rd)=@_;
168 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Domain "'.$op.'" operation needs a keep_ds attribute') unless Net::DRI::Util::has_key($rd,'keep_ds');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rd, "keep_ds") 0 0 0
169 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('keep_ds attribute must be boolean, not '.$rd->{keep_ds}) unless Net::DRI::Util::xml_is_boolean($rd->{keep_ds});
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_boolean($rd->{"keep_ds"}) 0 0 0
170  
171 0 return { 'keepDS' => $rd->{keep_ds} };
172 }
173  
174 sub transfer_request
175 0 ▶{
Subroutine transfer_request: not called CC=1 SCAR=6.9
Pod undocumented
176 0 my ($epp,$domain,$rd)=@_;
177  
178 0 verify_contacts($rd);
179 0 $epp->message()->command_extension('frnic', ['ext', ['transfer', ['domain', add_keepds('transfer',$rd), build_contacts($rd)]]]);
180 0 return;
181 }
182  
183 sub parse_trade_recover
184 0 ▶{
Subroutine parse_trade_recover: not called CC=8 SCAR=42.8
Pod undocumented
185 0 my ($po,$otype,$oaction,$oname,$rinfo,$s)=@_;
186 0 my $mes=$po->message();
187  
188 0 my $infdata=$mes->get_extension('frnic','ext');
189 0 ▶ return unless defined $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $infdata 0 0 0
190  
191 0 my $ns=$mes->ns('frnic');
192 0 $infdata=Net::DRI::Util::xml_traverse($infdata,$ns,'resData',$s,'domain');
193 0 ▶ return unless defined $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $infdata 0 0 0
194  
195 0 foreach my $el (Net::DRI::Util::xml_list_children($infdata))
196 {
197 0 my ($name,$c)=@$el;
198 0 ▶ if ($name eq 'name')
Branch: 4 branches
BranchTrueFalseTotal
if ($name eq 'name') { } 0 0 0
elsif ($name eq 'trStatus') { } 0 0 0
elsif ($name =~ /^(reID|reHldID|acID|acHldID)$/) { } 0 0 0
elsif ($name =~ /^(reDate|rhDate|ahDate)$/) { } 0 0 0
199 {
200 0 $oname=lc($c->textContent());
201 0 $rinfo->{domain}->{$oname}->{action}=$oaction;
202 0 $rinfo->{domain}->{$oname}->{exist}=1;
203 } elsif ($name eq 'trStatus')
204 {
205 0 $rinfo->{domain}->{$oname}->{$name}=$c->textContent();
206 } elsif ($name=~m/^(reID|reHldID|acID|acHldID)$/)
207 {
208 0 $rinfo->{domain}->{$oname}->{$name}=$c->textContent();
209 } elsif ($name=~m/^(reDate|rhDate|ahDate)$/)
210 {
211 0 $rinfo->{domain}->{$oname}->{$name}=$po->parse_iso8601($c->textContent());
212 }
213 }
214 0 return;
215 }
216  
217 sub trade_request
218 0 ▶{
Subroutine trade_request: not called CC=1 SCAR=6.9
Pod undocumented
219 0 my ($epp,$domain,$rd)=@_;
220 0 my $mes=$epp->message();
221  
222 0 my @n=build_domain($domain);
223 0 push @n,build_registrant($rd);
224 0 push @n,build_authinfo($mes, $rd, 'trade request');
225 0 $mes->command_extension('frnic', ['ext', ['command', ['trade', {op=>'request'}, ['domain', @n]], build_cltrid($mes)]]);
226 0 return;
227 }
228  
229 sub trade_query
230 0 ▶{
Subroutine trade_query: not called CC=1 SCAR=6.9
Pod undocumented
231 0 my ($epp,$domain,$rd)=@_;
232 0 my $mes=$epp->message();
233  
234 0 my @n=build_domain($domain);
235 0 push @n,build_authinfo($mes, $rd, 'trade query');
236 0 $mes->command_extension('frnic', ['ext', ['command', ['trade', {op=>'query'}, ['domain', @n]], build_cltrid($mes)]]);
237 0 return;
238 }
239  
240 sub trade_cancel
241 0 ▶{
Subroutine trade_cancel: not called CC=1 SCAR=6.9
Pod undocumented
242 0 my ($epp,$domain,$rd)=@_;
243 0 my $mes=$epp->message();
244  
245 0 my @n=build_domain($domain);
246 0 push @n,build_authinfo($mes, $rd, 'trade cancel');
247 0 $mes->command_extension('frnic', ['ext', ['command', ['trade', {op=>'cancel'}, ['domain', @n]], build_cltrid($mes)]]);
248 0 return;
249 }
250  
251 sub trade_parse
252 0 ▶{
Subroutine trade_parse: not called CC=2 SCAR=17.9
Pod undocumented
253 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
254 0 my $mes=$po->message();
255 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
256  
257 0 parse_trade_recover($po,$otype,'trade',$oname,$rinfo,'trdData');
258 0 return;
259 }
260  
261 sub recover_request
262 0 ▶{
Subroutine recover_request: not called CC=1 SCAR=6.9
Pod undocumented
263 0 my ($epp,$domain,$rd)=@_;
264 0 my $mes=$epp->message();
265  
266 0 my @n=build_domain($domain);
267 0 push @n,build_authinfo($mes, $rd, 'recover request');
268 0 push @n,build_registrant($rd);
269 0 push @n,build_contacts($rd);
270 0 $mes->command_extension('frnic', ['ext', ['command', ['recover', {op=>'request'}, ['domain', add_keepds('recover', $rd), @n]], build_cltrid($mes)]]);
271 0 return;
272 }
273  
274 sub recover_parse
275 0 ▶{
Subroutine recover_parse: not called CC=2 SCAR=17.9
Pod undocumented
276 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
277 0 my $mes=$po->message();
278 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
279  
280 0 parse_trade_recover($po,$otype,'recover',$oname,$rinfo,'recData');
281 0 return;
282 }
283  
284 sub check_parse
285 0 ▶{
Subroutine check_parse: not called CC=11 SCAR=48.8
Pod undocumented
286 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
287 0 my $mes=$po->message();
288 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
289  
290 0 my $chkdata=$mes->get_extension('frnic','ext');
291 0 ▶ return unless defined $chkdata;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $chkdata 0 0 0
292  
293 0 my $ns=$mes->ns('frnic');
294 0 $chkdata=Net::DRI::Util::xml_traverse($chkdata,$ns,'resData','chkData','domain');
295 0 ▶ return unless defined $chkdata;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $chkdata 0 0 0
296  
297 0 foreach my $cd ($chkdata->getChildrenByTagNameNS($ns,'cd'))
298 {
299 0 my (@r,@f,$domain);
300 0 foreach my $el (Net::DRI::Util::xml_list_children($cd))
301 {
302 0 my ($n,$c)=@$el;
303 0 ▶ if ($n eq 'name')
Branch: 3 branches
BranchTrueFalseTotal
if ($n eq 'name') { } 0 0 0
elsif ($n eq 'rsvReason') { } 0 0 0
elsif ($n eq 'fbdReason') { } 0 0 0
304 {
305 0 $domain=lc($c->textContent());
306 0 $rinfo->{domain}->{$domain}->{action}='check';
307 0 $rinfo->{domain}->{$domain}->{reserved}=Net::DRI::Util::xml_parse_boolean($c->getAttribute('reserved'));
308 0 $rinfo->{domain}->{$domain}->{forbidden}=Net::DRI::Util::xml_parse_boolean($c->getAttribute('forbidden'));
309 } elsif ($n eq 'rsvReason')
310 {
311 0 push @r,$c->textContent();
312 } elsif ($n eq 'fbdReason')
313 {
314 0 push @f,$c->textContent();
315 }
316 }
317  
318 ## There may be multiple of them !
319 0 ▶ $rinfo->{domain}->{$domain}->{reserved_reason}=join("\n",@r) if @r;
Branch: 1 branch
BranchTrueFalseTotal
if @r 0 0 0
320 0 ▶ $rinfo->{domain}->{$domain}->{forbidden_reason}=join("\n",@f) if @f;
Branch: 1 branch
BranchTrueFalseTotal
if @f 0 0 0
321 }
322 0 return;
323 }
324  
325 sub info_parse
326 0 ▶{
Subroutine info_parse: not called CC=5 SCAR=34.0
Pod undocumented
327 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
328 0 my $mes=$po->message();
329 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
330  
331 0 my $infdata=$mes->get_extension('frnic','ext');
332 0 ▶ return unless defined $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $infdata 0 0 0
333  
334 0 my $ns=$mes->ns('frnic');
335 0 $infdata=Net::DRI::Util::xml_traverse($infdata,$ns,'resData','infData','domain');
336 0 ▶ return unless defined $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $infdata 0 0 0
337  
338 0 my $cs=$rinfo->{domain}->{$oname}->{status}; ## a Net::DRI::Protocol::EPP::Extensions::AFNIC::Status object
339 0 foreach my $el ($infdata->getChildrenByTagNameNS($ns,'status'))
340 {
341 0 $cs->rem('ok');
342 0 $cs->add($el->getAttribute('s'));
343 }
344 0 return;
345 }
346  
347 ####################################################################################################
348 1 1;
« DRI/Protocol/OVH/WS/Domain.pm ↑ Summary DRI/Protocol/EPP/Extensions/ARNES/Contact.pm »