DRI/Protocol/EPP/Extensions/NO/Host.pm

filter: Statementstmt 6.8% 10 / 147 Branchbran 0.0% 0 / 70 Conditioncond 0.0% 0 / 36 MC/DCmcdc 0.0% 0 / 21 Subroutinesub 30.0% 3 / 10 Podpod 0.0% 0 / 7 totaltotal 4.4% 13 / 291 CC 59 SCAR 59.4
CC
59
Cov
4%
update
756.0
create
272.0
parse_info
72.0
CRAP 380.7
« DRI/Protocol/RRI/RegistryMessage.pm ↑ Summary DRI/Protocol/Whois/Domain/common.pm »
1 ## Domain Registry Interface, .NO Host extensions
2 ##
3 ## Copyright (c) 2008,2010,2013-2014 UNINETT Norid AS, E<lt>http://www.norid.noE<gt>,
4 ## Trond Haugen E<lt>info@norid.noE<gt>
5 ## Copyright (c) 2016 Patrick Mevzek <netdri@dotandco.com>.
6 ## All rights reserved.
7 ##
8 ## This file is part of Net::DRI
9 ##
10 ## Net::DRI is free software; you can redistribute it and/or modify
11 ## it under the terms of the GNU General Public License as published by
12 ## the Free Software Foundation; either version 2 of the License, or
13 ## (at your option) any later version.
14 ##
15 ## See the LICENSE file that comes with this distribution for more details.
16 ####################################################################################################
17  
18 package Net::DRI::Protocol::EPP::Extensions::NO::Host;
19  
20 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 =pod
26  
27 =head1 NAME
28  
29 Net::DRI::Protocol::EPP::Extensions::NO::Host - .NO Host Extensions for Net::DRI
30  
31 =head1 DESCRIPTION
32  
33 Please see the README file for details.
34  
35 =head1 SUPPORT
36  
37 For now, support questions should be sent to:
38  
39 E<lt>netdri@dotandco.comE<gt>
40  
41 Please also see the SUPPORT file in the distribution.
42  
43 =head1 SEE ALSO
44  
45 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
46  
47 =head1 AUTHOR
48  
49 Trond Haugen, E<lt>info@norid.noE<gt>
50  
51 =head1 COPYRIGHT
52  
53 Copyright (c) 2008,2010,2013-2014 UNINETT Norid AS, E<lt>http://www.norid.noE<gt>,
54 Trond Haugen E<lt>info@norid.noE<gt>
55 Copyright (c) 2016 Patrick Mevzek <netdri@dotandco.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  
69 sub register_commands {
70 0 ▶ my ( $class, $version ) = @_;
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
71 0 my %tmp = (
72 create => [ \&create, undef ],
73 update => [ \&update, undef ],
74 delete => [ \&facet, undef ],
75 check => [ \&facet, undef ],
76 info => [ \&info, \&parse_info ],
77 );
78  
79 0 return { 'host' => \%tmp };
80 }
81  
82 ####################################################################################################
83  
84 ##
85 # This facet method is generic and can be called from all object operations
86 #
87 sub build_facets {
88 0 ▶ my ( $epp, $rd ) = @_;
Subroutine build_facets: not called CC=5 SCAR=34.0
Pod undocumented
89  
90 0 my @e;
91 my $eid;
92  
93 0 my $mes = $epp->message();
94 0 ▶ if (exists($rd->{facets}) && defined($rd->{facets})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $rd->{"facets"} and defined $rd->{"facets"}) 0 0 0
Condition0%0/3
exists $rd->{"facets"} and defined $rd->{"facets"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $rd->{"facets"} and defined $rd->{"facets"}
exists $rd->{"facets"} defined $rd->{"facets"}
Truth table0%0/3
A and B
A= exists $rd->{"facets"}B= defined $rd->{"facets"}
ABresult
0X0
100
111
95 0 $eid = $mes->command_extension_register('no-ext-epp', 'extended');
96 0 foreach my $fkey (sort { $a cmp $b } keys(%{$rd->{facets}})) {
97 0 push @e, [ 'no-ext-epp:facet', { name => $fkey }, $rd->{facets}->{$fkey} ];
98 }
99 }
100 0 ▶ return $mes->command_extension( $eid, \@e ) if (@e);
Branch: 1 branch
BranchTrueFalseTotal
if @e 0 0 0
101 0 return;
102 }
103  
104  
105 sub facet {
106 0 ▶ my ( $epp, $o, $rd ) = @_;
Subroutine facet: not called CC=1 SCAR=6.9
Pod undocumented
107  
108 0 return build_facets( $epp, $rd );
109 }
110  
111  
112 sub parse_info {
113 0 ▶ my ( $po, $otype, $oaction, $oname, $rinfo ) = @_;
Subroutine parse_info: not called CC=8 SCAR=42.8
Pod undocumented
114 0 my $mes = $po->message();
115 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
116  
117 0 my $NS = $mes->ns('no-ext-host');
118  
119 0 my $condata = $mes->get_extension('no-ext-host','infData');
120 0 ▶ return unless $condata;
Branch: 1 branch
BranchTrueFalseTotal
unless $condata 0 0 0
121  
122 0 my @e = $condata->getElementsByTagNameNS( $NS, 'contact' );
123 0 ▶ return unless @e;
Branch: 1 branch
BranchTrueFalseTotal
unless @e 0 0 0
124  
125 # Contact is optional, may be single or multiple,
126 # return the contactIDs in an ARRAY
127 0 my @hc;
128 0 foreach my $el ( @e)
129 {
130 0 my $c = $el->getFirstChild();
131 0 my $v;
132 0 ▶ $v = $c->getData() if ($c);
Branch: 1 branch
BranchTrueFalseTotal
if $c 0 0 0
133 0 ▶ push @hc, $v if ($v);
Branch: 1 branch
BranchTrueFalseTotal
if $v 0 0 0
134 }
135 0 ▶ if ( @hc > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@hc > 0) 0 0 0
136 # multiple, return array
137 0 push @{$rinfo->{host}->{$oname}->{contact}}, @hc;
138 }
139 0 return;
140 }
141  
142 sub info {
143 0 ▶ my ( $epp, $ho, $rd ) = @_;
Subroutine info: not called CC=7 SCAR=40.3
Pod undocumented
144 0 my $mes = $epp->message();
145  
146 0 my $si;
147 0 ▶ $si = $rd->{sponsoringclientid} if (exists($rd->{sponsoringclientid}));
Branch: 1 branch
BranchTrueFalseTotal
if exists $rd->{"sponsoringclientid"} 0 0 0
148 0 my $fs;
149 0 ▶ $fs = $rd->{facets} if (exists($rd->{facets}));
Branch: 1 branch
BranchTrueFalseTotal
if exists $rd->{"facets"} 0 0 0
150  
151 0 ▶ return unless ( $si || $fs );
Branch: 1 branch
BranchTrueFalseTotal
unless $si or $fs 0 0 0
Condition0%0/3
$si or $fs
l!l&&r!l&&!r
000
MC/DC0%0/2
$si or $fs
$si $fs
Truth table0%0/3
A or B
A= $siB= $fs
ABresult
1X1
011
000
152  
153 0 my $r;
154  
155 0 ▶ if ($si) {
Branch: 1 branch
BranchTrueFalseTotal
if ($si) 0 0 0
156 0 my $eid = $mes->command_extension_register('no-ext-host', 'info' );
157 0 my @e;
158 0 push @e, [ 'no-ext-host:sponsoringClientID', $si ];
159 0 $r = $mes->command_extension( $eid, \@e );
160 }
161 0 ▶ if ($fs) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fs) 0 0 0
162 0 $r = facet( $epp, $ho, $rd );
163 }
164
165 0 return $r;
166 }
167  
168 sub create {
169 0 ▶ my ( $epp, $ho, $rd ) = @_;
Subroutine create: not called CC=16 SCAR=56.1
Pod undocumented
170 0 my $mes = $epp->message();
171  
172 0 ▶ return unless ((exists($rd->{contact}) && defined($rd->{contact})) || (exists($rd->{facets}) && defined($rd->{facets})));
Branch: 1 branch
BranchTrueFalseTotal
unless exists $rd->{"contact"} and defined $rd->{"contact"} or exists $rd->{"facets"} and defined $rd->{"facets"} 0 0 0
Condition0%0/9
exists $rd->{"contact"} and defined $rd->{"contact"} or exists $rd->{"facets"} and defined $rd->{"facets"}
l!l&&r!l&&!r
000
exists $rd->{"contact"} and defined $rd->{"contact"}
!ll&&!rl&&r
000
exists $rd->{"facets"} and defined $rd->{"facets"}
!ll&&!rl&&r
000
MC/DC0%0/4
exists $rd->{"contact"} and defined $rd->{"contact"} or exists $rd->{"facets"} and defined $rd->{"facets"}
exists $rd->{"contact"} defined $rd->{"contact"} exists $rd->{"facets"} defined $rd->{"facets"}
Truth table0%0/7
A and B or C and D
A= exists $rd->{"contact"}B= defined $rd->{"contact"}C= exists $rd->{"facets"}D= defined $rd->{"facets"}
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
173  
174 0 my $r;
175  
176 0 ▶ if (exists($rd->{contact}) && defined($rd->{contact})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $rd->{"contact"} and defined $rd->{"contact"}) 0 0 0
Condition0%0/3
exists $rd->{"contact"} and defined $rd->{"contact"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $rd->{"contact"} and defined $rd->{"contact"}
exists $rd->{"contact"} defined $rd->{"contact"}
Truth table0%0/3
A and B
A= exists $rd->{"contact"}B= defined $rd->{"contact"}
ABresult
0X0
100
111
177 0 my @e;
178 0 my $eid = $mes->command_extension_register('no-ext-host', 'create' );
179 0 my $c = $rd->{contact};
180 0 my $srid;
181
182 0 ▶ if ( ref($c) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $c eq 'ARRAY') { } 0 0 0
183 0 foreach my $cn (@$c) {
184 0 ▶ if (Net::DRI::Util::isa_contact($cn))
Branch: 1 branch
BranchTrueFalseTotal
if (Net::DRI::Util::isa_contact($cn)) { } 0 0 0
185 {
186 0 $srid = $cn->srid();
187 } else {
188 0 $srid = $cn;
189 }
190 0 push @e, [ 'no-ext-host:contact', $srid ];
191 }
192 } else {
193 # $c may be a contact set, contact object or a direct scalar
194 0 my @contacts;
195 0 ▶ if (Net::DRI::Util::isa_contactset($c)) {
Branch: 2 branches
BranchTrueFalseTotal
if (Net::DRI::Util::isa_contactset($c)) { } 0 0 0
elsif (Net::DRI::Util::isa_contact($c)) { } 0 0 0
196 0 foreach my $cn (sort { $a cmp $b } keys %{ $$c{'c'} } ) {
197 0 push @contacts, ${$$c{'c'}}{$cn}->[0]->srid();
198 }
199 } elsif (Net::DRI::Util::isa_contact($c)) {
200 0 @contacts = $c->srid();
201 } else {
202 0 @contacts = $c;
203 }
204 0 foreach my $srid (@contacts) {
205 0 push @e, [ 'no-ext-host:contact', $srid ];
206 }
207 }
208 0 $r = $mes->command_extension( $eid, \@e );
209 }
210  
211 # Add facet if any is set
212 0 ▶ if (exists($rd->{facets}) && defined($rd->{facets})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $rd->{"facets"} and defined $rd->{"facets"}) 0 0 0
Condition0%0/3
exists $rd->{"facets"} and defined $rd->{"facets"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $rd->{"facets"} and defined $rd->{"facets"}
exists $rd->{"facets"} defined $rd->{"facets"}
Truth table0%0/3
A and B
A= exists $rd->{"facets"}B= defined $rd->{"facets"}
ABresult
0X0
100
111
213 0 $r = facet( $epp, $ho, $rd );
214 }
215  
216 0 return $r;
217 }
218  
219 sub update {
220 0 ▶ my ( $epp, $ho, $todo ) = @_;
Subroutine update: not called CC=27 SCAR=66.3
Pod undocumented
221 0 my $mes = $epp->message();
222  
223 0 my $ca = $todo->add('contact');
224 0 my $cd = $todo->del('contact');
225 0 my $fs = $todo->set('facets');
226  
227 0 ▶ return unless ( $ca || $cd || $fs); # No updates asked
Branch: 1 branch
BranchTrueFalseTotal
unless $ca or $cd or $fs 0 0 0
Condition0%0/6
$ca or $cd or $fs
l!l&&r!l&&!r
000
$ca or $cd
l!l&&r!l&&!r
000
MC/DC0%0/3
$ca or $cd or $fs
$ca $cd $fs
Truth table0%0/4
A or B or C
A= $caB= $cdC= $fs
ABCresult
1XX1
01X1
0011
0000
228  
229 0 my $r;
230  
231 0 ▶ if ( $ca || $cd ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ca or $cd) 0 0 0
Condition0%0/3
$ca or $cd
l!l&&r!l&&!r
000
MC/DC0%0/2
$ca or $cd
$ca $cd
Truth table0%0/3
A or B
A= $caB= $cd
ABresult
1X1
011
000
232 0 my $eid = $mes->command_extension_register('no-ext-host', 'update' );
233  
234 0 my ( @n, @e, $c, $srid );
235  
236 0 ▶ if ( defined($ca) && $ca ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ca and $ca) 0 0 0
Condition0%0/3
defined $ca and $ca
!ll&&!rl&&r
000
MC/DC0%0/2
defined $ca and $ca
defined $ca $ca
Truth table0%0/3
A and B
A= defined $caB= $ca
ABresult
0X0
100
111
237 0 $c = $ca;
238 0 ▶ if ( ref($c) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $c eq 'ARRAY') { } 0 0 0
239 0 foreach my $cn (@$c) {
240 0 ▶ if (Net::DRI::Util::isa_contact($cn))
Branch: 1 branch
BranchTrueFalseTotal
if (Net::DRI::Util::isa_contact($cn)) { } 0 0 0
241 {
242 0 $srid = $cn->srid();
243 } else {
244 0 $srid = $cn;
245 }
246 0 push @e, [ 'no-ext-host:contact', $srid ];
247 }
248 } else {
249 # $c may be a contact set, contact object or a direct scalar
250 0 my @contacts;
251 0 ▶ if (Net::DRI::Util::isa_contactset($c)) {
Branch: 2 branches
BranchTrueFalseTotal
if (Net::DRI::Util::isa_contactset($c)) { } 0 0 0
elsif (Net::DRI::Util::isa_contact($c)) { } 0 0 0
252 0 foreach my $cn (sort { $a cmp $b } keys %{ $$c{'c'} } ) {
253 0 push @contacts, ${$$c{'c'}}{$cn}->[0]->srid();
254 }
255 } elsif (Net::DRI::Util::isa_contact($c)) {
256 0 @contacts = $c->srid();
257 } else {
258 0 @contacts = $c;
259 }
260 0 foreach my $srid (@contacts) {
261 0 push @e, [ 'no-ext-host:contact', $srid ];
262 }
263 }
264  
265 0 ▶ push @n, [ 'no-ext-host:add', @e ] if ( @e > 0 );
Branch: 1 branch
BranchTrueFalseTotal
if @e > 0 0 0 0
266 }
267 0 @e = undef;
268 0 ▶ if ( 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
269  
270 0 $c = $cd;
271 0 ▶ if ( ref($c) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $c eq 'ARRAY') { } 0 0 0
272 0 foreach my $cn (@$c) {
273 0 ▶ if (Net::DRI::Util::isa_contact($cn))
Branch: 1 branch
BranchTrueFalseTotal
if (Net::DRI::Util::isa_contact($cn)) { } 0 0 0
274 {
275 0 $srid = $cn->srid();
276 } else {
277 0 $srid = $cn;
278 }
279 0 push @e, [ 'no-ext-host:contact', $srid ];
280 }
281 } else {
282 # $c may be a contact set, contact object or a direct scalar
283 0 my @contacts;
284 0 ▶ if (Net::DRI::Util::isa_contactset($c)) {
Branch: 2 branches
BranchTrueFalseTotal
if (Net::DRI::Util::isa_contactset($c)) { } 0 0 0
elsif (Net::DRI::Util::isa_contact($c)) { } 0 0 0
285 0 foreach my $cn (sort { $a cmp $b } keys %{ $$c{'c'} } ) {
286 0 push @contacts, ${$$c{'c'}}{$cn}->[0]->srid();
287 }
288 } elsif (Net::DRI::Util::isa_contact($c)) {
289 0 @contacts = $c->srid();
290 } else {
291 0 @contacts = $c;
292 }
293 0 foreach my $srid (@contacts) {
294 0 push @e, [ 'no-ext-host:contact', $srid ];
295 }
296 }
297 0 ▶ push @n, [ 'no-ext-host:rem', @e ] if ( @e > 0 );
Branch: 1 branch
BranchTrueFalseTotal
if @e > 0 0 0 0
298 }
299 0 $r = $mes->command_extension( $eid, \@n );
300 }
301  
302 # Add facet if any is set
303 0 ▶ if ($fs) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fs) 0 0 0
304 0 my $rd;
305 0 $rd->{facets} = $fs;
306 0 $r = facet( $epp, $ho, $rd );
307 }
308 0 return $r;
309 }
310  
311 ####################################################################################################
312 1 1;
« DRI/Protocol/RRI/RegistryMessage.pm ↑ Summary DRI/Protocol/Whois/Domain/common.pm »