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

filter: Statementstmt 13.7% 16 / 116 Branchbran 0.0% 0 / 56 Conditioncond 0.0% 0 / 18 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 31.2% 5 / 16 Podpod 0.0% 0 / 11 totaltotal 9.1% 21 / 229 CC 38 SCAR 41.8
CC
38
Cov
8%
create
110.0
info_parse
110.0
renew
90.0
CRAP 65.5
« DRI/Protocol/EPP/Extensions/Afilias/Trademark.pm ↑ Summary DRI/Transport.pm »
1 ## Domain Registry Interface, .PT Domain EPP extension commands
2 ##
3 ## Copyright (c) 2008,2013-2014,2016 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::FCCN::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  
20 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use DateTime::Duration;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 =pod
25  
26 =head1 NAME
27  
28 Net::DRI::Protocol::EPP::Extensions::FCCN::Domain - FCCN (.PT) EPP Domain extension commands 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,2013-2014,2016 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 {
68 0 ▶ my ($class,$version)=@_;
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
69 0 my %tmp=(
70 create => [ \&create, \&create_parse ],
71 info => [ \&info, \&info_parse ],
72 update => [ \&update ],
73 renew => [ \&renew ],
74 renounce => [ \&renounce ],
75 delete => [ \&delete ],
76 transfer_request => [ \&transfer_request ],
77 );
78  
79 0 return { 'domain' => \%tmp };
80 }
81  
82 ####################################################################################################
83  
84 sub create
85 {
86 0 ▶ my ($epp,$domain,$rd)=@_;
Subroutine create: not called CC=10 SCAR=47.0
Pod undocumented
87  
88 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Registrant contact required for .PT domain name creation') unless (Net::DRI::Util::has_contact($rd) && $rd->{contact}->has_type('registrant'));
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_contact($rd) and $rd->{"contact"}->has_type("registrant") 0 0 0
Condition0%0/3
Net::DRI::Util::has_contact($rd) and $rd->{"contact"}->has_type("registrant")
!ll&&!rl&&r
000
MC/DC0%0/2
Net::DRI::Util::has_contact($rd) and $rd->{"contact"}->has_type("registrant")
Net::DRI::Util::has_contact($rd) $rd->{"contact"}->has_type("registrant")
Truth table0%0/3
A and B
A= Net::DRI::Util::has_contact($rd)B= $rd->{"contact"}->has_type("registrant")
ABresult
0X0
100
111
89 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Tech contact required for .PT domain name creation') unless (Net::DRI::Util::has_contact($rd) && $rd->{contact}->has_type('tech'));
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_contact($rd) and $rd->{"contact"}->has_type("tech") 0 0 0
Condition0%0/3
Net::DRI::Util::has_contact($rd) and $rd->{"contact"}->has_type("tech")
!ll&&!rl&&r
000
MC/DC0%0/2
Net::DRI::Util::has_contact($rd) and $rd->{"contact"}->has_type("tech")
Net::DRI::Util::has_contact($rd) $rd->{"contact"}->has_type("tech")
Truth table0%0/3
A and B
A= Net::DRI::Util::has_contact($rd)B= $rd->{"contact"}->has_type("tech")
ABresult
0X0
100
111
90  
91 0 foreach my $d (qw/legitimacy registration_basis auto_renew/)
92 {
93 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters($d.' attribute is mandatory for .PT domain name creation') unless Net::DRI::Util::has_key($rd,$d);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rd, $d) 0 0 0
94 }
95 0 foreach my $d (qw/auto_renew/)
96 {
97 0 ▶ Net::DRI::Exception::usererr_invalid_parameters($d.' must be either 0 or 1 for .PT domain name creation') unless ($rd->{$d}==0 || $rd->{$d}==1);
Branch: 1 branch
BranchTrueFalseTotal
unless $rd->{$d} == 0 or $rd->{$d} == 1 0 0 0
Condition0%0/3
$rd->{$d} == 0 or $rd->{$d} == 1
l!l&&r!l&&!r
000
MC/DC0%0/2
$rd->{$d} == 0 or $rd->{$d} == 1
$rd->{$d} == 0 $rd->{$d} == 1
Truth table0%0/3
A or B
A= $rd->{$d} == 0B= $rd->{$d} == 1
ABresult
1X1
011
000
98 }
99  
100 0 my $mes=$epp->message();
101 0 my @n;
102 0 push @n,['ptdomain:legitimacy',{type => $rd->{legitimacy}}];
103 0 push @n,['ptdomain:registration_basis',{type => $rd->{registration_basis}}];
104 0 push @n,['ptdomain:autoRenew',$rd->{auto_renew}];
105 0 my $eid=$mes->command_extension_register('ptdomain', 'create');
106 0 $mes->command_extension($eid,\@n);
107 0 return;
108 }
109  
110 sub create_parse
111 {
112 0 ▶ my ($po,$otype,$oaction,$oname,$rinfo)=@_;
Subroutine create_parse: not called CC=7 SCAR=40.3
Pod undocumented
113 0 my $mes=$po->message();
114 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
115  
116 0 my $credata=$mes->get_extension('ptdomain','creData');
117 0 ▶ return unless $credata;
Branch: 1 branch
BranchTrueFalseTotal
unless $credata 0 0 0
118  
119 0 my $c=$credata->getFirstChild();
120 0 ▶ while($c)
Branch: 1 branch
BranchTrueFalseTotal
if ($c) 0 0 0
121 {
122 0 ▶ next unless ($c->nodeType() == 1); ## only for element nodes
Branch: 1 branch
BranchTrueFalseTotal
unless $c->nodeType == 1 0 0 0
123 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
124 0 ▶ if ($n eq 'roid')
Branch: 1 branch
BranchTrueFalseTotal
if ($n eq "roid") 0 0 0
125 {
126 0 $rinfo->{domain}->{$oname}->{roid}=$c->getFirstChild()->getData();
127 }
128 0 } continue { $c=$c->getNextSibling(); }
129 0 return;
130 }
131  
132 sub add_roid
133 {
134 0 ▶ my ($roid)=@_;
Subroutine add_roid: not called CC=1 SCAR=6.9
Pod undocumented
135 0 return ['ptdomain:roid',$roid];
136 }
137  
138 sub info
139 {
140 0 ▶ my ($epp,$domain,$rd)=@_;
Subroutine info: not called CC=2 SCAR=17.9
Pod undocumented
141  
142 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('roid attribute required for .PT domain name info') unless (Net::DRI::Util::has_key($rd,'roid'));
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rd, "roid") 0 0 0
143  
144 0 my $mes=$epp->message();
145 0 my $eid=$mes->command_extension_register('ptdomain', 'info');
146 0 my @n=add_roid($rd->{roid});
147 0 $mes->command_extension($eid,\@n);
148 0 return;
149 }
150  
151 sub info_parse
152 {
153 0 ▶ my ($po,$otype,$oaction,$oname,$rinfo)=@_;
Subroutine info_parse: not called CC=10 SCAR=47.0
Pod undocumented
154 0 my $mes=$po->message();
155 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
156  
157 0 my $infdata=$mes->get_extension('ptdomain','infData');
158 0 ▶ return unless $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless $infdata 0 0 0
159  
160 0 my $c=$infdata->getFirstChild();
161 0 ▶ while($c)
Branch: 1 branch
BranchTrueFalseTotal
if ($c) 0 0 0
162 {
163 0 ▶ next unless ($c->nodeType() == 1); ## only for element nodes
Branch: 1 branch
BranchTrueFalseTotal
unless $c->nodeType == 1 0 0 0
164 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
165 0 ▶ next unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 0 0
166  
167 0 ▶ if ($name=~m/^(?:legitimacy|registration_basis)$/)
Branch: 3 branches
BranchTrueFalseTotal
if ($name =~ /^(?:legitimacy|registration_basis)$/) { } 0 0 0
elsif ($name =~ /^(?:autoRenew|notRenew|nextPossibleRegistration|addPeriod|waitingRemoval)$/) { } 0 0 0
elsif ($name eq 'renew') { } 0 0 0
168 {
169 0 $rinfo->{domain}->{$oname}->{$name}=$c->getAttribute('type');
170 } elsif ($name=~m/^(?:autoRenew|notRenew|nextPossibleRegistration|addPeriod|waitingRemoval)$/)
171 {
172 0 $rinfo->{domain}->{$oname}->{Net::DRI::Util::remcam($name)}=Net::DRI::Util::xml_parse_boolean($c->getFirstChild()->getData());
173 } elsif ($name eq 'renew')
174 {
175 0 $rinfo->{domain}->{$oname}->{renew_period}=DateTime::Duration->new(years => $c->getAttribute('period'));
176 }
177 0 } continue { $c=$c->getNextSibling(); }
178 0 return;
179 }
180  
181 sub update
182 {
183 0 ▶ my ($epp,$domain,$toc,$rd)=@_;
Subroutine update: not called CC=2 SCAR=17.9
Pod undocumented
184  
185 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('roid attribute required for .PT domain name update') unless (Net::DRI::Util::has_key($rd,'roid'));
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rd, "roid") 0 0 0
186  
187 0 my $mes=$epp->message();
188 0 my $eid=$mes->command_extension_register('ptdomain', 'update');
189 0 my @n=add_roid($rd->{roid});
190 0 $mes->command_extension($eid,\@n);
191 0 return;
192 }
193  
194 sub renew
195 {
196 0 ▶ my ($epp,$domain,$rd)=@_;
Subroutine renew: not called CC=9 SCAR=45.0
Pod undocumented
197  
198 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('roid attribute required for .PT domain name renew') unless (Net::DRI::Util::has_key($rd,'roid'));
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rd, "roid") 0 0 0
199  
200 0 my $c=Net::DRI::Util::has_key($rd,'duration');
201 0 foreach my $d (qw/auto_renew not_renew/)
202 {
203 0 ▶ next unless Net::DRI::Util::has_key($rd,$d);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rd, $d) 0 0 0
204 0 ▶ Net::DRI::Exception::usererr_invalid_parameters($d.' must be either 0 or 1 for .PT domain name creation') unless ($rd->{$d}==0 || $rd->{$d}==1);
Branch: 1 branch
BranchTrueFalseTotal
unless $rd->{$d} == 0 or $rd->{$d} == 1 0 0 0
Condition0%0/3
$rd->{$d} == 0 or $rd->{$d} == 1
l!l&&r!l&&!r
000
MC/DC0%0/2
$rd->{$d} == 0 or $rd->{$d} == 1
$rd->{$d} == 0 $rd->{$d} == 1
Truth table0%0/3
A or B
A= $rd->{$d} == 0B= $rd->{$d} == 1
ABresult
1X1
011
000
205 0 $c+=$rd->{$d};
206 }
207 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('only one of duration, auto_renew and not_renew attributes can be set for .PT domain name renew') if $c > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $c > 1 0 0 0
208  
209 0 my $mes=$epp->message();
210 0 my $eid=$mes->command_extension_register('ptdomain', 'renew');
211 0 my @n=add_roid($rd->{roid});
212 0 ▶ push @n,['ptdomain:autoRenew',$rd->{auto_renew}] if Net::DRI::Util::has_key($rd,'auto_renew');
Branch: 1 branch
BranchTrueFalseTotal
if Net::DRI::Util::has_key($rd, "auto_renew") 0 0 0
213 0 ▶ push @n,['ptdomain:notRenew',$rd->{not_renew}] if Net::DRI::Util::has_key($rd,'not_renew');
Branch: 1 branch
BranchTrueFalseTotal
if Net::DRI::Util::has_key($rd, "not_renew") 0 0 0
214 0 $mes->command_extension($eid,\@n);
215 0 return;
216 }
217  
218 sub renounce
219 {
220 0 ▶ my ($epp,$domain,$rd)=@_;
Subroutine renounce: not called CC=2 SCAR=17.9
Pod undocumented
221  
222 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('roid attribute required for .PT domain name renounce') unless (Net::DRI::Util::has_key($rd,'roid'));
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rd, "roid") 0 0 0
223  
224 0 my $mes=$epp->message();
225 0 my $eid=$mes->command_extension_register('ptdomain', 'renounce');
226 0 my @n=(['ptdomain:name',$domain]);
227 0 push @n,add_roid($rd->{roid});
228 0 push @n,['ptdomain:clTRID',$mes->cltrid()];
229 0 $mes->command_extension($eid,\@n);
230 0 return;
231 }
232  
233 sub delete ## no critic (Subroutines::ProhibitBuiltinHomonyms)
234 {
235 0 ▶ my ($epp,$domain,$rd)=@_;
Subroutine delete: not called CC=2 SCAR=17.9
Pod undocumented
236  
237 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('roid attribute required for .PT domain name delete') unless (Net::DRI::Util::has_key($rd,'roid'));
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rd, "roid") 0 0 0
238  
239 0 my $mes=$epp->message();
240 0 my $eid=$mes->command_extension_register('ptdomain', 'delete');
241 0 my @n=add_roid($rd->{roid});
242 0 $mes->command_extension($eid,\@n);
243 0 return;
244 }
245  
246 sub transfer_request
247 {
248 0 ▶ my ($epp,$domain,$rd)=@_;
Subroutine transfer_request: not called CC=2 SCAR=17.9
Pod undocumented
249  
250 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('you have to specify authinfo for .PT domain transfer (mapped to transferKey)') unless Net::DRI::Util::has_auth($rd);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_auth($rd) 0 0 0
251  
252 0 my $mes=$epp->message();
253 0 my $eid=$mes->command_extension_register('ptdomain', 'transfer');
254 0 $mes->command_extension($eid,['ptdomain:transferKey',$rd->{"auth"}->{"pw"}]);
255 0 return;
256 }
257  
258 ####################################################################################################
259 1 1;
« DRI/Protocol/EPP/Extensions/Afilias/Trademark.pm ↑ Summary DRI/Transport.pm »