DRI/Protocol/EPP/Extensions/PRO/AV.pm

filter: Statementstmt 11.5% 16 / 138 Branchbran 0.0% 0 / 90 Conditioncond 0.0% 0 / 36 MC/DCmcdc 0.0% 0 / 24 Subroutinesub 38.4% 5 / 13 Podpod 0.0% 0 / 8 totaltotal 6.8% 21 / 309 CC 59 SCAR 58.5
CC
59
Cov
6%
info_parse
756.0
check_parse
182.0
create_parse
110.0
CRAP 346.7
« DRI/Protocol/EPP/Extensions/Validate.pm ↑ Summary DRI/Protocol/EPP/Extensions/PRO/Domain.pm »
1 ## Domain Registry Interface, .PRO A/V extensions
2 ##
3 ## Copyright (c) 2008,2009,2013 Tonnerre Lombard <tonnerre.lombard@sygroup.ch>.
4 ## 2018 Patrick Mevzek <netdri@dotandco.com>
5 ## 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::PRO::AV;
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 Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use DateTime::Format::ISO8601;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 =pod
27  
28 =head1 NAME
29  
30 Net::DRI::Protocol::EPP::Extensions::PRO::AV - .PRO EPP A/V extensions for Net::DRI
31  
32 =head1 DESCRIPTION
33  
34 Please see the README file for details.
35  
36 =head1 SUPPORT
37  
38 For now, support questions should be sent to:
39  
40 E<lt>development@sygroup.chE<gt>
41  
42 Please also see the SUPPORT file in the distribution.
43  
44 =head1 SEE ALSO
45  
46 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt> and
47 E<lt>http://oss.bdsprojects.net/projects/netdri/E<gt>
48  
49 =head1 AUTHOR
50  
51 Tonnerre Lombard E<lt>tonnerre.lombard@sygroup.chE<gt>,
52 Alexander Biehl, E<lt>info@hexonet.netE<gt>, HEXONET Support GmbH,
53 E<lt>http://www.hexonet.net/E<gt>.
54  
55 =head1 COPYRIGHT
56  
57 Copyright (c) 2008,2009,2013 Tonnerre Lombard <tonnerre.lombard@sygroup.ch>.
58 2018 Patrick Mevzek <netdri@dotandco.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 %avcmds = (
76 create => [ \&create, \&create_parse ],
77 check => [ \&check, \&check_parse ],
78 info => [ \&info, \&info_parse ],
79 );
80  
81 0 return { 'av' => \%avcmds };
82 }
83  
84 ####################################################################################################
85 ############ Query commands
86  
87 sub build_command
88 0 ▶{
Subroutine build_command: not called CC=8 SCAR=42.8
Pod undocumented
89 0 my ($msg, $command, $domain, $domainattr) = @_;
90 0 ▶ my @dom = (ref($domain) ? @$domain : ($domain));
Branch: 1 branch
BranchTrueFalseTotal
ref $domain ? : 0 0 0
91  
92 0 ▶ Net::DRI::Exception->die(1, 'protocol/EPP', 2, 'Domain name needed')
Branch: 1 branch
BranchTrueFalseTotal
unless @dom 0 0 0
93 unless @dom;
94  
95 0 foreach my $d (@dom)
96 {
97 0 ▶ Net::DRI::Exception->die(1, 'protocol/EPP', 2,
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
98 'Domain name needed') unless (defined($d) && $d);
99 0 ▶ Net::DRI::Exception->die(1, 'protocol/EPP', 10,
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::is_hostname($d) 0 0 0
100 'Invalid domain name: ' . $d)
101 unless Net::DRI::Util::is_hostname($d);
102 }
103  
104 0 ▶ my $tcommand = (ref($command) ? $command->[0] : $command);
Branch: 1 branch
BranchTrueFalseTotal
ref $command ? : 0 0 0
105 0 $msg->command([$command, 'av:' . $tcommand, $msg->nsattrs('av')]);
106 0 return map { ['av:id', $_, $domainattr] } @dom;
107 }
108  
109 sub check
110 0 ▶{
Subroutine check: not called CC=1 SCAR=6.9
Pod undocumented
111 0 my ($epp, $av, $rd) = @_;
112 0 my $mes = $epp->message();
113 0 my @d = build_command($mes, 'check', $av);
114 0 $mes->command_body(\@d);
115 0 return;
116 }
117  
118 sub check_parse
119 0 ▶{
Subroutine check_parse: not called CC=13 SCAR=52.0
Pod undocumented
120 0 my ($po, $otype, $oaction, $oname, $rinfo) = @_;
121 0 my $mes = $po->message();
122  
123 0 ▶ return unless ($mes->is_success());
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
124  
125 0 my $chkdata = $mes->get_response('av','chkData');
126 0 ▶ return unless $chkdata;
Branch: 1 branch
BranchTrueFalseTotal
unless $chkdata 0 0 0
127  
128 0 my $cd = $chkdata->getFirstChild();
129  
130 0 ▶ while (defined($cd) && $cd)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cd and $cd) 0 0 0
Condition0%0/3
defined $cd and $cd
!ll&&!rl&&r
000
MC/DC0%0/2
defined $cd and $cd
defined $cd $cd
Truth table0%0/3
A and B
A= defined $cdB= $cd
ABresult
0X0
100
111
131 {
132 0 my $cdn;
133 my $avid;
134 0 my $c;
135  
136 0 ▶ next unless ($cd->nodeType() == 1); ## only for element nodes
Branch: 1 branch
BranchTrueFalseTotal
unless $cd->nodeType == 1 0 0 0
137 0 ▶ $cdn = $cd->localname() || $cd->nodeName();
Condition0%0/3
$cd->localname || $cd->nodeName
l!l&&r!l&&!r
000
MC/DC0%0/2
$cd->localname || $cd->nodeName
$cd->localname $cd->nodeName
Truth table0%0/3
A || B
A= $cd->localnameB= $cd->nodeName
ABresult
1X1
011
000
138 0 $c = $cd->getFirstChild();
139  
140 0 ▶ while (defined($c) && $c)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $c and $c) 0 0 0
Condition0%0/3
defined $c and $c
!ll&&!rl&&r
000
MC/DC0%0/2
defined $c and $c
defined $c $c
Truth table0%0/3
A and B
A= defined $cB= $c
ABresult
0X0
100
111
141 {
142 ## only for element nodes
143 0 ▶ next unless ($c->nodeType() == 1);
Branch: 1 branch
BranchTrueFalseTotal
unless $c->nodeType == 1 0 0 0
144 0 ▶ my $n = $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
145  
146 0 ▶ if ($n eq 'id')
Branch: 2 branches
BranchTrueFalseTotal
if ($n eq 'id') { } 0 0 0
elsif ($n eq 'reason') { } 0 0 0
147 {
148 0 $avid = $c->getFirstChild()->getData();
149 0 $rinfo->{av}->{$avid}->{action} = 'check';
150 $rinfo->{av}->{$avid}->{exist} =
151 0 1 - Net::DRI::Util::xml_parse_boolean($c->getAttribute('avail'));
152 }
153 elsif ($n eq 'reason')
154 {
155 $rinfo->{av}->{$avid}->{exist_reason} =
156 0 $c->getFirstChild()->getData();
157 }
158 0 } continue { $c = $c->getNextSibling(); }
159 0 } continue { $cd = $cd->getNextSibling(); }
160 0 return;
161 }
162  
163 sub info
164 0 ▶{
Subroutine info: not called CC=1 SCAR=6.9
Pod undocumented
165 0 my ($epp, $av, $rd) = @_;
166 0 my $mes = $epp->message();
167 0 my @d = build_command($mes, 'info', $av);
168 0 $mes->command_body(\@d);
169 0 return;
170 }
171  
172 sub info_parse
173 0 ▶{
Subroutine info_parse: not called CC=27 SCAR=66.3
Pod undocumented
174 0 my ($po, $otype, $oaction, $oname, $rinfo) = @_;
175 0 my $mes = $po->message();
176 0 my $ns = $mes->ns('av');
177 0 my $infdata;
178 my $avid;
179 0 my $cd;
180 0 my $pd;
181  
182 0 ▶ return unless ($mes->is_success());
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
183  
184 0 $infdata = $mes->get_response('av','infData');
185 0 ▶ return unless $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless $infdata 0 0 0
186  
187 0 $cd = $infdata->getFirstChild();
188 0 $pd = DateTime::Format::ISO8601->new();
189  
190 0 ▶ while (defined($cd) && $cd)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cd and $cd) 0 0 0
Condition0%0/3
defined $cd and $cd
!ll&&!rl&&r
000
MC/DC0%0/2
defined $cd and $cd
defined $cd $cd
Truth table0%0/3
A and B
A= defined $cdB= $cd
ABresult
0X0
100
111
191 {
192 0 ▶ next unless ($cd->nodeType() == 1); ## only for element nodes
Branch: 1 branch
BranchTrueFalseTotal
unless $cd->nodeType == 1 0 0 0
193 0 ▶ my $cdn = $cd->localname() || $cd->nodeName();
Condition0%0/3
$cd->localname || $cd->nodeName
l!l&&r!l&&!r
000
MC/DC0%0/2
$cd->localname || $cd->nodeName
$cd->localname $cd->nodeName
Truth table0%0/3
A || B
A= $cd->localnameB= $cd->nodeName
ABresult
1X1
011
000
194  
195 0 ▶ if ($cdn eq 'id')
Branch: 7 branches
BranchTrueFalseTotal
if ($cdn eq 'id') { } 0 0 0
elsif ($cdn =~ /^(?:avurl|roid|host)$/i) { } 0 0 0
elsif (lc $cdn eq 'checktype') { } 0 0 0
elsif ($cdn =~ /^(?:c[lr]|up)id$/i) { } 0 0 0
elsif ($cdn =~ /^(?:c[lr]|up)date$/i) { } 0 0 0
elsif (lc $cdn eq 'contactid') { } 0 0 0
elsif (lc $cdn eq 'avresult') { } 0 0 0
196 {
197 0 $avid = $cd->getFirstChild()->getData();
198 0 $rinfo->{av}->{$avid}->{id} = $avid;
199 0 $rinfo->{av}->{$avid}->{action} = 'info';
200 }
201 elsif ($cdn =~ /^(?:avurl|roid|host)$/i)
202 {
203 0 $rinfo->{av}->{$avid}->{lc($cdn)} =
204 $cd->getFirstChild()->getData();
205 }
206 elsif (lc($cdn) eq 'checktype')
207 {
208 $rinfo->{av}->{$avid}->{type} =
209 0 $cd->getFirstChild()->getData();
210 }
211 elsif ($cdn =~ /^(?:c[lr]|up)id$/i)
212 {
213 0 $cdn = lc($cdn); $cdn =~ s/id$/ID/;
214 0 $rinfo->{av}->{$avid}->{$cdn} =
215 $cd->getFirstChild()->getData();
216 }
217 elsif ($cdn =~ /^(?:c[lr]|up)date$/i)
218 {
219 0 $cdn = lc($cdn); $cdn =~ s/date$/Date/;
220 0 $rinfo->{av}->{$avid}->{$cdn} = $pd->parse_datetime(
221 $cd->getFirstChild()->getData());
222 }
223 elsif (lc($cdn) eq 'contactid')
224 {
225 0 my $c = $po->create_local_object('contact');
226 0 $c->srid($cd->getFirstChild()->getData());
227 0 $rinfo->{av}->{$avid}->{contact} = $c;
228 }
229 elsif (lc($cdn) eq 'avresult')
230 {
231 0 my $res = +{};
232 0 my $c = $cd->getFirstChild();
233  
234 0 ▶ while (defined($c) && $c)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $c and $c) 0 0 0
Condition0%0/3
defined $c and $c
!ll&&!rl&&r
000
MC/DC0%0/2
defined $c and $c
defined $c $c
Truth table0%0/3
A and B
A= defined $cB= $c
ABresult
0X0
100
111
235 {
236 ## only for element nodes
237 0 ▶ next unless ($c->nodeType() == 1);
Branch: 1 branch
BranchTrueFalseTotal
unless $c->nodeType == 1 0 0 0
238 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
239 0 ▶ next unless ($name);
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 0 0
240  
241 0 ▶ if (lc($name) eq 'avcheckid')
Branch: 6 branches
BranchTrueFalseTotal
if (lc $name eq 'avcheckid') { } 0 0 0
elsif (lc $name eq 'personalavdatafingerprint') { } 0 0 0
elsif (lc $name eq 'professionalavdatafingerprint') { } 0 0 0
elsif (lc $name eq 'professionalavdatafingerprint') { } 0 0 0
elsif ($name =~ /^(?:oobmethodid|profession|jurisdiction|status)$/i) { } 0 0 0
elsif (lc $name eq 'resultdata') { } 0 0 0
242 {
243 $res->{checkid} =
244 0 $c->getFirstChild()->getData();
245 }
246 elsif (lc($name) eq 'personalavdatafingerprint')
247 {
248 $res->{persfingerprint} =
249 0 $c->getFirstChild()->getData();
250 }
251 elsif (lc($name) eq 'professionalavdatafingerprint')
252 {
253 $res->{proffingerprint} =
254 0 $c->getFirstChild()->getData();
255 }
256 elsif (lc($name) eq 'professionalavdatafingerprint')
257 {
258 $res->{proffingerprint} =
259 0 $c->getFirstChild()->getData();
260 }
261 elsif ($name =~ /^(?:oobmethodid|profession|jurisdiction|status)$/i)
262 {
263 0 $res->{lc($name)} =
264 $c->getFirstChild()->getData();
265 }
266 elsif (lc($name) eq 'resultdata')
267 {
268 0 my $inf = $c->getElementsByTagNameNS($ns, 'result');
269 0 ▶ $res->{avresult} = $inf->shift()->getFirstChild()->getData() if ($inf);
Branch: 1 branch
BranchTrueFalseTotal
if $inf 0 0 0
270 0 $inf = $c->getElementsByTagNameNS($ns, 'date');
271 0 ▶ $res->{avDate} = $pd->parse_datetime($inf->shift()->getFirstChild()->getData()) if ($inf);
Branch: 1 branch
BranchTrueFalseTotal
if $inf 0 0 0
272 }
273 0 } continue { $c = $c->getNextSibling(); }
274  
275 0 $rinfo->{av}->{$avid}->{avresult} = $res;
276 }
277 0 } continue { $cd = $cd->getNextSibling(); }
278 0 return;
279 }
280  
281 ####################################################################################################
282 ############ Transform commands
283  
284 sub create
285 0 ▶{
Subroutine create: not called CC=5 SCAR=34.0
Pod undocumented
286 0 my ($epp, $av, $rd) = @_;
287 0 my $mes = $epp->message();
288 0 my @d = build_command($mes, 'create', $av);
289  
290 0 ▶ push(@d, ['av:checkType', $rd->{type}]) if Net::DRI::Util::has_key($rd, 'type');
Branch: 1 branch
BranchTrueFalseTotal
if Net::DRI::Util::has_key($rd, "type") 0 0 0
291 0 ▶ push(@d, ['av:host', $rd->{host}]) if Net::DRI::Util::has_key($rd, 'host');
Branch: 1 branch
BranchTrueFalseTotal
if Net::DRI::Util::has_key($rd, "host") 0 0 0
292 0 ▶ push(@d, ['av:contact', ['av:contactId', $rd->{contact}->srid()]]) if (Net::DRI::Util::has_key($rd,'contact') && Net::DRI::Util::isa_contact($rd->{contact}));
Branch: 1 branch
BranchTrueFalseTotal
if Net::DRI::Util::has_key($rd, "contact") and Net::DRI::Util::isa_contact($rd->{"contact"}) 0 0 0
Condition0%0/3
Net::DRI::Util::has_key($rd, "contact") and Net::DRI::Util::isa_contact($rd->{"contact"})
!ll&&!rl&&r
000
MC/DC0%0/2
Net::DRI::Util::has_key($rd, "contact") and Net::DRI::Util::isa_contact($rd->{"contact"})
Net::DRI::Util::has_key($rd, "contact") Net::DRI::Util::isa_contact($rd->{"contact"})
Truth table0%0/3
A and B
A= Net::DRI::Util::has_key($rd, "contact")B= Net::DRI::Util::isa_contact($rd->{"contact"})
ABresult
0X0
100
111
293  
294 0 $mes->command_body(\@d);
295 0 return;
296 }
297  
298 sub create_parse
299 0 ▶{
Subroutine create_parse: not called CC=10 SCAR=47.0
Pod undocumented
300 0 my ($po, $otype, $oaction, $oname, $rinfo) = @_;
301 0 my $mes = $po->message();
302 0 my $avid;
303  
304 0 ▶ return unless ($mes->is_success());
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
305  
306 0 my $credata = $mes->get_response('av','creData');
307 0 ▶ return unless $credata;
Branch: 1 branch
BranchTrueFalseTotal
unless $credata 0 0 0
308  
309 0 my $cd = $credata->getFirstChild();
310 0 my $pd = DateTime::Format::ISO8601->new();
311  
312 0 ▶ while (defined($cd) && $cd)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cd and $cd) 0 0 0
Condition0%0/3
defined $cd and $cd
!ll&&!rl&&r
000
MC/DC0%0/2
defined $cd and $cd
defined $cd $cd
Truth table0%0/3
A and B
A= defined $cdB= $cd
ABresult
0X0
100
111
313 {
314 0 ▶ next unless ($cd->nodeType() == 1); ## only for element nodes
Branch: 1 branch
BranchTrueFalseTotal
unless $cd->nodeType == 1 0 0 0
315 0 ▶ my $cdn = $cd->localname() || $cd->nodeName();
Condition0%0/3
$cd->localname || $cd->nodeName
l!l&&r!l&&!r
000
MC/DC0%0/2
$cd->localname || $cd->nodeName
$cd->localname $cd->nodeName
Truth table0%0/3
A || B
A= $cd->localnameB= $cd->nodeName
ABresult
1X1
011
000
316  
317 0 ▶ if ($cdn eq 'id')
Branch: 3 branches
BranchTrueFalseTotal
if ($cdn eq 'id') { } 0 0 0
elsif ($cdn =~ /^(avurl|roid)$/i) { } 0 0 0
elsif (lc $cdn eq 'crdate') { } 0 0 0
318 {
319 0 $avid = $cd->getFirstChild()->getData();
320 0 $rinfo->{av}->{$avid}->{id} = $avid;
321 0 $rinfo->{av}->{$avid}->{action} = 'create';
322 }
323 elsif ($cdn =~ /^(avurl|roid)$/i)
324 {
325 0 $rinfo->{av}->{$avid}->{lc($cdn)} =
326 $cd->getFirstChild()->getData();
327 }
328 elsif (lc($cdn) eq 'crdate')
329 {
330 0 $rinfo->{av}->{$avid}->{crDate} = $pd->parse_datetime(
331 $cd->getFirstChild()->getData());
332 }
333 0 } continue { $cd = $cd->getNextSibling(); }
334 0 return;
335 }
336  
337 ####################################################################################################
338 1 1;
« DRI/Protocol/EPP/Extensions/Validate.pm ↑ Summary DRI/Protocol/EPP/Extensions/PRO/Domain.pm »