DRI/Protocol/EPP/Extensions/VeriSign/EmailFwd.pm

filter: Statementstmt 16.8% 25 / 148 Branchbran 0.0% 0 / 52 Conditioncond 0.0% 0 / 14 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 42.1% 8 / 19 Podpod 0.0% 0 / 11 totaltotal 13.0% 33 / 253 CC 35 SCAR 47.5
CC
35
Cov
12%
info_parse
272.0
build_command
110.0
check_parse
72.0
CRAP 115.7
« DRI/Protocol/EPP/Core/Host.pm ↑ Summary DRI/Protocol/Whois/Domain/LU.pm »
1 ## Domain Registry Interface, EPP Email forwarding extension commands
2 ## (based on .NAME Technical Accreditation Guide v3.03)
3 ##
4 ## Copyright (c) 2007,2008,2013,2016 Tonnerre Lombard <tonnerre.lombard@sygroup.ch>. All rights reserved.
5 ## 2018 Patrick Mevzek <netdri@dotandco.com>
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::VeriSign::EmailFwd;
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 1 ▶use feature 'state';
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use Net::DRI::Data::Contact;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶use Net::DRI::Data::ContactSet;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 1 ▶use DateTime::Format::ISO8601;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 =pod
30  
31 =head1 NAME
32  
33 Net::DRI::Protocol::EPP::Extensions::VeriSign::EmailFwd - EPP EmailFwd 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> or
50 E<lt>http://oss.bsdprojects.net/projects/netdri/E<gt>
51  
52 =head1 AUTHOR
53  
54 Tonnerre Lombard, E<lt>tonnerre.lombard@sygroup.chE<gt>
55  
56 =head1 COPYRIGHT
57  
58 Copyright (c) 2007,2008,2013,2016 Tonnerre Lombard <tonnerre.lombard@sygroup.ch>.
59 2018 Patrick Mevzek <netdri@dotandco.com>
60 All rights reserved.
61  
62 This program is free software; you can redistribute it and/or modify
63 it under the terms of the GNU General Public License as published by
64 the Free Software Foundation; either version 2 of the License, or
65 (at your option) any later version.
66  
67 See the LICENSE file that comes with this distribution for more details.
68  
69 =cut
70  
71 ####################################################################################################
72  
73 sub register_commands
74 {
75 0 ▶ my ($class,$version)=@_;
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
76 0 my %tmp1=( create => [ \&create ],
77 check => [ \&check, \&check_parse ],
78 info => [ \&info, \&info_parse ],
79 delete => [ \&delete ],
80 update => [ \&update ],
81 renew => [ \&renew ]
82 );
83  
84 0 $tmp1{check_multi}=$tmp1{check};
85
86 0 return { 'emailfwd' => \%tmp1 };
87 }
88  
89 sub setup
90 {
91 0 ▶ my ($class,$po,$version)=@_;
Subroutine setup: not called CC=1 SCAR=6.9
Pod undocumented
92  
93 0 state $ns = { 'emailFwd' => 'http://www.nic.name/epp/emailFwd-1.0' };
94 0 $po->ns($ns);
95 0 return;
96 }
97  
98 sub build_command
99 {
100 0 ▶ my ($epp,$msg,$command,$info)=@_;
Subroutine build_command: not called CC=10 SCAR=47.0
Pod undocumented
101 0 my $contacts = $info->{contact};
102 0 my $authid = $info->{auth};
103 0 my @ret;
104 my @auth;
105  
106 0 delete $info->{contact};
107 0 delete $info->{auth};
108  
109 0 ▶ Net::DRI::Exception->die(1,'protocol/EPP',2,'emailFwd name needed') unless (defined($info->{name}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $info->{"name"} 0 0 0
110  
111 0 my $ns=$msg->nsattrs('emailFwd');
112 0 $msg->command([$command,'emailFwd:'.$command,sprintf('xmlns:emailFwd="%s"', $ns)]);
113  
114 # @ret = map { ['emailFwd:' . $_, $info->{$_}] } keys(%{$info});
115 0 ▶ push(@ret, ['emailFwd:name', $info->{name}]) if (defined($info->{name}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $info->{"name"} 0 0 0
116 0 ▶ push(@ret, ['emailFwd:fwdTo', $info->{fwdTo}]) if (defined($info->{fwdTo}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $info->{"fwdTo"} 0 0 0
117 push(@ret, ['emailFwd:curExpDate', $info->{curExpDate}])
118 0 ▶ if (defined($info->{curExpDate}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $info->{"curExpDate"} 0 0 0
119 push(@ret, ['emailFwd:period', { unit => 'y' },
120 0 ▶ $info->{period}->in_units('years')]) if (defined($info->{period}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $info->{"period"} 0 0 0
121 0 ▶ push(@ret, ['emailFwd:registrant', $info->{registrant}]) if (defined($info->{registrant}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $info->{"registrant"} 0 0 0
122 0 foreach my $type (sort { $a cmp $b } keys %$contacts)
123 {
124 0 push(@ret, ['emailFwd:contact', {type => $type}, $contacts->{$type}]);
125 }
126  
127 0 foreach my $auth (sort { $a cmp $b } keys %$authid)
128 {
129 0 push(@auth, ['emailFwd:' . $auth, $authid->{$auth}]);
130 }
131 0 ▶ push(@ret, ['emailFwd:authInfo', @auth]) if (@auth);
Branch: 1 branch
BranchTrueFalseTotal
if @auth 0 0 0
132  
133 0 return @ret;
134 }
135  
136 ####################################################################################################
137 ########### Query commands
138  
139 sub check
140 {
141 0 ▶ my $epp=shift;
Subroutine check: not called CC=1 SCAR=6.9
Pod undocumented
142 0 my $info=shift;
143 0 my $mes=$epp->message();
144 0 my @d=build_command($epp,$mes,'check', { name => $info });
145 0 $mes->command_body(\@d);
146 0 return;
147 }
148  
149 sub check_parse
150 {
151 0 ▶ my ($po,$otype,$oaction,$oname,$rinfo)=@_;
Subroutine check_parse: not called CC=8 SCAR=42.8
Pod undocumented
152 0 my $mes=$po->message();
153 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
154  
155 0 my $chkdata=$mes->get_response('emailFwd', 'chkData');
156 0 ▶ return unless $chkdata;
Branch: 1 branch
BranchTrueFalseTotal
unless $chkdata 0 0 0
157 0 foreach my $cd ($chkdata->getElementsByTagNameNS($mes->ns('emailFwd'),'cd'))
158 {
159 0 my $c = $cd->getFirstChild();
160 0 my $fwd;
161  
162 0 ▶ while($c)
Branch: 1 branch
BranchTrueFalseTotal
if ($c) 0 0 0
163 {
164 0 ▶ next unless ($c->nodeType() == 1); ## only for element nodes
Branch: 1 branch
BranchTrueFalseTotal
unless $c->nodeType == 1 0 0 0
165 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
166 0 ▶ if ($n eq 'name')
Branch: 1 branch
BranchTrueFalseTotal
if ($n eq "name") 0 0 0
167 {
168 0 $fwd = $c->getFirstChild()->getData();
169 0 $rinfo->{emailFwd}->{$fwd}->{exist} = 1 -
170 Net::DRI::Util::xml_parse_boolean($c->getAttribute('avail'));
171 0 $rinfo->{emailFwd}->{$fwd}->{action} = 'check';
172 }
173 0 } continue { $c = $c->getNextSibling(); }
174 }
175 0 return;
176 }
177  
178 sub info
179 {
180 0 ▶ my ($epp,$mail)=@_;
Subroutine info: not called CC=1 SCAR=6.9
Pod undocumented
181 0 my $mes = $epp->message();
182 0 my @d = build_command($epp,$mes,'info',{ name => $mail });
183 0 $mes->command_body(\@d);
184 0 return;
185 }
186  
187 sub info_parse
188 {
189 0 ▶ my ($po,$otype,$oaction,$oname,$rinfo)=@_;
Subroutine info_parse: not called CC=16 SCAR=56.1
Pod undocumented
190 0 my $mes=$po->message();
191 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
192  
193 0 my $infdata=$mes->get_response('emailFwd', 'infData');
194 0 ▶ return unless $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless $infdata 0 0 0
195  
196 0 my $nm;
197 0 my $cs = Net::DRI::Data::ContactSet->new();
198 0 my $info = {};
199 0 my $ginfo = {};
200  
201 0 my $c=$infdata->getFirstChild();
202 0 ▶ while ($c)
Branch: 1 branch
BranchTrueFalseTotal
if ($c) 0 0 0
203 {
204 0 ▶ next unless ($c->nodeType() == 1); ## only for element nodes
Branch: 1 branch
BranchTrueFalseTotal
unless $c->nodeType == 1 0 0 0
205 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
206 0 ▶ next unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 0 0
207  
208 0 ▶ if ($name eq 'name')
Branch: 6 branches
BranchTrueFalseTotal
if ($name eq 'name') { } 0 0 0
elsif ($name eq 'fwdTo') { } 0 0 0
elsif (grep {$_ eq $name;} 'clID', 'crID', 'upID') { } 0 0 0
elsif (grep {$_ eq $name;} 'crDate', 'upDate', 'trDate', 'exDate') { } 0 0 0
elsif (grep {$_ eq $name;} 'registrant', 'contact') { } 0 0 0
elsif ($name eq 'authInfo') { } 0 0 0
209 {
210 0 $info->{name} = $nm = $c->getFirstChild()->getData();
211 }
212 elsif ($name eq 'fwdTo')
213 {
214 0 $info->{$name} = $c->getFirstChild()->getData();
215 }
216 0 elsif (grep { $_ eq $name } qw/clID crID upID/)
217 {
218 0 $ginfo->{$name} = $c->getFirstChild()->getData();
219 }
220 0 elsif (grep { $_ eq $name } qw/crDate upDate trDate exDate/)
221 {
222 0 $ginfo->{$name} = DateTime::Format::ISO8601()->new()->
223 parse_datetime($c->getFirstChild()->getData());
224 }
225 0 elsif (grep { $_ eq $name } qw/registrant contact/)
226 {
227 0 ▶ my $type = $c->getAttribute('type') || 'registrant';
Condition0%0/2
$c->getAttribute('type') || 'registrant'
l!l
00
MC/DC0%0/1
$c->getAttribute('type') || 'registrant'
$c->getAttribute('type')
Truth table0%0/2
A
A= $c->getAttribute('type')
Aresult
11
00
228 0 $cs->add(Net::DRI::Data::Contact()->new()->
229 srid($c->getFirstChild()->getData()), $type);
230 }
231 elsif ($name eq 'authInfo')
232 {
233 0 my $pw = ($c->getElementsByTagNameNS($mes->ns('emailFwd'),'pw'))[0];
234 0 ▶ $ginfo->{auth} = { pw => (defined($pw) && $pw->hasChildNodes() ?
Branch: 1 branch
BranchTrueFalseTotal
defined $pw && $pw->hasChildNodes ? : 0 0 0
Condition0%0/3
defined $pw and $pw->hasChildNodes
!ll&&!rl&&r
000
MC/DC0%0/2
defined $pw and $pw->hasChildNodes
defined $pw $pw->hasChildNodes
Truth table0%0/3
A and B
A= defined $pwB= $pw->hasChildNodes
ABresult
0X0
100
111
235 $pw->getFirstChild->getData() : undef) };
236 }
237 0 } continue { $c=$c->getNextSibling(); }
238  
239 0 $info->{contact} = $cs;
240  
241 0 $ginfo->{exist} = defined($nm);
242 0 $ginfo->{action} = 'info';
243 0 $ginfo->{self} = $info;
244 0 $rinfo->{emailFwd}->{$nm} = $ginfo;
245 0 return;
246 }
247  
248 ############ Transform commands
249  
250 sub create
251 {
252 0 ▶ my ($epp,$mail,$info)=@_;
Subroutine create: not called CC=1 SCAR=6.9
Pod undocumented
253 0 my $mes = $epp->message();
254 0 my @d;
255 0 $info->{name} = $mail;
256 0 @d = build_command($epp,$mes,'create',$info);
257 0 $mes->command_body(\@d);
258 0 return;
259 }
260  
261 sub delete ## no critic (Subroutines::ProhibitBuiltinHomonyms)
262 {
263 0 ▶ my ($epp,$mail)=@_;
Subroutine delete: not called CC=1 SCAR=6.9
Pod undocumented
264 0 my $mes=$epp->message();
265 0 my @d=build_command($epp,$mes,'delete',{ name => $mail });
266 0 $mes->command_body(\@d);
267 0 return;
268 }
269  
270 sub update
271 {
272 0 ▶ my ($epp,$hosts,$todo)=@_;
Subroutine update: not called CC=4 SCAR=30.0
Pod undocumented
273 0 my $mes=$epp->message();
274  
275 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
276  
277 0 ▶ if ((grep { ! /^(?:ns)$/ } $todo->types()) || (grep { ! /^(?:set)$/ } $todo->types('ns') ))
Branch: 1 branch
BranchTrueFalseTotal
if (grep {not /^(?:ns)$/;} $todo->types or grep {not /^(?:set)$/;} $todo->types("ns")) 0 0 0
Condition0%0/3
grep {not /^(?:ns)$/;} $todo->types or grep {not /^(?:set)$/;} $todo->types("ns")
l!l&&r!l&&!r
000
MC/DC0%0/2
grep {not /^(?:ns)$/;} $todo->types or grep {not /^(?:set)$/;} $todo->types("ns")
grep {not /^(?:ns)$/;} $todo->types grep {not /^(?:set)$/;} $todo->types("ns")
Truth table0%0/3
A or B
A= grep {not /^(?:ns)$/;} $todo->typesB= grep {not /^(?:set)$/;} $todo->types("ns")
ABresult
1X1
011
000
278 {
279 0 Net::DRI::Exception->die(0,'protocol/EPP',11,'Only ns set available for nsgroup');
280 }
281  
282 0 my $ns=$todo->set('ns');
283 0 my @d=build_command($epp,$mes,'update',$hosts);
284 0 push @d,add_nsname($ns);
285 0 $mes->command_body(\@d);
286 0 return;
287 }
288  
289 sub renew
290 {
291 0 ▶ my ($epp,$mail,$period,$curexp)=@_;
Subroutine renew: not called CC=1 SCAR=6.9
Pod undocumented
292 0 my $mes = $epp->message();
293  
294 0 Net::DRI::Util::check_isa($curexp,'DateTime');
295 0 Net::DRI::Util::check_isa($period,'DateTime::Duration');
296  
297 0 my $info = {
298 name => $mail,
299 curExpDate => $curexp->ymd,
300 period => $period
301 };
302  
303 0 my @d = build_command($epp,$mes,'renew',$info);
304 0 $mes->command_body(\@d);
305 0 return;
306 }
307  
308 ####################################################################################################
309 1 1;
« DRI/Protocol/EPP/Core/Host.pm ↑ Summary DRI/Protocol/Whois/Domain/LU.pm »