DRI/Protocol/EPP/Extensions/E164Validation.pm

filter: Statementstmt 20.5% 21 / 102 Branchbran 0.0% 0 / 36 Conditioncond 0.0% 0 / 45 MC/DCmcdc 0.0% 0 / 20 Subroutinesub 33.3% 6 / 18 Podpod 0.0% 0 / 12 totaltotal 11.5% 27 / 233 CC 36 SCAR 44.0
CC
36
Cov
11%
format_validation
156.0
update
156.0
add_validation_information
42.0
CRAP 81.4
« DRI/Protocol/IRIS/XCP.pm ↑ Summary DRI/Data/RegistryObject.pm »
1 ## Domain Registry Interface, EPP E.164 Validation (RFC5076)
2 ##
3 ## Copyright (c) 2008,2009,2013,2016,2018 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::E164Validation;
16  
17 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
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 1 ▶use feature 'state';
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 1 our @VALIDATION_MODULES=qw/RFC5076/; ## modules to handle validation information, override this variable to use other validation modules
26  
27 =pod
28  
29 =head1 NAME
30  
31 Net::DRI::Protocol::EPP::Extensions::E164Validation - EPP E.164 Validation (RFC5076) for Net::DRI
32  
33 =head1 DESCRIPTION
34  
35 Please see the README file for details.
36  
37 =head1 SUPPORT
38  
39 For now, support questions should be sent to:
40  
41 E<lt>netdri@dotandco.comE<gt>
42  
43 Please also see the SUPPORT file in the distribution.
44  
45 =head1 SEE ALSO
46  
47 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
48  
49 =head1 AUTHOR
50  
51 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
52  
53 =head1 COPYRIGHT
54  
55 Copyright (c) 2008,2009,2013,2016,2018 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 {
71 0 ▶ my ($class,$version)=@_;
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
72 0 state $domain = {
73 info => [ undef, \&info_parse ],
74 create => [ \&create, undef ],
75 renew => [ \&renew, undef ],
76 transfer_request => [ \&transfer_request, undef ],
77 update => [ \&update, undef ],
78 };
79 0 state $commands = { 'domain' => $domain };
80  
81 0 load_validation_modules();
82  
83 0 return $commands;
84 }
85  
86 sub setup
87 {
88 0 ▶ my ($class,$po,$version)=@_;
Subroutine setup: not called CC=1 SCAR=6.9
Pod undocumented
89 0 $po->ns({ 'e164val' => 'urn:ietf:params:xml:ns:e164val-1.0' });
90 0 return;
91 }
92  
93 0 ▶sub capabilities_add { return ('domain_update','e164_validation_information',['add','del','set']); }
Subroutine capabilities_add: not called CC=1 SCAR=6.9
Pod undocumented
94  
95 1 our %VAL;
96 sub load_validation_modules ## §4.4 §4.5
97 {
98 0 ▶ foreach my $mod (@VALIDATION_MODULES)
Subroutine load_validation_modules: not called CC=3 SCAR=24.8
Pod undocumented
99 {
100 0 ▶ my $class=($mod=~m/::/)? $mod : 'Net::DRI::Protocol::EPP::Extensions::E164Validation::'.$mod;
Branch: 1 branch
BranchTrueFalseTotal
$mod =~ /::/ ? : 0 0 0
101 0 Net::DRI::Util::load_module($class,'protocol/epp_e164validation');
102 0 my ($uri)=$class->load();
103 0 $VAL{$uri}=$class;
104 }
105 0 return;
106 }
107  
108 ####################################################################################################
109  
110 sub format_validation
111 {
112 0 ▶ my ($e,$what,$top)=@_;
Subroutine format_validation: not called CC=12 SCAR=50.5
Pod undocumented
113  
114 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Each validation information must be a reference to an array with 3 elements : 2 strings (id & uri) and a reference of an hash') unless (ref($e) eq 'ARRAY' && @$e==3 && !ref($e->[0]) && length $e->[0] && !ref($e->[1]) && length $e->[1] && (ref($e->[2]) eq 'HASH') && keys(%{$e->[2]}));
Branch: 1 branch
BranchTrueFalseTotal
unless ref $e eq "ARRAY" and @$e == 3 and not ref $e->[0] and length $e->[0] and not ref $e->[1] and length $e->[1] and ref $e->[2] eq "HASH" and keys %{$$e[2];} 0 0 0
Condition0%0/21
ref $e eq "ARRAY" and @$e == 3 and not ref $e->[0] and length $e->[0] and not ref $e->[1] and length $e->[1] and ref $e->[2] eq "HASH" and keys %{$$e[2];}
!ll&&!rl&&r
000
ref $e eq "ARRAY" and @$e == 3 and not ref $e->[0] and length $e->[0] and not ref $e->[1] and length $e->[1] and ref $e->[2] eq "HASH"
!ll&&!rl&&r
000
ref $e eq "ARRAY" and @$e == 3 and not ref $e->[0] and length $e->[0] and not ref $e->[1] and length $e->[1]
!ll&&!rl&&r
000
ref $e eq "ARRAY" and @$e == 3 and not ref $e->[0] and length $e->[0] and not ref $e->[1]
!ll&&!rl&&r
000
ref $e eq "ARRAY" and @$e == 3 and not ref $e->[0] and length $e->[0]
!ll&&!rl&&r
000
ref $e eq "ARRAY" and @$e == 3 and not ref $e->[0]
!ll&&!rl&&r
000
ref $e eq "ARRAY" and @$e == 3
!ll&&!rl&&r
000
MC/DC0%0/8
ref $e eq "ARRAY" and @$e == 3 and not ref $e->[0] and length $e->[0] and not ref $e->[1] and length $e->[1] and ref $e->[2] eq "HASH" and keys %{$$e[2];}
ref $e eq "ARRAY" @$e == 3 not ref $e->[0] length $e->[0] not ref $e->[1] length $e->[1] ref $e->[2] eq "HASH" keys %{$$e[2];}
Truth table0%0/9
A and B and not(C) and D and not(E) and F and G and H
A= ref $e eq "ARRAY"B= @$e == 3C= not ref $e->[0]D= length $e->[0]E= not ref $e->[1]F= length $e->[1]G= ref $e->[2] eq "HASH"H= keys %{$$e[2];}
ABCDEFGHresult
0XXXXXXX0
10XXXXXX0
110XXXXX0
1110XXXX0
11110XXX0
111110XX0
1111110X0
111111100
111111111
115 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Id is syntaxically invalid: '.$e->[0]) unless Net::DRI::Util::xml_is_ncname($e->[0]);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_ncname($e->[0]) 0 0 0
116 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('No validation information module found for URI='.$e->[1]) unless exists($VAL{$e->[1]});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $Net::DRI::Protocol::EPP::Extensions::E164Validation::VAL{$e->[1]} 0 0 0
117 0 ▶ Net::DRI::Exception::usererr_invalid_parameters(sprintf('Validation module %s for URI %s must a have a %s method',$VAL{$e->[1]},$e->[1],$what)) unless $VAL{$e->[1]}->can($what);
Branch: 1 branch
BranchTrueFalseTotal
unless $Net::DRI::Protocol::EPP::Extensions::E164Validation::VAL{$e->[1]}->can($what) 0 0 0
118 0 my @c=$VAL{$e->[1]}->$what($e->[2]);
119 0 return [$top,{id=>$e->[0]},['e164val:validationInfo',@c]];
120 }
121  
122 sub add_validation_information
123 {
124 0 ▶ my ($epp,$domain,$rd,$action)=@_;
Subroutine add_validation_information: not called CC=6 SCAR=37.4
Pod undocumented
125 0 ▶ return unless (defined($rd) && (ref($rd) eq 'HASH') && exists($rd->{e164_validation_information}) && (ref($rd->{e164_validation_information}) eq 'ARRAY') && @{$rd->{e164_validation_information}});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $rd and ref $rd eq "HASH" and exists $rd->{"e164_validation_information"} and ref $rd->{"e164_validation_information"} eq "ARRAY" and @{$rd->{"e164_validation_information"};} 0 0 0
Condition0%0/12
defined $rd and ref $rd eq "HASH" and exists $rd->{"e164_validation_information"} and ref $rd->{"e164_validation_information"} eq "ARRAY" and @{$rd->{"e164_validation_information"};}
!ll&&!rl&&r
000
defined $rd and ref $rd eq "HASH" and exists $rd->{"e164_validation_information"} and ref $rd->{"e164_validation_information"} eq "ARRAY"
!ll&&!rl&&r
000
defined $rd and ref $rd eq "HASH" and exists $rd->{"e164_validation_information"}
!ll&&!rl&&r
000
defined $rd and ref $rd eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/5
defined $rd and ref $rd eq "HASH" and exists $rd->{"e164_validation_information"} and ref $rd->{"e164_validation_information"} eq "ARRAY" and @{$rd->{"e164_validation_information"};}
defined $rd ref $rd eq "HASH" exists $rd->{"e164_validation_information"} ref $rd->{"e164_validation_information"} eq "ARRAY" @{$rd->{"e164_validation_information"};}
Truth table0%0/6
A and B and C and D and E
A= defined $rdB= ref $rd eq "HASH"C= exists $rd->{"e164_validation_information"}D= ref $rd->{"e164_validation_information"} eq "ARRAY"E= @{$rd->{"e164_validation_information"};}
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
126  
127 0 my $mes=$epp->message();
128 0 my $eid=$mes->command_extension_register('e164val', $action);
129 0 my @n=map { format_validation($_,$action,'e164val:add') } as_array($rd->{e164_validation_information});
130 0 $mes->command_extension($eid,\@n);
131 0 return;
132 }
133  
134 sub as_array
135 {
136 0 ▶ my $ra=shift;
Subroutine as_array: not called CC=2 SCAR=17.9
Pod undocumented
137 0 ▶ if (grep { !ref($_) } @$ra)
Branch: 1 branch
BranchTrueFalseTotal
if (grep {not ref $_;} @$ra) { } 0 0 0
138 {
139 0 return ($ra);
140 } else
141 {
142 0 return @$ra;
143 }
144 }
145  
146 ####################################################################################################
147 ########### Query commands
148  
149 sub info_parse ## §5.1.2
150 {
151 0 ▶ my ($po,$otype,$oaction,$oname,$rinfo)=@_;
Subroutine info_parse: not called CC=6 SCAR=37.4
Pod undocumented
152 0 my $mes=$po->message();
153 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
154  
155 0 my $infdata=$mes->get_extension('e164val','infData');
156 0 ▶ return unless defined $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $infdata 0 0 0
157  
158 0 my $ns = $mes->ns('e164val');
159 0 my @val;
160 0 foreach my $el ($infdata->getChildrenByTagNameNS($ns,'inf'))
161 {
162 0 my $id=$el->getAttribute('id');
163 0 my $r=($el->getChildrenByTagNameNS($ns,'validationInfo'))[0];
164 0 $r=$r->getFirstChild();
165 0 ▶ while( $r->nodeType()!=1) { $r=$r->getNextSibling(); }
Branch: 1 branch
BranchTrueFalseTotal
if ($r->nodeType != 1) 0 0 0
166 0 my $uri=$r->namespaceURI();
167 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('No validation information module found for URI='.$uri) unless exists($VAL{$uri});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $Net::DRI::Protocol::EPP::Extensions::E164Validation::VAL{$uri} 0 0 0
168 0 push @val,[$id,$uri,$VAL{$uri}->info_parse($po,$r)];
169 }
170  
171 0 $rinfo->{domain}->{$oname}->{e164_validation_information}=\@val;
172 0 return;
173 }
174  
175 ####################################################################################################
176 ############ Transform commands
177  
178 sub create ## §5.2.1
179 {
180 0 ▶ my ($epp,$domain,$rd)=@_;
Subroutine create: not called CC=1 SCAR=6.9
Pod undocumented
181 0 add_validation_information($epp,$domain,$rd,'create');
182 0 return;
183 }
184  
185 sub renew ## §5.2.3
186 {
187 0 ▶ my ($epp,$domain,$rd)=@_;
Subroutine renew: not called CC=1 SCAR=6.9
Pod undocumented
188 0 add_validation_information($epp,$domain,$rd,'renew');
189 0 return;
190 }
191  
192 sub transfer_request ## §5.2.4
193 {
194 0 ▶ my ($epp,$domain,$rd)=@_;
Subroutine transfer_request: not called CC=1 SCAR=6.9
Pod undocumented
195 0 add_validation_information($epp,$domain,$rd,'transfer');
196 0 return;
197 }
198  
199 sub update ## §5.2.5
200 {
201 0 ▶ my ($epp,$domain,$todo)=@_;
Subroutine update: not called CC=12 SCAR=50.5
Pod undocumented
202 0 my $mes=$epp->message();
203  
204 0 my $toadd=$todo->add('e164_validation_information');
205 0 my $todel=$todo->del('e164_validation_information');
206 0 my $toset=$todo->set('e164_validation_information');
207 0 ▶ return unless (defined($toadd) || defined($todel) || defined($toset));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $toadd or defined $todel or defined $toset 0 0 0
Condition0%0/6
defined $toadd or defined $todel or defined $toset
l!l&&r!l&&!r
000
defined $toadd or defined $todel
l!l&&r!l&&!r
000
MC/DC0%0/3
defined $toadd or defined $todel or defined $toset
defined $toadd defined $todel defined $toset
Truth table0%0/4
A or B or C
A= defined $toaddB= defined $todelC= defined $toset
ABCresult
1XX1
01X1
0011
0000
208  
209 0 my @n;
210 0 ▶ push @n,map { format_validation($_,'update','e164val:add') } as_array($toadd) if (defined($toadd) && (ref($toadd) eq 'ARRAY'));
Branch: 1 branch
BranchTrueFalseTotal
if defined $toadd and ref $toadd eq "ARRAY" 0 0 0
Condition0%0/3
defined $toadd and ref $toadd eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $toadd and ref $toadd eq "ARRAY"
defined $toadd ref $toadd eq "ARRAY"
Truth table0%0/3
A and B
A= defined $toaddB= ref $toadd eq "ARRAY"
ABresult
0X0
100
111
211 0 ▶ push @n,map { ['e164val:rem',{id=>(ref($_) eq 'ARRAY')? $_->[0] : $_->[0]}] } as_array($todel) if (defined($todel) && (ref($todel) eq 'ARRAY'));
Branch: 2 branches
BranchTrueFalseTotal
if defined $todel and ref $todel eq "ARRAY" 0 0 0
ref $_ eq 'ARRAY' ? : 0 0 0
Condition0%0/3
defined $todel and ref $todel eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $todel and ref $todel eq "ARRAY"
defined $todel ref $todel eq "ARRAY"
Truth table0%0/3
A and B
A= defined $todelB= ref $todel eq "ARRAY"
ABresult
0X0
100
111
212 0 ▶ push @n,map { format_validation($_,'update','e164val:chg') } (ref($toset) eq 'ARRAY')? @$toset : ($toset) if (defined($toset));
Branch: 2 branches
BranchTrueFalseTotal
if defined $toset 0 0 0
ref $toset eq 'ARRAY' ? : 0 0 0
213 0 ▶ return unless @n;
Branch: 1 branch
BranchTrueFalseTotal
unless @n 0 0 0
214  
215 0 my $eid=$mes->command_extension_register('e164val', 'update');
216 0 $mes->command_extension($eid,\@n);
217 0 return;
218 }
219  
220 ####################################################################################################
221 1 1;
« DRI/Protocol/IRIS/XCP.pm ↑ Summary DRI/Data/RegistryObject.pm »