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

filter: Statementstmt 13.5% 19 / 140 Branchbran 0.0% 0 / 78 Conditioncond 0.0% 0 / 27 MC/DCmcdc 0.0% 0 / 16 Subroutinesub 31.5% 6 / 19 Podpod 0.0% 0 / 13 totaltotal 8.5% 25 / 293 CC 59 SCAR 49.0
CC
59
Cov
8%
domain_nom_ext
420.0
list
90.0
handshake_parse
42.0
CRAP 134.4
« DRI/Protocol/EPP/Extensions/CZ/Contact.pm ↑ Summary DRI/Data/Contact/SIDN.pm »
1 ## Domain Registry Interface, .UK EPP Domain commands
2 ##
3 ## Copyright (c) 2008-2010,2013-2014,2016,2018-2019 Patrick Mevzek <netdri@dotandco.com>. All rights reserved.
4 ## (c) 2013 Michael Holloway <michael@thedarkwinter.com>. All rights reserved.
5 ##
6 ## This file is part of Net::DRI
7 ##
8 ## Net::DRI is free software; you can redistribute it and/or modify
9 ## it under the terms of the GNU General Public License as published by
10 ## the Free Software Foundation; either version 2 of the License, or
11 ## (at your option) any later version.
12 ##
13 ## See the LICENSE file that comes with this distribution for more details.
14 ####################################################################################################
15  
16 package Net::DRI::Protocol::EPP::Extensions::Nominet::Domain;
17  
18 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use warnings;
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 1 ▶use Net::DRI::Protocol::EPP::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use Net::DRI::Protocol::EPP::Core::Domain;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 =pod
27  
28 =head1 NAME
29  
30 Net::DRI::Protocol::EPP::Extensions::Nominet::Domain - .UK EPP Domain commands 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>netdri@dotandco.comE<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>
47  
48 =head1 AUTHOR
49  
50 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
51  
52 =head1 COPYRIGHT
53  
54 Copyright (c) 2008-2010,2013-2014,2016,2018-2019 Patrick Mevzek <netdri@dotandco.com>.
55 (c) 2013 Michael Holloway <michael@thedarkwinter.com>.
56 All rights reserved.
57  
58 This program is free software; you can redistribute it and/or modify
59 it under the terms of the GNU General Public License as published by
60 the Free Software Foundation; either version 2 of the License, or
61 (at your option) any later version.
62  
63 See the LICENSE file that comes with this distribution for more details.
64  
65 =cut
66  
67 ####################################################################################################
68 sub register_commands
69 0 ▶{
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
70 0 my ($class,$version)=@_;
71 0 my %tmp=(
72 info => [ undef, \&info_parse ],
73 create => [ \&create ],
74 update => [\&update],
75 unrenew => [\&unrenew, \&Net::DRI::Protocol::EPP::Core::Domain::renew_parse ],
76 list => [\&list, \&list_parse ],
77 lock => [\&lock],
78 transfer_start => [\&release],
79 transfer_accept => [\&handshake_accept, \&handshake_parse],
80 transfer_refuse => [\&handshake_reject],
81 );
82 0 return { 'domain' => \%tmp };
83 }
84  
85 ####################################################################################################
86 ########### Query commands
87  
88  
89 sub info_parse
90 0 ▶{
Subroutine info_parse: not called CC=5 SCAR=34.0
Pod undocumented
91 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
92 0 my $mes=$po->message();
93 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
94  
95 0 my $infdata=$mes->get_extension('domain-nom-ext','infData');
96 0 ▶ return unless $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless $infdata 0 0 0
97  
98 0 foreach my $el (Net::DRI::Util::xml_list_children($infdata))
99 {
100 0 my ($name,$c)=@$el;
101 0 ▶ next unless $name =~ m/^(reg-status|first-bill|recur-bill|auto-bill|next-bill|auto-period|next-period|notes|reseller|renew-not-required)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $name =~ /^(reg-status|first-bill|recur-bill|auto-bill|next-bill|auto-period|next-period|notes|reseller|renew-not-required)$/ 0 0 0
102 0 $rinfo->{domain}->{$oname}->{$name} = $c->textContent();
103 }
104 0 return;
105 }
106  
107 sub list_parse
108 0 ▶{
Subroutine list_parse: not called CC=5 SCAR=34.0
Pod undocumented
109 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
110 0 my $mes=$po->message();
111 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
112 0 my $infdata=$mes->get_response('std-list','listData');
113 0 ▶ return unless $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless $infdata 0 0 0
114 0 $rinfo->{domain_list}->{0}->{total} = $infdata->getAttribute('noDomains');
115 0 foreach my $el (Net::DRI::Util::xml_list_children($infdata))
116 {
117 0 my ($name,$c)=@$el;
118 0 ▶ push @{$rinfo->{domain_list}->{0}->{domains}}, $c->textContent() if $name eq 'domainName';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "domainName" 0 0 0
119 }
120 0 return;
121 }
122  
123 sub handshake_parse
124 0 ▶{
Subroutine handshake_parse: not called CC=6 SCAR=37.4
Pod undocumented
125 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
126 0 my $mes=$po->message();
127 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
128 0 ▶ return unless my $infdata=$mes->get_response('std-handshake','hanData');
Branch: 1 branch
BranchTrueFalseTotal
unless my $infdata = $mes->get_response("std-handshake", "hanData") 0 0 0
129 0 my $ns = $mes->ns('std-handshake');
130 0 ▶ return unless my $dl = $infdata->getChildrenByTagNameNS($ns,'domainListData')->shift();
Branch: 1 branch
BranchTrueFalseTotal
unless my $dl = $infdata->getChildrenByTagNameNS($ns, "domainListData")->shift 0 0 0
131 0 $rinfo->{domain_list}->{0}->{total} = $dl->getAttribute('noDomains');
132 0 foreach my $el (Net::DRI::Util::xml_list_children($dl))
133 {
134 0 my ($name,$c)=@$el;
135 0 ▶ push @{$rinfo->{domain_list}->{0}->{domains}}, $c->textContent() if $name eq 'domainName';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "domainName" 0 0 0
136 }
137 0 return;
138 }
139  
140 ############ Transform commands ####################################################################
141  
142 sub domain_nom_ext
143 0 ▶{
Subroutine domain_nom_ext: not called CC=20 SCAR=60.4
Pod undocumented
144 0 my $rd=shift;
145 0 my @n;
146 #TODO Validate these fields?
147 my @errs;
148 0 ▶ foreach (qw/first-bill recur-bill/) { push @errs, "$_ [$rd->{$_}]" if ($rd->{$_} && $rd->{$_} !~ m/^(bc|th)$/); }
Branch: 1 branch
BranchTrueFalseTotal
if $rd->{$_} and not $rd->{$_} =~ /^(bc|th)$/ 0 0 0
Condition0%0/3
$rd->{$_} and not $rd->{$_} =~ /^(bc|th)$/
!ll&&!rl&&r
000
MC/DC0%0/2
$rd->{$_} and not $rd->{$_} =~ /^(bc|th)$/
$rd->{$_} not $rd->{$_} =~ /^(bc|th)$/
Truth table0%0/3
A and not(B)
A= $rd->{$_}B= not $rd->{$_} =~ /^(bc|th)$/
ABresult
0X0
100
111
149 0 ▶ foreach (qw/auto-bill next-bill/) { push @errs, "$_ [$rd->{$_}]" if ($rd->{$_} && !($rd->{$_} =~ /^[+]?\d+$/ && $rd->{$_}<183)); }
Branch: 1 branch
BranchTrueFalseTotal
if $rd->{$_} and not $rd->{$_} =~ /^[+]?\d+$/ && $rd->{$_} < 183 0 0 0
Condition0%0/6
$rd->{$_} and not $rd->{$_} =~ /^[+]?\d+$/ && $rd->{$_} < 183
!ll&&!rl&&r
000
$rd->{$_} =~ /^[+]?\d+$/ && $rd->{$_} < 183
!ll&&!rl&&r
000
MC/DC0%0/3
$rd->{$_} and not $rd->{$_} =~ /^[+]?\d+$/ && $rd->{$_} < 183
$rd->{$_} $rd->{$_} =~ /^[+]?\d+$/ $rd->{$_} < 183
Truth table0%0/4
A and not(B && C)
A= $rd->{$_}B= $rd->{$_} =~ /^[+]?\d+$/C= $rd->{$_} < 183
ABCresult
0XX0
1110
10X1
1101
150 0 ▶ foreach (qw/auto-period next-period/) { push @errs, "$_ [$rd->{$_}]" if ($rd->{$_} && !($rd->{$_} =~ /^[+]?\d+$/ && $rd->{$_}<10)); }
Branch: 1 branch
BranchTrueFalseTotal
if $rd->{$_} and not $rd->{$_} =~ /^[+]?\d+$/ && $rd->{$_} < 10 0 0 0
Condition0%0/6
$rd->{$_} and not $rd->{$_} =~ /^[+]?\d+$/ && $rd->{$_} < 10
!ll&&!rl&&r
000
$rd->{$_} =~ /^[+]?\d+$/ && $rd->{$_} < 10
!ll&&!rl&&r
000
MC/DC0%0/3
$rd->{$_} and not $rd->{$_} =~ /^[+]?\d+$/ && $rd->{$_} < 10
$rd->{$_} $rd->{$_} =~ /^[+]?\d+$/ $rd->{$_} < 10
Truth table0%0/4
A and not(B && C)
A= $rd->{$_}B= $rd->{$_} =~ /^[+]?\d+$/C= $rd->{$_} < 10
ABCresult
0XX0
1110
10X1
1101
151 0 foreach (qw/renew-not-required/)
152 {
153 0 ▶ next unless $rd->{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless $rd->{$_} 0 0 0
154 0 ▶ $rd->{$_} = 'Y' if $rd->{$_} =~ m/^(1|Y|YES|TRUE)$/i;
Branch: 1 branch
BranchTrueFalseTotal
if $rd->{$_} =~ /^(1|Y|YES|TRUE)$/i 0 0 0
155 0 ▶ $rd->{$_} = 'N' if $rd->{$_} =~ m/^(0|N|NO|FALSE)$/i;
Branch: 1 branch
BranchTrueFalseTotal
if $rd->{$_} =~ /^(0|N|NO|FALSE)$/i 0 0 0
156 0 ▶ push @errs, "$_ [$rd->{$_}]" if $rd->{$_} !~ m/^(Y|N)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $rd->{$_} =~ /^(Y|N)$/ 0 0 0
157 }
158 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Invalid domain information: '.join('/',@errs)) if @errs;
Branch: 1 branch
BranchTrueFalseTotal
if @errs 0 0 0
159  
160 0 foreach (qw/first-bill recur-bill auto-bill next-bill notes reseller auto-period next-period renew-not-required/) {
161 0 my $f = $_;
162 0 ▶ push @n, ['domain-nom-ext:'.$f, $rd->{$_}] if defined $rd->{$_};
Branch: 1 branch
BranchTrueFalseTotal
if defined $rd->{$_} 0 0 0
163 }
164 0 return @n;
165 }
166  
167 0 ▶sub create {
Subroutine create: not called CC=2 SCAR=17.9
Pod undocumented
168 0 my ($epp,$domain,$rd)=@_;
169 0 undef $rd->{'renew-not-required'}; # only for updates
170 0 my @n = domain_nom_ext($rd);
171 0 ▶ return unless @n;
Branch: 1 branch
BranchTrueFalseTotal
unless @n 0 0 0
172 0 $epp->message()->command_extension('domain-nom-ext', ['create', @n]);
173 0 return;
174 }
175  
176 0 ▶sub update {
Subroutine update: not called CC=5 SCAR=34.0
Pod undocumented
177 0 my ($epp,$domain,$todo)=@_;
178 0 my $rd;
179 0 foreach (qw/first-bill recur-bill auto-bill next-bill notes reseller auto-period next-period renew-not-required/) {
180 0 ▶ $rd->{$_} = $todo->set($_) if defined $todo->set($_);
Branch: 1 branch
BranchTrueFalseTotal
if defined $todo->set($_) 0 0 0
181 }
182 0 ▶ return unless $rd;
Branch: 1 branch
BranchTrueFalseTotal
unless $rd 0 0 0
183 0 my @n = domain_nom_ext($rd);
184 0 ▶ return unless @n;
Branch: 1 branch
BranchTrueFalseTotal
unless @n 0 0 0
185 0 $epp->message()->command_extension('domain-nom-ext', ['update', @n]);
186 0 return;
187 }
188  
189 sub list
190 0 ▶{
Subroutine list: not called CC=9 SCAR=45.0
Pod undocumented
191 0 my ($epp,$rd)=@_;
192 0 my $mes=$epp->message();
193 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('month or expiry is required') unless $rd->{regMonth} || $rd->{exMonth};
Branch: 1 branch
BranchTrueFalseTotal
unless $rd->{"regMonth"} or $rd->{"exMonth"} 0 0 0
Condition0%0/3
$rd->{"regMonth"} or $rd->{"exMonth"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$rd->{"regMonth"} or $rd->{"exMonth"}
$rd->{"regMonth"} $rd->{"exMonth"}
Truth table0%0/3
A or B
A= $rd->{"regMonth"}B= $rd->{"exMonth"}
ABresult
1X1
011
000
194 0 foreach (qw/regMonth exMonth/)
195 {
196 0 ▶ $rd->{$_} = $rd->{$_}->format_cldr('yyyy-MM') if UNIVERSAL::isa($rd->{$_},'DateTime');
Branch: 1 branch
BranchTrueFalseTotal
if UNIVERSAL::isa($rd->{$_}, "DateTime") 0 0 0
197 0 ▶ Net::DRI::Exception::usererr_invalid_parameters($_) if $rd->{$_} and $rd->{$_} !~ m/^[0-9]{4}-[0-9]{2}$/;
Branch: 1 branch
BranchTrueFalseTotal
if $rd->{$_} and not $rd->{$_} =~ /^[0-9]{4}-[0-9]{2}$/ 0 0 0
Condition0%0/3
$rd->{$_} and not $rd->{$_} =~ /^[0-9]{4}-[0-9]{2}$/
!ll&&!rl&&r
000
MC/DC0%0/2
$rd->{$_} and not $rd->{$_} =~ /^[0-9]{4}-[0-9]{2}$/
$rd->{$_} not $rd->{$_} =~ /^[0-9]{4}-[0-9]{2}$/
Truth table0%0/3
A and not(B)
A= $rd->{$_}B= not $rd->{$_} =~ /^[0-9]{4}-[0-9]{2}$/
ABresult
0X0
100
111
198 }
199  
200 0 $mes->command(['info','l:list',sprintf('xmlns:l="%s"',$mes->ns('std-list'))]);
201 0 my @d;
202 0 ▶ push @d, ['l:month',$rd->{'regMonth'}] if $rd->{regMonth};
Branch: 1 branch
BranchTrueFalseTotal
if $rd->{"regMonth"} 0 0 0
203 0 ▶ push @d, ['l:expiry',$rd->{'exMonth'}] if $rd->{exMonth};
Branch: 1 branch
BranchTrueFalseTotal
if $rd->{"exMonth"} 0 0 0
204 0 $mes->command_body(\@d);
205 0 return;
206 }
207  
208 ## Warning: this can also be used for multiple domain names at once,
209 ## see http://www.nominet.org.uk/registrars/systems/nominetepp/Unrenew/
210 ## However, if we accept that, we will probably have to tweak Core::Domain::renew_parse
211 ## to handle multiple renData nodes in the response.
212 sub unrenew
213 0 ▶{
Subroutine unrenew: not called CC=3 SCAR=24.8
Pod undocumented
214 0 my ($epp,$domain,$rd)=@_;
215 0 my $mes=$epp->message();
216 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Domain name required') unless $domain;
Branch: 1 branch
BranchTrueFalseTotal
unless $domain 0 0 0
217 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('domain') unless Net::DRI::Util::is_hostname($domain);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::is_hostname($domain) 0 0 0
218 0 $mes->command(['update','u:unrenew',sprintf('xmlns:u="%s"',$mes->ns('std-unrenew'))]);
219 0 my @d=(['u:domainName',$domain]);
220 0 $mes->command_body(\@d);
221 0 return;
222 }
223  
224 # called by domain_transfer_start, can release a domain or an account here
225 sub release
226 0 ▶{
Subroutine release: not called CC=6 SCAR=37.4
Pod undocumented
227 0 my ($epp,$domain,$rd)=@_;
228 0 my $mes=$epp->message();
229 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Domain name required, specify alldomains.co.uk if you are releasing an account') unless $domain;
Branch: 1 branch
BranchTrueFalseTotal
unless $domain 0 0 0
230 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('registar_tag is required') unless $rd->{registrar_tag};
Branch: 1 branch
BranchTrueFalseTotal
unless $rd->{"registrar_tag"} 0 0 0
231 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('To release an account you must specify alldomains.co.uk as the domain name') if defined $rd->{account_id} && $domain ne 'alldomains.co.uk'; # failsafe
Branch: 1 branch
BranchTrueFalseTotal
if defined $rd->{"account_id"} and $domain ne "alldomains.co.uk" 0 0 0
Condition0%0/3
defined $rd->{"account_id"} and $domain ne "alldomains.co.uk"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $rd->{"account_id"} and $domain ne "alldomains.co.uk"
defined $rd->{"account_id"} $domain ne "alldomains.co.uk"
Truth table0%0/3
A and B
A= defined $rd->{"account_id"}B= $domain ne "alldomains.co.uk"
ABresult
0X0
100
111
232 0 $mes->command(['update','r:release',sprintf('xmlns:r="%s"',$mes->ns('std-release'))]);
233 0 ▶ my @d=((defined $rd->{account_id} ? ['r:registrant',$rd->{account_id}] : ['r:domainName',$domain]),['r:registrarTag',$rd->{registrar_tag}]);
Branch: 1 branch
BranchTrueFalseTotal
defined $rd->{'account_id'} ? : 0 0 0
234 0 $mes->command_body(\@d);
235 0 return;
236 }
237  
238 # called by domain_transfer_accept
239 sub handshake_accept
240 0 ▶{
Subroutine handshake_accept: not called CC=3 SCAR=24.8
Pod undocumented
241 0 my ($epp,$domain,$rd)=@_;
242 0 my $mes=$epp->message();
243 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('case_id is required') unless $rd->{case_id};
Branch: 1 branch
BranchTrueFalseTotal
unless $rd->{"case_id"} 0 0 0
244 0 $mes->command(['update','h:accept',sprintf('xmlns:h="%s"',$mes->ns('std-handshake'))]);
245 0 my @d=(['h:caseId',$rd->{case_id}]);
246 0 ▶ push @d, ['h:registrant',$rd->{'registrant'}] if $rd->{'registrant'};
Branch: 1 branch
BranchTrueFalseTotal
if $rd->{"registrant"} 0 0 0
247 0 $mes->command_body(\@d);
248 0 return;
249 }
250  
251 # called by domain_transfer_refuse
252 sub handshake_reject
253 0 ▶ {
Subroutine handshake_reject: not called CC=2 SCAR=17.9
Pod undocumented
254 0 my ($epp,$domain,$rd)=@_;
255 0 my $mes=$epp->message();
256 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('case_id is required') unless $rd->{case_id};
Branch: 1 branch
BranchTrueFalseTotal
unless $rd->{"case_id"} 0 0 0
257 0 $mes->command(['update','h:reject',sprintf('xmlns:h="%s"',$mes->ns('std-handshake'))]);
258 0 my @d=(['h:caseId',$rd->{case_id}]);
259 0 $mes->command_body(\@d);
260 0 return;
261 }
262  
263 sub lock ## no critic (Subroutines::ProhibitBuiltinHomonyms)
264 0 ▶{
Subroutine lock: not called CC=4 SCAR=30.0
Pod undocumented
265 0 my ($epp,$domain,$rd)=@_;
266 0 my $mes=$epp->message();
267 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Domain name required') unless $domain;
Branch: 1 branch
BranchTrueFalseTotal
unless $domain 0 0 0
268 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('type must be set to investigation to lock a domain') unless $rd->{type} && $rd->{type} eq 'investigation';
Branch: 1 branch
BranchTrueFalseTotal
unless $rd->{"type"} and $rd->{"type"} eq "investigation" 0 0 0
Condition0%0/3
$rd->{"type"} and $rd->{"type"} eq "investigation"
!ll&&!rl&&r
000
MC/DC0%0/2
$rd->{"type"} and $rd->{"type"} eq "investigation"
$rd->{"type"} $rd->{"type"} eq "investigation"
Truth table0%0/3
A and B
A= $rd->{"type"}B= $rd->{"type"} eq "investigation"
ABresult
0X0
100
111
269 0 $mes->command(['update','l:lock',sprintf('xmlns:l="%s"',$mes->ns('std-locks')). ' object="domain" type="investigation"']);
270 0 my @d=(['l:domainName',$domain]);
271 0 $mes->command_body(\@d);
272 0 return;
273 }
274  
275 ####################################################################################################
276 1 1;
« DRI/Protocol/EPP/Extensions/CZ/Contact.pm ↑ Summary DRI/Data/Contact/SIDN.pm »