DRI/Protocol/EPP/Extensions/NSgroup.pm

filter: Statementstmt 12.0% 13 / 108 Branchbran 0.0% 0 / 38 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 25.0% 4 / 16 Podpod 0.0% 0 / 12 totaltotal 8.8% 17 / 192 CC 29 SCAR 37.2
CC
29
Cov
8%
build_command
90.0
add_nsname
56.0
check_parse
42.0
CRAP 41.2
« DRI/Protocol/EPP/Extensions/ARNES/Contact.pm ↑ Summary DRI/Protocol/EPP/Extensions/VeriSign/ClientAttributes.pm »
1 ## Domain Registry Interface, EPP NSgroup extension commands
2 ## (based on .BE Registration_guidelines_v4_7_1)
3 ##
4 ## Copyright (c) 2005-2010,2013,2018 Patrick Mevzek <netdri@dotandco.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::NSgroup;
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  
24 =pod
25  
26 =head1 NAME
27  
28 Net::DRI::Protocol::EPP::Extensions::NSgroup - EPP NSgroup 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) 2005-2010,2013,2018 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 %tmp1=( create => [ \&create ],
70 check => [ \&check, \&check_parse ],
71 info => [ \&info, \&info_parse ],
72 delete => [ \&delete ],
73 update => [ \&update ],
74 );
75  
76 0 $tmp1{check_multi}=$tmp1{check};
77
78 0 return { 'nsgroup' => \%tmp1 };
79 }
80  
81 0 ▶sub capabilities_add { return ('nsgroup_update','ns',['set']); }
Subroutine capabilities_add: not called CC=1 SCAR=6.9
Pod undocumented
82  
83 sub ns
84 {
85 0 ▶ my ($mes)=@_;
Subroutine ns: not called CC=2 SCAR=17.9
Pod undocumented
86 0 my $ns=$mes->ns('nsgroup');
87 0 ▶ return defined $ns? $ns : 'http://www.dns.be/xml/epp/nsgroup-1.0';
Branch: 1 branch
BranchTrueFalseTotal
defined $ns ? : 0 0 0
88 }
89  
90 sub build_command
91 {
92 0 ▶ my ($epp,$msg,$command,$hosts)=@_;
Subroutine build_command: not called CC=9 SCAR=45.0
Pod undocumented
93  
94 0 my @gn;
95 0 ▶ foreach my $h ( grep { defined } (ref $hosts eq 'ARRAY')? @$hosts : ($hosts))
Branch: 1 branch
BranchTrueFalseTotal
ref $hosts eq 'ARRAY' ? : 0 0 0
96 {
97 0 ▶ my $gn=Net::DRI::Util::isa_nsgroup($h)? $h->name() : $h;
Branch: 1 branch
BranchTrueFalseTotal
Net::DRI::Util::isa_nsgroup($h) ? : 0 0 0
98 0 ▶ Net::DRI::Exception->die(1,'protocol/EPP',10,'Invalid NSgroup name: '.$gn) unless (defined $gn && $gn && ! ref $gn && Net::DRI::Util::xml_is_normalizedstring($gn,1,100));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $gn and $gn and not ref $gn and Net::DRI::Util::xml_is_normalizedstring($gn, 1, 100) 0 0 0
Condition0%0/9
defined $gn and $gn and not ref $gn and Net::DRI::Util::xml_is_normalizedstring($gn, 1, 100)
!ll&&!rl&&r
000
defined $gn and $gn and not ref $gn
!ll&&!rl&&r
000
defined $gn and $gn
!ll&&!rl&&r
000
MC/DC0%0/4
defined $gn and $gn and not ref $gn and Net::DRI::Util::xml_is_normalizedstring($gn, 1, 100)
defined $gn $gn not ref $gn Net::DRI::Util::xml_is_normalizedstring($gn, 1, 100)
Truth table0%0/5
A and B and not(C) and D
A= defined $gnB= $gnC= not ref $gnD= Net::DRI::Util::xml_is_normalizedstring($gn, 1, 100)
ABCDresult
0XXX0
10XX0
110X0
11100
11111
99 0 push @gn,$gn;
100 }
101  
102 0 ▶ Net::DRI::Exception->die(1,'protocol/EPP',2,'NSgroup name needed') unless @gn;
Branch: 1 branch
BranchTrueFalseTotal
unless @gn 0 0 0
103 0 $msg->command([$command,'nsgroup:'.$command, $msg->nsattrs('nsgroup')]);
104 0 return map { ['nsgroup:name',$_] } @gn;
105 }
106  
107 sub add_nsname
108 {
109 0 ▶ my ($ns)=@_;
Subroutine add_nsname: not called CC=7 SCAR=40.3
Pod undocumented
110 0 ▶ return () unless defined $ns;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ns 0 0 0
111 0 my @names;
112 0 ▶ if (! ref $ns)
Branch: 3 branches
BranchTrueFalseTotal
if (not ref $ns) { } 0 0 0
elsif (ref $ns eq 'ARRAY') { } 0 0 0
elsif (Net::DRI::Util::isa_nsgroup($ns)) { } 0 0 0
113 {
114 0 @names=($ns);
115 } elsif (ref $ns eq 'ARRAY')
116 {
117 0 @names=@$ns;
118 } elsif (Net::DRI::Util::isa_nsgroup($ns))
119 {
120 0 @names=$ns->get_names();
121 }
122  
123 0 foreach my $n (@names)
124 {
125 0 ▶ next if Net::DRI::Util::is_hostname($n);
Branch: 1 branch
BranchTrueFalseTotal
if Net::DRI::Util::is_hostname($n) 0 0 0
126 0 Net::DRI::Exception->die(1,'protocol/EPP',10,'Invalid host name: '.$n);
127 }
128  
129 0 return map { ['nsgroup:ns',$_] } @names;
130 }
131  
132 ####################################################################################################
133 ########### Query commands
134  
135 sub check
136 {
137 0 ▶ my ($epp,@hosts)=@_;
Subroutine check: not called CC=1 SCAR=6.9
Pod undocumented
138 0 my $mes=$epp->message();
139 0 my @d=build_command($epp,$mes,'check',\@hosts);
140 0 $mes->command_body(\@d);
141 0 return;
142 }
143  
144 sub check_parse
145 {
146 0 ▶ my ($po,$otype,$oaction,$oname,$rinfo)=@_;
Subroutine check_parse: not called CC=6 SCAR=37.4
Pod undocumented
147 0 my $mes=$po->message();
148 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
149  
150 0 my $ns=$mes->ns('nsgroup');
151 0 my $chkdata=$mes->get_response('nsgroup', 'chkData');
152 0 ▶ return unless defined $chkdata;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $chkdata 0 0 0
153  
154 0 foreach my $cd ($chkdata->getChildrenByTagNameNS($ns,'cd'))
155 {
156 0 my $nsgroup;
157 0 foreach my $el (Net::DRI::Util::xml_list_children($cd))
158 {
159 0 my ($n,$c)=@$el;
160 0 ▶ if ($n eq 'name')
Branch: 1 branch
BranchTrueFalseTotal
if ($n eq "name") 0 0 0
161 {
162 0 $nsgroup=$c->textContent();
163 0 $rinfo->{nsgroup}->{$nsgroup}->{exist}=1-Net::DRI::Util::xml_parse_boolean($c->getAttribute('avail'));
164 0 $rinfo->{nsgroup}->{$nsgroup}->{action}='check';
165 }
166 }
167 }
168 0 return;
169 }
170  
171 sub info
172 {
173 0 ▶ my ($epp,$hosts)=@_;
Subroutine info: not called CC=1 SCAR=6.9
Pod undocumented
174 0 my $mes=$epp->message();
175 0 my @d=build_command($epp,$mes,'info',$hosts);
176 0 $mes->command_body(\@d);
177 0 return;
178 }
179  
180 sub info_parse
181 {
182 0 ▶ my ($po,$otype,$oaction,$oname,$rinfo)=@_;
Subroutine info_parse: not called CC=6 SCAR=37.4
Pod undocumented
183 0 my $mes=$po->message();
184 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
185  
186 0 my $infdata=$mes->get_response('nsgroup', 'infData');
187 0 ▶ return unless defined $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $infdata 0 0 0
188  
189 0 my $ns=$po->create_local_object('hosts');
190 0 foreach my $el (Net::DRI::Util::xml_list_children($infdata))
191 {
192 0 my ($name,$c)=@$el;
193 0 ▶ if ($name eq 'name')
Branch: 2 branches
BranchTrueFalseTotal
if ($name eq 'name') { } 0 0 0
elsif ($name eq 'ns') { } 0 0 0
194 {
195 0 $oname=$c->textContent();
196 0 $ns->name($oname);
197 0 $rinfo->{nsgroup}->{$oname}->{exist}=1;
198 0 $rinfo->{nsgroup}->{$oname}->{action}='info';
199 } elsif ($name eq 'ns')
200 {
201 0 $ns->add($c->textContent());
202 }
203 }
204  
205 0 $rinfo->{nsgroup}->{$oname}->{self}=$ns;
206 0 return;
207 }
208  
209 ############ Transform commands
210  
211 sub create
212 {
213 0 ▶ my ($epp,$hosts)=@_;
Subroutine create: not called CC=1 SCAR=6.9
Pod undocumented
214 0 my $mes=$epp->message();
215 0 my @d=build_command($epp,$mes,'create',$hosts);
216 0 push @d,add_nsname($hosts);
217 0 $mes->command_body(\@d);
218 0 return;
219 }
220  
221 sub delete ## no critic (Subroutines::ProhibitBuiltinHomonyms)
222 {
223 0 ▶ my ($epp,$hosts)=@_;
Subroutine delete: not called CC=1 SCAR=6.9
Pod undocumented
224 0 my $mes=$epp->message();
225 0 my @d=build_command($epp,$mes,'delete',$hosts);
226 0 $mes->command_body(\@d);
227 0 return;
228 }
229  
230 sub update
231 {
232 0 ▶ my ($epp,$hosts,$todo)=@_;
Subroutine update: not called CC=4 SCAR=30.0
Pod undocumented
233 0 my $mes=$epp->message();
234  
235 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
236  
237 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
238 {
239 0 Net::DRI::Exception->die(0,'protocol/EPP',11,'Only ns set available for nsgroup');
240 }
241  
242 0 my $ns=$todo->set('ns');
243 0 my @d=build_command($epp,$mes,'update',$hosts);
244 0 push @d,add_nsname($ns);
245 0 $mes->command_body(\@d);
246 0 return;
247 }
248  
249 ####################################################################################################
250 1 1;
« DRI/Protocol/EPP/Extensions/ARNES/Contact.pm ↑ Summary DRI/Protocol/EPP/Extensions/VeriSign/ClientAttributes.pm »