DRI/Protocol/EPP/Extensions/CZ/Contact.pm

filter: Statementstmt 12.6% 16 / 127 Branchbran 0.0% 0 / 80 Conditioncond 0.0% 0 / 36 MC/DCmcdc 0.0% 0 / 19 Subroutinesub 38.4% 5 / 13 Podpod 0.0% 0 / 8 totaltotal 7.4% 21 / 283 CC 55 SCAR 49.1
CC
55
Cov
7%
build_command
272.0
build_cdata
182.0
build_disclose
110.0
CRAP 136.1
« DRI/Protocol/EPP/Extensions/SIDN/Notifications.pm ↑ Summary DRI/Protocol/EPP/Extensions/Nominet/Domain.pm »
1 ## Domain Registry Interface, .CZ Contact EPP extension commands
2 ##
3 ## Copyright (c) 2008,2010,2013 Tonnerre Lombard <tonnerre.lombard@sygroup.ch>.
4 ## 2018 Patrick Mevzek <netdri@dotandco.com>.
5 ## All rights reserved.
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::CZ::Contact;
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  
22 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use Net::DRI::Protocol::EPP::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 =pod
27  
28 =head1 NAME
29  
30 Net::DRI::Protocol::EPP::Extensions::CZ::Contact - .CZ EPP Contact extension 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>development@sygroup.chE<gt>
41  
42 Please also see the SUPPORT file in the distribution.
43  
44 =head1 SEE ALSO
45  
46 E<lt>http://oss.bsdprojects.net/projects/netdri/E<gt> or
47 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
48  
49 =head1 AUTHOR
50  
51 Tonnerre Lombard, E<lt>tonnerre.lombard@sygroup.chE<gt>
52  
53 =head1 COPYRIGHT
54  
55 Copyright (c) 2008,2010,2013 Tonnerre Lombard <tonnerre.lombard@sygroup.ch>.
56 2018 Patrick Mevzek <netdri@dotandco.com>
57 All rights reserved.
58  
59 This program is free software; you can redistribute it and/or modify
60 it under the terms of the GNU General Public License as published by
61 the Free Software Foundation; either version 2 of the License, or
62 (at your option) any later version.
63  
64 See the LICENSE file that comes with this distribution for more details.
65  
66 =cut
67  
68 ####################################################################################################
69  
70 sub register_commands
71 0 ▶{
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
72 0 my ($class, $version) = @_;
73 0 my %tmp = (
74 info => [ undef, \&info_parse ],
75 create => [ \&create, undef ],
76 update => [ \&update, undef ]
77 );
78  
79 0 return { 'contact' => \%tmp };
80 }
81  
82 ####################################################################################################
83  
84 sub build_command
85 0 ▶{
Subroutine build_command: not called CC=16 SCAR=56.1
Pod undocumented
86 0 my ($msg, $command, $contact) = @_;
87 0 ▶ my @contact = (ref($contact) eq 'ARRAY')? @$contact : ($contact);
Branch: 1 branch
BranchTrueFalseTotal
ref $contact eq 'ARRAY' ? : 0 0 0
88 0 ▶ my @c = map { Net::DRI::Util::isa_contact($_) ?
Branch: 1 branch
BranchTrueFalseTotal
Net::DRI::Util::isa_contact($_) ? : 0 0 0
89 $_->srid() : $_ } @contact;
90  
91 0 ▶ Net::DRI::Exception->die(1,'protocol/EPP',2,'Contact id needed')
Branch: 1 branch
BranchTrueFalseTotal
unless @c 0 0 0
92 unless @c;
93 0 foreach my $n (@c)
94 {
95 0 ▶ Net::DRI::Exception->die(1, 'protocol/EPP', 2,
Branch: 1 branch
BranchTrueFalseTotal
unless defined $n and $n and not ref $n 0 0 0
Condition0%0/6
defined $n and $n and not ref $n
!ll&&!rl&&r
000
defined $n and $n
!ll&&!rl&&r
000
MC/DC0%0/3
defined $n and $n and not ref $n
defined $n $n not ref $n
Truth table0%0/4
A and B and not(C)
A= defined $nB= $nC= not ref $n
ABCresult
0XX0
10X0
1100
1111
96 'Contact id needed') unless (defined($n) && $n && !ref($n));
97 0 ▶ Net::DRI::Exception->die(1, 'protocol/EPP', 10,
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($n, 3, 16) 0 0 0
98 'Invalid contact id: ' . $n)
99 unless Net::DRI::Util::xml_is_token($n, 3, 16);
100 }
101  
102 0 ▶ my $tcommand = (ref($command)) ? $command->[0] : $command;
Branch: 1 branch
BranchTrueFalseTotal
ref $command ? : 0 0 0
103 0 $msg->command([$command, 'contact:' . $tcommand, $msg->nsattrs('contact')]);
104  
105 0 my @d = map { ['contact:id', $_] } @c;
106 0 ▶ if (($tcommand =~ m/^(?:info|transfer)$/) && ref($contact[0]) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($tcommand =~ /^(?:info|transfer)$/ and ref $contact[0] and Net::DRI::Util::isa_contact($contact[0])) 0 0 0
Condition0%0/6
$tcommand =~ /^(?:info|transfer)$/ and ref $contact[0] and Net::DRI::Util::isa_contact($contact[0])
!ll&&!rl&&r
000
$tcommand =~ /^(?:info|transfer)$/ and ref $contact[0]
!ll&&!rl&&r
000
MC/DC0%0/3
$tcommand =~ /^(?:info|transfer)$/ and ref $contact[0] and Net::DRI::Util::isa_contact($contact[0])
$tcommand =~ /^(?:info|transfer)$/ ref $contact[0] Net::DRI::Util::isa_contact($contact[0])
Truth table0%0/4
A and B and C
A= $tcommand =~ /^(?:info|transfer)$/B= ref $contact[0]C= Net::DRI::Util::isa_contact($contact[0])
ABCresult
0XX0
10X0
1100
1111
107 Net::DRI::Util::isa_contact($contact[0]))
108 {
109 0 my $az = $contact[0]->auth();
110 0 ▶ if ($az && ref($az) && exists($az->{pw}))
Branch: 1 branch
BranchTrueFalseTotal
if ($az and ref $az and exists $az->{"pw"}) 0 0 0
Condition0%0/6
$az and ref $az and exists $az->{"pw"}
!ll&&!rl&&r
000
$az and ref $az
!ll&&!rl&&r
000
MC/DC0%0/3
$az and ref $az and exists $az->{"pw"}
$az ref $az exists $az->{"pw"}
Truth table0%0/4
A and B and C
A= $azB= ref $azC= exists $az->{"pw"}
ABCresult
0XX0
10X0
1100
1111
111 {
112 0 push(@d, ['contact:authInfo', $az->{pw}]);
113 }
114 }
115  
116 0 return @d;
117 }
118  
119 ############ Query commands
120  
121 sub info_parse
122 0 ▶{
Subroutine info_parse: not called CC=7 SCAR=40.3
Pod undocumented
123 0 my ($po, $otype, $oaction, $oname, $rinfo) = @_;
124 0 my $mes = $po->message();
125  
126 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
127  
128 0 my $infdata = $mes->get_response('contact','infData');
129 0 ▶ return unless $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless $infdata 0 0 0
130  
131 0 my $s = $rinfo->{contact}->{$oname}->{self};
132 0 my $el = $infdata->getElementsByTagNameNS($mes->ns('contact'),
133 'authInfo');
134 0 ▶ while (my $ai = $el->shift())
Branch: 1 branch
BranchTrueFalseTotal
if (my $ai = $el->shift) 0 0 0
135 {
136 0 ▶ $s->auth({pw => $ai->getFirstChild()->getData()})
Branch: 1 branch
BranchTrueFalseTotal
if defined $ai and defined $ai->getFirstChild and $ai->getFirstChild->nodeType == 3 0 0 0
Condition0%0/6
defined $ai and defined $ai->getFirstChild and $ai->getFirstChild->nodeType == 3
!ll&&!rl&&r
000
defined $ai and defined $ai->getFirstChild
!ll&&!rl&&r
000
MC/DC0%0/3
defined $ai and defined $ai->getFirstChild and $ai->getFirstChild->nodeType == 3
defined $ai defined $ai->getFirstChild $ai->getFirstChild->nodeType == 3
Truth table0%0/4
A and B and C
A= defined $aiB= defined $ai->getFirstChildC= $ai->getFirstChild->nodeType == 3
ABCresult
0XX0
10X0
1100
1111
137 if (defined($ai) && defined($ai->getFirstChild()) &&
138 $ai->getFirstChild()->nodeType() == 3);
139 }
140 0 return;
141 }
142  
143 ############ Transform commands
144  
145 sub build_authinfo
146 0 ▶{
Subroutine build_authinfo: not called CC=4 SCAR=30.0
Pod undocumented
147 0 my $contact = shift;
148 0 my $az = $contact->auth();
149 0 ▶ return () unless ($az && ref($az) && exists($az->{pw}));
Branch: 1 branch
BranchTrueFalseTotal
unless $az and ref $az and exists $az->{"pw"} 0 0 0
Condition0%0/6
$az and ref $az and exists $az->{"pw"}
!ll&&!rl&&r
000
$az and ref $az
!ll&&!rl&&r
000
MC/DC0%0/3
$az and ref $az and exists $az->{"pw"}
$az ref $az exists $az->{"pw"}
Truth table0%0/4
A and B and C
A= $azB= ref $azC= exists $az->{"pw"}
ABCresult
0XX0
10X0
1100
1111
150 0 return ['contact:authInfo', $az->{pw}];
151 }
152  
153 sub build_disclose
154 0 ▶{
Subroutine build_disclose: not called CC=10 SCAR=47.0
Pod undocumented
155 0 my $contact = shift;
156 0 my $d=$contact->disclose();
157 0 ▶ return () unless ($d && ref($d));
Branch: 1 branch
BranchTrueFalseTotal
unless $d and ref $d 0 0 0
Condition0%0/3
$d and ref $d
!ll&&!rl&&r
000
MC/DC0%0/2
$d and ref $d
$d ref $d
Truth table0%0/3
A and B
A= $dB= ref $d
ABresult
0X0
100
111
158 0 my %v=map { $_ => 1 } values(%$d);
159 0 ▶ return () unless (keys(%v)==1); ## 1 or 0 as values, not both at same time
Branch: 1 branch
BranchTrueFalseTotal
unless keys %v == 1 0 0 0
160  
161 0 my @d;
162 0 ▶ push(@d, ['contact:name']) if (exists($d->{name}));
Branch: 1 branch
BranchTrueFalseTotal
if exists $d->{"name"} 0 0 0
163 0 ▶ push(@d, ['contact:org']) if (exists($d->{org}));
Branch: 1 branch
BranchTrueFalseTotal
if exists $d->{"org"} 0 0 0
164 0 ▶ push(@d, ['contact:addr']) if (exists($d->{addr}));
Branch: 1 branch
BranchTrueFalseTotal
if exists $d->{"addr"} 0 0 0
165 0 ▶ push(@d, ['contact:voice']) if (exists($d->{voice}));
Branch: 1 branch
BranchTrueFalseTotal
if exists $d->{"voice"} 0 0 0
166 0 ▶ push(@d, ['contact:fax']) if (exists($d->{fax}));
Branch: 1 branch
BranchTrueFalseTotal
if exists $d->{"fax"} 0 0 0
167 0 ▶ push(@d, ['contact:email']) if (exists($d->{email}));
Branch: 1 branch
BranchTrueFalseTotal
if exists $d->{"email"} 0 0 0
168  
169 0 return ['contact:disclose',@d,{flag=>(keys(%v))[0]}];
170 }
171  
172 sub build_cdata
173 0 ▶{
Subroutine build_cdata: not called CC=13 SCAR=52.0
Pod undocumented
174 0 my ($contact, $v) = @_;
175 0 my (@post, @addr);
176 0 my @tmp;
177 0 my @d;
178  
179 0 @tmp = $contact->name();
180 0 ▶ if (defined($tmp[0])) { push(@post, ['contact:name', $tmp[0]]); }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tmp[0]) 0 0 0
181  
182 0 @tmp = $contact->org();
183 0 ▶ if (defined($tmp[0])) { push(@post, ['contact:org', $tmp[0]]); }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tmp[0]) 0 0 0
184  
185 0 @tmp = $contact->street();
186 0 ▶ if (defined($tmp[0])) { foreach (@{$tmp[0]}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tmp[0]) 0 0 0
187 0 push(@addr, ['contact:street', $_]);
188 } }
189  
190 0 @tmp = $contact->city();
191 0 ▶ if (defined($tmp[0])) { push(@addr, ['contact:city', $tmp[0]]); }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tmp[0]) 0 0 0
192  
193 0 @tmp = $contact->sp();
194 0 ▶ if (defined($tmp[0])) { push(@addr, ['contact:sp', $tmp[0]]); }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tmp[0]) 0 0 0
195  
196 0 @tmp = $contact->pc();
197 0 ▶ if (defined($tmp[0])) { push(@addr, ['contact:pc', $tmp[0]]); }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tmp[0]) 0 0 0
198  
199 0 @tmp = $contact->cc();
200 0 ▶ if (defined($tmp[0])) { push(@addr, ['contact:cc', $tmp[0]]); }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tmp[0]) 0 0 0
201  
202 0 ▶ push(@post, ['contact:addr', @addr]) if (@addr);
Branch: 1 branch
BranchTrueFalseTotal
if @addr 0 0 0
203 0 push(@d, ['contact:postalInfo', @post]);
204 0 ▶ push(@d, Net::DRI::Protocol::EPP::Util::build_tel('contact:voice', $contact->voice()))
Branch: 1 branch
BranchTrueFalseTotal
if defined $contact->voice 0 0 0
205 if (defined($contact->voice()));
206 0 ▶ push(@d, Net::DRI::Protocol::EPP::Util::build_tel('contact:fax', $contact->fax()))
Branch: 1 branch
BranchTrueFalseTotal
if defined $contact->fax 0 0 0
207 if (defined($contact->fax()));
208 0 ▶ push(@d, ['contact:email', $contact->email()])
Branch: 1 branch
BranchTrueFalseTotal
if defined $contact->email 0 0 0
209 if (defined($contact->email()));
210 0 push(@d, build_authinfo($contact));
211 0 push(@d, build_disclose($contact));
212  
213 0 return @d;
214 }
215  
216 sub create
217 0 ▶{
Subroutine create: not called CC=2 SCAR=17.9
Pod undocumented
218 0 my ($epp, $contact) = @_;
219 0 my $mes = $epp->message();
220 0 my @d = build_command($mes, 'create', $contact);
221  
222 0 ▶ Net::DRI::Exception->die(1, 'protocol/EPP', 10, 'Invalid contact ' .
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::isa_contact($contact) 0 0 0
223 $contact) unless Net::DRI::Util::isa_contact($contact);
224 0 $contact->validate(); ## will trigger an Exception if needed
225 0 push(@d, build_cdata($contact, $epp->{contacti18n}));
226 0 $mes->command_body(\@d);
227 0 return;
228 }
229  
230 sub update
231 0 ▶{
Subroutine update: not called CC=9 SCAR=45.0
Pod undocumented
232 0 my ($epp, $contact, $todo) = @_;
233 0 my $mes = $epp->message();
234  
235 0 ▶ Net::DRI::Exception::usererr_invalid_parameters($todo .
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::isa_changes($todo) 0 0 0
236 ' must be a Net::DRI::Data::Changes object')
237 unless Net::DRI::Util::isa_changes($todo);
238 0 ▶ if ((grep { ! /^(?:add|del)$/ } $todo->types('status')) ||
Branch: 1 branch
BranchTrueFalseTotal
if (grep {not /^(?:add|del)$/;} $todo->types("status") or grep {not /^(?:set)$/;} $todo->types("info")) 0 0 0
Condition0%0/3
grep {not /^(?:add|del)$/;} $todo->types("status") or grep {not /^(?:set)$/;} $todo->types("info")
l!l&&r!l&&!r
000
MC/DC0%0/2
grep {not /^(?:add|del)$/;} $todo->types("status") or grep {not /^(?:set)$/;} $todo->types("info")
grep {not /^(?:add|del)$/;} $todo->types("status") grep {not /^(?:set)$/;} $todo->types("info")
Truth table0%0/3
A or B
A= grep {not /^(?:add|del)$/;} $todo->types("status")B= grep {not /^(?:set)$/;} $todo->types("info")
ABresult
1X1
011
000
239 0 (grep { ! /^(?:set)$/ } $todo->types('info')))
240 {
241 0 Net::DRI::Exception->die(0, 'protocol/EPP', 11,
242 'Only status add/del or info set available for ' .
243 'contact');
244 }
245  
246 0 my @d = build_command($mes, 'update', $contact);
247  
248 0 my $sadd = $todo->add('status');
249 0 my $sdel = $todo->del('status');
250 0 ▶ push(@d, ['contact:add', $sadd->build_xml('contact:status')])
Branch: 1 branch
BranchTrueFalseTotal
if $sadd 0 0 0
251 if ($sadd);
252 0 ▶ push(@d, ['contact:rem', $sdel->build_xml('contact:status')])
Branch: 1 branch
BranchTrueFalseTotal
if $sdel 0 0 0
253 if ($sdel);
254  
255 0 my $newc = $todo->set('info');
256 0 ▶ if ($newc)
Branch: 1 branch
BranchTrueFalseTotal
if ($newc) 0 0 0
257 {
258 0 ▶ Net::DRI::Exception->die(1, 'protocol/EPP', 10,
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::isa_contact($newc) 0 0 0
259 'Invalid contact ' . $newc)
260 unless Net::DRI::Util::isa_contact($newc);
261 0 $newc->validate(1); ## will trigger an Exception if needed
262 0 my @c = build_cdata($newc, $epp->{contacti18n});
263 0 ▶ push(@d, ['contact:chg', @c]) if (@c);
Branch: 1 branch
BranchTrueFalseTotal
if @c 0 0 0
264 }
265  
266 0 $mes->command_body(\@d);
267 0 return;
268 }
269  
270 ####################################################################################################
271 1 1;
« DRI/Protocol/EPP/Extensions/SIDN/Notifications.pm ↑ Summary DRI/Protocol/EPP/Extensions/Nominet/Domain.pm »