EPP/Test/Base.pm

filter: Statementstmt 82.0% 895 / 1091 Branchbran 67.0% 445 / 664 Conditioncond 65.1% 73 / 112 MC/DCmcdc 34.4% 21 / 61 Subroutinesub 96.9% 32 / 33 Podpod 0.0% 0 / 23 totaltotal 73.8% 1466 / 1984 SCAR 80.7
CC
438
Cov
76%
contact_create_update
173.6
domain_update
99.0
domain_transfer
74.1
CRAP 3196.6
« EPP/IRRP.pm ↑ Summary EPP/RRPProxy.pm »
1 package IO::EPP::Test::Base;
2  
3 =encoding utf8
4  
5 =head1 NAME
6  
7 IO::EPP::Test::Base
8  
9 =head1 SYNOPSIS
10  
11 Call IO::EPP::Base with parameter "test_mode=1"
12  
13 =head1 DESCRIPTION
14  
15 Module for testing IO::EPP::CNic,
16 emulates answers of base registry
17  
18 =head1 AUTHORS
19  
20 Vadim Likhota <vadiml@cpan.org>
21  
22 =cut
23  
24 2 ▶use Digest::MD5 qw(md5_hex);
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 2 ▶use IO::EPP::Base ();
Subroutine BEGIN: called CC=1 SCAR=0.0
27 2 ▶use IO::EPP::Test::Server;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 2 ▶no utf8; # !!!
Subroutine BEGIN: called CC=1 SCAR=0.0
33  
34 2 our %statuses = (
35 clientHold => '+',
36 clientRenewProhibited => 'renewed',
37 clientDeleteProhibited => 'deleted',
38 clientUpdateProhibited => 'updated',
39 clientTransferProhibited => 'transfered',
40 serverHold => '+',
41 serverRenewProhibited => 'renewed',
42 serverDeleteProhibited => 'deleted',
43 serverUpdateProhibited => 'updated',
44 serverTransferProhibited => 'transfered',
45 );
46  
47 sub req {
48 238 ▶ my ( $obj, $out_data, undef ) = @_;
Subroutine req: called CC=23 SCAR=31.4
Pod undocumented
49  
50 238 my $in_data;
51  
52 238 ▶ if ( !$out_data or $out_data =~ m|<hello[^<>]+/>| ) {
Branch: 21 branches
BranchTrueFalseTotal
if (not $out_data or $out_data =~ m[<hello[^<>]+/>]) { } 49 189 238
elsif ($out_data =~ /<login>/s) { } 49 140 189
elsif ($out_data =~ /<contact:check[^<>]+>/) { } 1 139 140
elsif ($out_data =~ /<contact:create[^<>]+>/) { } 11 128 139
elsif ($out_data =~ /<contact:update[^<>]+>/) { } 2 126 128
elsif ($out_data =~ /<contact:info[^<>]+>/) { } 4 122 126
elsif ($out_data =~ /<contact:delete[^<>]+>/) { } 2 120 122
elsif ($out_data =~ /<host:check[^<>]+>/) { } 1 119 120
elsif ($out_data =~ /<host:create[^<>]+>/) { } 8 111 119
elsif ($out_data =~ /<host:info[^<>]+>/) { } 2 109 111
elsif ($out_data =~ /<host:update[^<>]+>/) { } 3 106 109
elsif ($out_data =~ /<host:delete[^<>]+>/) { } 2 104 106
elsif ($out_data =~ /<domain:check[^<>]+>/) { } 2 102 104
elsif ($out_data =~ /<domain:create[^<>]+>/) { } 12 90 102
elsif ($out_data =~ /<domain:info[^<>]+>/) { } 4 86 90
elsif ($out_data =~ /<domain:renew[^<>]+>/) { } 5 81 86
elsif ($out_data =~ /<domain:update[^<>]+>/) { } 20 61 81
elsif ($out_data =~ /<domain:delete[^<>]+>/) { } 4 57 61
elsif ($out_data =~ /<domain:transfer[^<>]+>/) { } 7 50 57
elsif ($out_data =~ /<poll [^<>]+>/) { } 1 49 50
elsif ($out_data =~ m[<logout/>]) { } 49 0 49
Condition100%3/3
not $out_data or $out_data =~ m[<hello[^<>]+/>]
l!l&&r!l&&!r
472189
MC/DC100%2/2
not $out_data or $out_data =~ m[<hello[^<>]+/>]
not $out_data $out_data =~ m[<hello[^<>]+/>]
Truth table100%3/3
not(A) or B
A= not $out_dataB= $out_data =~ m[<hello[^<>]+/>]
ABresult
1X1
011
000
53 49 $in_data = hello( $out_data );
54 }
55 elsif ( $out_data =~ m|<login>|s ) {
56 49 $in_data = login( $out_data );
57 }
58 elsif ( $out_data =~ m|<contact:check[^<>]+>| ) {
59 1 $in_data = contact_check( $obj, $out_data );
60 }
61 elsif ( $out_data =~ m|<contact:create[^<>]+>| ) {
62 11 $in_data = contact_create_update( $obj, $out_data, 'create' );
63 }
64 elsif ( $out_data =~ m|<contact:update[^<>]+>| ) {
65 2 $in_data = contact_create_update( $obj, $out_data, 'update' );
66 }
67 elsif ( $out_data =~ m|<contact:info[^<>]+>| ) {
68 4 $in_data = contact_info( $obj, $out_data );
69 }
70 elsif ( $out_data =~ m|<contact:delete[^<>]+>| ) {
71 2 $in_data = contact_delete( $obj, $out_data );
72 }
73 elsif ( $out_data =~ m|<host:check[^<>]+>| ) {
74 1 $in_data = host_check( $obj, $out_data );
75 }
76 elsif ( $out_data =~ m|<host:create[^<>]+>| ) {
77 8 $in_data = host_create( $obj, $out_data );
78 }
79 elsif ( $out_data =~ m|<host:info[^<>]+>| ) {
80 2 $in_data = host_info( $obj, $out_data );
81 }
82 elsif ( $out_data =~ m|<host:update[^<>]+>| ) {
83 3 $in_data = host_update( $obj, $out_data );
84 }
85 elsif ( $out_data =~ m|<host:delete[^<>]+>| ) {
86 2 $in_data = host_delete( $obj, $out_data );
87 }
88 elsif ( $out_data =~ m|<domain:check[^<>]+>| ) {
89 2 $in_data = domain_check( $obj, $out_data );
90 }
91 elsif ( $out_data =~ m|<domain:create[^<>]+>| ) {
92 12 $in_data = domain_create( $obj, $out_data );
93 }
94 elsif ( $out_data =~ m|<domain:info[^<>]+>| ) {
95 4 $in_data = domain_info( $obj, $out_data );
96 }
97 elsif ( $out_data =~ m|<domain:renew[^<>]+>| ) {
98 5 $in_data = domain_renew( $obj, $out_data );
99 }
100 elsif ( $out_data =~ m|<domain:update[^<>]+>| ) {
101 20 $in_data = domain_update( $obj, $out_data );
102 }
103 elsif ( $out_data =~ m|<domain:delete[^<>]+>| ) {
104 4 $in_data = domain_delete( $obj, $out_data );
105 }
106 elsif ( $out_data =~ m|<domain:transfer[^<>]+>| ) {
107 7 $in_data = domain_transfer( $obj, $out_data );
108 }
109 elsif ( $out_data =~ m|<poll [^<>]+>| ) {
110 1 $in_data = poll( $obj, $out_data );
111 }
112 elsif ( $out_data =~ m|<logout/>| ) {
113 49 $in_data = logout( $out_data );
114 }
115 else {
116 0 die "closed connection\n"; # behavior centralnic
117 }
118  
119 238 return $in_data;
120 }
121  
122  
123 sub get_svtrid {
124 263 ▶ return 'TEST-' . uc( md5_hex( time() . $$ . rand(1000000) ) ); # as CNIC-7E024512B06F1FC202C6E625DE12C69984799AA81D578111813DFF29646
Subroutine get_svtrid: called CC=1 SCAR=0.0
Pod undocumented
125 }
126  
127  
128 sub get_dates {
129 66 ▶ my ( $y ) = @_;
Subroutine get_dates: called CC=2 SCAR=6.9
Pod undocumented
130 66 ▶ $y ||= 0;
Condition100%2/2
$y ||= 0
l!l
264
MC/DC100%1/1
$y ||= 0
$y
Truth table100%2/2
A
A= $y
Aresult
11
00
131 66 my ($sec,$min,$hour,$mday,$mon,$year) = localtime(time);
132  
133 66 $year += 1900;
134 66 $mon += 1;
135 66 my $year2 = $year + $y;
136  
137 66 my $dt1 = sprintf( '%0004d-%02d-%02dT%02d:%02d:%02d.0Z', $year, $mon, $mday, $hour, $min, $sec );
138 66 my $dt2 = sprintf( '%0004d-%02d-%02dT23:59:59.0Z', $year2, $mon, $mday );
139  
140 66 return $dt1, $dt2;
141 }
142  
143  
144 sub hello {
145 49 ▶ my ( $dt ) = get_dates();
Subroutine hello: called CC=1 SCAR=0.0
Pod undocumented
146  
147 49 return qq|<?xml version="1.0" encoding="UTF-8" standalone="no"?><epp xmlns="urn:ietf:params:xml:ns:epp-1.0"><greeting><svID>EXAMPLE EPP server EPP.EXAMPLE.COM</svID><svDate>$dt</svDate><svcMenu><version>1.0</version><lang>en</lang><objURI>urn:ietf:params:xml:ns:domain-1.0</objURI><objURI>urn:ietf:params:xml:ns:contact-1.0</objURI><objURI>urn:ietf:params:xml:ns:host-1.0</objURI><svcExtension><extURI>urn:ietf:params:xml:ns:rgp-1.0</extURI><extURI>urn:ietf:params:xml:ns:secDNS-1.1</extURI><extURI>urn:ietf:params:xml:ns:idn-1.0</extURI></svcExtension></svcMenu><dcp><access><all></all></access><statement><purpose><admin></admin><prov></prov></purpose><recipient><ours></ours><public></public></recipient><retention><stated></stated></retention></statement></dcp></greeting></epp>|;
148 }
149  
150 sub _fail_cltrid {
151 0 ▶ my $svtrid = get_svtrid();
Subroutine _fail_cltrid: not called CC=1 SCAR=6.9
152  
153 0 return qq|<?xml version="1.0" encoding="UTF-8" standalone="no"?>
154 <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
155 <response>
156 <result code="2001">
157 <msg>XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:epp-1.0}clTRID&#039;: The value has a length of &#039;0&#039;;</msg>
158 </result>
159 <trID>
160 <clTRID>xxxx</clTRID>
161 <svTRID>$svtrid</svTRID>
162 </trID>
163 </response>
164 </epp>|;
165 }
166  
167 sub _fail_body {
168 63 ▶ my ( $err, $code, $cl ) = @_;
Subroutine _fail_body: called CC=2 SCAR=7.0
169 63 my $svtrid = get_svtrid();
170 63 ▶ $cl ||= 'xxxx';
Condition50%1/2
$cl ||= "xxxx"
l!l
630
MC/DC0%0/1
$cl ||= "xxxx"
$cl
Truth table50%1/2
A
A= $cl
Aresult
11
00
171  
172 63 return qq|<?xml version="1.0" encoding="UTF-8" standalone="no"?>
173 <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
174 <response>
175 <result code="$code">
176 <msg>$err</msg>
177 </result>
178 <trID>
179 <clTRID>$cl</clTRID>
180 <svTRID>$svtrid</svTRID>
181 </trID>
182 </response>
183 </epp>|;
184 }
185  
186 sub _ok_answ {
187 20 ▶ my ( $res, $cl ) = @_;
Subroutine _ok_answ: called CC=2 SCAR=7.0
188  
189 20 my $svtrid = get_svtrid();
190  
191 20 ▶ $cl ||= 'xxxx';
Condition50%1/2
$cl ||= "xxxx"
l!l
200
MC/DC0%0/1
$cl ||= "xxxx"
$cl
Truth table50%1/2
A
A= $cl
Aresult
11
00
192  
193 20 return qq|<?xml version="1.0" encoding="UTF-8" standalone="no"?><epp xmlns="urn:ietf:params:xml:ns:epp-1.0"><response><result code="1000"><msg>Command completed successfully.</msg></result><resData>$res</resData><trID><clTRID>$cl</clTRID><svTRID>$svtrid</svTRID></trID></response></epp>|;
194 }
195  
196 sub _min_answ {
197 63 ▶ my ( $code, $cl ) = @_;
Subroutine _min_answ: called CC=2 SCAR=7.0
198  
199 63 my $svtrid = get_svtrid();
200  
201 63 ▶ $cl ||= 'xxxx';
Condition50%1/2
$cl ||= "xxxx"
l!l
630
MC/DC0%0/1
$cl ||= "xxxx"
$cl
Truth table50%1/2
A
A= $cl
Aresult
11
00
202  
203 63 return qq|<?xml version="1.0" encoding="UTF-8" standalone="no"?><epp xmlns="urn:ietf:params:xml:ns:epp-1.0"><response><result code="$code"><msg>Command completed successfully.</msg></result><trID><clTRID>$cl</clTRID><svTRID>$svtrid</svTRID></trID></response></epp>|;
204 }
205  
206 sub login {
207 49 ▶ my ( $body ) = @_;
Subroutine login: called CC=9 SCAR=25.9
Pod undocumented
208  
209 49 my ( $cltrid ) = $body =~ m|<clTRID>([0-9A-Za-z\-]+)</clTRID>|;
210  
211 49 ▶ return _fail_cltrid() unless $cltrid;
Branch: 1 branch
BranchTrueFalseTotal
unless $cltrid 0 49 49
212  
213 49 ▶ unless ( $body =~ s|^<\?xml version="1.0" encoding="UTF-8"\?>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<\?xml version="1.0" encoding="UTF-8"\?>\s+//s) 0 49 49
214 0 _fail_body( 'XML schema validation failed: ', '2001', $cltrid );
215 }
216  
217 49 ▶ unless ( $body =~ s|^<epp xmlns="[^"]+" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<epp xmlns="[^"]+" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+//s) 0 49 49
218 0 _fail_body( 'XML schema validation failed: Element &#039;{uurn:ietf:params:xml:ns:epp-1.0}epp&#039;: No matching global declaration available for the validation root.', '2001', $cltrid );
219 }
220  
221 49 my $body2;
222 49 ▶ if ( $body =~ m|<command>\s*<login>\s*(.+?)</login>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>|s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ m[<command>\s*<login>\s*(.+?)</login>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>]s) { } 49 0 49
223 49 $body2 = $1;
224 }
225 else {
226 0 die "closed connection\n"; # behavior centralnic
227 }
228  
229 49 my ( $login ) = $body =~ m|<clID>([0-9A-Za-z_\-]+)</clID>|;
230  
231 49 my $svtrid = get_svtrid();
232  
233 49 ▶ return qq|<?xml version="1.0" encoding="UTF-8" standalone="no"?>
Branch: 1 branch
BranchTrueFalseTotal
unless $login 0 49 49
234 <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
235 <response>
236 <result code="2400">
237 <msg>Cannot authenticate $login: not found in database.</msg>
238 </result>
239 <trID>
240 <clTRID>$cltrid</clTRID>
241 <svTRID>$svtrid</svTRID>
242 </trID>
243 </response>
244 </epp>|
245 unless $login;
246  
247 49 my ( $pass ) = $body =~ m|<pw>([0-9A-Za-z!\@\$\%*_.:=+?#,"'\-{}\[\]\(\)]+)</pw>|;
248  
249 49 ▶ if ( !$pass || length( $pass ) < 6 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $pass or length $pass < 6) 0 49 49
Condition33%1/3
not $pass or length $pass < 6
l!l&&r!l&&!r
0049
MC/DC0%0/2
not $pass or length $pass < 6
not $pass length $pass < 6
Truth table33%1/3
not(A) or B
A= not $passB= length $pass < 6
ABresult
1X1
011
000
250 0 return qq|<?xml version="1.0" encoding="UTF-8" standalone="no"?>
251 <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
252 <response>
253 <result code="2001">
254 <msg>XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:epp-1.0}pw&#039;: [facet &#039;minLength&#039;] The value has a length of &#039;0&#039;; this underruns the allowed minimum length of &#039;6&#039;.</msg>
255 </result>
256 <trID>
257 <clTRID>$cltrid</clTRID>
258 <svTRID>$svtrid</svTRID>
259 </trID>
260 </response>
261 </epp>|;
262 }
263  
264 49 ▶ if ( $pass eq 'fail-pass' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pass eq "fail-pass") 0 49 49
265 0 return qq|<?xml version="1.0" encoding="UTF-8" standalone="no"?>
266 <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
267 <response>
268 <result code="2200">
269 <msg>Invalid password</msg>
270 </result>
271 <trID>
272 <clTRID>$cltrid</clTRID>
273 <svTRID>$svtrid</svTRID>
274 </trID>
275 </response>
276 </epp>|;
277 }
278  
279 49 return qq|<?xml version="1.0" encoding="UTF-8" standalone="no"?><epp xmlns="urn:ietf:params:xml:ns:epp-1.0"><response><result code="1000"><msg>Welcome user.</msg></result><trID><clTRID>$cltrid</clTRID><svTRID>$svtrid</svTRID></trID></response></epp>|;
280 }
281  
282  
283 sub contact_check {
284 1 ▶ my ( $obj, $body ) = @_;
Subroutine contact_check: called CC=11 SCAR=27.4
Pod undocumented
285  
286 1 my ( $cltrid ) = $body =~ m|<clTRID>([0-9A-Za-z\-]+)</clTRID>|s;
287  
288 1 ▶ return _fail_cltrid() unless $cltrid;
Branch: 1 branch
BranchTrueFalseTotal
unless $cltrid 0 1 1
289  
290 1 ▶ unless ( $body =~ s|^<\?xml version="1.0" encoding="UTF-8"\?>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<\?xml version="1.0" encoding="UTF-8"\?>\s+//s) 0 1 1
291 0 return _fail_body( 'XML schema validation failed: ', '2001', $cltrid );
292 }
293  
294 1 ▶ unless ( $body =~ s|^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+//s) 0 1 1
295 0 return _fail_body( 'XML schema validation failed: Element &#039;{uurn:ietf:params:xml:ns:epp-1.0}epp&#039;: No matching global declaration available for the validation root.', '2001', $cltrid );
296 }
297  
298 1 ▶ unless ( $body =~ s|^<command>\s+<check>\s+<contact:check[^<>]+>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<command>\s+<check>\s+<contact:check[^<>]+>\s+//s) 0 1 1
299 0 return _fail_body( 'XML schema validation failed: contact:check', '2001', $cltrid );
300 }
301  
302 1 ▶ unless ( $body =~ s|\s+</contact:check>\s+</check>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s[\s+</contact:check>\s+</check>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$][]s) 0 1 1
303 0 return _fail_body( 'XML schema validation failed: /contact:check', '2001', $cltrid );
304 }
305  
306 1 my ( @contacts ) = $body =~ m|(<contact:id>[^<>]+</contact:id>)|g;
307  
308 1 ▶ unless ( scalar @contacts ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (scalar @contacts) 0 1 1
309 0 return _fail_body( 'XML schema validation failed: contact:cd' );
310 }
311  
312 1 my $srv_url = $obj->{sock};
313 1 my $s = new IO::EPP::Test::Server( $srv_url );
314 1 my $answ_list = '';
315 1 foreach my $row ( @contacts ) {
316 2 my ( $cont_id ) = $row =~ m|<contact:id>([^<>]+)</contact:id>|;
317  
318 2 my $reason = '';
319 2 ▶ if ( $s->data->{conts}{$cont_id} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s->data->{"conts"}{$cont_id}) 0 2 2
320 0 $reason = $s->data->{conts}{$cont_id}{reason};
321 }
322  
323 2 ▶ my $avail = $reason ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$reason ? : 0 2 2
324  
325 2 ▶ $reason = "<contact:reason>$reason</contact:reason>" if $reason;
Branch: 1 branch
BranchTrueFalseTotal
if $reason 0 2 2
326  
327 2 $answ_list .= qq|<contact:id avail="$avail">$cont_id</contact:id>$reason</contact:cd>|;
328 }
329  
330 1 my $svtrid = get_svtrid();
331  
332 1 return qq|<?xml version="1.0" encoding="UTF-8" standalone="no"?>
333 <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
334 <response>
335 <result code="1000">
336 <msg>Command completed successfully.</msg>
337 </result>
338 <resData><contact:chkData xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">$answ_list</contact:chkData></resData><trID>
339 <clTRID>$cltrid</clTRID><svTRID>$svtrid</svTRID>
340 </trID>
341 </response>
342 </epp>|;
343 }
344  
345  
346 sub contact_create_update {
347 13 ▶ my ( $obj, $body, $act ) = @_;
Subroutine contact_create_update: called CC=64 SCAR=51.6
Pod undocumented
348  
349 13 my ( $cltrid ) = $body =~ m|<clTRID>([0-9A-Za-z\-]+)</clTRID>|s;
350  
351 13 ▶ return _fail_cltrid() unless $cltrid;
Branch: 1 branch
BranchTrueFalseTotal
unless $cltrid 0 13 13
352  
353 13 ▶ unless ( $body =~ s|^<\?xml version="1.0" encoding="UTF-8"\?>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<\?xml version="1.0" encoding="UTF-8"\?>\s+//s) 0 13 13
354 0 return _fail_body( 'XML schema validation failed: ', '2001', $cltrid );
355 }
356  
357 13 ▶ unless ( $body =~ s|^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+//s) 0 13 13
358 0 return _fail_body( 'XML schema validation failed: Element &#039;{uurn:ietf:params:xml:ns:epp-1.0}epp&#039;: No matching global declaration available for the validation root.', '2001', $cltrid );
359 }
360  
361 13 ▶ unless ( $body =~ s|^<command>\s+<$act>\s+<contact:$act[^<>]+>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<command>\s+<$act>\s+<contact:${act}[^<>]+>\s+//s) 0 13 13
362 0 return _fail_body( "XML schema validation failed: contact:$act", '2001', $cltrid );
363 }
364  
365 13 ▶ unless ( $body =~ s|\s+</contact:$act>\s+</$act>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s[\s+</contact:$act>\s+</$act>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$][]s) 0 13 13
366 0 return _fail_body( "XML schema validation failed: /contact:$act", '2001', $cltrid );
367 }
368  
369 13 my $i = () = $body =~ /<postalInfo type="int">/g;
370  
371 13 ▶ if ( $i > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i > 1) 0 13 13
372 # text from verisign NameStore server
373 0 _fail_body( 'Parameter value policy error, Only one int postal address information allowed', '2306', $cltrid );
374 }
375  
376 13 my $l = () = $body =~ /<postalInfo type="loc">/g;
377  
378 13 ▶ if ( $l > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($l > 1) 0 13 13
379 0 _fail_body( 'Parameter value policy error, Only one loc postal address information allowed', '2306', $cltrid );
380 }
381  
382 13 ▶ if ( $i+$l == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i + $l == 0) 13 0 13
383 13 _fail_body( 'XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:contact-1.0}voice&#039;: This element is not expected. Expected is ( {urn:ietf:params:xml:ns:contact-1.0}postalInfo ).', '2001', $cltrid );
384 }
385  
386 13 my %cont;
387 13 ▶ if ( $body =~ m|<contact:id>([^<>]+)</contact:id>| ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ m[<contact:id>([^<>]+)</contact:id>]) { } 13 0 13
388 13 $cont{id} = $1;
389 }
390 else {
391 0 return _fail_body( "XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:contact-1.0}$act&#039;: Missing child element(s). Expected is one of ( {urn:ietf:params:xml:ns:contact-1.0}id, {urn:ietf:params:xml:ns:contact-1.0}ext ).", '2001', $cltrid );
392 }
393  
394 13 my $srv_url = $obj->{sock};
395 13 my $s = new IO::EPP::Test::Server( $srv_url );
396  
397 13 my $top;
398 13 ▶ if ( $act eq 'create' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($act eq 'create') { } 11 2 13
elsif ($act eq 'update') { } 2 0 2
399 11 ▶ if ( $s->data->{conts}{$cont{id}} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s->data->{"conts"}{$cont{"id"}}) 1 10 11
400 1 ▶ if ( $s->data->{conts}{$cont{id}}{reason} eq 'in use' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s->data->{'conts'}{$cont{'id'}}{'reason'} eq 'in use') { } 1 0 1
401 1 return _fail_body( "Contact object &#039;$cont{id}&#039; already exists.", '2302', $cltrid );
402 }
403 else {
404 0 return _fail_body( "Contact object &#039;$cont{id}&#039; $s->data->{conts}{$cont{id}}{reason}.", '2302', $cltrid );
405 }
406 }
407  
408 10 $top = 'create';
409 }
410 elsif ( $act eq 'update' ) {
411 2 ▶ unless ( $s->data->{conts}{$cont{id}} and $s->data->{conts}{$cont{id}}{reason} eq 'in use' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($s->data->{"conts"}{$cont{"id"}} and $s->data->{"conts"}{$cont{"id"}}{"reason"} eq "in use") 1 1 2
Condition66%2/3
$s->data->{"conts"}{$cont{"id"}} and $s->data->{"conts"}{$cont{"id"}}{"reason"} eq "in use"
!ll&&!rl&&r
101
MC/DC50%1/2
$s->data->{"conts"}{$cont{"id"}} and $s->data->{"conts"}{$cont{"id"}}{"reason"} eq "in use"
$s->data->{"conts"}{$cont{"id"}} $s->data->{"conts"}{$cont{"id"}}{"reason"} eq "in use"
Truth table66%2/3
A and B
A= $s->data->{"conts"}{$cont{"id"}}B= $s->data->{"conts"}{$cont{"id"}}{"reason"} eq "in use"
ABresult
0X0
100
111
412 # contact does not exist, the reason does not
413 1 return _fail_body( 'Cannot find that object.', '2303', $cltrid );
414 }
415  
416 1 $top = 'chg';
417 }
418  
419 11 for my $t ( 'int', 'loc' ) {
420 22 ▶ if ( $body =~ m|<contact:postalInfo type="$t">(.+?)</contact:postalInfo>|s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ m[<contact:postalInfo type="$t">(.+?)</contact:postalInfo>]s) 15 7 22
421 15 $cont{$t} = $1;
422 }
423 }
424  
425  
426 11 for my $t ( 'int', 'loc' ) {
427 22 my $pi = delete $cont{$t};
428 22 ▶ next unless $pi;
Branch: 1 branch
BranchTrueFalseTotal
unless $pi 7 15 22
429  
430 15 $cont{$t} = {};
431 15 foreach my $f ( 'name', 'org', 'addr' ) {
432 45 ▶ if ( $pi =~ m|<contact:$f>(.+?)</contact:$f>|s ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($pi =~ m[<contact:$f>(.+?)</contact:$f>]s) { } 37 8 45
elsif ($pi =~ m[<contact:$f/>]) { } 7 1 8
433 37 $cont{$t}{$f} = $1;
434 }
435 elsif ( $pi =~ m|<contact:$f/>| ) {
436 7 ▶ if ( $f eq 'org' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($f eq 'org') { } 7 0 7
437 # $cont{$t}{$f} = undef;
438 }
439 else {
440 0 return _fail_body( "XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:contact-1.0}$f&#039;: [facet &#039;minLength&#039;] The value has a length of &#039;0&#039;; this underruns the allowed minimum length of &#039;1&#039;.", '2001', $cltrid );
441 }
442 }
443 else {
444 1 ▶ if ( $f eq 'name' && $act eq 'create' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($f eq "name" and $act eq "create") 0 1 1
Condition33%1/3
$f eq "name" and $act eq "create"
!ll&&!rl&&r
010
MC/DC0%0/2
$f eq "name" and $act eq "create"
$f eq "name" $act eq "create"
Truth table33%1/3
A and B
A= $f eq "name"B= $act eq "create"
ABresult
0X0
100
111
445 0 return _fail_body( "XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:contact-1.0}postalInfo&#039;: Missing child element(s). Expected is one of ( {urn:ietf:params:xml:ns:contact-1.0}$f, {urn:ietf:params:xml:ns:contact-1.0}ext ).", '2001', $cltrid );
446 }
447 }
448 }
449  
450 15 my $addr = delete $cont{$t}{addr};
451 15 $cont{$t}{addr} = {};
452  
453 15 my @street = $addr =~ m|(<contact:street>[^<>]+</contact:street>)|g;
454 15 ▶ unless ( scalar @street ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (scalar @street) 0 15 15
455 0 return _fail_body( "XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:contact-1.0}addr&#039;: Missing child element(s). Expected is one of ( {urn:ietf:params:xml:ns:contact-1.0}street, {urn:ietf:params:xml:ns:contact-1.0}ext ).", '2001', $cltrid );
456 }
457 15 $cont{$t}{addr}{street} = [];
458 15 foreach my $row ( @street ) {
459 19 ▶ if ( $row =~ m|<contact:street>([^<>]+)</contact:street>| ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($row =~ m[<contact:street>([^<>]+)</contact:street>]) 19 0 19
460 19 push @{$cont{$t}{addr}{street}}, $1;
461 }
462 }
463  
464 15 foreach my $f ( 'city', 'sp', 'pc' , 'cc' ) {
465 60 ▶ if ( $pi =~ m|<contact:$f>(.+?)</contact:$f>|s ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($pi =~ m[<contact:$f>(.+?)</contact:$f>]s) { } 60 0 60
elsif ($pi =~ m[<contact:$f/>]) { } 0 0 0
466 60 $cont{$t}{addr}{$f} = $1;
467 }
468 elsif ( $pi =~ m|<contact:$f/>| ) {
469 0 ▶ if ( $f eq 'sp' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($f eq 'sp') { } 0 0 0
470 # $cont{$t}{addr}{$f} = undef;
471 }
472 else {
473 0 return _fail_body( "XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:contact-1.0}$f&#039;: [facet &#039;minLength&#039;] The value has a length of &#039;0&#039;; this underruns the allowed minimum length of &#039;1&#039;.", '2001', $cltrid );
474 }
475 }
476 else {
477 0 return _fail_body( "XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:contact-1.0}addr&#039;: Missing child element(s). Expected is one of ( {urn:ietf:params:xml:ns:contact-1.0}$f, {urn:ietf:params:xml:ns:contact-1.0}ext ).", '2001', $cltrid );
478 }
479 }
480  
481 15 ▶ unless ( $cont{$t}{addr}{cc} && length( $cont{$t}{addr}{cc} ) == 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($cont{$t}{"addr"}{"cc"} and length $cont{$t}{"addr"}{"cc"} == 2) 0 15 15
Condition33%1/3
$cont{$t}{"addr"}{"cc"} and length $cont{$t}{"addr"}{"cc"} == 2
!ll&&!rl&&r
0015
MC/DC0%0/2
$cont{$t}{"addr"}{"cc"} and length $cont{$t}{"addr"}{"cc"} == 2
$cont{$t}{"addr"}{"cc"} length $cont{$t}{"addr"}{"cc"} == 2
Truth table33%1/3
A and B
A= $cont{$t}{"addr"}{"cc"}B= length $cont{$t}{"addr"}{"cc"} == 2
ABresult
0X0
100
111
482 0 return _fail_body( 'XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:contact-1.0}cc&#039;: [facet &#039;length&#039;] The value has a length of &#039;4&#039;; this differs from the allowed length of &#039;2&#039;.', '2001', $cltrid );
483 }
484  
485 15 ▶ if ( $cont{$t}{addr}{cc} !~ /^[A-Z]+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($cont{$t}{"addr"}{"cc"} =~ /^[A-Z]+$/) 0 15 15
486 0 return _fail_body( "The country code &#039;$cont{$t}{addr}{cc}&#039; is not known to us", '2004', $cltrid );
487 }
488 }
489  
490 11 foreach my $f ( 'voice', 'fax', 'email' ) {
491 31 ▶ if ( $body =~ /<contact:$f>/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($body =~ /<contact:$f>/) { } 21 10 31
elsif ($f eq 'fax' and $body =~ m[<contact:$f/>]) { } 10 0 10
492 21 my @cfs = $body =~ m|(<contact:$f>[^<>]*</contact:$f>)|g; # contact fields
493  
494 21 $cont{$f} = [];
495 21 foreach my $cf ( @cfs ) {
496 24 ▶ if ( $cf =~ m|<contact:$f>([^<>]*)</contact:$f>| ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cf =~ m[<contact:$f>([^<>]*)</contact:$f>]) 24 0 24
497 24 my $c = $1;
498  
499 24 ▶ if ( length( $c ) == 0 ) {
Branch: 3 branches
BranchTrueFalseTotal
if (length $c == 0) { } 0 24 24
elsif ($f eq 'fax' || $f eq 'voice' and not $c =~ /^\+\d{1,3}\.\d{1,14}$/) { } 1 23 24
elsif ($f eq 'email' and not $c =~ /^[0-9a-z\.\-]+\@[0-9a-z\.\-]+$/) { } 0 23 23
500 0 return _fail_body( "XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:contact-1.0}$f&#039;: [facet &#039;minLength&#039;] The value has a length of &#039;0&#039;; this underruns the allowed minimum length of &#039;1&#039;.", '2001', $cltrid );
501 }
502 ▶ elsif ( $f eq 'fax' || $f eq 'voice' and $c !~ /^\+\d{1,3}\.\d{1,14}$/ ) {
Condition83%5/6
$f eq "fax" || $f eq "voice" and not $c =~ /^\+\d{1,3}\.\d{1,14}$/
!ll&&!rl&&r
10131
$f eq "fax" or $f eq "voice"
l!l&&r!l&&!r
01410
MC/DC66%2/3
$f eq "fax" || $f eq "voice" and not $c =~ /^\+\d{1,3}\.\d{1,14}$/
$f eq "fax" $f eq "voice" not $c =~ /^\+\d{1,3}\.\d{1,14}$/
Truth table60%3/5
A or B and not(C)
A= $f eq "fax"B= $f eq "voice"C= not $c =~ /^\+\d{1,3}\.\d{1,14}$/
ABCresult
00X0
1X00
0100
1X11
0111
503 1 return _fail_body( 'XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:contact-1.0}voice&#039;: [facet &#039;pattern&#039;] The value &#039;A380954272445&#039; is not accepted by the pattern &#039;(\\+[0-9]{1,3}\\.[0-9]{1,14})?&#039;.', '2001', $cltrid );
504 }
505 ▶ elsif ( $f eq 'email' and $c !~ /^[0-9a-z\.\-]+\@[0-9a-z\.\-]+$/ ) {
Condition66%2/3
$f eq "email" and not $c =~ /^[0-9a-z\.\-]+\@[0-9a-z\.\-]+$/
!ll&&!rl&&r
13100
MC/DC0%0/2
$f eq "email" and not $c =~ /^[0-9a-z\.\-]+\@[0-9a-z\.\-]+$/
$f eq "email" not $c =~ /^[0-9a-z\.\-]+\@[0-9a-z\.\-]+$/
Truth table66%2/3
A and not(B)
A= $f eq "email"B= not $c =~ /^[0-9a-z\.\-]+\@[0-9a-z\.\-]+$/
ABresult
0X0
100
111
506 0 return _fail_body( 'E-mail address is invalid or missing', '2004', $cltrid );
507 }
508 else {
509 23 push @{$cont{$f}}, $c;
510 }
511 }
512 }
513 }
514 ▶ elsif ( $f eq 'fax' and $body =~ m|<contact:$f/>| ) {
Condition33%1/3
$f eq "fax" and $body =~ m[<contact:$f/>]
!ll&&!rl&&r
0010
MC/DC0%0/2
$f eq "fax" and $body =~ m[<contact:$f/>]
$f eq "fax" $body =~ m[<contact:$f/>]
Truth table33%1/3
A and B
A= $f eq "fax"B= $body =~ m[<contact:$f/>]
ABresult
0X0
100
111
515 10 $cont{$f} = [];
516 }
517 else {
518 0 return _fail_body( "XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:contact-1.0}$top&#039;: Missing child element(s). Expected is one of ( {urn:ietf:params:xml:ns:contact-1.0}$f, {urn:ietf:params:xml:ns:contact-1.0}ext ).", '2001', $cltrid );
519 }
520 }
521  
522 10 ▶ if ( $body =~ m|<contact:authInfo>\s*<contact:pw>([^<>]+)</contact:pw>\s*</contact:authInfo>|s ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($body =~ m[<contact:authInfo>\s*<contact:pw>([^<>]+)</contact:pw>\s*</contact:authInfo>]s) { } 10 0 10
elsif ($body =~ m[<contact:authInfo>\s*<contact:pw/>\s*</contact:authInfo>]) { } 0 0 0
523 10 $cont{authInfo} = $1;
524 }
525 elsif ( $body =~ m|<contact:authInfo>\s*<contact:pw/>\s*</contact:authInfo>| ) {
526 0 $cont{authInfo} = '';
527 }
528 else {
529 0 return _fail_body( 'XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:contact-1.0}authInfo&#039;: Missing child element(s). Expected is one of ( {urn:ietf:params:xml:ns:contact-1.0}pw, {urn:ietf:params:xml:ns:contact-1.0}ext ).', '2001', $cltrid );
530 }
531 10 ▶ if ( $cont{authInfo} and length( $cont{authInfo} ) < 16 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cont{"authInfo"} and length $cont{"authInfo"} < 16) 1 9 10
Condition66%2/3
$cont{"authInfo"} and length $cont{"authInfo"} < 16
!ll&&!rl&&r
091
MC/DC50%1/2
$cont{"authInfo"} and length $cont{"authInfo"} < 16
$cont{"authInfo"} length $cont{"authInfo"} < 16
Truth table66%2/3
A and B
A= $cont{"authInfo"}B= length $cont{"authInfo"} < 16
ABresult
0X0
100
111
532 1 return _fail_body( 'authInfo code is invalid: password must be at least 16 characters', '2004', $cltrid );
533 }
534 9 ▶ unless ( $cont{authInfo} and $cont{authInfo} =~ /[A-Z]/ and $cont{authInfo} =~ /[a-z]/ and $cont{authInfo} =~ /[0-9]/ and $cont{authInfo} =~ /[!\@\$\%*_.:\-=+?#,"'\\\/&]/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($cont{"authInfo"} and $cont{"authInfo"} =~ /[A-Z]/ and $cont{"authInfo"} =~ /[a-z]/ and $cont{"authInfo"} =~ /[0-9]/ and $cont{"authInfo"} =~ m[[!\@\$\%*_.:\-=+?#,"'\\/&]]) 0 8 8
Condition66%8/12
$cont{"authInfo"} and $cont{"authInfo"} =~ /[A-Z]/ and $cont{"authInfo"} =~ /[a-z]/ and $cont{"authInfo"} =~ /[0-9]/ and $cont{"authInfo"} =~ m[[!\@\$\%*_.:\-=+?#,"'\\/&]]
!ll&&!rl&&r
108
$cont{"authInfo"} and $cont{"authInfo"} =~ /[A-Z]/ and $cont{"authInfo"} =~ /[a-z]/ and $cont{"authInfo"} =~ /[0-9]/
!ll&&!rl&&r
108
$cont{"authInfo"} and $cont{"authInfo"} =~ /[A-Z]/ and $cont{"authInfo"} =~ /[a-z]/
!ll&&!rl&&r
108
$cont{"authInfo"} and $cont{"authInfo"} =~ /[A-Z]/
!ll&&!rl&&r
018
MC/DC20%1/5
$cont{"authInfo"} and $cont{"authInfo"} =~ /[A-Z]/ and $cont{"authInfo"} =~ /[a-z]/ and $cont{"authInfo"} =~ /[0-9]/ and $cont{"authInfo"} =~ m[[!\@\$\%*_.:\-=+?#,"'\\/&]]
$cont{"authInfo"} $cont{"authInfo"} =~ /[A-Z]/ $cont{"authInfo"} =~ /[a-z]/ $cont{"authInfo"} =~ /[0-9]/ $cont{"authInfo"} =~ m[[!\@\$\%*_.:\-=+?#,"'\\/&]]
Truth table33%2/6
A and B and C and D and E
A= $cont{"authInfo"}B= $cont{"authInfo"} =~ /[A-Z]/C= $cont{"authInfo"} =~ /[a-z]/D= $cont{"authInfo"} =~ /[0-9]/E= $cont{"authInfo"} =~ m[[!\@\$\%*_.:\-=+?#,"'\\/&]]
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
535 1 return _fail_body( 'authInfo code is invalid: password must contain a mix of uppercase and lowercase characters', '2004', $cltrid );
536 }
537  
538 # TODO: update statuses
539  
540 8 ▶ if ( $act eq 'create' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($act eq 'create') { } 7 1 8
541 7 my ( $cre_date ) = get_dates();
542  
543 7 $s->data->{conts}{$cont{id}} = { %cont, reason => 'in use', statuses => { 'ok' => '+' }, owner => $obj->{user}, creater => $obj->{user}, updater => $obj->{user}, cre_date => $cre_date, upd_date => $cre_date, roid => uc(md5_hex($cont{id}.$cre_date)) . '-TEST' };
544  
545 7 return _ok_answ( qq|<contact:creData xmlns:contact="urn:ietf:params:xml:ns:contact-1.0"><contact:id>$cont{id}</contact:id><contact:crDate>$cre_date</contact:crDate></contact:creData>|, $cltrid );
546 }
547 else { # update
548 1 my $old = $s->data->{conts}{$cont{id}};
549  
550 1 ▶ if ( $old->{owner} ne $obj->{user} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($old->{"owner"} ne $obj->{"user"}) 0 1 1
551 # TODO: check main domain
552 0 return _fail_body( 'You are not authorised to modify this contact object (you do not sponsor the parent domain).', '2201', $cltrid );
553 }
554  
555 1 my ( $upd_date ) = get_dates();
556  
557 1 foreach my $f ( 'voice','fax','email','authInfo' ) {
558 4 $old->{$f} = $cont{$f};
559 }
560  
561 1 for my $t ( 'int', 'loc' ) {
562 2 ▶ if ( $cont{$t} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cont{$t}) { } 1 1 2
563 1 ▶ $old->{$t}{name} = $cont{$t}{name} if $cont{$t}{name};
Branch: 1 branch
BranchTrueFalseTotal
if $cont{$t}{"name"} 0 1 1
564 1 ▶ if ( $cont{$t}{org} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cont{$t}{'org'}) { } 0 1 1
565 $old->{$t}{org} = $cont{$t}{org}
566 0 }
567 else {
568 1 delete $old->{$t}{org};
569 }
570 1 $old->{$t}{addr} = $cont{$t}{addr};
571 }
572 else {
573 1 delete $old->{$t};
574 }
575 }
576  
577 1 $old->{upd_date} = $upd_date;
578 1 $old->{updater} = $obj->{user};
579  
580 1 my $svtrid = get_svtrid();
581  
582 1 return _min_answ( '1000', $cltrid );
583 }
584 }
585  
586  
587 sub contact_info {
588 4 ▶ my ( $obj, $body ) = @_;
Subroutine contact_info: called CC=22 SCAR=33.4
Pod undocumented
589  
590 4 my ( $cltrid ) = $body =~ m|<clTRID>([0-9A-Za-z\-]+)</clTRID>|s;
591  
592 4 ▶ return _fail_cltrid() unless $cltrid;
Branch: 1 branch
BranchTrueFalseTotal
unless $cltrid 0 4 4
593  
594 4 ▶ unless ( $body =~ s|^<\?xml version="1.0" encoding="UTF-8"\?>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<\?xml version="1.0" encoding="UTF-8"\?>\s+//s) 0 4 4
595 0 return _fail_body( 'XML schema validation failed: ', '2001', $cltrid );
596 }
597  
598 4 ▶ unless ( $body =~ s|^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+//s) 0 4 4
599 0 return _fail_body( 'XML schema validation failed: Element &#039;{uurn:ietf:params:xml:ns:epp-1.0}epp&#039;: No matching global declaration available for the validation root.', '2001', $cltrid );
600 }
601  
602 4 ▶ unless ( $body =~ s|^<command>\s+<info>\s+<contact:info[^<>]+>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<command>\s+<info>\s+<contact:info[^<>]+>\s+//s) 0 4 4
603 0 return _fail_body( 'XML schema validation failed: contact:info', '2001', $cltrid );
604 }
605  
606 4 ▶ unless ( $body =~ s|\s+</contact:info>\s+</info>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s[\s+</contact:info>\s+</info>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$][]s) 0 4 4
607 0 return _fail_body( 'XML schema validation failed: /contact:info', '2001', $cltrid );
608 }
609  
610 4 my $id;
611 4 ▶ if ( $body =~ m|<contact:id>([^<>]+)</contact:id>| ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ m[<contact:id>([^<>]+)</contact:id>]) { } 4 0 4
612 4 $id = $1;
613 }
614 else {
615 0 return _fail_body( 'XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:contact-1.0}id&#039;: [facet &#039;minLength&#039;] The value has a length of &#039;1&#039;; this underruns the allowed minimum length of &#039;3&#039;.', '2001', $cltrid );
616 }
617  
618 4 my $srv_url = $obj->{sock};
619 4 my $s = new IO::EPP::Test::Server( $srv_url );
620  
621 4 ▶ unless ( $s->data->{conts}{$id} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($s->data->{"conts"}{$id}) 1 3 4
622 1 return _fail_body( "Cannot find an object with an ID of $id.", '2303', $cltrid );
623 }
624  
625 3 my %cont = %{$s->data->{conts}{$id}};
626  
627 my $answ = '<contact:infData xmlns:contact="urn:ietf:params:xml:ns:contact-1.0"><contact:id>' .
628 3 $id . '</contact:id><contact:roid>' . $cont{roid} . '</contact:roid>';
629  
630 3 foreach my $s ( keys %{ $cont{statuses} } ) {
631 3 ▶ if ( $cont{statuses}{$s} eq '+' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cont{'statuses'}{$s} eq '+') { } 3 0 3
632 3 $answ .= qq|<contact:status s="$s" />|;
633 }
634 else {
635 0 $answ .= qq|<contact:status s="$s">| . $cont{statuses}{$s} . '<contact:status>';
636 }
637 }
638  
639 3 for my $t ( 'int', 'loc' ) {
640 6 ▶ if ( $cont{$t} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cont{$t}) 5 1 6
641 5 $answ .= qq|<contact:postalInfo type="$t"><contact:name>|.$cont{$t}{name}.'</contact:name>';
642 5 ▶ $answ .= $cont{$t}{org} ? qq|<contact:org>$cont{$t}{org}</contact:org>| : '<contact:org/>' ;
Branch: 1 branch
BranchTrueFalseTotal
$cont{$t}{'org'} ? : 4 1 5
643 5 $answ .= '<contact:addr>';
644 5 $answ .= qq|<contact:street>$_</contact:street>| for @{$cont{$t}{addr}{street}};
645 5 $answ .= qq|<contact:city>$cont{$t}{addr}{city}</contact:city>|;
646 5 ▶ $answ .= $cont{$t}{addr}{sp} ? qq|<contact:sp>$cont{$t}{addr}{sp}</contact:sp>| : '<contact:sp/>';
Branch: 1 branch
BranchTrueFalseTotal
$cont{$t}{'addr'}{'sp'} ? : 5 0 5
647 5 ▶ $answ .= $cont{$t}{addr}{sp} ? qq|<contact:pc>$cont{$t}{addr}{sp}</contact:pc>| : '<contact:pc/>';
Branch: 1 branch
BranchTrueFalseTotal
$cont{$t}{'addr'}{'sp'} ? : 5 0 5
648 5 ▶ $answ .= $cont{$t}{addr}{cc} ? qq|<contact:cc>$cont{$t}{addr}{cc}</contact:cc>| : '<contact:cc/>';
Branch: 1 branch
BranchTrueFalseTotal
$cont{$t}{'addr'}{'cc'} ? : 5 0 5
649 5 $answ .= '</contact:addr>';
650 5 $answ .= '</contact:postalInfo>';
651 }
652 }
653 3 foreach my $v ( @{$cont{voice}} ) {
654 5 $answ .= "<contact:voice>$v</contact:voice>";
655 }
656 3 ▶ if ( scalar @{$cont{fax}} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$cont{'fax'};}) { } 0 3 3
657 0 foreach my $f ( @{$cont{fax}} ) {
658 0 $answ .= "<contact:fax>$f</contact:fax>";
659 }
660 }
661 else {
662 3 $answ .= '<contact:fax/>';
663 }
664 3 foreach my $e ( @{$cont{email}} ) {
665 3 $answ .= "<contact:email>$e</contact:email>";
666 }
667 3 $answ .= "<contact:clID>$cont{owner}</contact:clID>";
668 3 $answ .= "<contact:crID>$cont{creater}</contact:crID>";
669 3 $answ .= "<contact:crDate>$cont{cre_date}</contact:crDate>";
670 3 ▶ $answ .= "<contact:upID>$cont{updater}</contact:upID>" if $cont{updater};
Branch: 1 branch
BranchTrueFalseTotal
if $cont{"updater"} 3 0 3
671 3 $answ .= "<contact:upDate>$cont{upd_date}</contact:upDate>";
672  
673 3 $answ .= qq|<contact:disclose flag="1"><contact:voice/><contact:email/></contact:disclose></contact:infData>|;
674  
675 3 return _ok_answ( $answ, $cltrid );
676 }
677  
678  
679 sub contact_delete {
680 2 ▶ my ( $obj, $body ) = @_;
Subroutine contact_delete: called CC=10 SCAR=26.4
Pod undocumented
681  
682 2 my ( $cltrid ) = $body =~ m|<clTRID>([0-9A-Za-z\-]+)</clTRID>|s;
683  
684 2 ▶ return _fail_cltrid() unless $cltrid;
Branch: 1 branch
BranchTrueFalseTotal
unless $cltrid 0 2 2
685  
686 2 ▶ unless ( $body =~ s|^<\?xml version="1.0" encoding="UTF-8"\?>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<\?xml version="1.0" encoding="UTF-8"\?>\s+//s) 0 2 2
687 0 return _fail_body( 'XML schema validation failed: ', '2001', $cltrid );
688 }
689  
690 2 ▶ unless ( $body =~ s|^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+//s) 0 2 2
691 0 return _fail_body( 'XML schema validation failed: Element &#039;{uurn:ietf:params:xml:ns:epp-1.0}epp&#039;: No matching global declaration available for the validation root.', '2001', $cltrid );
692 }
693  
694 2 ▶ unless ( $body =~ s|^<command>\s+<delete>\s+<contact:delete[^<>]+>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<command>\s+<delete>\s+<contact:delete[^<>]+>\s+//s) 0 2 2
695 0 return _fail_body( 'XML schema validation failed: contact:info', '2001', $cltrid );
696 }
697  
698 2 ▶ unless ( $body =~ s|\s+</contact:delete>\s+</delete>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s[\s+</contact:delete>\s+</delete>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$][]s) 0 2 2
699 0 return _fail_body( 'XML schema validation failed: /contact:delete', '2001', $cltrid );
700 }
701  
702 2 my $id;
703 2 ▶ if ( $body =~ m|<contact:id>([^<>]+)</contact:id>| ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ m[<contact:id>([^<>]+)</contact:id>]) { } 2 0 2
704 2 $id = $1;
705 }
706 else {
707 0 return _fail_body( 'XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:contact-1.0}id&#039;: [facet &#039;minLength&#039;] The value has a length of &#039;1&#039;; this underruns the allowed minimum length of &#039;3&#039;.', '2001', $cltrid );
708 }
709  
710 2 my $srv_url = $obj->{sock};
711 2 my $s = new IO::EPP::Test::Server( $srv_url );
712  
713 2 ▶ unless ( $s->data->{conts}{$id} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($s->data->{"conts"}{$id}) 1 1 2
714 1 return _fail_body( "Contact object cannot be found.", '2303', $cltrid );
715 }
716  
717 1 ▶ if ( $s->data->{conts}{$id}{statuses}{linked} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s->data->{"conts"}{$id}{"statuses"}{"linked"}) 0 1 1
718 0 return _fail_body( 'Contact object is linked to one or more domains.', '2305', $cltrid );
719 }
720  
721 1 ▶ if ( $s->data->{conts}{$id}{owner} ne $obj->{user} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s->data->{"conts"}{$id}{"owner"} ne $obj->{"user"}) 0 1 1
722 0 return _fail_body( 'Permission denied.', '2201', $cltrid );
723 }
724  
725 1 delete $s->data->{conts}->{$id};
726  
727 1 my $svtrid = get_svtrid();
728  
729 1 return _min_answ( '1000', $cltrid );
730 }
731  
732  
733 sub host_check {
734 1 ▶ my ( $obj, $body ) = @_;
Subroutine host_check: called CC=13 SCAR=27.1
Pod undocumented
735  
736 1 my ( $cltrid ) = $body =~ m|<clTRID>([0-9A-Za-z\-]+)</clTRID>|s;
737  
738 1 ▶ return _fail_cltrid() unless $cltrid;
Branch: 1 branch
BranchTrueFalseTotal
unless $cltrid 0 1 1
739  
740 1 ▶ unless ( $body =~ s|^<\?xml version="1.0" encoding="UTF-8"\?>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<\?xml version="1.0" encoding="UTF-8"\?>\s+//s) 0 1 1
741 0 return _fail_body( 'XML schema validation failed: ', '2001', $cltrid );
742 }
743  
744 1 ▶ unless ( $body =~ s|^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+//s) 0 1 1
745 0 return _fail_body( 'XML schema validation failed: Element &#039;{uurn:ietf:params:xml:ns:epp-1.0}epp&#039;: No matching global declaration available for the validation root.', '2001', $cltrid );
746 }
747  
748 1 ▶ unless ( $body =~ s|^<command>\s+<check>\s+<host:check[^<>]+>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<command>\s+<check>\s+<host:check[^<>]+>\s+//s) 0 1 1
749 0 return _fail_body( 'XML schema validation failed: host:check', '2001', $cltrid );
750 }
751  
752 1 ▶ unless ( $body =~ s|\s+</host:check>\s+</check>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s[\s+</host:check>\s+</check>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$][]s) 0 1 1
753 0 return _fail_body( 'XML schema validation failed: /host:check', '2001', $cltrid );
754 }
755  
756 1 my ( @hosts ) = $body =~ m|(<host:name>[^<>]+</host:name>)|g;
757  
758 1 ▶ unless ( scalar @hosts ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (scalar @hosts) 0 1 1
759 0 return _fail_body( 'XML schema validation failed: host:cd', '2001', $cltrid );
760 }
761  
762 1 my $srv_url = $obj->{sock};
763 1 my $s = new IO::EPP::Test::Server( $srv_url );
764 1 my $answ_list = '';
765 1 foreach my $row ( @hosts ) {
766 3 my ( $ns ) = $row =~ m|<host:name>([^<>]+)</host:name>|;
767 3 $ns = lc $ns;
768  
769 3 my $reason = '';
770  
771 3 ▶ if ( $s->data->{nss}{$ns} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($s->data->{'nss'}{$ns}) { } 1 2 3
elsif (not $ns =~ /^[0-9a-z\.\-]+$/) { } 1 1 2
772 1 ▶ $reason = $s->data->{nss}{$ns}{reason} || '';
Condition50%1/2
$s->data->{'nss'}{$ns}{'reason'} || ''
l!l
10
MC/DC0%0/1
$s->data->{'nss'}{$ns}{'reason'} || ''
$s->data->{'nss'}{$ns}{'reason'}
Truth table50%1/2
A
A= $s->data->{'nss'}{$ns}{'reason'}
Aresult
11
00
773 }
774 elsif ( $ns !~ /^[0-9a-z\.\-]+$/ ) {
775 1 my ( $c ) = $ns !~ /([^0-9a-z\.\-])/;
776 1 $reason = 'the following characters are not permitted: &#039;'.$c.'&#039;';
777 }
778  
779 3 ▶ my $avail = $reason ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$reason ? : 2 1 3
780  
781 3 ▶ $reason = "<host:reason>$reason</host:reason>" if $reason;
Branch: 1 branch
BranchTrueFalseTotal
if $reason 2 1 3
782  
783 3 $answ_list .= qq|<host:cd><host:name avail="$avail">$ns</host:name>$reason</host:cd>|;
784 }
785  
786 1 my $svtrid = get_svtrid();
787  
788 1 return qq|<?xml version="1.0" encoding="UTF-8" standalone="no"?>
789 <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
790 <response>
791 <result code="1000">
792 <msg>Command completed successfully.</msg>
793 </result>
794 <resData><host:chkData xmlns:host="urn:ietf:params:xml:ns:host-1.0">$answ_list</host:chkData></resData><trID>
795 <clTRID>$cltrid</clTRID><svTRID>$svtrid</svTRID>
796 </trID>
797 </response>
798 </epp>|;
799 }
800  
801  
802 sub host_create {
803 8 ▶ my ( $obj, $body ) = @_;
Subroutine host_create: called CC=17 SCAR=30.1
Pod undocumented
804  
805 8 my ( $cltrid ) = $body =~ m|<clTRID>([0-9A-Za-z\-]+)</clTRID>|s;
806  
807 8 ▶ return _fail_cltrid() unless $cltrid;
Branch: 1 branch
BranchTrueFalseTotal
unless $cltrid 0 8 8
808  
809 8 ▶ unless ( $body =~ s|^<\?xml version="1.0" encoding="UTF-8"\?>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<\?xml version="1.0" encoding="UTF-8"\?>\s+//s) 0 8 8
810 0 return _fail_body( 'XML schema validation failed: ', '2001', $cltrid );
811 }
812  
813 8 ▶ unless ( $body =~ s|^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+//s) 0 8 8
814 0 return _fail_body( 'XML schema validation failed: Element &#039;{uurn:ietf:params:xml:ns:epp-1.0}epp&#039;: No matching global declaration available for the validation root.', '2001', $cltrid );
815 }
816  
817 8 ▶ unless ( $body =~ s|^<command>\s+<create>\s+<host:create[^<>]+>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<command>\s+<create>\s+<host:create[^<>]+>\s+//s) 0 8 8
818 0 return _fail_body( 'XML schema validation failed: host:create', '2001', $cltrid );
819 }
820  
821 8 ▶ unless ( $body =~ s|\s+</host:create>\s+</create>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s[\s+</host:create>\s+</create>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$][]s) 0 8 8
822 0 return _fail_body( 'XML schema validation failed: /host:create', '2001', $cltrid );
823 }
824  
825 8 my ( $ns, $local_ns );
826 8 ▶ if ( $body =~ m|<host:name>([0-9A-Za-z\-\.]+)</host:name>| ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ m[<host:name>([0-9A-Za-z\-\.]+)</host:name>]) { } 8 0 8
827 8 $ns = lc $1;
828 }
829 else {
830 0 return _fail_body( 'Host name is invalid.', '2004', $cltrid );
831 }
832  
833 8 my $srv_url = $obj->{sock};
834 8 my $s = new IO::EPP::Test::Server( $srv_url );
835 8 my $nss = $s->data->{nss};
836 8 my $doms = $s->data->{doms};
837  
838 8 ▶ if ( $nss->{$ns} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nss->{$ns}) 1 7 8
839 1 return _fail_body( 'A host object with that hostname already exists.', '2302', $cltrid );
840 }
841  
842 7 my @v4 = $body =~ m|<host:addr ip="v4">([^<>]+)</host:addr>|g;
843 7 my @v6 = $body =~ m|<host:addr ip="v6">([^<>]+)</host:addr>|g;
844  
845 7 foreach my $dm ( keys %{$doms} ) {
846 28 ▶ if ( $ns =~ /\.$dm$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ns =~ /\.$dm$/) 7 21 28
847 7 ▶ if ( $doms->{$dm}{owner} ne $obj->{user} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($doms->{$dm}{'owner'} ne $obj->{'user'}) { } 1 6 7
elsif (scalar(@v4) + scalar(@v6) == 0) { } 2 4 6
848 1 return _fail_body( 'You are not the sponsor for the parent domain of this host and cannot create subordinate host objects for it.', '2201', $cltrid );
849 }
850 elsif ( ( scalar( @v4 ) + scalar( @v6 ) ) == 0 ) {
851 2 return _fail_body( 'You need IPv4 or IPv6 address.', '2004', $cltrid );
852 }
853  
854 4 $local_ns = $dm;
855 }
856 }
857  
858 4 foreach my $v ( @v4 ) {
859 3 ▶ unless ( $v =~ /^\d+\.\d+\.\d+\.\d+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($v =~ /^\d+\.\d+\.\d+\.\d+$/) 0 3 3
860 0 return _fail_body( "IP address $v is not valid.", '2004', $cltrid );
861 }
862 }
863 4 foreach my $v ( @v6 ) {
864 1 ▶ unless ( $v =~ /^[0-9a-z:]{1,29}$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($v =~ /^[0-9a-z:]{1,29}$/) 1 0 1
865 1 return _fail_body( "IP address $v is not valid.", '2004', $cltrid );
866 }
867 }
868  
869 3 my ( $cre_date ) = get_dates();
870  
871 3 $nss->{$ns} = { avail => 0, reason => 'in use', statuses => { ok => '+' }, creater => $obj->{user}, owner => $obj->{user}, cre_date => $cre_date, addr_v4 => \@v4, addr_v6 => \@v6, roid => uc(md5_hex($ns.$cre_date)) . '-TEST' };
872  
873 3 ▶ if ( $local_ns ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($local_ns) 3 0 3
874 3 $doms->{$local_ns}{hosts}{$ns} = '+';
875 }
876  
877 3 return _ok_answ( qq|<host:creData xmlns:host="urn:ietf:params:xml:ns:host-1.0"><host:name>$ns</host:name><host:crDate>$cre_date</host:crDate></host:creData>|, $cltrid );
878 }
879  
880  
881 sub host_info {
882 2 ▶ my ( $obj, $body ) = @_;
Subroutine host_info: called CC=13 SCAR=27.7
Pod undocumented
883  
884 2 my ( $cltrid ) = $body =~ m|<clTRID>([0-9A-Za-z\-]+)</clTRID>|s;
885  
886 2 ▶ return _fail_cltrid() unless $cltrid;
Branch: 1 branch
BranchTrueFalseTotal
unless $cltrid 0 2 2
887  
888 2 ▶ unless ( $body =~ s|^<\?xml version="1.0" encoding="UTF-8"\?>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<\?xml version="1.0" encoding="UTF-8"\?>\s+//s) 0 2 2
889 0 return _fail_body( 'XML schema validation failed: ', '2001', $cltrid );
890 }
891  
892 2 ▶ unless ( $body =~ s|^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+//s) 0 2 2
893 0 return _fail_body( 'XML schema validation failed: Element &#039;{uurn:ietf:params:xml:ns:epp-1.0}epp&#039;: No matching global declaration available for the validation root.', '2001', $cltrid );
894 }
895  
896 2 ▶ unless ( $body =~ s|^<command>\s+<info>\s+<host:info[^<>]+>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<command>\s+<info>\s+<host:info[^<>]+>\s+//s) 0 2 2
897 0 return _fail_body( 'XML schema validation failed: host:info', '2001', $cltrid );
898 }
899  
900 2 ▶ unless ( $body =~ s|\s+</host:info>\s+</info>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s[\s+</host:info>\s+</info>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$][]s) 0 2 2
901 0 return _fail_body( 'XML schema validation failed: /host:info', '2001', $cltrid );
902 }
903  
904 2 my $ns;
905 2 ▶ if ( $body =~ m|<host:name>([0-9A-Za-z\-\.]+)</host:name>| ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ m[<host:name>([0-9A-Za-z\-\.]+)</host:name>]) { } 2 0 2
906 2 $ns = lc $1;
907 }
908 else {
909 0 return _fail_body( 'Host name is invalid.', '2004', $cltrid );
910 }
911  
912 2 my $srv_url = $obj->{sock};
913 2 my $s = new IO::EPP::Test::Server( $srv_url );
914 2 my $nss = $s->data->{nss};
915  
916 2 ▶ unless ( $nss->{$ns} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($nss->{$ns}) 1 1 2
917 1 return _fail_body( "The host &#039;$ns&#039; does not exist", '2303', $cltrid );
918 }
919  
920 1 my $answ = '<host:infData xmlns:host="urn:ietf:params:xml:ns:host-1.0">';
921 1 $answ .= "<host:name>$ns</host:name>";
922 1 $answ .= "<host:roid>$$nss{$ns}{roid}</host:roid>";
923 1 foreach my $st ( keys %{$$nss{$ns}{statuses}} ) {
924 1 ▶ if ( $$nss{$ns}{statuses}{$st} eq '+' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nss->{$ns}{'statuses'}{$st} eq '+') { } 1 0 1
925 1 $answ .= qq|<host:status s="$st" />|;
926 }
927 else {
928 0 $answ .= qq|<host:status s="$st">| . $$nss{$ns}{statuses}{$st} . '</host:status>';
929 }
930 }
931 1 foreach my $v ( @{$$nss{$ns}{addr_v4}} ) {
932 1 $answ .= qq|<host:addr ip="v4">$v</host:addr>|;
933 }
934 1 foreach my $v ( @{$$nss{$ns}{addr_v6}} ) {
935 0 $answ .= qq|<host:addr ip="v6">$v</host:addr>|;
936 }
937 1 $answ .= "<host:clID>$$nss{$ns}{owner}</host:clID>";
938 1 $answ .= "<host:crID>$$nss{$ns}{creater}</host:crID>";
939 1 $answ .= "<host:crDate>$$nss{$ns}{cre_date}</host:crDate>";
940 1 ▶ $answ .= "<host:crDate>$$nss{$ns}{upd_date}</host:crDate>" if $$nss{$ns}{upd_date};
Branch: 1 branch
BranchTrueFalseTotal
if $nss->{$ns}{"upd_date"} 0 1 1
941 1 $answ .= '</host:infData>';
942  
943 1 return _ok_answ( $answ, $cltrid );
944 }
945  
946  
947 sub host_update {
948 3 ▶ my ( $obj, $body ) = @_;
Subroutine host_update: called CC=25 SCAR=42.7
Pod undocumented
949  
950 3 my ( $cltrid ) = $body =~ m|<clTRID>([0-9A-Za-z\-]+)</clTRID>|s;
951  
952 3 ▶ return _fail_cltrid() unless $cltrid;
Branch: 1 branch
BranchTrueFalseTotal
unless $cltrid 0 3 3
953  
954 3 ▶ unless ( $body =~ s|^<\?xml version="1.0" encoding="UTF-8"\?>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<\?xml version="1.0" encoding="UTF-8"\?>\s+//s) 0 3 3
955 0 return _fail_body( 'XML schema validation failed: ', '2001', $cltrid );
956 }
957  
958 3 ▶ unless ( $body =~ s|^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+//s) 0 3 3
959 0 return _fail_body( 'XML schema validation failed: Element &#039;{uurn:ietf:params:xml:ns:epp-1.0}epp&#039;: No matching global declaration available for the validation root.', '2001', $cltrid );
960 }
961  
962 3 ▶ unless ( $body =~ s|^<command>\s+<update>\s+<host:update[^<>]+>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<command>\s+<update>\s+<host:update[^<>]+>\s+//s) 0 3 3
963 0 return _fail_body( 'XML schema validation failed: host:update', '2001', $cltrid );
964 }
965  
966 3 ▶ unless ( $body =~ s|\s+</host:update>\s+</update>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s[\s+</host:update>\s+</update>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$][]s) 0 3 3
967 0 return _fail_body( 'XML schema validation failed: /host:update', '2001', $cltrid );
968 }
969  
970 3 my ( $ns, $local_ns );
971 3 ▶ if ( $body =~ m|<host:name>([0-9A-Za-z\-\.]+)</host:name>| ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ m[<host:name>([0-9A-Za-z\-\.]+)</host:name>]) { } 3 0 3
972 3 $ns = lc $1;
973 }
974 else {
975 0 return _fail_body( 'Host name is invalid.', '2004', $cltrid );
976 }
977  
978 3 my $srv_url = $obj->{sock};
979 3 my $s = new IO::EPP::Test::Server( $srv_url );
980 3 my $nss = $s->data->{nss};
981  
982 3 ▶ unless ( $nss->{$ns} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($nss->{$ns}) 1 2 3
983 1 return _fail_body( "The host &#039;$ns&#039; does not exist", '2303', $cltrid );
984 }
985  
986 2 ▶ if ( $nss->{$ns}{owner} ne $obj->{user} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nss->{$ns}{"owner"} ne $obj->{"user"}) 0 2 2
987 # TODO: check main domain
988 0 return _fail_body( 'You are not authorised to modify this host object (you do not sponsor the parent domain).', '2201', $cltrid );
989 }
990  
991 2 my ( @a4, @a6, @d4, @d6, @ast, @dst );
992  
993 2 for my $act ( 'add', 'rem' ) {
994 3 ▶ if ( $body =~ m|<host:$act>(.+?)</host:$act>|s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ m[<host:$act>(.+?)</host:$act>]s) 2 1 3
995 2 my $ab = $1;
996  
997 2 my @v4 = $ab =~ m|<host:addr ip="v4">([^<>]+)</host:addr>|g;
998 2 my @v6 = $ab =~ m|<host:addr ip="v6">([^<>]+)</host:addr>|g;
999  
1000 2 foreach my $v ( @v4 ) {
1001 1 ▶ unless ( $v =~ /^\d+\.\d+\.\d+\.\d+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($v =~ /^\d+\.\d+\.\d+\.\d+$/) 0 1 1
1002 0 return _fail_body( "IP address $v is not valid.", '2004', $cltrid );
1003 }
1004  
1005 1 ▶ if ( $act eq 'add' ) { push @a4, $v } else { push @d4, $v }
Branch: 1 branch
BranchTrueFalseTotal
if ($act eq 'add') { } 1 0 1
1006 }
1007  
1008 2 foreach my $v ( @v6 ) {
1009 1 ▶ unless ( $v =~ /^[0-9a-f:]{1,29}$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($v =~ /^[0-9a-f:]{1,29}$/) 1 0 1
1010 1 return _fail_body( "IP address $v is not valid.", '2004', $cltrid );
1011 }
1012  
1013 0 ▶ if ( $act eq 'add' ) { push @a6, $v } else { push @d6, $v }
Branch: 1 branch
BranchTrueFalseTotal
if ($act eq 'add') { } 0 0 0
1014 }
1015  
1016 # Centralnic ignored add/rem client* statuses for host
1017 }
1018 }
1019  
1020 # TODO: chg name
1021  
1022 1 ▶ if ( scalar @a4 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @a4) 1 0 1
1023 1 my %h = map { $_ => '+' } @{$nss->{$ns}{addr_v4}};
1024  
1025 1 $h{$_} = '+' for @a4;
1026  
1027 1 $nss->{$ns}{addr_v4} = [ sort keys %h ];
1028 }
1029  
1030 1 ▶ if ( scalar @a6 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @a6) 0 1 1
1031 0 my %h = map { $_ => '+' } @{$nss->{$ns}{addr_v6}};
1032  
1033 0 $h{$_} = '+' for @a6;
1034  
1035 0 $nss->{$ns}{addr_v6} = [ sort keys %h ];
1036 }
1037  
1038 1 ▶ if ( scalar @d4 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @d4) 0 1 1
1039 0 my %h = map { $_ => '+' } @{$nss->{$ns}{addr_v4}};
1040  
1041 0 delete( $h{$_} ) for @d4;
1042  
1043 0 $nss->{$ns}{addr_v4} = [ sort keys %h ];
1044 }
1045  
1046 1 ▶ if ( scalar @d6 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @d6) 0 1 1
1047 0 my %h = map { $_ => '+' } @{$nss->{$ns}{addr_v6}};
1048  
1049 0 delete( $h{$_} ) for @d6;
1050  
1051 0 $nss->{$ns}{addr_v6} = [ sort keys %h ];
1052 }
1053  
1054 1 my $svtrid = get_svtrid();
1055  
1056 1 return _min_answ( '1000', $cltrid );
1057 }
1058  
1059  
1060 sub host_delete {
1061 2 ▶ my ( $obj, $body ) = @_;
Subroutine host_delete: called CC=12 SCAR=27.4
Pod undocumented
1062  
1063 2 my ( $cltrid ) = $body =~ m|<clTRID>([0-9A-Za-z\-]+)</clTRID>|s;
1064  
1065 2 ▶ return _fail_cltrid() unless $cltrid;
Branch: 1 branch
BranchTrueFalseTotal
unless $cltrid 0 2 2
1066  
1067 2 ▶ unless ( $body =~ s|^<\?xml version="1.0" encoding="UTF-8"\?>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<\?xml version="1.0" encoding="UTF-8"\?>\s+//s) 0 2 2
1068 0 return _fail_body( 'XML schema validation failed: ', '2001', $cltrid );
1069 }
1070  
1071 2 ▶ unless ( $body =~ s|^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+//s) 0 2 2
1072 0 return _fail_body( 'XML schema validation failed: Element &#039;{uurn:ietf:params:xml:ns:epp-1.0}epp&#039;: No matching global declaration available for the validation root.', '2001', $cltrid );
1073 }
1074  
1075 2 ▶ unless ( $body =~ s|^<command>\s+<delete>\s+<host:delete[^<>]+>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<command>\s+<delete>\s+<host:delete[^<>]+>\s+//s) 0 2 2
1076 0 return _fail_body( 'XML schema validation failed: host:delete', '2001', $cltrid );
1077 }
1078  
1079 2 ▶ unless ( $body =~ s|\s+</host:delete>\s+</delete>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s[\s+</host:delete>\s+</delete>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$][]s) 0 2 2
1080 0 return _fail_body( 'XML schema validation failed: /host:delete', '2001', $cltrid );
1081 }
1082  
1083 2 my $ns;
1084 2 ▶ if ( $body =~ m|<host:name>([0-9A-Za-z\-\.]+)</host:name>| ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ m[<host:name>([0-9A-Za-z\-\.]+)</host:name>]) { } 2 0 2
1085 2 $ns = lc $1;
1086 }
1087 else {
1088 0 return _fail_body( 'Host name is invalid.', '2004', $cltrid );
1089 }
1090  
1091 2 my $srv_url = $obj->{sock};
1092 2 my $s = new IO::EPP::Test::Server( $srv_url );
1093 2 my $nss = $s->data->{nss};
1094  
1095 2 ▶ unless ( $nss->{$ns} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($nss->{$ns}) 1 1 2
1096 1 return _fail_body( "The host &#039;$ns&#039; does not exist", '2303', $cltrid );
1097 }
1098  
1099 1 ▶ if ( $nss->{$ns}{statuses}{linked} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nss->{$ns}{"statuses"}{"linked"}) 0 1 1
1100 0 return _fail_body( 'Host object is linked to one or more domains.', '2305', $cltrid );
1101 }
1102  
1103 1 my $doms = $s->data->{doms};
1104 1 foreach my $dm ( keys %{$doms} ) {
1105 2 ▶ if ( $ns =~ /\.$dm$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ns =~ /\.$dm$/) 1 1 2
1106 1 delete $doms->{$dm}{hosts}->{$ns};
1107 }
1108 }
1109  
1110 1 ▶ if ( $nss->{$ns}{owner} ne $obj->{user} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nss->{$ns}{"owner"} ne $obj->{"user"}) 0 1 1
1111 0 return _fail_body( 'Permission denied.', '2201', $cltrid );
1112 }
1113  
1114 1 delete $nss->{$ns};
1115  
1116 1 my $svtrid = get_svtrid();
1117  
1118 1 return _min_answ( '1000', $cltrid );
1119 }
1120  
1121  
1122 sub domain_check {
1123 2 ▶ my ( $obj, $body ) = @_;
Subroutine domain_check: called CC=20 SCAR=31.3
Pod undocumented
1124  
1125 2 my ( $cltrid ) = $body =~ m|<clTRID>([0-9A-Za-z\-]+)</clTRID>|s;
1126  
1127 2 ▶ return _fail_cltrid() unless $cltrid;
Branch: 1 branch
BranchTrueFalseTotal
unless $cltrid 0 2 2
1128  
1129 2 ▶ unless ( $body =~ s|^<\?xml version="1.0" encoding="UTF-8"\?>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<\?xml version="1.0" encoding="UTF-8"\?>\s+//s) 0 2 2
1130 0 return _fail_body( 'XML schema validation failed: ', '2001', $cltrid );
1131 }
1132  
1133 2 ▶ unless ( $body =~ s|^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+//s) 0 2 2
1134 0 return _fail_body( 'XML schema validation failed: Element &#039;{uurn:ietf:params:xml:ns:epp-1.0}epp&#039;: No matching global declaration available for the validation root.', '2001', $cltrid );
1135 }
1136  
1137 2 ▶ unless ( $body =~ s|^<command>\s+<check>\s+<domain:check[^<>]+>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<command>\s+<check>\s+<domain:check[^<>]+>\s+//s) 0 2 2
1138 0 return _fail_body( 'XML schema validation failed: domain:check', '2001', $cltrid );
1139 }
1140  
1141 2 ▶ unless ( $body =~ s|\s+</domain:check>\s+</check>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s[\s+</domain:check>\s+</check>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$][]s) 0 2 2
1142 0 return _fail_body( 'XML schema validation failed: /domain:check', '2001', $cltrid );
1143 }
1144  
1145 2 my ( @domains ) = $body =~ m|(<domain:name>[^<>]+</domain:name>)|g;
1146  
1147 2 ▶ unless ( scalar @domains ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (scalar @domains) 0 2 2
1148 0 return _fail_body( 'XML schema validation failed: domain:cd', '2001', $cltrid );
1149 }
1150  
1151 2 my $srv_url = $obj->{sock};
1152 2 my $s = new IO::EPP::Test::Server( $srv_url );
1153 2 my $answ_list = '';
1154 2 foreach my $row ( @domains ) {
1155 20 my ( $dm ) = $row =~ m|<domain:name>([^<>]+)</domain:name>|;
1156 20 $dm = lc $dm;
1157  
1158 20 my $reason = '';
1159  
1160 20 ▶ if ( $s->data->{doms}{$dm} ) {
Branch: 5 branches
BranchTrueFalseTotal
if ($s->data->{'doms'}{$dm}) { } 2 18 20
elsif (not $dm =~ /^[0-9a-z\.\-]+$/) { } 1 17 18
elsif ($dm =~ /^reg/) { } 0 17 17
elsif ($dm =~ /^blo/) { } 1 16 17
elsif ($dm =~ /^ava/) { } 1 15 16
1161 2 ▶ $reason = $s->data->{doms}{$dm}{reason} || '';
Condition100%2/2
$s->data->{'doms'}{$dm}{'reason'} || ''
l!l
11
MC/DC100%1/1
$s->data->{'doms'}{$dm}{'reason'} || ''
$s->data->{'doms'}{$dm}{'reason'}
Truth table100%2/2
A
A= $s->data->{'doms'}{$dm}{'reason'}
Aresult
11
00
1162 }
1163 elsif ( $dm !~ /^[0-9a-z\.\-]+$/ ) {
1164 1 my ( $c ) = $dm !~ /([^0-9a-z\.\-])/;
1165 1 $reason = 'the following characters are not permitted: &#039;'.$c.'&#039;';
1166 }
1167 elsif ( $dm =~ /^reg/ ) { # reged
1168 0 $reason = 'in use';
1169 }
1170 elsif ( $dm =~ /^blo/ ) {
1171 1 $reason = 'blocked';
1172 }
1173 elsif ( $dm =~ /^ava/ ) {
1174 # available
1175 }
1176 else {
1177 15 ▶ $reason = int( rand( 10 ) ) == 1 ? 'in use' : ''; # 10% -- domains is not available
Branch: 1 branch
BranchTrueFalseTotal
int rand 10 == 1 ? : 0 15 15
1178 }
1179  
1180 20 ▶ my $avail = $reason ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$reason ? : 3 17 20
1181  
1182 20 ▶ unless ( $s->data->{doms}{$dm} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($s->data->{"doms"}{$dm}) 18 2 20
1183 18 ▶ if ( $reason && $reason !~ /not permitted/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($reason and not $reason =~ /not permitted/) 1 17 18
Condition100%3/3
$reason and not $reason =~ /not permitted/
!ll&&!rl&&r
1611
MC/DC100%2/2
$reason and not $reason =~ /not permitted/
$reason not $reason =~ /not permitted/
Truth table100%3/3
A and not(B)
A= $reasonB= not $reason =~ /not permitted/
ABresult
0X0
100
111
1184 1 $s->data->{doms}{$dm} = { avail => $avail, reason => $reason };
1185 }
1186 }
1187  
1188 20 ▶ $reason = "<domain:reason>$reason</domain:reason>" if $reason;
Branch: 1 branch
BranchTrueFalseTotal
if $reason 3 17 20
1189  
1190 20 $answ_list .= qq|<domain:cd><domain:name avail="$avail">$dm</domain:name>$reason</domain:cd>|;
1191 }
1192  
1193 2 my $svtrid = get_svtrid();
1194  
1195 2 return qq|<?xml version="1.0" encoding="UTF-8" standalone="no"?>
1196 <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
1197 <response>
1198 <result code="1000">
1199 <msg>Command completed successfully.</msg>
1200 </result>
1201 <resData><domain:chkData xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">$answ_list</domain:chkData></resData><trID>
1202 <clTRID>$cltrid</clTRID><svTRID>$svtrid</svTRID>
1203 </trID>
1204 </response>
1205 </epp>|;
1206 }
1207  
1208  
1209 sub domain_create {
1210 12 ▶ my ( $obj, $body ) = @_;
Subroutine domain_create: called CC=36 SCAR=38.8
Pod undocumented
1211  
1212 12 my ( $cltrid ) = $body =~ m|<clTRID>([0-9A-Za-z\-]+)</clTRID>|s;
1213  
1214 12 ▶ return _fail_cltrid() unless $cltrid;
Branch: 1 branch
BranchTrueFalseTotal
unless $cltrid 0 12 12
1215  
1216 12 ▶ unless ( $body =~ s|^<\?xml version="1.0" encoding="UTF-8"\?>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<\?xml version="1.0" encoding="UTF-8"\?>\s+//s) 0 12 12
1217 0 return _fail_body( 'XML schema validation failed: ', '2001', $cltrid );
1218 }
1219  
1220 12 ▶ unless ( $body =~ s|^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+//s) 0 12 12
1221 0 return _fail_body( 'XML schema validation failed: Element &#039;{uurn:ietf:params:xml:ns:epp-1.0}epp&#039;: No matching global declaration available for the validation root.', '2001', $cltrid );
1222 }
1223  
1224 12 ▶ unless ( $body =~ s|^<command>\s+<create>\s+<domain:create[^<>]+>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<command>\s+<create>\s+<domain:create[^<>]+>\s+//s) 0 12 12
1225 0 return _fail_body( 'XML schema validation failed: domain:create', '2001', $cltrid );
1226 }
1227  
1228 12 ▶ unless ( $body =~ s|\s+</domain:create>\s+</create>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s[\s+</domain:create>\s+</create>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$][]s) 0 12 12
1229 0 return _fail_body( 'XML schema validation failed: /domain:create', '2001', $cltrid );
1230 }
1231  
1232 12 my $dname;
1233 12 ▶ if ( $body =~ m|<domain:name>([^<>]+)</domain:name>| ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ m[<domain:name>([^<>]+)</domain:name>]) { } 12 0 12
1234 12 $dname = lc $1;
1235 }
1236 else {
1237 0 return _fail_body( 'XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:domain-1.0}name&#039;: [facet &#039;minLength&#039;] The value has a length of &#039;0&#039;; this underruns the allowed minimum length of &#039;1&#039;.', '2001', $cltrid );
1238 }
1239  
1240 12 ▶ if ( $dname =~ /([^0-9a-z\.\-])/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dname =~ /([^0-9a-z\.\-])/) 1 11 12
1241 1 return _fail_body( "&#039;$dname&#039; is not a valid domain name: the following characters are not permitted: &#039;$1&#039;", '2004', $cltrid );
1242 }
1243  
1244 11 ▶ if ( $dname !~ /^[0-9a-z\.\-]+\.[0-9a-z\-]+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dname =~ /^[0-9a-z\.\-]+\.[0-9a-z\-]+$/) 1 10 11
1245 1 return _fail_body( "&#039;$dname&#039; is not a valid domain name: suffix ... does not exist", '2004', $cltrid );
1246 }
1247  
1248 10 my $srv_url = $obj->{sock};
1249 10 my $s = new IO::EPP::Test::Server( $srv_url );
1250 10 my $conts = $s->data->{conts};
1251 10 my $nss = $s->data->{nss};
1252 10 my $doms = $s->data->{doms};
1253  
1254 10 ▶ if ( $doms->{$dname} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($doms->{$dname}) 2 8 10
1255 2 return _fail_body( "&#039;$dname&#039; is already registered.", '2302', $cltrid );
1256 }
1257  
1258 8 my $period;
1259 8 ▶ if ( $body =~ m|<domain:period unit="y">([^<>]+)</domain:period>| ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ m[<domain:period unit="y">([^<>]+)</domain:period>]) { } 8 0 8
1260 8 $period = $1;
1261  
1262 8 ▶ if ( $period =~ /([^0-9])/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($period =~ /([^0-9])/) 0 8 8
1263 0 return _fail_body( "XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:domain-1.0}period&#039;: &#039;$period&#039; is not a valid value of the atomic type &#039;{urn:ietf:params:xml:ns:domain-1.0}pLimitType&#039;." );
1264 }
1265 }
1266 else {
1267 0 $period = 1;
1268 }
1269  
1270 8 ▶ if ( $period < 1 or $period > 9 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($period < 1 or $period > 9) 0 8 8
Condition33%1/3
$period < 1 or $period > 9
l!l&&r!l&&!r
008
MC/DC0%0/2
$period < 1 or $period > 9
$period < 1 $period > 9
Truth table33%1/3
A or B
A= $period < 1B= $period > 9
ABresult
1X1
011
000
1271 0 return _fail_body( "XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:domain-1.0}period&#039;: [facet &#039;maxInclusive&#039;] The value &#039;100&#039; is greater than the maximum value allowed (&#039;9&#039;).", '2001', $cltrid );
1272 }
1273  
1274 8 my $reg_id;
1275 8 ▶ if ( $body =~ m|<domain:registrant>([^<>]+)</domain:registrant>| ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ m[<domain:registrant>([^<>]+)</domain:registrant>]) { } 7 1 8
1276 7 $reg_id = $1;
1277  
1278 7 ▶ unless ( $conts->{$reg_id} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($conts->{$reg_id}) 1 6 7
1279 1 return _fail_body( "Specified registrant contact $reg_id is not registered here.", '2303', $cltrid );
1280 }
1281 }
1282 else {
1283 1 return _fail_body( 'The &#039;registrant&#039; attribute is empty or missing', '2003', $cltrid );
1284 }
1285  
1286 6 my %cc = ( admin => {}, tech => {}, billing => {} );
1287 6 for my $t ( 'admin', 'tech', 'billing' ) {
1288 16 my @acs = $body =~ m|<domain:contact type="$t">([^<>]+)</domain:contact>|gs;
1289  
1290 16 foreach my $ac ( @acs ) {
1291 16 ▶ if ( $conts->{$ac} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conts->{$ac}) { } 15 1 16
1292 15 $cc{$t}{$ac} = '+';
1293 }
1294 else {
1295 1 return _fail_body( "Specified $t contact $ac is not registered here.", '2303', $cltrid );
1296 }
1297 }
1298 }
1299  
1300 5 my $pw;
1301 5 ▶ if ( $body =~ m|<domain:authInfo>\s*<domain:pw>([^<>]+)</domain:pw>\s*</domain:authInfo>|s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ m[<domain:authInfo>\s*<domain:pw>([^<>]+)</domain:pw>\s*</domain:authInfo>]s) { } 5 0 5
1302 5 $pw = $1;
1303 }
1304 else {
1305 0 return _fail_body( 'XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:domain-1.0}authInfo&#039;: Missing child element(s). Expected is one of ( {urn:ietf:params:xml:ns:domain-1.0}pw, {urn:ietf:params:xml:ns:domain-1.0}ext ).', '2001', $cltrid );
1306 }
1307 5 ▶ if ( $pw and length( $pw ) < 16 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pw and length $pw < 16) 1 4 5
Condition66%2/3
$pw and length $pw < 16
!ll&&!rl&&r
041
MC/DC50%1/2
$pw and length $pw < 16
$pw length $pw < 16
Truth table66%2/3
A and B
A= $pwB= length $pw < 16
ABresult
0X0
100
111
1308 1 return _fail_body( 'authInfo code is invalid: password must be at least 16 characters', '2004', $cltrid );
1309 }
1310 4 ▶ unless ( $pw and $pw =~ /[A-Z]/ and $pw =~ /[a-z]/ and $pw =~ /[0-9]/ and $pw =~ /[!\@\$\%*_.:\-=+?#,"'\\\/&]/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pw and $pw =~ /[A-Z]/ and $pw =~ /[a-z]/ and $pw =~ /[0-9]/ and $pw =~ m[[!\@\$\%*_.:\-=+?#,"'\\/&]]) 0 3 3
Condition66%8/12
$pw and $pw =~ /[A-Z]/ and $pw =~ /[a-z]/ and $pw =~ /[0-9]/ and $pw =~ m[[!\@\$\%*_.:\-=+?#,"'\\/&]]
!ll&&!rl&&r
103
$pw and $pw =~ /[A-Z]/ and $pw =~ /[a-z]/ and $pw =~ /[0-9]/
!ll&&!rl&&r
103
$pw and $pw =~ /[A-Z]/ and $pw =~ /[a-z]/
!ll&&!rl&&r
103
$pw and $pw =~ /[A-Z]/
!ll&&!rl&&r
013
MC/DC20%1/5
$pw and $pw =~ /[A-Z]/ and $pw =~ /[a-z]/ and $pw =~ /[0-9]/ and $pw =~ m[[!\@\$\%*_.:\-=+?#,"'\\/&]]
$pw $pw =~ /[A-Z]/ $pw =~ /[a-z]/ $pw =~ /[0-9]/ $pw =~ m[[!\@\$\%*_.:\-=+?#,"'\\/&]]
Truth table33%2/6
A and B and C and D and E
A= $pwB= $pw =~ /[A-Z]/C= $pw =~ /[a-z]/D= $pw =~ /[0-9]/E= $pw =~ m[[!\@\$\%*_.:\-=+?#,"'\\/&]]
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
1311 1 return _fail_body( 'authInfo code is invalid: password must contain a mix of uppercase and lowercase characters', '2004', $cltrid );
1312 }
1313  
1314 3 my %nss;
1315 3 ▶ if ( $body =~ m|<domain:ns>(.+?)</domain:ns>|s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ m[<domain:ns>(.+?)</domain:ns>]s) 3 0 3
1316 3 my $hosts = $1;
1317  
1318 3 my @nss0 = $hosts =~ m|<domain:hostObj>([^<>]+)</domain:hostObj>|gs;
1319  
1320 3 foreach my $ns ( @nss0 ) {
1321 5 ▶ unless ( $nss->{$ns} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($nss->{$ns}) 1 4 5
1322 1 return _fail_body( "Cannot find host object &#039;$ns&#039;", '2303', $cltrid );
1323 }
1324  
1325 4 $nss{$ns} = '+';
1326 }
1327 }
1328  
1329 2 my ( $cre_date, $exp_date ) = get_dates( 1 );
1330  
1331 $doms->{$dname} = {
1332 registrant => $reg_id,
1333 admin => $cc{admin},
1334 tech => $cc{tech},
1335 billing => $cc{billing},
1336 nss => \%nss,
1337 cre_date => $cre_date,
1338 upd_date => $cre_date,
1339 exp_date => $exp_date,
1340 authInfo => $pw,
1341 roid => uc(md5_hex($dname.$cre_date)).'-TEST',
1342 statuses => { },
1343 creater => $obj->{user},
1344 owner => $obj->{user},
1345 updater => $obj->{user},
1346 2 avail => 0,
1347 reason => 'in use',
1348 };
1349  
1350 2 $conts->{$reg_id}{statuses}{linked}++;
1351  
1352 2 ▶ if ( $conts->{$reg_id}{statuses}{ok} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conts->{$reg_id}{"statuses"}{"ok"}) 1 1 2
1353 1 delete $conts->{$reg_id}{statuses}{ok};
1354 1 $conts->{$reg_id}{statuses}{serverDeleteProhibited} = '+';
1355 }
1356  
1357 2 for my $t ( 'admin', 'tech', 'billing' ) {
1358  
1359 6 foreach my $c ( keys %{$cc{$t}} ) {
1360 6 $conts->{$c}{statuses}{linked}++;
1361  
1362 6 ▶ if ( $conts->{$c}{statuses}{ok} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conts->{$c}{"statuses"}{"ok"}) 3 3 6
1363 3 delete $conts->{$c}{statuses}{ok};
1364 3 $conts->{$c}{statuses}{serverDeleteProhibited} = '+';
1365 }
1366 }
1367 }
1368  
1369 2 foreach my $ns ( keys %nss ) {
1370 4 $nss->{$ns}{statuses}{linked}++;
1371  
1372 4 ▶ if ( $nss->{$ns}{statuses}{ok} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nss->{$ns}{"statuses"}{"ok"}) 0 4 4
1373 0 delete $nss->{$ns}{statuses}{ok};
1374 0 $nss->{$ns}{statuses}{serverDeleteProhibited} = '+';
1375 }
1376 }
1377  
1378 2 return _ok_answ( qq|<domain:creData xmlns:domain="urn:ietf:params:xml:ns:domain-1.0"><domain:name>$dname</domain:name><domain:crDate>$cre_date</domain:crDate><domain:exDate>$exp_date</domain:exDate></domain:creData>|, $cltrid );
1379 }
1380  
1381  
1382 sub domain_info {
1383 4 ▶ my ( $obj, $body ) = @_;
Subroutine domain_info: called CC=22 SCAR=32.9
Pod undocumented
1384  
1385 4 my ( $cltrid ) = $body =~ m|<clTRID>([0-9A-Za-z\-]+)</clTRID>|s;
1386  
1387 4 ▶ return _fail_cltrid() unless $cltrid;
Branch: 1 branch
BranchTrueFalseTotal
unless $cltrid 0 4 4
1388  
1389 4 ▶ unless ( $body =~ s|^<\?xml version="1.0" encoding="UTF-8"\?>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<\?xml version="1.0" encoding="UTF-8"\?>\s+//s) 0 4 4
1390 0 return _fail_body( 'XML schema validation failed: ', '2001', $cltrid );
1391 }
1392  
1393 4 ▶ unless ( $body =~ s|^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+//s) 0 4 4
1394 0 return _fail_body( 'XML schema validation failed: Element &#039;{uurn:ietf:params:xml:ns:epp-1.0}epp&#039;: No matching global declaration available for the validation root.', '2001', $cltrid );
1395 }
1396  
1397 4 ▶ unless ( $body =~ s|^<command>\s+<info>\s+<domain:info[^<>]+>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<command>\s+<info>\s+<domain:info[^<>]+>\s+//s) 0 4 4
1398 0 return _fail_body( 'XML schema validation failed: domain:info', '2001', $cltrid );
1399 }
1400  
1401 4 ▶ unless ( $body =~ s|\s+</domain:info>\s+</info>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s[\s+</domain:info>\s+</info>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$][]s) 0 4 4
1402 0 return _fail_body( 'XML schema validation failed: /domain:info', '2001', $cltrid );
1403 }
1404  
1405 4 my $dname;
1406 4 ▶ if ( $body =~ m|<domain:name>([^<>]+)</domain:name>| ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ m[<domain:name>([^<>]+)</domain:name>]) { } 4 0 4
1407 4 $dname = lc $1;
1408 }
1409 else {
1410 0 return _fail_body( 'XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:domain-1.0}name&#039;: [facet &#039;minLength&#039;] The value has a length of &#039;0&#039;; this underruns the allowed minimum length of &#039;1&#039;.', '2001', $cltrid );
1411 }
1412  
1413 4 ▶ if ( $dname =~ /([^0-9a-z\.\-])/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dname =~ /([^0-9a-z\.\-])/) 0 4 4
1414 0 return _fail_body( "&#039;$dname&#039; is not a valid domain name: the following characters are not permitted: &#039;$1&#039;", '2004', $cltrid );
1415 }
1416  
1417 4 ▶ if ( $dname !~ /^[0-9a-z\.\-]+\.[0-9a-z\-]+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dname =~ /^[0-9a-z\.\-]+\.[0-9a-z\-]+$/) 0 4 4
1418 0 return _fail_body( "&#039;$dname&#039; is not a valid domain name: suffix ... does not exist", '2004', $cltrid );
1419 }
1420  
1421 4 my $srv_url = $obj->{sock};
1422 4 my $s = new IO::EPP::Test::Server( $srv_url );
1423 4 my $doms = $s->data->{doms};
1424  
1425 4 ▶ unless ( $s->data->{doms}{$dname} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($s->data->{"doms"}{$dname}) 1 3 4
1426 1 return _fail_body( "The domain &#039;$dname&#039; does not exist", '2303', $cltrid );
1427 }
1428  
1429 3 my $dm = $s->data->{doms}{$dname};
1430  
1431 3 my $answ = qq|<domain:infData xmlns:domain="urn:ietf:params:xml:ns:domain-1.0"><domain:name>$dname</domain:name>|;
1432 3 $answ .= "<domain:roid>$$dm{roid}</domain:roid>";
1433 3 ▶ unless ( scalar( keys %{$$dm{statuses}} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar keys %{$$dm{'statuses'};}) { } 1 2 3
1434 2 $answ .= qq|<domain:status s="ok" />|;
1435 }
1436 else {
1437 1 for my $st ( keys %{$$dm{statuses}} ) {
1438 1 ▶ if ( $$dm{statuses}{$st} eq '+' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dm->{'statuses'}{$st} eq '+') { } 1 0 1
1439 1 $answ .= qq|<domain:status s="$st" />|;
1440 }
1441 else {
1442 0 $answ .= qq|<domain:status s="$st">| . $$dm{statuses}{$st} . '</domain:status>';
1443 }
1444 }
1445 }
1446 3 $answ .= "<domain:registrant>$$dm{registrant}</domain:registrant>";
1447 3 for my $t ( 'tech', 'admin', 'billing' ) {
1448 9 for my $c ( keys %{$$dm{$t}} ) {
1449 9 $answ .= qq|<domain:contact type="$t">$c</domain:contact>|;
1450 }
1451 }
1452 3 ▶ if ( $$dm{nss} && scalar( keys %{$$dm{nss}} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dm->{"nss"} and scalar keys %{$$dm{"nss"};}) 3 0 3
Condition50%1/2
$dm->{"nss"} and scalar keys %{$$dm{"nss"};}
!ll
03
MC/DC0%0/1
$dm->{"nss"} and scalar keys %{$$dm{"nss"};}
$dm->{"nss"}
Truth table50%1/2
A
A= $dm->{"nss"}
Aresult
00
11
1453 3 $answ .= '<domain:ns>';
1454 3 foreach my $ns ( keys %{$$dm{nss}} ) {
1455 6 $answ .= "<domain:hostObj>$ns</domain:hostObj>";
1456 }
1457 3 $answ .= '</domain:ns>';
1458 }
1459 3 ▶ if ( $$dm{hosts} && scalar( keys %{$$dm{hosts}} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dm->{"hosts"} and scalar keys %{$$dm{"hosts"};}) 1 2 3
Condition100%2/2
$dm->{"hosts"} and scalar keys %{$$dm{"hosts"};}
!ll
21
MC/DC100%1/1
$dm->{"hosts"} and scalar keys %{$$dm{"hosts"};}
$dm->{"hosts"}
Truth table100%2/2
A
A= $dm->{"hosts"}
Aresult
00
11
1460 1 foreach my $host ( sort keys %{$$dm{hosts}} ) {
1461 2 $answ .= "<domain:host>$host</domain:host>";
1462 }
1463 }
1464 # centralnic does not show authinfo to anybody
1465 3 $answ .= "<domain:clID>$$dm{owner}</domain:clID>";
1466 3 $answ .= "<domain:crID>$$dm{creater}</domain:crID>";
1467 3 $answ .= "<domain:crDate>$$dm{cre_date}</domain:crDate>";
1468 3 $answ .= "<domain:upID>$$dm{updater}</domain:upID>";
1469 3 $answ .= "<domain:upDate>$$dm{upd_date}</domain:upDate>";
1470 3 $answ .= "<domain:exDate>$$dm{exp_date}</domain:exDate>";
1471 3 ▶ $answ .= "<domain:trDate>$$dm{trans_date}</domain:trDate>" if $dm->{trans_date};
Branch: 1 branch
BranchTrueFalseTotal
if $dm->{"trans_date"} 0 3 3
1472 3 $answ .= '</domain:infData>';
1473  
1474 3 return _ok_answ( $answ, $cltrid );
1475 }
1476  
1477  
1478 sub domain_renew {
1479 5 ▶ my ( $obj, $body ) = @_;
Subroutine domain_renew: called CC=16 SCAR=29.9
Pod undocumented
1480  
1481 5 my ( $cltrid ) = $body =~ m|<clTRID>([0-9A-Za-z\-]+)</clTRID>|s;
1482  
1483 5 ▶ return _fail_cltrid() unless $cltrid;
Branch: 1 branch
BranchTrueFalseTotal
unless $cltrid 0 5 5
1484  
1485 5 ▶ unless ( $body =~ s|^<\?xml version="1.0" encoding="UTF-8"\?>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<\?xml version="1.0" encoding="UTF-8"\?>\s+//s) 0 5 5
1486 0 return _fail_body( 'XML schema validation failed: ', '2001', $cltrid );
1487 }
1488  
1489 5 ▶ unless ( $body =~ s|^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+//s) 0 5 5
1490 0 return _fail_body( 'XML schema validation failed: Element &#039;{uurn:ietf:params:xml:ns:epp-1.0}epp&#039;: No matching global declaration available for the validation root.', '2001', $cltrid );
1491 }
1492  
1493 5 ▶ unless ( $body =~ s|^<command>\s+<renew>\s+<domain:renew[^<>]+>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<command>\s+<renew>\s+<domain:renew[^<>]+>\s+//s) 0 5 5
1494 0 return _fail_body( 'XML schema validation failed: domain:renew', '2001', $cltrid );
1495 }
1496  
1497 5 ▶ unless ( $body =~ s|\s+</domain:renew>\s+</renew>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s[\s+</domain:renew>\s+</renew>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$][]s) 0 5 5
1498 0 return _fail_body( 'XML schema validation failed: /domain:renew', '2001', $cltrid );
1499 }
1500  
1501 5 my $dname;
1502 5 ▶ if ( $body =~ m|<domain:name>([^<>]+)</domain:name>| ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ m[<domain:name>([^<>]+)</domain:name>]) { } 5 0 5
1503 5 $dname = lc $1;
1504 }
1505 else {
1506 0 return _fail_body( 'XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:domain-1.0}name&#039;: [facet &#039;minLength&#039;] The value has a length of &#039;0&#039;; this underruns the allowed minimum length of &#039;1&#039;.', '2001', $cltrid );
1507 }
1508  
1509 5 ▶ if ( $dname =~ /([^0-9a-z\.\-])/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dname =~ /([^0-9a-z\.\-])/) 0 5 5
1510 0 return _fail_body( "&#039;$dname&#039; is not a valid domain name: the following characters are not permitted: &#039;$1&#039;", '2004', $cltrid );
1511 }
1512  
1513 5 ▶ if ( $dname !~ /^[0-9a-z\.\-]+\.[0-9a-z\-]+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dname =~ /^[0-9a-z\.\-]+\.[0-9a-z\-]+$/) 0 5 5
1514 0 return _fail_body( "&#039;$dname&#039; is not a valid domain name: suffix ... does not exist", '2004', $cltrid );
1515 }
1516  
1517 5 my $srv_url = $obj->{sock};
1518 5 my $s = new IO::EPP::Test::Server( $srv_url );
1519 5 my $doms = $s->data->{doms};
1520  
1521 5 ▶ unless ( $s->data->{doms}{$dname} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($s->data->{"doms"}{$dname}) 0 5 5
1522 0 return _fail_body( "The domain &#039;$dname&#039; does not exist", '2303', $cltrid );
1523 }
1524  
1525 5 my $dm = $s->data->{doms}{$dname};
1526  
1527 5 for my $s ( 'clientRenewProhibited', 'serverRenewProhibited' ) {
1528 10 ▶ if ( $dm->{statuses}{$s} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dm->{"statuses"}{$s}) 1 9 10
1529 1 return _fail_body( "Domain cannot be renewed ($s)", 2304, $cltrid );
1530 }
1531 }
1532  
1533 4 my $period = 1;
1534 4 ▶ if ( $body =~ m|<domain:period unit="y">(\d+)</domain:period>| ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ m[<domain:period unit="y">(\d+)</domain:period>]) 4 0 4
1535 4 $period = $1;
1536  
1537 4 ▶ if ( $period > 9 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($period > 9) 1 3 4
1538 1 return _fail_body( "XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:domain-1.0}period&#039;: [facet &#039;maxInclusive&#039;] The value &#039;$period&#039; is greater than the maximum value allowed (&#039;9&#039;).", '2001', $cltrid );
1539 }
1540 }
1541  
1542 3 my $edt;
1543 3 ▶ if ( $body =~ m|<domain:curExpDate>(\d\d\d\d-\d\d-\d\d)</domain:curExpDate>| ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ m[<domain:curExpDate>(\d\d\d\d-\d\d-\d\d)</domain:curExpDate>]) { } 2 1 3
1544 2 $edt = $1;
1545 }
1546 else {
1547 1 return _fail_body( "XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:domain-1.0}curExpDate&#039;: &#039;xxx&#039; is not a valid value of the atomic type &#039;xs:date&#039;.", '2001', $cltrid );
1548 }
1549  
1550 2 my ( $old_exp_date ) = $dm->{exp_date} =~ /^(\d\d\d\d-\d\d-\d\d)/;
1551 2 ▶ if ( $old_exp_date ne $edt ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($old_exp_date ne $edt) 1 1 2
1552 1 return _fail_body( 'Expiry date is not correct.', '2004', $cltrid );
1553 }
1554  
1555 1 $dm->{exp_date} =~ s/^(\d+)/$1+$period/e;
1556 1 my $new_exp_date = $dm->{exp_date};
1557  
1558 1 my $svtrid = get_svtrid();
1559  
1560 1 return qq|<?xml version="1.0" encoding="UTF-8" standalone="no"?><epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
1561 <response>
1562 <result code="1000">
1563 <msg>Command completed successfully.</msg>
1564 </result>
1565  
1566 <resData>
1567 <domain:renData xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
1568 <domain:name>$dname</domain:name>
1569 <domain:exDate>$new_exp_date</domain:exDate>
1570 </domain:renData>
1571 </resData>
1572 <trID>
1573 <clTRID>$cltrid</clTRID>
1574 <svTRID>$svtrid</svTRID>
1575 </trID>
1576 </response>
1577 </epp>|;
1578 =rem
1579 <?xml version="1.0" encoding="UTF-8" standalone="no"?><epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
1580 <response>
1581 <result code="1000">
1582 <msg>Command completed successfully.</msg>
1583 </result>
1584  
1585 <resData>
1586 <domain:renData xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
1587 <domain:name>xxx.ru.com</domain:name>
1588 <domain:exDate>2022-07-18T23:59:59.0Z</domain:exDate>
1589 </domain:renData>
1590 </resData>
1591 <extension><fee:renData xmlns:fee="urn:ietf:params:xml:ns:fee-0.5"><fee:currency>USD</fee:currency><fee:fee>18.00</fee:fee></fee:renData></extension>
1592 <trID>
1593 <clTRID>f919bef2e68b168e5d39bf91aff6fa6e</clTRID>
1594 <svTRID>CNIC-7295E4F58291FFD21B1702346BA9D70F25952BD03CF3780ECF0DA0D8285</svTRID>
1595 </trID>
1596 </response>
1597 </epp>
1598 =cut
1599 }
1600  
1601  
1602 sub domain_update {
1603 20 ▶ my ( $obj, $body ) = @_;
Subroutine domain_update: called CC=77 SCAR=46.0
Pod undocumented
1604  
1605 20 my ( $cltrid ) = $body =~ m|<clTRID>([0-9A-Za-z\-]+)</clTRID>|s;
1606  
1607 20 ▶ return _fail_cltrid() unless $cltrid;
Branch: 1 branch
BranchTrueFalseTotal
unless $cltrid 0 20 20
1608  
1609 20 ▶ unless ( $body =~ s|^<\?xml version="1.0" encoding="UTF-8"\?>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<\?xml version="1.0" encoding="UTF-8"\?>\s+//s) 0 20 20
1610 0 return _fail_body( 'XML schema validation failed: ', '2001', $cltrid );
1611 }
1612  
1613 20 ▶ unless ( $body =~ s|^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+//s) 0 20 20
1614 0 return _fail_body( 'XML schema validation failed: Element &#039;{uurn:ietf:params:xml:ns:epp-1.0}epp&#039;: No matching global declaration available for the validation root.', '2001', $cltrid );
1615 }
1616  
1617 20 ▶ unless ( $body =~ s|^<command>\s+<update>\s+<domain:update[^<>]+>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<command>\s+<update>\s+<domain:update[^<>]+>\s+//s) 0 20 20
1618 0 return _fail_body( 'XML schema validation failed: domain:update', '2001', $cltrid );
1619 }
1620  
1621 20 ▶ unless ( $body =~ s|\s+</domain:update>\s+</update>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s[\s+</domain:update>\s+</update>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$][]s) 0 20 20
1622 0 return _fail_body( 'XML schema validation failed: /domain:update', '2001', $cltrid );
1623 }
1624  
1625 20 my $dname;
1626 20 ▶ if ( $body =~ m|<domain:name>([^<>]+)</domain:name>| ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ m[<domain:name>([^<>]+)</domain:name>]) { } 20 0 20
1627 20 $dname = lc $1;
1628 }
1629 else {
1630 0 return _fail_body( 'XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:domain-1.0}name&#039;: [facet &#039;minLength&#039;] The value has a length of &#039;0&#039;; this underruns the allowed minimum length of &#039;1&#039;.', '2001', $cltrid );
1631 }
1632  
1633 20 ▶ if ( $dname =~ /([^0-9a-z\.\-])/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dname =~ /([^0-9a-z\.\-])/) 0 20 20
1634 0 return _fail_body( "&#039;$dname&#039; is not a valid domain name: the following characters are not permitted: &#039;$1&#039;", '2004', $cltrid );
1635 }
1636  
1637 20 ▶ if ( $dname !~ /^[0-9a-z\.\-]+\.[0-9a-z\-]+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dname =~ /^[0-9a-z\.\-]+\.[0-9a-z\-]+$/) 0 20 20
1638 0 return _fail_body( "&#039;$dname&#039; is not a valid domain name: suffix ... does not exist", '2004', $cltrid );
1639 }
1640  
1641 20 my $srv_url = $obj->{sock};
1642 20 my $s = new IO::EPP::Test::Server( $srv_url );
1643 20 my $conts = $s->data->{conts};
1644 20 my $nss = $s->data->{nss};
1645 20 my $doms = $s->data->{doms};
1646  
1647 20 ▶ unless ( $s->data->{doms}{$dname} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($s->data->{"doms"}{$dname}) 1 19 20
1648 1 return _fail_body( "The domain &#039;$dname&#039; does not exist", '2303', $cltrid );
1649 }
1650  
1651 19 my $dm = $s->data->{doms}{$dname};
1652  
1653 19 ▶ if ( $dm->{statuses}{serverUpdateProhibited} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dm->{"statuses"}{"serverUpdateProhibited"}) 1 18 19
1654 1 return _fail_body( 'The domain name cannot be updated (serverUpdateProhibited).', '2304', $cltrid );
1655 }
1656  
1657 18 ▶ my $no_upd = $dm->{statuses}{clientUpdateProhibited} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$dm->{'statuses'}{'clientUpdateProhibited'} ? : 2 16 18
1658  
1659 18 ▶ if ( $body =~ m|<domain:rem>(.+?)</domain:rem>|s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ m[<domain:rem>(.+?)</domain:rem>]s) 6 12 18
1660 6 my $u = $1;
1661  
1662 6 my @sts = $u =~ m|<domain:status\s+s="(\w+)"|gs;
1663  
1664 6 foreach my $st ( @sts ) {
1665 1 ▶ if ( $no_upd && $st eq 'clientUpdateProhibited' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($no_upd and $st eq "clientUpdateProhibited") 1 0 1
Condition33%1/3
$no_upd and $st eq "clientUpdateProhibited"
!ll&&!rl&&r
001
MC/DC0%0/2
$no_upd and $st eq "clientUpdateProhibited"
$no_upd $st eq "clientUpdateProhibited"
Truth table33%1/3
A and B
A= $no_updB= $st eq "clientUpdateProhibited"
ABresult
0X0
100
111
1666 1 $no_upd = 0;
1667 }
1668 }
1669 }
1670  
1671 18 ▶ if ( $no_upd ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($no_upd) 1 17 18
1672 1 return _fail_body( 'The domain name cannot be updated (clientUpdateProhibited).', '2304', $cltrid );
1673 }
1674  
1675  
1676 17 my %add;
1677 my %rem;
1678 17 my %chg;
1679  
1680 # For NSS Registry at first adds everything, then deletes -- it is already checked
1681 17 ▶ if ( $body =~ m|<domain:add>(.+?)</domain:add>|s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ m[<domain:add>(.+?)</domain:add>]s) 9 8 17
1682 9 my $add = $1;
1683  
1684 # CentralNIC not save the status reason
1685 9 my @sts = $add =~ /<domain:status\s+s="(\w+)"/gs;
1686  
1687 9 foreach my $st ( @sts ) {
1688 4 ▶ unless ( $statuses{$st} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($IO::EPP::Test::Base::statuses{$st}) 1 3 4
1689 1 return _fail_body( "XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:domain-1.0}status&#039;, attribute &#039;s&#039;: [facet &#039;enumeration&#039;] The value &#039;$st&#039; is not an element of the set {&#039;clientDeleteProhibited&#039;, &#039;clientHold&#039;, &#039;clientRenewProhibited&#039;, &#039;clientTransferProhibited&#039;, &#039;clientUpdateProhibited&#039;, &#039;inactive&#039;, &#039;ok&#039;, &#039;pendingCreate&#039;, &#039;pendingDelete&#039;, &#039;pendingRenew&#039;, &#039;pendingTransfer&#039;, &#039;pendingUpdate&#039;, &#039;serverDeleteProhibited&#039;, &#039;serverHold&#039;, &#039;serverRenewProhibited&#039;, &#039;serverTransferProhibited&#039;, &#039;serverUpdateProhibited&#039;}.", '2001', $cltrid );
1690 }
1691  
1692 3 ▶ if ( $dm->{statuses}{$st} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dm->{"statuses"}{$st}) 1 2 3
1693 1 return _fail_body( "$st is already set on this domain.", '2004', $cltrid );
1694 }
1695  
1696 2 push @{$add{statuses}}, $st;
1697 }
1698  
1699 7 foreach my $t ( 'admin', 'tech', 'billing' ) {
1700 21 ▶ if ( $add =~ m|<domain:contact type="$t">([^<>]+)</domain:contact>| ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($add =~ m[<domain:contact type="$t">([^<>]+)</domain:contact>]) 2 19 21
1701 2 $add{$t} = $1;
1702  
1703 2 ▶ unless ( $conts->{$add{$t}} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($$conts{$add{$t}}) 0 2 2
1704 0 return _fail_body( "Cannot add $t contact $add{$t} contact not found.", '2303', $cltrid );
1705 }
1706 }
1707 }
1708  
1709 7 ▶ if ( $add =~ m|<domain:ns>(.+?)</domain:ns>|s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($add =~ m[<domain:ns>(.+?)</domain:ns>]s) 3 4 7
1710 3 my $ns = $1;
1711  
1712 3 my @hosts = $ns =~ m|<domain:hostObj>([^<>]+)</domain:hostObj>|g;
1713  
1714 3 $add{nss} = {};
1715  
1716 3 foreach my $h ( @hosts ) {
1717 3 ▶ if ( $nss->{$h} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nss->{$h}) { } 2 1 3
1718 2 $add{nss}{$h} = '+';
1719 }
1720 else {
1721 1 return _fail_body( "Cannot find host object &#039;$h&#039;", '2303', $cltrid );
1722 }
1723 }
1724 }
1725 }
1726  
1727 14 ▶ if ( $body =~ m|<domain:rem>(.+?)</domain:rem>|s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ m[<domain:rem>(.+?)</domain:rem>]s) 6 8 14
1728 6 my $rem = $1;
1729  
1730 6 my @sts = $rem =~ m|<domain:status\s+s="(\w+)"|gs;
1731  
1732 6 foreach my $st ( @sts ) {
1733 1 ▶ unless ( $statuses{$st} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($IO::EPP::Test::Base::statuses{$st}) 0 1 1
1734 0 return _fail_body( "XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:domain-1.0}status&#039;, attribute &#039;s&#039;: [facet &#039;enumeration&#039;] The value &#039;$st&#039; is not an element of the set {&#039;clientDeleteProhibited&#039;, &#039;clientHold&#039;, &#039;clientRenewProhibited&#039;, &#039;clientTransferProhibited&#039;, &#039;clientUpdateProhibited&#039;, &#039;inactive&#039;, &#039;ok&#039;, &#039;pendingCreate&#039;, &#039;pendingDelete&#039;, &#039;pendingRenew&#039;, &#039;pendingTransfer&#039;, &#039;pendingUpdate&#039;, &#039;serverDeleteProhibited&#039;, &#039;serverHold&#039;, &#039;serverRenewProhibited&#039;, &#039;serverTransferProhibited&#039;, &#039;serverUpdateProhibited&#039;}.", '2001', $cltrid );
1735 }
1736  
1737 1 ▶ unless ( $dm->{statuses}{$st} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dm->{"statuses"}{$st}) 0 1 1
1738 0 return _fail_body( "$st is not set on this domain.", '2004', $cltrid );
1739 }
1740  
1741 1 push @{$rem{statuses}}, $st;
1742 }
1743  
1744 6 foreach my $t ( 'admin', 'tech', 'billing' ) {
1745 18 ▶ if ( $rem =~ m|<domain:contact type="$t">([^<>]+)</domain:contact>| ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rem =~ m[<domain:contact type="$t">([^<>]+)</domain:contact>]) 2 16 18
1746 2 $rem{$t} = $1;
1747  
1748 2 ▶ unless ( $conts->{$rem{$t}} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($$conts{$rem{$t}}) 0 2 2
1749 0 return _fail_body( "Cannot remove $t contact $rem{$t}: contact not found.", '2303', $cltrid );
1750 }
1751  
1752 2 ▶ unless ( $dm->{$t}{$rem{$t}} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dm->{$t}{$rem{$t}}) 0 2 2
1753 0 return _fail_body( "Invalid contact association type &#039;$t&#039;", '2004', $cltrid );
1754 }
1755 }
1756 }
1757  
1758 6 ▶ if ( $rem =~ m|<domain:ns>(.+?)</domain:ns>|s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rem =~ m[<domain:ns>(.+?)</domain:ns>]s) 3 3 6
1759 3 my $ns = $1;
1760  
1761 3 my @hosts = $ns =~ m|<domain:hostObj>([^<>]+)</domain:hostObj>|g;
1762  
1763 3 $rem{nss} = {};
1764  
1765 3 foreach my $h ( @hosts ) {
1766 3 ▶ if ( $add{nss}{$h} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($add{"nss"}{$h}) 1 2 3
1767 1 delete $add{nss}{$h};
1768 1 next;
1769 }
1770  
1771 2 ▶ if ( $dm->{nss}{$h} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dm->{'nss'}{$h}) { } 1 1 2
1772 1 $rem{nss}{$h} = '+';
1773 }
1774 else {
1775 1 return _fail_body( "The host $h is not linked to this domain name.", '2303', $cltrid );
1776 }
1777 }
1778 }
1779 }
1780  
1781 13 foreach my $t ( 'admin', 'tech', 'billing' ) {
1782 37 ▶ if ( $add{$t} and not $rem{$t} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($add{$t} and not $rem{$t}) 1 36 37
Condition100%3/3
$add{$t} and not $rem{$t}
!ll&&!rl&&r
3511
MC/DC100%2/2
$add{$t} and not $rem{$t}
$add{$t} not $rem{$t}
Truth table100%3/3
A and not(B)
A= $add{$t}B= not $rem{$t}
ABresult
0X0
100
111
1783 1 return _fail_body( "Cannot assign a new $t contact without removing current tech contact.", '2004', $cltrid );
1784 }
1785  
1786 36 ▶ if ( not $add{$t} and $rem{$t} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $add{$t} and $rem{$t}) 1 35 36
Condition100%3/3
not $add{$t} and $rem{$t}
!ll&&!rl&&r
1341
MC/DC100%2/2
not $add{$t} and $rem{$t}
not $add{$t} $rem{$t}
Truth table100%3/3
not(A) and B
A= not $add{$t}B= $rem{$t}
ABresult
0X0
100
111
1787 1 return _fail_body( "Invalid contact association type &#039;$t&#039;", '2004', $cltrid );
1788 }
1789 }
1790  
1791 11 ▶ if ( $body =~ m|<domain:chg>(.+?)</domain:chg>|s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ m[<domain:chg>(.+?)</domain:chg>]s) 5 6 11
1792 5 my $chg = $1;
1793  
1794 5 ▶ if ( $chg =~ m|<domain:registrant>([^<>]+)</domain:registrant>| ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chg =~ m[<domain:registrant>([^<>]+)</domain:registrant>]) 2 3 5
1795 2 $chg{registrant} = $1;
1796  
1797 2 ▶ unless ( $conts->{$chg{registrant}} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($$conts{$chg{"registrant"}}) 1 1 2
1798 1 return _fail_body( "Contact $chg{registrant} does not exist, cannot change registrant.", '2303', $cltrid );
1799 }
1800 }
1801  
1802 4 ▶ if ( $chg =~ m|authInfo.+<domain:pw>([^<>]*)</domain:pw>.+authInfo|s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chg =~ m[authInfo.+<domain:pw>([^<>]*)</domain:pw>.+authInfo]s) 3 1 4
1803 3 my $pw = $1;
1804  
1805 3 ▶ if ( $pw and length( $pw ) < 16 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pw and length $pw < 16) 1 2 3
Condition66%2/3
$pw and length $pw < 16
!ll&&!rl&&r
021
MC/DC50%1/2
$pw and length $pw < 16
$pw length $pw < 16
Truth table66%2/3
A and B
A= $pwB= length $pw < 16
ABresult
0X0
100
111
1806 1 return _fail_body( 'authInfo code is invalid: password must be at least 16 characters', '2004', $cltrid );
1807 }
1808  
1809 2 ▶ unless ( $pw and $pw =~ /[A-Z]/ and $pw =~ /[a-z]/ and $pw =~ /[0-9]/ and $pw =~ /[!\@\$\%*_.:\-=+?#,"'\\\/&]/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pw and $pw =~ /[A-Z]/ and $pw =~ /[a-z]/ and $pw =~ /[0-9]/ and $pw =~ m[[!\@\$\%*_.:\-=+?#,"'\\/&]]) 0 1 1
Condition66%8/12
$pw and $pw =~ /[A-Z]/ and $pw =~ /[a-z]/ and $pw =~ /[0-9]/ and $pw =~ m[[!\@\$\%*_.:\-=+?#,"'\\/&]]
!ll&&!rl&&r
101
$pw and $pw =~ /[A-Z]/ and $pw =~ /[a-z]/ and $pw =~ /[0-9]/
!ll&&!rl&&r
101
$pw and $pw =~ /[A-Z]/ and $pw =~ /[a-z]/
!ll&&!rl&&r
101
$pw and $pw =~ /[A-Z]/
!ll&&!rl&&r
011
MC/DC20%1/5
$pw and $pw =~ /[A-Z]/ and $pw =~ /[a-z]/ and $pw =~ /[0-9]/ and $pw =~ m[[!\@\$\%*_.:\-=+?#,"'\\/&]]
$pw $pw =~ /[A-Z]/ $pw =~ /[a-z]/ $pw =~ /[0-9]/ $pw =~ m[[!\@\$\%*_.:\-=+?#,"'\\/&]]
Truth table33%2/6
A and B and C and D and E
A= $pwB= $pw =~ /[A-Z]/C= $pw =~ /[a-z]/D= $pw =~ /[0-9]/E= $pw =~ m[[!\@\$\%*_.:\-=+?#,"'\\/&]]
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
1810 1 return _fail_body( 'authInfo code is invalid: password must contain a mix of uppercase and lowercase characters', '2004', $cltrid );
1811 }
1812  
1813 1 $chg{authInfo} = $pw;
1814 }
1815 }
1816  
1817 # at first there is adding!!!
1818 8 ▶ if ( scalar( keys %add ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar keys %add) 5 3 8
1819 5 ▶ if ( $add{statuses} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($add{"statuses"}) 2 3 5
1820 2 foreach my $st ( @{$add{statuses}} ) {
1821 2 $dm->{statuses}{$st} = '+';
1822 }
1823 }
1824  
1825 5 foreach my $t ( 'admin', 'tech', 'billing' ) {
1826 15 ▶ if ( $add{$t} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($add{$t}) 1 14 15
1827 1 $dm->{$t}{$add{$t}} = '+';
1828  
1829 1 $conts->{$add{$t}}{statuses}{linked}++;
1830  
1831 1 ▶ if ( $conts->{$add{$t}}{statuses}{ok} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$conts{$add{$t}}{"statuses"}{"ok"}) 1 0 1
1832 1 delete $conts->{$add{$t}}{statuses}{ok};
1833 1 $conts->{$add{$t}}{statuses}{serverDeleteProhibited} = '+';
1834 }
1835 }
1836 }
1837  
1838 5 ▶ if ( $add{nss} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($add{"nss"}) 2 3 5
1839 2 foreach my $ns ( keys %{$add{nss}} ) {
1840 1 $dm->{nss}{$ns} = '+';
1841  
1842 1 $nss->{$ns}{statuses}{linked}++;
1843  
1844 1 ▶ if ( $nss->{$ns}{statuses}{ok} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nss->{$ns}{"statuses"}{"ok"}) 1 0 1
1845 1 delete $nss->{$ns}{statuses}{ok};
1846 1 $nss->{$ns}{statuses}{serverDeleteProhibited} = '+';
1847 }
1848 }
1849 }
1850 }
1851  
1852 8 ▶ if ( scalar( keys %rem ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar keys %rem) 4 4 8
1853 4 ▶ if ( $rem{statuses} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rem{"statuses"}) 1 3 4
1854 1 foreach my $st ( @{$rem{statuses}} ) {
1855 1 delete $dm->{statuses}->{$st};
1856 }
1857 }
1858  
1859 4 foreach my $t ( 'admin', 'tech', 'billing' ) {
1860 12 ▶ if ( $rem{$t} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rem{$t}) 1 11 12
1861 1 delete $dm->{$t}{$rem{$t}};
1862  
1863 1 $conts->{$rem{$t}}{statuses}{linked}--;
1864  
1865 1 ▶ if ( $conts->{$rem{$t}}{statuses}{linked} <= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$conts{$rem{$t}}{"statuses"}{"linked"} <= 0) 0 1 1
1866 0 delete $conts->{$rem{$t}}{statuses}{linked};
1867  
1868 0 $conts->{$rem{$t}}{statuses}{ok} = '+';
1869 0 delete $conts->{$rem{$t}}{statuses}{serverDeleteProhibited};
1870 }
1871 }
1872 }
1873  
1874 4 ▶ if ( $rem{nss} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rem{"nss"}) 2 2 4
1875 2 foreach my $ns ( keys %{$rem{nss}} ) {
1876 1 delete $dm->{nss}->{$ns};
1877  
1878 1 $nss->{$ns}{statuses}{linked}--;
1879  
1880 1 ▶ if ( $nss->{$ns}{statuses}{linked} <= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nss->{$ns}{"statuses"}{"linked"} <= 0) 1 0 1
1881 1 delete $nss->{$ns}{statuses}{linked};
1882  
1883 1 $nss->{$ns}{statuses}{ok} = '+';
1884 1 delete $nss->{$ns}{statuses}{serverDeleteProhibited};
1885 }
1886 }
1887 }
1888 }
1889  
1890 8 ▶ if ( $chg{registrant} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chg{"registrant"}) 1 7 8
1891 1 $conts->{$dm->{registrant}}{statuses}{linked}--;
1892  
1893 1 ▶ if ( $conts->{$dm->{registrant}}{statuses}{linked} <= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$conts{$dm->{"registrant"}}{"statuses"}{"linked"} <= 0) 0 1 1
1894 0 delete $conts->{$dm->{registrant}}{statuses}{linked};
1895  
1896 0 $conts->{$dm->{registrant}}{statuses}{ok} = '+';
1897 0 delete $conts->{$dm->{registrant}}{statuses}{serverDeleteProhibited};
1898 }
1899  
1900 1 $dm->{registrant} = $chg{registrant};
1901  
1902 1 $conts->{$chg{registrant}}{statuses}{linked}++;
1903  
1904 1 ▶ if ( $conts->{$chg{registrant}}{statuses}{ok} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$conts{$chg{"registrant"}}{"statuses"}{"ok"}) 1 0 1
1905 1 delete $conts->{$chg{registrant}}{statuses}{ok};
1906 1 $conts->{$chg{registrant}}{statuses}{serverDeleteProhibited} = '+';
1907 }
1908 }
1909  
1910 8 ▶ $dm->{authInfo} = $chg{authInfo} if $chg{authInfo};
Branch: 1 branch
BranchTrueFalseTotal
if $chg{"authInfo"} 1 7 8
1911  
1912 8 my $svtrid = get_svtrid();
1913  
1914 8 return _min_answ( '1000', $cltrid );
1915 }
1916  
1917  
1918 sub domain_delete {
1919 4 ▶ my ( $obj, $body ) = @_;
Subroutine domain_delete: called CC=24 SCAR=34.5
Pod undocumented
1920  
1921 4 my ( $cltrid ) = $body =~ m|<clTRID>([0-9A-Za-z\-]+)</clTRID>|s;
1922  
1923 4 ▶ return _fail_cltrid() unless $cltrid;
Branch: 1 branch
BranchTrueFalseTotal
unless $cltrid 0 4 4
1924  
1925 4 ▶ unless ( $body =~ s|^<\?xml version="1.0" encoding="UTF-8"\?>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<\?xml version="1.0" encoding="UTF-8"\?>\s+//s) 0 4 4
1926 0 return _fail_body( 'XML schema validation failed: ', '2001', $cltrid );
1927 }
1928  
1929 4 ▶ unless ( $body =~ s|^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+//s) 0 4 4
1930 0 return _fail_body( 'XML schema validation failed: Element &#039;{uurn:ietf:params:xml:ns:epp-1.0}epp&#039;: No matching global declaration available for the validation root.', '2001', $cltrid );
1931 }
1932  
1933 4 ▶ unless ( $body =~ s|^<command>\s+<delete>\s+<domain:delete[^<>]+>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<command>\s+<delete>\s+<domain:delete[^<>]+>\s+//s) 0 4 4
1934 0 return _fail_body( 'XML schema validation failed: domain:delete', '2001', $cltrid );
1935 }
1936  
1937 4 ▶ unless ( $body =~ s|\s+</domain:delete>\s+</delete>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s[\s+</domain:delete>\s+</delete>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$][]s) 0 4 4
1938 0 return _fail_body( 'XML schema validation failed: /domain:delete', '2001', $cltrid );
1939 }
1940  
1941 4 my $dname;
1942 4 ▶ if ( $body =~ m|<domain:name>([^<>]+)</domain:name>| ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ m[<domain:name>([^<>]+)</domain:name>]) { } 4 0 4
1943 4 $dname = lc $1;
1944 }
1945 else {
1946 0 return _fail_body( 'XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:domain-1.0}name&#039;: [facet &#039;minLength&#039;] The value has a length of &#039;0&#039;; this underruns the allowed minimum length of &#039;1&#039;.', '2001', $cltrid );
1947 }
1948  
1949 4 ▶ if ( $dname =~ /([^0-9a-z\.\-])/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dname =~ /([^0-9a-z\.\-])/) 0 4 4
1950 0 return _fail_body( "&#039;$dname&#039; is not a valid domain name: the following characters are not permitted: &#039;$1&#039;", '2004', $cltrid );
1951 }
1952  
1953 4 ▶ if ( $dname !~ /^[0-9a-z\.\-]+\.[0-9a-z\-]+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dname =~ /^[0-9a-z\.\-]+\.[0-9a-z\-]+$/) 0 4 4
1954 0 return _fail_body( "&#039;$dname&#039; is not a valid domain name: suffix ... does not exist", '2004', $cltrid );
1955 }
1956  
1957 4 my $srv_url = $obj->{sock};
1958 4 my $s = new IO::EPP::Test::Server( $srv_url );
1959 4 my $conts = $s->data->{conts};
1960 4 my $nss = $s->data->{nss};
1961 4 my $doms = $s->data->{doms};
1962  
1963 4 ▶ unless ( $doms->{$dname} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($doms->{$dname}) 1 3 4
1964 1 return _fail_body( "The domain &#039;$dname&#039; does not exist", '2303', $cltrid );
1965 }
1966  
1967 3 my $dm = $doms->{$dname};
1968  
1969 3 ▶ unless ( $dm->{reason} eq 'in use' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dm->{"reason"} eq "in use") 1 2 3
1970 1 return _fail_body( "The domain &#039;$dname&#039; does not exist", '2303', $cltrid );
1971 }
1972  
1973 2 foreach my $st ( 'clientDeleteProhibited', 'serverDeleteProhibited', 'clientUpdateProhibited', 'serverUpdateProhibited' ) {
1974 8 ▶ if ( $dm->{statuses}{$st} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dm->{"statuses"}{$st}) 0 8 8
1975 0 return _fail_body( "The domain name cannot be $statuses{$st} ($st).", '2304', $cltrid );
1976 }
1977 }
1978  
1979 2 ▶ if ( $dm->{hosts} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dm->{"hosts"}) 1 1 2
1980 1 foreach my $h ( keys %{$dm->{hosts}} ) {
1981 2 ▶ if ( $nss->{$h}{statuses}{linked} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nss->{$h}{"statuses"}{"linked"}) 1 1 2
1982 1 return _fail_body( "Domain host $h is linked to one or more domains.", '2305', $cltrid );
1983 }
1984 }
1985 }
1986  
1987 1 ▶ if ( $dm->{hosts} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dm->{"hosts"}) 0 1 1
1988 0 foreach my $h ( keys %{$dm->{hosts}} ) {
1989 0 delete $nss->{$h};
1990 }
1991 }
1992  
1993 1 $conts->{$dm->{registrant}}{statuses}{linked}--;
1994  
1995 1 ▶ if ( $conts->{$dm->{registrant}}{statuses}{linked} <= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$conts{$dm->{"registrant"}}{"statuses"}{"linked"} <= 0) 1 0 1
1996 1 delete $conts->{$dm->{registrant}}{statuses}{linked};
1997 1 delete $conts->{$dm->{registrant}}{statuses}{serverDeleteProhibited};
1998 1 $conts->{$dm->{registrant}}{statuses}{ok} = '+';
1999 }
2000  
2001 1 foreach my $t ( 'admin', 'tech', 'billing' ) {
2002 3 foreach my $c ( keys %{$dm->{$t}} ) {
2003 3 $conts->{$c}{statuses}{linked}--;
2004  
2005 3 ▶ if ( $conts->{$c}{statuses}{linked} <= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conts->{$c}{"statuses"}{"linked"} <= 0) 1 2 3
2006 1 delete $conts->{$c}{statuses}{linked};
2007 1 delete $conts->{$c}{statuses}{serverDeleteProhibited};
2008 1 $conts->{$c}{statuses}{ok} = '+';
2009 }
2010 }
2011 }
2012  
2013 1 foreach my $ns ( keys %{$dm->{nss}} ) {
2014 2 $nss->{$ns}{statuses}{linked}--;
2015  
2016 2 ▶ if ( $nss->{$ns}{statuses}{linked} <= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nss->{$ns}{"statuses"}{"linked"} <= 0) 2 0 2
2017 2 delete $nss->{$ns}{statuses}{linked};
2018 2 delete $nss->{$ns}{statuses}{serverDeleteProhibited};
2019 2 $nss->{$ns}{statuses}{ok} = '+';
2020 }
2021 }
2022  
2023 1 undef $dm;
2024 1 delete $doms->{$dname};
2025  
2026 1 return _min_answ( '1000', $cltrid );
2027 }
2028  
2029  
2030 sub domain_transfer {
2031 7 ▶ my ( $obj, $body ) = @_;
Subroutine domain_transfer: called CC=33 SCAR=43.1
Pod undocumented
2032  
2033 7 my ( $cltrid ) = $body =~ m|<clTRID>([0-9A-Za-z\-]+)</clTRID>|s;
2034  
2035 7 ▶ return _fail_cltrid() unless $cltrid;
Branch: 1 branch
BranchTrueFalseTotal
unless $cltrid 0 7 7
2036  
2037 7 ▶ unless ( $body =~ s|^<\?xml version="1.0" encoding="UTF-8"\?>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<\?xml version="1.0" encoding="UTF-8"\?>\s+//s) 0 7 7
2038 0 return _fail_body( 'XML schema validation failed: ', '2001', $cltrid );
2039 }
2040  
2041 7 ▶ unless ( $body =~ s|^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="[^"]+" xsi:schemaLocation="[^"]+">\s+//s) 0 7 7
2042 0 return _fail_body( 'XML schema validation failed: Element &#039;{uurn:ietf:params:xml:ns:epp-1.0}epp&#039;: No matching global declaration available for the validation root.', '2001', $cltrid );
2043 }
2044  
2045 7 my $op;
2046 7 ▶ if ( $body =~ /<transfer\s+op="(query|request|cancel|reject|approve)">/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ /<transfer\s+op="(query|request|cancel|reject|approve)">/) { } 7 0 7
2047 7 $op = $1;
2048 }
2049 else {
2050 0 return _fail_body( 'XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:epp-1.0}transfer&#039;, attribute &#039;op&#039;: [facet &#039;enumeration&#039;] The value &#039;xxxx&#039; is not an element of the set {&#039;approve&#039;, &#039;cancel&#039;, &#039;query&#039;, &#039;reject&#039;, &#039;request&#039;}.', '2001', $cltrid );
2051 }
2052  
2053 7 ▶ unless ( $body =~ s|^<command>\s+<transfer op="[a-z]+">\s+<domain:transfer[^<>]+>\s+||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<command>\s+<transfer op="[a-z]+">\s+<domain:transfer[^<>]+>\s+//s) 0 7 7
2054 0 return _fail_body( 'XML schema validation failed: domain:transfer', '2001', $cltrid );
2055 }
2056  
2057 7 ▶ unless ( $body =~ s|\s+</domain:transfer>\s+</transfer>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s[\s+</domain:transfer>\s+</transfer>\s+<clTRID>[^<>]+</clTRID>\s+</command>\s+</epp>\s*$][]s) 0 7 7
2058 0 return _fail_body( 'XML schema validation failed: /domain:transfer', '2001', $cltrid );
2059 }
2060  
2061 7 my $dname;
2062 7 ▶ if ( $body =~ m|<domain:name>([^<>]+)</domain:name>| ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ m[<domain:name>([^<>]+)</domain:name>]) { } 7 0 7
2063 7 $dname = lc $1;
2064 }
2065 else {
2066 0 return _fail_body( 'XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:domain-1.0}name&#039;: [facet &#039;minLength&#039;] The value has a length of &#039;0&#039;; this underruns the allowed minimum length of &#039;1&#039;.', '2001', $cltrid );
2067 }
2068  
2069 7 ▶ if ( $dname =~ /([^0-9a-z\.\-])/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dname =~ /([^0-9a-z\.\-])/) 0 7 7
2070 0 return _fail_body( "&#039;$dname&#039; is not a valid domain name: the following characters are not permitted: &#039;$1&#039;", '2004', $cltrid );
2071 }
2072  
2073 7 ▶ if ( $dname !~ /^[0-9a-z\.\-]+\.[0-9a-z\-]+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dname =~ /^[0-9a-z\.\-]+\.[0-9a-z\-]+$/) 0 7 7
2074 0 return _fail_body( "&#039;$dname&#039; is not a valid domain name: suffix ... does not exist", '2004', $cltrid );
2075 }
2076  
2077 7 my $srv_url = $obj->{sock};
2078 7 my $s = new IO::EPP::Test::Server( $srv_url );
2079 7 my $doms = $s->data->{doms};
2080  
2081 7 ▶ unless ( $doms->{$dname} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($doms->{$dname}) 1 6 7
2082 1 return _fail_body( "The domain &#039;$dname&#039; cannot be found.", '2303', $cltrid );
2083 }
2084  
2085 6 my $dm = $doms->{$dname};
2086  
2087 6 ▶ if ( $op eq 'cancel' or $op eq 'reject' or $op eq 'approve' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "cancel" or $op eq "reject" or $op eq "approve") 0 4 4
Condition66%4/6
$op eq "cancel" or $op eq "reject" or $op eq "approve"
l!l&&r!l&&!r
204
$op eq "cancel" or $op eq "reject"
l!l&&r!l&&!r
204
MC/DC33%1/3
$op eq "cancel" or $op eq "reject" or $op eq "approve"
$op eq "cancel" $op eq "reject" $op eq "approve"
Truth table50%2/4
A or B or C
A= $op eq "cancel"B= $op eq "reject"C= $op eq "approve"
ABCresult
1XX1
01X1
0011
0000
2088 2 ▶ unless ( $dm->{statuses}{pendingTransfer} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dm->{"statuses"}{"pendingTransfer"}) 1 1 2
2089 1 return _fail_body( 'There are no pending transfer requests for this object.', '2301', $cltrid );
2090 }
2091 }
2092  
2093 5 ▶ if ( $op eq 'query' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "query") 1 4 5
2094 1 ▶ unless ( $dm->{statuses}{pendingTransfer} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dm->{"statuses"}{"pendingTransfer"}) 0 1 1
2095 0 return _fail_body( 'You cannot view the details of this transfer.', '2201', $cltrid );
2096 }
2097  
2098 1 ▶ unless ( $dm->{owner} eq $obj->{user} or $dm->{transfer}{new_owner} eq $obj->{user} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dm->{"owner"} eq $obj->{"user"} or $dm->{"transfer"}{"new_owner"} eq $obj->{"user"}) 0 1 1
Condition33%1/3
$dm->{"owner"} eq $obj->{"user"} or $dm->{"transfer"}{"new_owner"} eq $obj->{"user"}
l!l&&r!l&&!r
010
MC/DC0%0/2
$dm->{"owner"} eq $obj->{"user"} or $dm->{"transfer"}{"new_owner"} eq $obj->{"user"}
$dm->{"owner"} eq $obj->{"user"} $dm->{"transfer"}{"new_owner"} eq $obj->{"user"}
Truth table33%1/3
A or B
A= $dm->{"owner"} eq $obj->{"user"}B= $dm->{"transfer"}{"new_owner"} eq $obj->{"user"}
ABresult
1X1
011
000
2099 0 return _fail_body( 'You cannot view the details of this transfer.', '2201', $cltrid );
2100 }
2101  
2102 1 my $from = $dm->{owner};
2103 1 my $to = $dm->{transfer}{new_owner};
2104  
2105 1 my $exp_date = $dm->{exp_date};
2106 1 my $period = $dm->{transfer}{period};
2107 1 $exp_date =~ s/^(\d+)/$1+$period/e;
2108  
2109 1 my $tr_dt = $dm->{transfer}{tr_date};
2110 1 my $q_dt = $dm->{transfer}{q_date};
2111  
2112  
2113 1 return _ok_answ( qq|<domain:trnData xmlns:domain="urn:ietf:params:xml:ns:domain-1.0"><domain:name>flowerlab.online</domain:name><domain:trStatus>pending</domain:trStatus><domain:reID>$to</domain:reID><domain:reDate>$q_dt</domain:reDate><domain:acID>$from</domain:acID><domain:acDate>$tr_dt</domain:acDate><domain:exDate>$exp_date</domain:exDate></domain:trnData>|, $cltrid );
2114 }
2115  
2116 4 ▶ if ( $op eq 'request' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "request") 3 1 4
2117 3 ▶ if ( $dm->{owner} eq $obj->{user} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dm->{"owner"} eq $obj->{"user"}) 1 2 3
2118 1 return _fail_body( 'You are already the sponsor for this domain', '2304', $cltrid );
2119 }
2120  
2121 2 foreach my $st ( 'clientTransferProhibited', 'clientUpdateProhibited', 'serverTransferProhibited', 'serverUpdateProhibited' ) {
2122 8 ▶ if ( $dm->{statuses}{$st} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dm->{"statuses"}{$st}) 0 8 8
2123 0 return _fail_body( "The domain name cannot be $statuses{$st} ($st).", '2304', $cltrid );
2124 }
2125 }
2126 }
2127  
2128 3 ▶ if ( $op eq 'cancel' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "cancel") 1 2 3
2129 1 ▶ if ( $dm->{transfer}{new_owner} eq $obj->{user} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dm->{"transfer"}{"new_owner"} eq $obj->{"user"}) 1 0 1
2130 1 delete $dm->{transfer};
2131 1 delete $dm->{statuses}{pendingTransfer};
2132  
2133 1 return _min_answ( '1000', $cltrid );
2134 }
2135  
2136 0 return _fail_body( 'You cannot cancel this transfer.', '2201', $cltrid );
2137 }
2138  
2139 2 ▶ if ( $op eq 'reject' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "reject") 0 2 2
2140 0 ▶ if ( $dm->{owner} eq $obj->{user} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dm->{"owner"} eq $obj->{"user"}) 0 0 0
2141 0 delete $dm->{transfer};
2142 0 delete $dm->{statuses}{pendingTransfer};
2143  
2144 0 return _min_answ( '1000', $cltrid );
2145 }
2146  
2147 0 return _fail_body( 'You cannot reject this transfer.', '2201', $cltrid );
2148 }
2149  
2150 2 ▶ if ( $op eq 'approve' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "approve") 0 2 2
2151 0 ▶ if ( $dm->{owner} eq $obj->{user} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dm->{"owner"} eq $obj->{"user"}) 0 0 0
2152 0 $dm->{owner} = $dm->{transfer}{new_owner};
2153 0 my $p = $dm->{transfer}{period};
2154 0 $dm->{exp_date} =~ s/^(\d+)/$1+$p/e;
2155  
2156 0 delete $dm->{transfer};
2157 0 delete $dm->{statuses}{pendingTransfer};
2158  
2159 0 return _min_answ( '1000', $cltrid );
2160 }
2161  
2162 0 return _fail_body( 'You cannot approve this transfer.', '2201', $cltrid );
2163 }
2164  
2165 2 my $period = 1;
2166 2 ▶ if ( $body =~ m|<domain:period unit="y">(\d+)</domain:period>| ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ m[<domain:period unit="y">(\d+)</domain:period>]) 2 0 2
2167 2 $period = $1;
2168  
2169 2 ▶ if ( $period > 9 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($period > 9) 0 2 2
2170 0 return _fail_body( "XML schema validation failed: Element &#039;{urn:ietf:params:xml:ns:domain-1.0}period&#039;: [facet &#039;maxInclusive&#039;] The value &#039;$period&#039; is greater than the maximum value allowed (&#039;9&#039;).", '2001', $cltrid );
2171 }
2172 }
2173  
2174 2 ▶ if ( $body =~ m|authInfo.+<domain:pw>([^<>]+)</domain:pw>.+authInfo|s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body =~ m[authInfo.+<domain:pw>([^<>]+)</domain:pw>.+authInfo]s) 2 0 2
2175 2 my $pw = $1;
2176  
2177 2 ▶ if ( $pw ne $dm->{authInfo} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pw ne $dm->{"authInfo"}) 1 1 2
2178 1 return _fail_body( 'Invalid authorisation code.', '2202', $cltrid );
2179 }
2180 }
2181  
2182 1 my $from = $dm->{owner};
2183 1 my $to = $obj->{user};
2184  
2185 1 my $exp_date = $dm->{exp_date};
2186 1 $exp_date =~ s/^(\d+)/$1+$period/e;
2187 1 my ( $q_dt ) = get_dates();
2188 1 my $tr_dt = $q_dt;
2189 1 $tr_dt =~ s/^(\d+)/$1+1/e;
2190  
2191 $dm->{transfer} = {
2192 period => $period,
2193 new_owner => $obj->{user},
2194 1 q_date => $q_dt,
2195 tr_date => $tr_dt,
2196 };
2197  
2198 1 $dm->{statuses}{pendingTransfer} = '+';
2199  
2200 1 my $svtrid = get_svtrid();
2201  
2202 1 return qq|<?xml version="1.0" encoding="UTF-8" standalone="no"?><epp xmlns="urn:ietf:params:xml:ns:epp-1.0"><response><result code="1001"><msg>Command completed OK; action pending</msg></result><resData><domain:trnData xmlns:domain="urn:ietf:params:xml:ns:domain-1.0"><domain:name>$dname</domain:name><domain:trStatus>pending</domain:trStatus><domain:reID>$to</domain:reID><domain:reDate>$q_dt</domain:reDate><domain:acID>$from</domain:acID><domain:acDate>$tr_dt</domain:acDate><domain:exDate>$exp_date</domain:exDate></domain:trnData></resData><trID><clTRID>$cltrid</clTRID><svTRID>$svtrid</svTRID></trID></response></epp>|;
2203 }
2204  
2205  
2206 sub poll {
2207 1 ▶ my ( $obj, $body ) = @_;
Subroutine poll: called CC=2 SCAR=7.0
Pod undocumented
2208  
2209 1 my ( $cltrid ) = $body =~ m|<clTRID>([0-9A-Za-z\-]+)</clTRID>|s;
2210  
2211 1 ▶ return _fail_cltrid() unless $cltrid;
Branch: 1 branch
BranchTrueFalseTotal
unless $cltrid 0 1 1
2212  
2213 1 my $svtrid = get_svtrid();
2214  
2215 1 return qq|<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2216 <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
2217 <response>
2218 <result code="1300">
2219 <msg>There are no messages for you!</msg>
2220 </result>
2221 <trID>
2222 <clTRID>$cltrid</clTRID>
2223 <svTRID>$svtrid</svTRID>
2224 </trID>
2225 </response>
2226 </epp>|;
2227 }
2228  
2229  
2230 sub logout {
2231 49 ▶ my ( $body ) = @_;
Subroutine logout: called CC=4 SCAR=15.8
Pod undocumented
2232  
2233 49 ▶ unless ( $body =~ s|^<\?xml[^<>]+\?>\s+<epp[^<>]+>||s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ s/^<\?xml[^<>]+\?>\s+<epp[^<>]+>//s) 0 49 49
2234 0 _fail_body( 'XML schema validation failed: ', '2001' );
2235 }
2236  
2237 49 ▶ unless ( $body =~ m|<command>(.+?)</command>|s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ m[<command>(.+?)</command>]s) 0 49 49
2238 0 die "closed connection\n";
2239 }
2240  
2241 49 my $svtrid = get_svtrid();
2242  
2243 49 my ( $cltrid ) = $body =~ m|<clTRID>([0-9A-Za-z\-]+)</clTRID>|s;
2244  
2245 49 ▶ if ( $cltrid ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cltrid) 49 0 49
2246 49 return _min_answ( '1500', $cltrid );
2247 }
2248  
2249 0 return _fail_cltrid();
2250 }
2251  
2252 2 1;
« EPP/IRRP.pm ↑ Summary EPP/RRPProxy.pm »