DRI/Protocol/EPP/Extensions/E164.pm

filter: Statementstmt 19.0% 16 / 84 Branchbran 0.0% 0 / 40 Conditioncond 0.0% 0 / 24 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 41.6% 5 / 12 Podpod 0.0% 0 / 7 totaltotal 11.7% 21 / 179 CC 31 SCAR 45.5
CC
31
Cov
11%
format_naptr
210.0
create
56.0
update
56.0
CRAP 94.9
« DRI/Protocol/OpenSRS/XCP/Message.pm ↑ Summary DRI/Protocol/EPP/Extensions/PL/Report.pm »
1 ## Domain Registry Interface, EPP E.164 Number Mapping (RFC4114)
2 ##
3 ## Copyright (c) 2005-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::E164;
16  
17 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use feature 'state';
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::E164 - EPP E.164 Number Mapping (RFC4114) 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-2009,2013,2016,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 state $domain = {
70 info => [ undef, \&info_parse ],
71 create => [ \&create, undef ],
72 update => [ \&update, undef ],
73 };
74 0 state $commands = { 'domain' => $domain };
75 0 return $commands;
76 }
77  
78 sub setup
79 {
80 0 ▶ my ($class,$po,$version)=@_;
Subroutine setup: not called CC=1 SCAR=6.9
Pod undocumented
81 0 $po->ns({ 'e164' => 'urn:ietf:params:xml:ns:e164epp-1.0' });
82 0 return;
83 }
84  
85 0 ▶sub capabilities_add { return ('domain_update','e164',['add','del']); }
Subroutine capabilities_add: not called CC=1 SCAR=6.9
Pod undocumented
86  
87 ####################################################################################################
88  
89 sub format_naptr
90 {
91 0 ▶ my $e=shift;
Subroutine format_naptr: not called CC=14 SCAR=53.5
Pod undocumented
92  
93 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Attributes order, pref and svc must exist') unless ((ref($e) eq 'HASH') && exists($e->{order}) && exists($e->{pref}) && exists($e->{svc}));
Branch: 1 branch
BranchTrueFalseTotal
unless ref $e eq "HASH" and exists $e->{"order"} and exists $e->{"pref"} and exists $e->{"svc"} 0 0 0
Condition0%0/9
ref $e eq "HASH" and exists $e->{"order"} and exists $e->{"pref"} and exists $e->{"svc"}
!ll&&!rl&&r
000
ref $e eq "HASH" and exists $e->{"order"} and exists $e->{"pref"}
!ll&&!rl&&r
000
ref $e eq "HASH" and exists $e->{"order"}
!ll&&!rl&&r
000
MC/DC0%0/4
ref $e eq "HASH" and exists $e->{"order"} and exists $e->{"pref"} and exists $e->{"svc"}
ref $e eq "HASH" exists $e->{"order"} exists $e->{"pref"} exists $e->{"svc"}
Truth table0%0/5
A and B and C and D
A= ref $e eq "HASH"B= exists $e->{"order"}C= exists $e->{"pref"}D= exists $e->{"svc"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
94  
95 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Order must be 16-bit unsigned integer') unless Net::DRI::Util::verify_ushort($e->{order});
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::verify_ushort($e->{"order"}) 0 0 0
96 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Pref must be 16-bit unsigned integer') unless Net::DRI::Util::verify_ushort($e->{pref});
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::verify_ushort($e->{"pref"}) 0 0 0
97 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Svc must be at least 1 character as xml token type') unless Net::DRI::Util::xml_is_token($e->{svc},1,undef);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($e->{"svc"}, 1, undef) 0 0 0
98  
99 0 my @c;
100 0 push @c,['e164:order',$e->{order}];
101 0 push @c,['e164:pref',$e->{pref}];
102 0 ▶ if (exists($e->{flags}))
Branch: 1 branch
BranchTrueFalseTotal
if (exists $e->{"flags"}) 0 0 0
103 {
104 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Flags must be a single letter or number') unless ($e->{flags}=~m/^[A-Z0-9]$/i);
Branch: 1 branch
BranchTrueFalseTotal
unless $e->{"flags"} =~ /^[A-Z0-9]$/i 0 0 0
105 0 push @c,['e164:flags',$e->{flags}];
106 }
107 0 push @c,['e164:svc',$e->{svc}];
108 0 ▶ if (exists($e->{regex}))
Branch: 1 branch
BranchTrueFalseTotal
if (exists $e->{"regex"}) 0 0 0
109 {
110 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Regex must be at least 1 character as xml token type') unless Net::DRI::Util::xml_is_token($e->{regex},1,undef);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($e->{"regex"}, 1, undef) 0 0 0
111 0 push @c,['e164:regex',$e->{regex}];
112 }
113 0 ▶ if (exists($e->{replacement}))
Branch: 1 branch
BranchTrueFalseTotal
if (exists $e->{"replacement"}) 0 0 0
114 {
115 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Regex must be between 1 and 255 characters as xml token type') unless Net::DRI::Util::xml_is_token($e->{regex},1,255);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($e->{"regex"}, 1, 255) 0 0 0
116 0 push @c,['e164:replacement',$e->{replacement}];
117 }
118  
119 0 return @c;
120 }
121  
122 ####################################################################################################
123 ########### Query commands
124  
125 sub info_parse
126 {
127 0 ▶ my ($po,$otype,$oaction,$oname,$rinfo)=@_;
Subroutine info_parse: not called CC=6 SCAR=37.4
Pod undocumented
128 0 my $mes=$po->message();
129 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
130  
131 0 my $infdata=$mes->get_extension('e164', 'infData');
132 0 ▶ return unless defined $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $infdata 0 0 0
133  
134 0 my @naptr;
135 0 foreach my $el ($infdata->getChildrenByTagNameNS($mes->ns('e164'), 'naptr'))
136 {
137 0 my %n;
138 0 foreach my $sel (Net::DRI::Util::xml_list_children($el))
139 {
140 0 my ($name,$c)=@$sel;
141 0 ▶ if ($name=~m/^(order|pref|flags|svc|regex|replacement)$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /^(order|pref|flags|svc|regex|replacement)$/) 0 0 0
142 {
143 0 $n{$1}=$c->textContent();
144 }
145 }
146 0 push @naptr,\%n;
147 }
148  
149 0 $rinfo->{domain}->{$oname}->{e164}=\@naptr;
150 0 return;
151 }
152  
153 ############ Transform commands
154  
155 sub create
156 {
157 0 ▶ my ($epp,$domain,$rd)=@_;
Subroutine create: not called CC=7 SCAR=40.3
Pod undocumented
158  
159 0 my $def=$epp->default_parameters();
160  
161 ## IENUMAT works without the e164 extension part
162 0 ▶ unless (exists($rd->{e164}) && (ref($rd->{e164}) eq 'ARRAY') && @{$rd->{e164}})
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $rd->{"e164"} and ref $rd->{"e164"} eq "ARRAY" and @{$rd->{"e164"};}) 0 0 0
Condition0%0/6
exists $rd->{"e164"} and ref $rd->{"e164"} eq "ARRAY" and @{$rd->{"e164"};}
!ll&&!rl&&r
000
exists $rd->{"e164"} and ref $rd->{"e164"} eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/3
exists $rd->{"e164"} and ref $rd->{"e164"} eq "ARRAY" and @{$rd->{"e164"};}
exists $rd->{"e164"} ref $rd->{"e164"} eq "ARRAY" @{$rd->{"e164"};}
Truth table0%0/4
A and B and C
A= exists $rd->{"e164"}B= ref $rd->{"e164"} eq "ARRAY"C= @{$rd->{"e164"};}
ABCresult
0XX0
10X0
1100
1111
163 {
164 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('One or more E164 data block must be provided') unless (defined($def) && exists($def->{rfc4114_relax}) && $def->{rfc4114_relax});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $def and exists $def->{"rfc4114_relax"} and $def->{"rfc4114_relax"} 0 0 0
Condition0%0/6
defined $def and exists $def->{"rfc4114_relax"} and $def->{"rfc4114_relax"}
!ll&&!rl&&r
000
defined $def and exists $def->{"rfc4114_relax"}
!ll&&!rl&&r
000
MC/DC0%0/3
defined $def and exists $def->{"rfc4114_relax"} and $def->{"rfc4114_relax"}
defined $def exists $def->{"rfc4114_relax"} $def->{"rfc4114_relax"}
Truth table0%0/4
A and B and C
A= defined $defB= exists $def->{"rfc4114_relax"}C= $def->{"rfc4114_relax"}
ABCresult
0XX0
10X0
1100
1111
165 0 return;
166 }
167  
168 0 my $mes=$epp->message();
169 0 my $eid=$mes->command_extension_register('e164', 'create');
170 0 my @n=map { ['e164:naptr',format_naptr($_)] } (@{$rd->{e164}});
171 0 $mes->command_extension($eid,\@n);
172 0 return;
173 }
174  
175 sub update
176 {
177 0 ▶ my ($epp,$domain,$todo)=@_;
Subroutine update: not called CC=7 SCAR=40.3
Pod undocumented
178  
179 0 my $toadd=$todo->add('e164');
180 0 my $todel=$todo->del('e164');
181  
182 0 ▶ return unless defined $toadd || defined $todel;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $toadd or defined $todel 0 0 0
Condition0%0/3
defined $toadd or defined $todel
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $toadd or defined $todel
defined $toadd defined $todel
Truth table0%0/3
A or B
A= defined $toaddB= defined $todel
ABresult
1X1
011
000
183  
184 0 my $mes=$epp->message();
185 0 my $eid=$mes->command_extension_register('e164', 'update');
186  
187 0 my @n;
188 0 ▶ push @n,['e164:add',map { ['e164:naptr',format_naptr($_)] } (ref($toadd) eq 'ARRAY')? @$toadd : ($toadd)] if (defined($toadd));
Branch: 2 branches
BranchTrueFalseTotal
if defined $toadd 0 0 0
ref $toadd eq 'ARRAY' ? : 0 0 0
189 0 ▶ push @n,['e164:rem',map { ['e164:naptr',format_naptr($_)] } (ref($todel) eq 'ARRAY')? @$todel : ($todel)] if (defined($todel));
Branch: 2 branches
BranchTrueFalseTotal
if defined $todel 0 0 0
ref $todel eq 'ARRAY' ? : 0 0 0
190  
191 0 $mes->command_extension($eid,\@n);
192 0 return;
193 }
194  
195 ####################################################################################################
196 1 1;
« DRI/Protocol/OpenSRS/XCP/Message.pm ↑ Summary DRI/Protocol/EPP/Extensions/PL/Report.pm »