DRI/Shell.pm

filter: Statementstmt 4.6% 40 / 870 Branchbran 0.4% 2 / 466 Conditioncond 1.5% 3 / 199 MC/DCmcdc 0.0% 0 / 113 Subroutinesub 19.3% 12 / 62 Podpod 6.6% 3 / 45 totaltotal 3.4% 60 / 1755 CC 337 SCAR 72.6
CC
337
Cov
3%
complete
5852.0
process
1463.6
wrap_command_domain
812.0
CRAP 1416.6
« DRI/Protocol/EPP/Extensions/NO/Contact.pm ↑ Summary DRI/Data/Contact/SWITCH.pm »
1 ## Domain Registry Interface, Shell interface
2 ##
3 ## Copyright (c) 2008-2014,2016-2017 Patrick Mevzek <netdri@dotandco.com>. All rights reserved.
4 ##
5 ## This file is part of Net::DRI
6 ##
7 ## Net::DRI is free software; you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation; either version 2 of the License, or
10 ## (at your option) any later version.
11 ##
12 ## See the LICENSE file that comes with this distribution for more details.
13 ####################################################################################################
14  
15 package Net::DRI::Shell;
16  
17 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use feature 'state';
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 our @EXPORT_OK=qw(run);
23  
24 1 ▶use Net::DRI;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶use Net::DRI::Protocol::ResultStatus;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 1 ▶use Term::ReadLine; ## see also Term::Shell
Subroutine BEGIN: called CC=1 SCAR=0.0
28 1 ▶use Time::HiRes ();
Subroutine BEGIN: called CC=1 SCAR=0.0
29 1 ▶use IO::Handle ();
Subroutine BEGIN: called CC=1 SCAR=0.0
30 1 ▶use DateTime::Duration;
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 1 ▶our $HISTORY=(exists $ENV{HOME} && defined $ENV{HOME} && length $ENV{HOME})? $ENV{HOME}.'/.drish_history' : undef;
Branch: 1 branch
BranchTrueFalseTotal
exists $ENV{'HOME'} && defined $ENV{'HOME'} && length $ENV{'HOME'} ? : 1 0 1
Condition33%2/6
exists $ENV{"HOME"} and defined $ENV{"HOME"} and length $ENV{"HOME"}
!ll&&!rl&&r
001
exists $ENV{"HOME"} and defined $ENV{"HOME"}
!ll&&!rl&&r
001
MC/DC0%0/3
exists $ENV{"HOME"} and defined $ENV{"HOME"} and length $ENV{"HOME"}
exists $ENV{"HOME"} defined $ENV{"HOME"} length $ENV{"HOME"}
Truth table25%1/4
A and B and C
A= exists $ENV{"HOME"}B= defined $ENV{"HOME"}C= length $ENV{"HOME"}
ABCresult
0XX0
10X0
1100
1111
33  
34 1 ▶exit __PACKAGE__->run(@ARGV) if (!caller() || caller() eq 'PAR'); ## This is a modulino :-)
Branch: 1 branch
BranchTrueFalseTotal
if not caller() or caller() eq "PAR" 0 1 1
Condition33%1/3
not caller() or caller() eq "PAR"
l!l&&r!l&&!r
001
MC/DC0%0/2
not caller() or caller() eq "PAR"
not caller() caller() eq "PAR"
Truth table33%1/3
not(A) or B
A= not caller()B= caller() eq "PAR"
ABresult
1X1
011
000
35  
36 =pod
37  
38 =head1 NAME
39  
40 Net::DRI::Shell - Command Line Shell for Net::DRI, with batch features and autocompletion support
41  
42 =head1 SYNOPSYS
43  
44 perl -I../../ ./Shell.pm
45 or
46 perl -MNet::DRI::Shell -e run
47 or
48 perl -MNet::DRI::Shell -e 'Net::DRI::Shell->run()'
49 or in your programs:
50 use Net::DRI::Shell;
51 Net::DRI::Shell->run();
52  
53 Welcome to Net::DRI $version shell, pid $pid
54 Net::DRI object created with a cache TTL of 10 seconds and logging into files in current directory
55  
56 NetDRI> add_registry registry=EURid client_id=YOURID
57 NetDRI(EURid)> add_current_profile name=profile1 type=epp client_login=YOURLOGIN client_password=YOURPASSWORD
58 Profile profile1 added successfully (1000/COMMAND_SUCCESSFUL) SUCCESS
59 NetDRI(EURid,profile1)> domain_info example.eu
60 Command completed successfully (1000/1000) SUCCESS
61 NetDRI(EURid,profile1)> get_info_all
62  
63 ... all data related to the domain name queried ...
64  
65 NetDRI(EURid,profile1)> domain_check whatever.eu
66 Command completed successfully (1000/1000) SUCCESS
67 NetDRI(EURid,profile1)> get_info_all
68  
69 ... all data related to the domain name queried ...
70  
71 NetDRI(EURid,profile1)> show profiles
72 EURid: profile1
73 NetDRI(EURid,profile1)> quit
74  
75  
76 =head1 DESCRIPTION
77  
78 This is a shell to be able to use Net::DRI without writing any code.
79  
80 Most of the time commands are the name of methods to use on the Net::DRI object,
81 with some extra ones and some variations in API to make passing parameters simpler.
82  
83 =head1 AVAILABLE COMMANDS
84  
85 After having started this shell, the available commands are the following.
86  
87 =head2 SESSION COMMANDS
88  
89 =head3 add_registry registry=REGISTRYNAME client_id=YOURID
90  
91 Replace REGISTRYNAME with the Net::DRI::DRD module you want to use, and YOURID
92 with your client identification for this registry (may be the same as the login used
93 to connect, or not).
94  
95 =head3 add_current_profile name=profile1 type=epp client_login=YOURLOGIN client_password=YOURPASSWORD
96  
97 This will really connect to the registry, replace YOURLOGIN by your client login at registry,
98 and YOURPASSWORD by the associated password. You may have to add parameters remote_host= and remote_port=
99 to connect to other endpoints than the hardcoded default which is most of the time the registry OT&E server,
100 and not the production one !
101  
102 =head3 add registry=REGISTRYNAME client_id=YOURID name=profile1 type=epp client_login=YOURLOGIN client_password=YOURPASSWORD
103  
104 This is a shortcut, doing the equivalent of add_registry, and then add_current_profile.
105  
106 =head3 get_info_all
107  
108 After each call to the registry, like domain_info or domain_check, this will list all available data
109 retrieved from registry. Things are pretty-printed as much as possible. You should call get_info_all
110 right after your domain_something call otherwise if you do another operation previous information
111 is lost. This is done automatically for you on the relevant commands, but you can also use it
112 manually at any time.
113  
114 =head3 show profiles
115  
116 Show the list of registries and associated profiles currently in use (opened in this shell with
117 add_registry + add_current_profile, or add).
118  
119 =head3 show tlds
120  
121 Show the list of TLDs handled by the currently selected registry.
122  
123 =head3 show periods
124  
125 Show the list of allowed periods (domain name durations) for the currently selected registry.
126  
127 =head3 show objects
128  
129 Show the list of managed objects types at the currently selected registry.
130  
131 =head3 show types
132  
133 Show the list of profile types at the currently selected registry
134  
135 =head3 show status
136  
137 Show the list of available status for the currently selected registry, to use
138 as status name in some commands below (domain_update_status_* domain_update
139 host_update_status_* host_update contact_update_status_* contact_update).
140  
141 =head3 show config
142  
143 This will show all current config options. See C<set> command below for the list of config options.
144  
145 =head3 set OPTION=VALUE
146  
147 The set command can be used to change some options inside the shell.
148  
149 The current list of available options is:
150  
151 =head4 verbose
152  
153 Set this option to 1 if you want a dump of all data retrieved from registry automatically after each operation, including failed ones, and including
154 all displaying raw data exchanged with registry.
155  
156 =head3 target REGISTRYNAME PROFILENAME
157  
158 Switch to registry REGISTRYNAME (from currently available registries) and profile PROFILENAME (from currently available
159 profiles in registry REGISTRYNAME).
160  
161 =head3 run FILENAME
162  
163 Will open the local FILENAME and read in it commands and execute all of them; you can also
164 start your shell with a filename as argument and its commands will be run at beginning of
165 session before giving the control back. They will be displayed (username and password will be
166 masked) with their results.
167 FILENAME content must be UTF-8 encoded.
168  
169 =head3 record FILENAME
170  
171 If called with a filename argument, all subsequent commands, and their results will be printed in the filename given, in UTF-8 encoding.
172 If called without argument, it stops a current recording session.
173  
174 =head3 !cmd
175  
176 All command line starting with a bang (!) will be treated as local commands to run through the local underlying OS shell.
177  
178 Example: !ls -l
179 will display the content of the current directory.
180  
181 =head3 help
182  
183 Returns a succinct list of available commands.
184  
185 =head3 quit
186  
187 Leave the shell.
188  
189 =head2 DOMAIN COMMANDS
190  
191 =head3 domain_create DOMAIN [duration=X] [ns=HOSTNAMEA IPA1 IPA2 ... HOSTNAMEB IPB1 IPB2 ...] [admin=SRID1] [registrant=SRID2] [billing=SRID3] [tech=SRID4] [auth=X]
192  
193 Create the given domain name. See above for the duration format to use. Admin, registrant, billing and tech
194 contact ids are mandatory or optional depending on the registry. They may be repeated (except registrant)
195 for registries allowing multiple contacts per role.
196  
197 =head3 domain_info DOMAIN
198  
199 Do a domain_info call to the registry for the domain YOURDOMAIN ; most of the the registries
200 prohibit getting information on domain names you do not sponsor.
201  
202 =head3 domain_check DOMAIN
203  
204 Do a domain_check call to the registry for the domain ANYDOMAIN ; you can check any domain,
205 existing or not, if you are the sponsoring registrar or not.
206  
207 =head3 domain_exist DOMAIN
208  
209 A kind of simpler domain_check, just reply by YES or NO for the given domain name.
210  
211 =head3 domain_transfer_start DOMAIN auth=AUTHCODE [duration=PERIOD]
212  
213 =head3 domain_transfer_stop DOMAIN [auth=AUTHCODE]
214  
215 =head3 domain_transfer_query DOMAIN [auth=AUTHCODE]
216  
217 =head3 domain_transfer_accept DOMAIN [auth=AUTHCODE]
218  
219 =head3 domain_transfer_refuse DOMAIN [auth=AUTHCODE]
220  
221 Start, or stop an incoming transfer, query status of a current running transfer, accept or refuse an outgoing domain name transfer.
222  
223 The AUTHCODE is mandatory or optional, depending on the registry.
224  
225 The duration is optional and can be specified (the allowed values depend on the registry) as Ayears or Bmonths
226 where A and B are integers for the number of years or months (this can be abbreviated as Ay or Bm).
227  
228 =head3 domain_update_ns_set DOMAIN HOSTNAMEA IPA1 IPA2 ... HOSTNAMEB IPB1 IPB2 ...
229  
230 =head3 domain_update_ns_add DOMAIN HOSTNAMEA IPA1 IPA2 ... HOSTNAMEB IPB1 IPB2 ...
231  
232 =head3 domain_update_ns_del DOMAIN HOSTNAMEA IPA1 IPA2 ... HOSTNAMEB IPB1 IPB2 ...
233  
234 Set the current list of nameservers associated to this DOMAIN, add to the current list or delete from the current list.
235  
236 =head3 domain_update_status_set DOMAIN STATUS1 STATUS2 ...
237  
238 =head3 domain_update_status_add DOMAIN STATUS1 STATUS2 ...
239  
240 =head3 domain_update_status_del DOMAIN STATUS1 STATUS2 ...
241  
242 Set the current list of status associated to this DOMAIN, add to the current
243 list or delete from the current list. First parameter is the domain name, then status names,
244 as needed.
245  
246 The status names are those in the list given back by the show status command (see above).
247  
248 =head3 domain_update_contact_set DOMAIN SRVID1 SRVID2 ...
249  
250 =head3 domain_update_contact_add DOMAIN SRVID2 SRVID2 ...
251  
252 =head3 domain_update_contact_del DOMAIN SRVID1 SRVID2 ...
253  
254 Set the current list of contacts associated to this DOMAIN, add to the current list or delete from the current list
255 by providing the contact server ids.
256  
257 =head3 domain_update DOMAIN +status=S1 -status=S2 +admin=C1 -tech=C2 -billing=C3 registrant=C4 auth=A +ns=... -ns=...
258  
259 Combination of the previous methods, plus ability to change authInfo and other parameters depending on registry.
260  
261 =head3 domain_renew DOMAIN [duration=X] [current_expiration=YYYY-MM-DD]
262  
263 Renew the given domain name. Duration and current expiration are optional. See above for the duration format to use.
264  
265 =head3 domain_delete DOMAIN
266  
267 Delete the given domain name.
268  
269  
270 =head2 HOST COMMANDS
271  
272 For registries handling nameservers as separate objects.
273  
274 =head3 host_create HOSTNAME IP1 IP2 ...
275  
276 Create the host named HOSTNAME at the registry with the list of IP (IPv4 and IPv6
277 depending on registry support) given.
278  
279 =head3 host_delete HOSTNAME
280  
281 =head3 host_info HOSTNAME
282  
283 =head3 host_check HOSTNAME
284  
285 Various operations on host objects.
286  
287 =head3 host_update_ip_set HOSTNAME IP1 IP2 ...
288  
289 =head3 host_update_ip_add HOSTNAME IP1 IP2 ...
290  
291 =head3 host_update_ip_del HOSTNAME IP1 IP2 ...
292  
293 Set the current list of IP addresses associated to this HOSTNAME, add to the current
294 list or delete from the current list. First parameter is the nameserver hostname, then IP addresses,
295 as needed.
296  
297 =head3 host_update_status_set HOSTNAME STATUS1 STATUS2 ...
298  
299 =head3 host_update_status_add HOSTNAME STATUS1 STATUS2 ...
300  
301 =head3 host_update_status_del HOSTNAME STATUS1 STATUS2 ...
302  
303 Set the current list of status associated to this HOSTNAME, add to the current
304 list or delete from the current list. First parameter is the nameserver hostname, then status names,
305 as needed.
306  
307 The status names are those in the list given back by the show status command (see above).
308  
309 =head3 host_update HOSTNAME +ip=IP1 +ip=IP2 -ip=IP3 +status=STATUS1 -status=STATUS2 name=NEWNAME
310  
311 Combines the previous operations.
312  
313 =head3 host_update_name_set HOSTNAME NEWNAME
314  
315 Change the current name of host objects from HOSTNAME to NEWNAME.
316  
317  
318 =head2 CONTACT COMMANDS
319  
320 For registries handling contacts as separate objects.
321  
322 =head3 contact_create name=X org=Y street=Z1 street=Z2 email=A voice=B ...
323  
324 Create a new contact object.
325  
326 The list of mandatory attributes depend on the registry. Some attributes (like street) may appear multiple times.
327  
328 Some registry allow setting an ID (using srid=yourchoice), others create the ID, in which case you need
329 to do a get_info_all after contact_create to retrieve the given server ID.
330  
331 =head3 contact_delete SRID
332  
333 =head3 contact_info SRID
334  
335 =head3 contact_check SRID
336  
337 Various operations on contacts.
338  
339 =head3 contact_update_status_set SRID STATUS1 STATUS2 ...
340  
341 =head3 contact_update_status_add SRID STATUS1 STATUS2 ...
342  
343 =head3 contact_update_status_del SRID STATUS1 STATUS2 ...
344  
345 Set the current list of status associated to this contact SRID, add to the current
346 list or delete from the current list. First parameter is the contact server ID, then status names,
347 as needed.
348  
349 The status names are those in the list given back by the show status command (see above).
350  
351 =head3 contact_update SRID name=X org=Y ... +status=... -status=...
352  
353 Change some contacts attributes, as well as statuses.
354  
355 =head3 contact_transfer_start SRID
356  
357 =head3 contact_transfer_stop SRID
358  
359 =head3 contact_transfer_query SRID
360  
361 =head3 contact_transfer_accept SRID
362  
363 =head3 contact_transfer_refuse SRID
364  
365 Start, or stop an incoming transfer, query status of a current running transfer, accept or refuse an outgoing contact transfer.
366  
367  
368 =head2 MESSAGE COMMANDS
369  
370 For registries handling messages, like EPP poll features.
371  
372 =head3 message_retrieve [ID]
373  
374 Retrieve a message waiting at registry.
375  
376 =head3 message_delete [ID]
377  
378 Delete a message waiting at registry.
379  
380 =head3 message_waiting
381  
382 Notifies if messages are waiting at registry.
383  
384 =head3 message_count
385  
386 Get the numbers of messages waiting at the registry.
387  
388 =head1 COMPLETION
389  
390 If Term::Readline::Gnu or Term::Readline::Perl are installed, it will be automatically used by this shell
391 to provide standard shell autocompletion for commands and parameters.
392  
393 All commands described above will be available through autocompletion. As you use them,
394 all parameters (domain names, contacts, hostnames, local files) will also be stored
395 and provided to later autocompletion calls (with the [TAB] key).
396  
397 It will also autocomplete registry= and type= parameters during add/add_registry, from
398 a basic default set of values: registry= values are taken from a basic Net::DRI install
399 without taking into account any private DRD module, and type= values are a default set,
400 not checked against registry= value.
401 Same for target calls, where registry and/or profile name will be autocompleted as possible.
402  
403 It will even autocomplete TLD on domain names for your current registry after your typed
404 the first label and a dot (and eventually some other characters), during any domain name operation.
405 Same for durations and status values.
406  
407 Contacts and nameservers will also be autocompleted when used in any domain_* operation.
408  
409 Contacts attributes will be autocompleted during contact_create based on the current registry & profile.
410  
411 Information retrieved with domain_info calls will also be used in later autocompletion tries,
412 regarding contact ids and hostnames. During a contact creation, the registry returned contact id
413 is also added for later autocompletion tries.
414  
415 For autocompletion, contacts are specific to each registry. Hostnames are common to all registries,
416 as are domain names, but domain names are checked against the available TLDs of the current registry when used
417 for autocompletion.
418  
419 =head1 LOGGING
420  
421 By default, all operations will have some logging information done in files stored in
422 the working directory. There will be a core.log file for all operations and then one
423 file per tuple (registry,profile).
424  
425 =head1 BATCH OPERATIONS
426  
427 Batch operations are available for some domain name commands: domain_create,
428 domain_delete, domain_renew, domain_check, domain_info, domain_transfer and
429 all domain_update commands. It can be used on a list of domain names for which
430 all other parameters needed by the command are the same.
431  
432 To do that, just use the command normally as outlined above, but instead of the
433 domain name, put a file path, with at least one / (so for a file "batch.txt" in the
434 current directory, use "./batch.txt").
435  
436 If you use backticks such as `command` for the domain name, the command will
437 be started locally and its output will be used just like a file.
438  
439 The shell will then apply the command and its parameters on the domain names
440 listed in the specified file: you should have one domain name per line, blank
441 lines and lines starting with # are ignored.
442  
443 At the same place a new file is created with a name derived from the given name
444 in which the result of each domain name command will be written. If "input" is
445 the filename used, the results will be written to "input.PID.TIME.results"
446 where PID is the program id of the running shell for these commands and TIME the
447 Unix epoch when the batch started.
448  
449 As output the shell will give a summary of the number of operations done
450 for each possible outcome (success or error), as well as time statistics.
451  
452 =head1 SUPPORT
453  
454 For now, support questions should be sent to:
455  
456 E<lt>netdri@dotandco.comE<gt>
457  
458 Please also see the SUPPORT file in the distribution.
459  
460 =head1 SEE ALSO
461  
462 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
463  
464 =head1 AUTHOR
465  
466 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
467  
468 =head1 COPYRIGHT
469  
470 Copyright (c) 2008-2014,2016-2017 Patrick Mevzek <netdri@dotandco.com>.
471 All rights reserved.
472  
473 This program is free software; you can redistribute it and/or modify
474 it under the terms of the GNU General Public License as published by
475 the Free Software Foundation; either version 2 of the License, or
476 (at your option) any later version.
477  
478 See the LICENSE file that comes with this distribution for more details.
479  
480 =cut
481  
482 ####################################################################################################
483  
484 sub run
485 0 ▶{
Subroutine run: not called CC=13 SCAR=52.0
Pod documented
486 0 my (@args)=@_;
487 0 binmode(STDIN, ':encoding(UTF-8)');
488 0 binmode(STDOUT, ':encoding(UTF-8)');
489 0 my $term=Term::ReadLine->new('Net::DRI shell', \*STDIN, \*STDOUT);
490 0 $term->MinLine(undef); # disable implicit add_history call()
491 0 ▶ my $ctx={ term => $term,
Condition0%0/2
$term->OUT || \*STDOUT
l!l
00
MC/DC0%0/1
$term->OUT || \*STDOUT
$term->OUT
Truth table0%0/2
A
A= $term->OUT
Aresult
11
00
492 term_features => $term->Features(),
493 term_attribs => $term->Attribs(),
494 dprompt => 'NetDRI',
495 output => $term->OUT() || \*STDOUT,
496 record_filename => undef,
497 record_filehandle => undef,
498 config => { verbose => 0 },
499 completion => { domains => {}, contacts => {}, hosts => {}, files => {} },
500 };
501 0 ▶ if (exists $ctx->{term_features}->{ornaments}) { $term->ornaments(1); }
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ctx->{"term_features"}{"ornaments"}) 0 0 0
502 0 ▶ $ctx->{term_attribs}->{completion_function}=sub { return complete($ctx,@_); };
Subroutine __ANON__: not called CC=1 SCAR=6.9
503 0 $ctx->{prompt}=$ctx->{dprompt};
504  
505 0 output($ctx,"Welcome to Net::DRI ${Net::DRI::VERSION} shell, pid $$\n");
506  
507 0 $ctx->{dri}=Net::DRI->new({cache_ttl => 10,logging=>['files',{level => 'info',sanitize_data => {session_password => 0}}]});
508 0 output($ctx,"Net::DRI object created with a cache TTL of 10 seconds and logging into files in current directory\n\n");
509  
510 0 ▶ if (exists $ctx->{term_features}->{readHistory} && defined $HISTORY)
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ctx->{"term_features"}{"readHistory"} and defined $Net::DRI::Shell::HISTORY) 0 0 0
Condition0%0/3
exists $ctx->{"term_features"}{"readHistory"} and defined $Net::DRI::Shell::HISTORY
!ll&&!rl&&r
000
MC/DC0%0/2
exists $ctx->{"term_features"}{"readHistory"} and defined $Net::DRI::Shell::HISTORY
exists $ctx->{"term_features"}{"readHistory"} defined $Net::DRI::Shell::HISTORY
Truth table0%0/3
A and B
A= exists $ctx->{"term_features"}{"readHistory"}B= defined $Net::DRI::Shell::HISTORY
ABresult
0X0
100
111
511 {
512 0 $term->ReadHistory($HISTORY);
513 }
514  
515 0 $ctx->{file_quit}=0;
516 0 ▶ shift(@args) if (@args && $args[0] eq 'Net::DRI::Shell');
Branch: 1 branch
BranchTrueFalseTotal
if @args and $args[0] eq "Net::DRI::Shell" 0 0 0
Condition0%0/3
@args and $args[0] eq "Net::DRI::Shell"
!ll&&!rl&&r
000
MC/DC0%0/2
@args and $args[0] eq "Net::DRI::Shell"
@args $args[0] eq "Net::DRI::Shell"
Truth table0%0/3
A and B
A= @argsB= $args[0] eq "Net::DRI::Shell"
ABresult
0X0
100
111
517 0 ▶ handle_line($ctx,'run '.$args[0]) if (@args);
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 0 0
518  
519 0 ▶ unless ($ctx->{file_quit})
Branch: 1 branch
BranchTrueFalseTotal
unless ($ctx->{"file_quit"}) 0 0 0
520 {
521 0 delete($ctx->{file_quit});
522 0 ▶ while (defined(my $l=$ctx->{term}->readline($ctx->{prompt}.'> ')))
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $l = $ctx->{"term"}->readline($ctx->{"prompt"} . '> '))) 0 0 0
523 {
524 0 ▶ last if handle_line($ctx,$l);
Branch: 1 branch
BranchTrueFalseTotal
if handle_line($ctx, $l) 0 0 0
525 }
526 }
527  
528 0 ▶ if (exists $ctx->{term_features}->{writeHistory} && defined $HISTORY)
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ctx->{"term_features"}{"writeHistory"} and defined $Net::DRI::Shell::HISTORY) 0 0 0
Condition0%0/3
exists $ctx->{"term_features"}{"writeHistory"} and defined $Net::DRI::Shell::HISTORY
!ll&&!rl&&r
000
MC/DC0%0/2
exists $ctx->{"term_features"}{"writeHistory"} and defined $Net::DRI::Shell::HISTORY
exists $ctx->{"term_features"}{"writeHistory"} defined $Net::DRI::Shell::HISTORY
Truth table0%0/3
A and B
A= exists $ctx->{"term_features"}{"writeHistory"}B= defined $Net::DRI::Shell::HISTORY
ABresult
0X0
100
111
529 {
530 0 $term->WriteHistory($HISTORY);
531 }
532  
533 0 $ctx->{dri}->end();
534 0 return 0; ## TODO : should reflect true result of last command ?
535 }
536  
537 sub output
538 0 ▶{
Subroutine output: not called CC=1 SCAR=6.9
Pod undocumented
539 0 my (@args)=@_;
540 0 my $ctx=shift;
541 0 print { $ctx->{output} } @args;
542 0 output_record($ctx,@args);
543 0 return;
544 }
545  
546 sub output_record
547 0 ▶{
Subroutine output_record: not called CC=6 SCAR=37.4
Pod undocumented
548 0 my ($ctx,@args)=@_;
549 0 ▶ return unless defined($ctx->{record_filehandle});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ctx->{"record_filehandle"} 0 0 0
550 0 ▶ return if (@args==1 && ($args[0] eq '.' || $args[0] eq "\n"));
Branch: 1 branch
BranchTrueFalseTotal
if @args == 1 and $args[0] eq "." || $args[0] eq "\n" 0 0 0
Condition0%0/6
@args == 1 and $args[0] eq "." || $args[0] eq "\n"
!ll&&!rl&&r
000
$args[0] eq "." or $args[0] eq "\n"
l!l&&r!l&&!r
000
MC/DC0%0/3
@args == 1 and $args[0] eq "." || $args[0] eq "\n"
@args == 1 $args[0] eq "." $args[0] eq "\n"
Truth table0%0/4
A and B or C
A= @args == 1B= $args[0] eq "."C= $args[0] eq "\n"
ABCresult
0XX0
1000
11X1
1011
551 0 my $l=$ctx->{last_line};
552 0 ▶ print { $ctx->{record_filehandle} } scalar(localtime(time)),"\n\n",(defined($l)? ($l,"\n\n") : ('')),@args,"\n\n";
Branch: 1 branch
BranchTrueFalseTotal
defined $l ? : 0 0 0
553 0 $ctx->{last_line}=undef;
554 0 return;
555 }
556  
557 sub handle_file
558 0 ▶{
Subroutine handle_file: not called CC=7 SCAR=40.3
Pod undocumented
559 0 my ($ctx,$file)=@_;
560 0 output($ctx,'Executing commands from file '.$file." :\n");
561 0 $ctx->{completion}->{files}->{$file}=time();
562 0 ▶ open(my $ch,'<:encoding(UTF-8)',$file) or die "Unable to open $file : $!"; ## no critic (InputOutput::RequireBriefOpen)
Branch: 1 branch
BranchTrueFalseTotal
open my $ch, "<:encoding(UTF-8)", $file or die "Unable to open $file : $!" 0 0 0
563 0 ▶ while(defined(my $l=<$ch>))
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $l = readline $ch)) 0 0 0
564 {
565 0 chomp($l);
566 0 ▶ next if ($l=~m/^\s*$/ || $l=~m/^#/);
Branch: 1 branch
BranchTrueFalseTotal
if $l =~ /^\s*$/ or $l =~ /^#/ 0 0 0
Condition0%0/3
$l =~ /^\s*$/ or $l =~ /^#/
l!l&&r!l&&!r
000
MC/DC0%0/2
$l =~ /^\s*$/ or $l =~ /^#/
$l =~ /^\s*$/ $l =~ /^#/
Truth table0%0/3
A or B
A= $l =~ /^\s*$/B= $l =~ /^#/
ABresult
1X1
011
000
567 0 my $pl=$l;
568 0 $pl=~s/(client_id|client_login|client_password)=\S+/$1=********/g;
569 0 output($ctx,$pl."\n");
570 0 ▶ if (handle_line($ctx,$l))
Branch: 1 branch
BranchTrueFalseTotal
if (handle_line($ctx, $l)) 0 0 0
571 {
572 0 $ctx->{file_quit}=1;
573 0 last;
574 }
575 }
576 0 ▶ close($ch) or die $!;
Branch: 1 branch
BranchTrueFalseTotal
close $ch or die $! 0 0 0
577 0 return;
578 }
579  
580 sub handle_line
581 0 ▶{
Subroutine handle_line: not called CC=19 SCAR=59.4
Pod undocumented
582 0 my ($ctx,$l)=@_;
583 0 ▶ return 0 if ($l=~m/^\s*$/);
Branch: 1 branch
BranchTrueFalseTotal
if $l =~ /^\s*$/ 0 0 0
584  
585 0 $l=~s/^\s*//;
586 0 $l=~s/\s*$//;
587  
588 0 ▶ return 1 if ($l eq 'quit' || $l eq 'q' || $l eq 'exit');
Branch: 1 branch
BranchTrueFalseTotal
if $l eq "quit" or $l eq "q" or $l eq "exit" 0 0 0
Condition0%0/6
$l eq "quit" or $l eq "q" or $l eq "exit"
l!l&&r!l&&!r
000
$l eq "quit" or $l eq "q"
l!l&&r!l&&!r
000
MC/DC0%0/3
$l eq "quit" or $l eq "q" or $l eq "exit"
$l eq "quit" $l eq "q" $l eq "exit"
Truth table0%0/4
A or B or C
A= $l eq "quit"B= $l eq "q"C= $l eq "exit"
ABCresult
1XX1
01X1
0011
0000
589  
590 0 my ($rc,$msg);
591  
592 my $ok=eval
593 0 {
594 0 ($rc,$msg)=process($ctx,$l);
595 0 ▶ $msg.="\n".dump_info($ctx,scalar $rc->get_data_collection()) if (defined($rc) && (($l=~m/^(?:(?:domain|contact|host)_?(?:check|info|create)|domain_renew) / && (!defined($msg) || index($msg,'on average')==-1) && $rc->is_success()) || $ctx->{config}->{verbose}==1));
Branch: 1 branch
BranchTrueFalseTotal
if defined $rc and $l =~ /^(?:(?:domain|contact|host)_?(?:check|info|create)|domain_renew) / && (!defined($msg) || index($msg, "on average") == -1) && $rc->is_success || $ctx->{"config"}{"verbose"} == 1 0 0 0
Condition0%0/15
defined $rc and $l =~ /^(?:(?:domain|contact|host)_?(?:check|info|create)|domain_renew) / && (!defined($msg) || index($msg, "on average") == -1) && $rc->is_success || $ctx->{"config"}{"verbose"} == 1
!ll&&!rl&&r
000
$l =~ /^(?:(?:domain|contact|host)_?(?:check|info|create)|domain_renew) / and !defined($msg) || index($msg, "on average") == -1 and $rc->is_success or $ctx->{"config"}{"verbose"} == 1
l!l&&r!l&&!r
000
$l =~ /^(?:(?:domain|contact|host)_?(?:check|info|create)|domain_renew) / and !defined($msg) || index($msg, "on average") == -1 and $rc->is_success
!ll&&!rl&&r
000
$l =~ /^(?:(?:domain|contact|host)_?(?:check|info|create)|domain_renew) / and !defined($msg) || index($msg, "on average") == -1
!ll&&!rl&&r
000
not defined $msg or index($msg, "on average") == -1
l!l&&r!l&&!r
000
MC/DC0%0/6
defined $rc and $l =~ /^(?:(?:domain|contact|host)_?(?:check|info|create)|domain_renew) / && (!defined($msg) || index($msg, "on average") == -1) && $rc->is_success || $ctx->{"config"}{"verbose"} == 1
defined $rc $l =~ /^(?:(?:domain|contact|host)_?(?:check|info|create)|domain_renew) / not defined $msg index($msg, "on average") == -1 $rc->is_success $ctx->{"config"}{"verbose"} == 1
Truth table0%0/11
A and B and not(C) or D and E or F
A= defined $rcB= $l =~ /^(?:(?:domain|contact|host)_?(?:check|info|create)|domain_renew) /C= not defined $msgD= index($msg, "on average") == -1E= $rc->is_successF= $ctx->{"config"}{"verbose"} == 1
ABCDEFresult
0XXXXX0
10XXX00
1100X00
111X000
1101000
111X1X1
11011X1
10XXX11
1100X11
111X011
1101011
596 0 1;
597 };
598 0 $ctx->{last_line}=$l;
599 0 ▶ if (! $ok)
Branch: 1 branch
BranchTrueFalseTotal
if (not $ok) { } 0 0 0
600 {
601 0 my $err=$@;
602 0 ▶ $err='XML error: '.$err->as_string() if ref $err eq 'XML::LibXML::Error';
Branch: 1 branch
BranchTrueFalseTotal
if ref $err eq "XML::LibXML::Error" 0 0 0
603 0 ▶ output($ctx,"An error happened:\n",ref $err ? $err->msg() : $err,"\n");
Branch: 1 branch
BranchTrueFalseTotal
ref $err ? : 0 0 0
604 } else
605 {
606 0 my @r;
607 0 ▶ if (defined($rc))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $rc) 0 0 0
608 {
609 0 push @r,scalar $rc->as_string(1),"\n";
610 }
611 0 ▶ push @r,$msg if (defined($msg));
Branch: 1 branch
BranchTrueFalseTotal
if defined $msg 0 0 0
612 0 ▶ if (defined($rc) && $rc->is_closing() && $ctx->{dri}->transport()->has_state())
Branch: 1 branch
BranchTrueFalseTotal
if (defined $rc and $rc->is_closing and $ctx->{"dri"}->transport->has_state) 0 0 0
Condition0%0/6
defined $rc and $rc->is_closing and $ctx->{"dri"}->transport->has_state
!ll&&!rl&&r
000
defined $rc and $rc->is_closing
!ll&&!rl&&r
000
MC/DC0%0/3
defined $rc and $rc->is_closing and $ctx->{"dri"}->transport->has_state
defined $rc $rc->is_closing $ctx->{"dri"}->transport->has_state
Truth table0%0/4
A and B and C
A= defined $rcB= $rc->is_closingC= $ctx->{"dri"}->transport->has_state
ABCresult
0XX0
10X0
1100
1111
613 {
614 0 $ctx->{dri}->transport()->current_state(0);
615 0 push @r,'Server connection closed, will try to reconnect during next command.'; ## TODO : this is triggered also for type=das, but shouldn't !
616 }
617 0 output($ctx,@r,"\n");
618 }
619  
620 0 $ctx->{term}->addhistory($l);
621 0 $ctx->{last_line}=undef;
622 0 return 0;
623 }
624  
625 sub complete
626 0 ▶{
Subroutine complete: not called CC=76 SCAR=86.7
Pod undocumented
627 0 my ($ctx,$text,$line,$start)=@_; ## $text is last space separated word, $line the whole line, $start the position of the cursor in the line
628  
629 ## Command completion
630 0 ▶ if ($start==0) ## command completion
Branch: 1 branch
BranchTrueFalseTotal
if ($start == 0) 0 0 0
631 {
632 0 my @r=sort { $a cmp $b } grep { /^$text/ } qw/quit exit help run record message_retrieve message_delete domain_create domain_renew domain_delete domain_check domain_info domain_transfer_start domain_transfer_stop domain_transfer_query domain_transfer_accept domain_transfer_refuse domain_update_ns_set domain_update_ns_add domain_update_ns_del domain_update_status_set domain_update_status_add domain_update_status_del domain_update_contact_set domain_update_contact_add domain_update_contact_del domain_update host_create host_delete host_info host_check host_update_ip_set host_update_ip_add host_update_ip_del host_update_status_set host_update_status_add host_update_status_del host_update_name_set host_update contact_create contact_info contact_check contact_delete contact_update contact_update_status_set contact_update_status_add contact_update_status_del contact_transfer_start contact_transfer_stop contact_transfer_query contact_transfer_accept contact_transfer_refuse set add add_registry target add_current_profile add_profile show get_info get_info_all message_waiting message_count domain_exist/;
633 0 return @r;
634 }
635  
636 ## Parameter completion
637 0 my ($cmd)=($line=~m/^(\S+)\s/);
638 0 ▶ if ($cmd eq 'show') { my @r=sort { $a cmp $b } grep { /^$text/ } qw/profiles tlds periods objects types status config/; return @r; }
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "show") 0 0 0
639 0 ▶ if ($cmd eq 'set') { return map { $_.'=' } sort { $a cmp $b } grep { /^$text/ } keys(%{$ctx->{config}}); }
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "set") 0 0 0
640 0 ▶ if ($cmd eq 'run' || $cmd eq 'record') { my @r=sort { $ctx->{completion}->{files}->{$b} <=> $ctx->{completion}->{files}->{$a} || $a cmp $b } grep { /^$text/ } keys(%{$ctx->{completion}->{files}}); return @r; }
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "run" or $cmd eq "record") 0 0 0
Condition0%0/6
$cmd eq "run" or $cmd eq "record"
l!l&&r!l&&!r
000
$ctx->{'completion'}{'files'}{$b} <=> $ctx->{'completion'}{'files'}{$a} || $a cmp $b
l!l&&r!l&&!r
000
MC/DC0%0/2
$cmd eq "run" or $cmd eq "record"
$cmd eq "run" $cmd eq "record"
MC/DC0%0/2
$ctx->{'completion'}{'files'}{$b} <=> $ctx->{'completion'}{'files'}{$a} || $a cmp $b
$ctx->{'completion'}{'files'}{$b} <=> $ctx->{'completion'}{'files'}{$a} $a cmp $b
Truth table0%0/3
A or B
A= $cmd eq "run"B= $cmd eq "record"
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $ctx->{'completion'}{'files'}{$b} <=> $ctx->{'completion'}{'files'}{$a}B= $a cmp $b
ABresult
1X1
011
000
641  
642 0 ▶ if ($cmd eq 'add' || $cmd eq 'add_registry' || $cmd eq 'add_current_profile' || $cmd eq 'add_profile')
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "add" or $cmd eq "add_registry" or $cmd eq "add_current_profile" or $cmd eq "add_profile") 0 0 0
Condition0%0/9
$cmd eq "add" or $cmd eq "add_registry" or $cmd eq "add_current_profile" or $cmd eq "add_profile"
l!l&&r!l&&!r
000
$cmd eq "add" or $cmd eq "add_registry" or $cmd eq "add_current_profile"
l!l&&r!l&&!r
000
$cmd eq "add" or $cmd eq "add_registry"
l!l&&r!l&&!r
000
MC/DC0%0/4
$cmd eq "add" or $cmd eq "add_registry" or $cmd eq "add_current_profile" or $cmd eq "add_profile"
$cmd eq "add" $cmd eq "add_registry" $cmd eq "add_current_profile" $cmd eq "add_profile"
Truth table0%0/5
A or B or C or D
A= $cmd eq "add"B= $cmd eq "add_registry"C= $cmd eq "add_current_profile"D= $cmd eq "add_profile"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
643 {
644 0 ▶ if (substr($line,$start-9,9) eq 'registry=')
Branch: 2 branches
BranchTrueFalseTotal
if (substr($line, $start - 9, 9) eq 'registry=') { } 0 0 0
elsif (substr($line, $start - 5, 5) eq 'type=') { } 0 0 0
645 {
646 0 my ($reg)=($text=~m/registry=(\S*)/);
647 0 ▶ $reg||='';
Condition0%0/2
$reg ||= ""
l!l
00
MC/DC0%0/1
$reg ||= ""
$reg
Truth table0%0/2
A
A= $reg
Aresult
11
00
648 0 my @r=sort { $a cmp $b } grep { /^$reg/ } $ctx->{dri}->installed_registries();
649 0 return @r;
650 } elsif (substr($line,$start-5,5) eq 'type=')
651 {
652 0 my ($type)=($text=~m/type=(\S*)/);
653 0 ▶ $type||='';
Condition0%0/2
$type ||= ""
l!l
00
MC/DC0%0/1
$type ||= ""
$type
Truth table0%0/2
A
A= $type
Aresult
11
00
654 0 ▶ my @r=sort { $a cmp $b } grep { /^$type/ } (defined $ctx->{dri}->registry_name()? $ctx->{dri}->registry()->driver()->profile_types() : qw/epp rrp rri dchk whois das ws/);
Branch: 1 branch
BranchTrueFalseTotal
defined $ctx->{'dri'}->registry_name ? : 0 0 0
655 0 return @r;
656 } else
657 {
658 0 my @p;
659 0 ▶ @p=qw/registry client_id/ if $cmd eq 'add_registry';
Branch: 1 branch
BranchTrueFalseTotal
if $cmd eq "add_registry" 0 0 0
660 0 ▶ @p=qw/type name/ if ($cmd=~m/^add_(?:current_)?profile$/);
Branch: 1 branch
BranchTrueFalseTotal
if $cmd =~ /^add_(?:current_)?profile$/ 0 0 0
661 0 ▶ @p=qw/registry client_id type name/ if $cmd eq 'add';
Branch: 1 branch
BranchTrueFalseTotal
if $cmd eq "add" 0 0 0
662 0 return map { $_.'=' } grep { /^$text/ } @p;
663 }
664 }
665  
666 0 ▶ if ($cmd eq 'target')
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "target") 0 0 0
667 {
668 0 my $regs=$ctx->{dri}->available_registries_profiles(0);
669 0 ▶ if (my ($reg)=($line=~m/^target\s+(\S+)\s+\S*$/))
Branch: 2 branches
BranchTrueFalseTotal
if (my($reg) = $line =~ /^target\s+(\S+)\s+\S*$/) { } 0 0 0
elsif ($line =~ /^target\s+\S*$/) { } 0 0 0
670 {
671 0 ▶ my @r=sort { $a cmp $b } grep { /^$text/ } (exists $regs->{$reg} ? @{$regs->{$reg}} : ());
Branch: 1 branch
BranchTrueFalseTotal
exists $regs->{$reg} ? : 0 0 0
672 0 return @r;
673 } elsif ($line=~m/^target\s+\S*$/)
674 {
675 0 my @r=sort { $a cmp $b } grep { /^$text/ } keys(%$regs);
676 0 return @r;
677 }
678 }
679  
680 0 ▶ if (substr($line,$start-9,9) eq 'duration=')
Branch: 1 branch
BranchTrueFalseTotal
if (substr($line, $start - 9, 9) eq "duration=") 0 0 0
681 {
682 0 ▶ return () unless defined $ctx->{dri}->registry_name();
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ctx->{"dri"}->registry_name 0 0 0
683 0 my ($p)=($text=~m/duration=(\S*)/);
684 0 ▶ $p||='';
Condition0%0/2
$p ||= ""
l!l
00
MC/DC0%0/1
$p ||= ""
$p
Truth table0%0/2
A
A= $p
Aresult
11
00
685 0 my %p;
686 0 foreach my $pd ($ctx->{dri}->registry()->driver()->periods())
687 {
688 0 my $d=$pd->in_units('years');
689 0 ▶ if ($d > 0) { $p{$d.'Y'}=12*$d; next; }
Branch: 1 branch
BranchTrueFalseTotal
if ($d > 0) 0 0 0
690 0 $d=$pd->in_units('months');
691 0 ▶ if ($d > 0) { $p{$d.'M'}=$d; next; }
Branch: 1 branch
BranchTrueFalseTotal
if ($d > 0) 0 0 0
692 }
693 0 my @r=sort { $p{$a} <=> $p{$b} } grep { /^$p/ } keys(%p); ## this is the correct ascending order, but it seems something else upstream is reordering it differently
694 0 return @r;
695 }
696  
697 0 ▶ if ($line=~m/^domain_\S+\s+\S*$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^domain_\S+\s+\S*$/) 0 0 0
698 {
699 0 my @p=sort { $a cmp $b } grep { /^$text/ } keys(%{$ctx->{completion}->{domains}});
700 0 ▶ if (defined $ctx->{dri}->registry())
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ctx->{"dri"}->registry) 0 0 0
701 {
702 0 my @tlds=$ctx->{dri}->registry()->driver()->tlds();
703 0 my $tlds=join('|',map { quotemeta($_) } @tlds);
704 0 @p=grep { /\.(?:$tlds)$/i } @p;
705 0 my $idx=index($text,'.');
706 0 ▶ if ( $idx >= 0 )
Branch: 1 branch
BranchTrueFalseTotal
if ($idx >= 0) 0 0 0
707 {
708 0 my $base=substr($text,0,$idx);
709 0 push @p,map { $base.'.'.$_ } @tlds;
710 }
711 }
712 0 ▶ my @r=sort { ( $ctx->{completion}->{domains}->{$b} || 0) <=> ( $ctx->{completion}->{domains}->{$a} || 0 ) || $a cmp $b } @p;
Condition0%0/7
($ctx->{'completion'}{'domains'}{$b} || 0) <=> ($ctx->{'completion'}{'domains'}{$a} || 0) || $a cmp $b
l!l&&r!l&&!r
000
$ctx->{'completion'}{'domains'}{$b} || 0
l!l
00
$ctx->{'completion'}{'domains'}{$a} || 0
l!l
00
MC/DC0%0/2
($ctx->{'completion'}{'domains'}{$b} || 0) <=> ($ctx->{'completion'}{'domains'}{$a} || 0) || $a cmp $b
$ctx->{'completion'}{'domains'}{$b} $a cmp $b
MC/DC0%0/1
$ctx->{'completion'}{'domains'}{$a} || 0
$ctx->{'completion'}{'domains'}{$a}
Truth table0%0/3
A || B
A= $ctx->{'completion'}{'domains'}{$b}B= $a cmp $b
ABresult
1X1
011
000
Truth table0%0/2
A
A= $ctx->{'completion'}{'domains'}{$a}
Aresult
11
00
713 0 return @r;
714 }
715  
716 0 my @ct=qw/registrant admin tech billing/; ## How to retrieve non core contact types ?
717 0 my $capa;
718 0 ▶ if ($ctx->{dri}->registry_name() && $ctx->{dri}->available_profile() && $ctx->{dri}->protocol())
Branch: 1 branch
BranchTrueFalseTotal
if ($ctx->{"dri"}->registry_name and $ctx->{"dri"}->available_profile and $ctx->{"dri"}->protocol) 0 0 0
Condition0%0/6
$ctx->{"dri"}->registry_name and $ctx->{"dri"}->available_profile and $ctx->{"dri"}->protocol
!ll&&!rl&&r
000
$ctx->{"dri"}->registry_name and $ctx->{"dri"}->available_profile
!ll&&!rl&&r
000
MC/DC0%0/3
$ctx->{"dri"}->registry_name and $ctx->{"dri"}->available_profile and $ctx->{"dri"}->protocol
$ctx->{"dri"}->registry_name $ctx->{"dri"}->available_profile $ctx->{"dri"}->protocol
Truth table0%0/4
A and B and C
A= $ctx->{"dri"}->registry_nameB= $ctx->{"dri"}->available_profileC= $ctx->{"dri"}->protocol
ABCresult
0XX0
10X0
1100
1111
719 {
720 0 ▶ @ct=('registrant',$ctx->{dri}->protocol()->core_contact_types()) if $ctx->{dri}->protocol()->can('core_contact_types');
Branch: 1 branch
BranchTrueFalseTotal
if $ctx->{"dri"}->protocol->can("core_contact_types") 0 0 0
721 0 $capa=$ctx->{dri}->protocol()->capabilities();
722 }
723 0 my $ctre=join('|',@ct);
724  
725 0 ▶ if ($cmd eq 'domain_create') ## If we are here, we are sure the domain name has been completed already, due to previous test block
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "domain_create") 0 0 0
726 {
727 0 ▶ if (substr($line,$start-3,3) eq 'ns=')
Branch: 2 branches
BranchTrueFalseTotal
if (substr($line, $start - 3, 3) eq 'ns=') { } 0 0 0
elsif (grep {substr($line, $start - (1 + length($_)), 1 + length($_)) eq $_ . '=';} @ct) { } 0 0 0
728 {
729 0 my ($ns)=($text=~m/ns=(\S*)/);
730 0 ▶ $ns||='';
Condition0%0/2
$ns ||= ""
l!l
00
MC/DC0%0/1
$ns ||= ""
$ns
Truth table0%0/2
A
A= $ns
Aresult
11
00
731 0 return _complete_hosts($ctx,$ns);
732 0 } elsif (grep { substr($line,$start-(1+length($_)),1+length($_)) eq $_.'=' } @ct)
733 {
734 0 my ($c)=($text=~m/(?:${ctre})=(\S*)/);
735 0 ▶ $c||='';
Condition0%0/2
$c ||= ""
l!l
00
MC/DC0%0/1
$c ||= ""
$c
Truth table0%0/2
A
A= $c
Aresult
11
00
736 0 return _complete_contacts($ctx,$c);
737 } else
738 {
739 0 return map { $_.'=' } grep { /^$text/ } (qw/duration ns auth/,@ct);
740 }
741 }
742  
743 0 ▶ if ($cmd eq 'domain_update') ## see previous comment
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "domain_update") 0 0 0
744 {
745 0 ▶ if (substr($line,$start-4,4)=~m/^[-+]ns=$/)
Branch: 3 branches
BranchTrueFalseTotal
if (substr($line, $start - 4, 4) =~ /^[-+]ns=$/) { } 0 0 0
elsif (grep {substr($line, $start - (1 + length($_)), 1 + length($_)) eq $_ . '=';} @ct) { } 0 0 0
elsif (substr($line, $start - 8, 8) =~ /^[-+]status=$/) { } 0 0 0
746 {
747 0 my ($ns)=($text=~m/ns=(\S*)/);
748 0 ▶ $ns||='';
Condition0%0/2
$ns ||= ""
l!l
00
MC/DC0%0/1
$ns ||= ""
$ns
Truth table0%0/2
A
A= $ns
Aresult
11
00
749 0 return _complete_hosts($ctx,$ns);
750 0 } elsif (grep { substr($line,$start-(1+length($_)),1+length($_)) eq $_.'=' } @ct) #####
751 {
752 0 my ($c)=($text=~m/(?:${ctre})=(\S*)/);
753 0 ▶ $c||='';
Condition0%0/2
$c ||= ""
l!l
00
MC/DC0%0/1
$c ||= ""
$c
Truth table0%0/2
A
A= $c
Aresult
11
00
754 0 return _complete_contacts($ctx,$c);
755 } elsif (substr($line,$start-8,8)=~m/^[-+]status=$/)
756 {
757 0 my $o=$ctx->{dri}->local_object('status');
758 0 ▶ if (! defined $o) { return (); }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $o) 0 0 0
759 0 my ($s)=($text=~m/status=(\S*)/);
760 0 ▶ $s||='';
Condition0%0/2
$s ||= ""
l!l
00
MC/DC0%0/1
$s ||= ""
$s
Truth table0%0/2
A
A= $s
Aresult
11
00
761 0 my @r=sort { $a cmp $b } grep { /^$s/ } map { 'no'.$_ } $o->possible_no();
762 0 return @r;
763 } else
764 {
765 0 $text=~s/\+/[+]/g;
766 0 ▶ return map { $_.'=' } sort { $a cmp $b } grep { /^$text/ } (map { if (/^([+-])contact$/) { map { $1.$_ } @ct } else { $_; } } _complete_capa2list($capa,'domain_update'));
Branch: 1 branch
BranchTrueFalseTotal
if (/^([+-])contact$/) { } 0 0 0
767 }
768 }
769  
770 0 ▶ if ($line=~m/^domain_update_ns_\S+\s+\S+\s+\S*/) { return _complete_hosts($ctx,$text); }
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^domain_update_ns_\S+\s+\S+\s+\S*/) 0 0 0
771  
772 0 ▶ if ($line=~m/^(?:domain|host|contact)_update_status_\S+\s+\S+\s+\S*/)
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^(?:domain|host|contact)_update_status_\S+\s+\S+\s+\S*/) 0 0 0
773 {
774 0 my $o=$ctx->{dri}->local_object('status');
775 0 ▶ if (! defined $o) { return (); }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $o) 0 0 0
776 0 my @r=sort { $a cmp $b } grep { /^$text/ } map { 'no'.$_ } $o->possible_no();
777 0 return @r;
778 }
779  
780 0 ▶ if ($line=~m/^domain_update_contact_\S+\s+\S+\s+\S*/) { return _complete_contacts($ctx,$text); }
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^domain_update_contact_\S+\s+\S+\s+\S*/) 0 0 0
781  
782 0 ▶ if (my ($trans)=($line=~m/^domain_transfer_(\S+)\s+\S+\s+\S*/))
Branch: 1 branch
BranchTrueFalseTotal
if (my($trans) = $line =~ /^domain_transfer_(\S+)\s+\S+\s+\S*/) 0 0 0
783 {
784 0 my @p=qw/auth/;
785 0 ▶ push @p,'duration' if $trans eq 'start';
Branch: 1 branch
BranchTrueFalseTotal
if $trans eq "start" 0 0 0
786 0 return map { $_.'=' } sort { $a cmp $b } grep { /^$text/ } @p;
787 }
788  
789 0 ▶ if ($cmd eq 'contact_create')
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "contact_create") 0 0 0
790 {
791 0 ▶ return () unless (defined $ctx->{dri}->registry_name() && defined $ctx->{dri}->profile());
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ctx->{"dri"}->registry_name and defined $ctx->{"dri"}->profile 0 0 0
Condition0%0/3
defined $ctx->{"dri"}->registry_name and defined $ctx->{"dri"}->profile
!ll&&!rl&&r
000
MC/DC0%0/2
defined $ctx->{"dri"}->registry_name and defined $ctx->{"dri"}->profile
defined $ctx->{"dri"}->registry_name defined $ctx->{"dri"}->profile
Truth table0%0/3
A and B
A= defined $ctx->{"dri"}->registry_nameB= defined $ctx->{"dri"}->profile
ABresult
0X0
100
111
792 0 my $c=$ctx->{dri}->local_object('contact');
793 0 ▶ if (! defined $c) { return (); }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $c) 0 0 0
794 0 return map { $_.'=' } sort { $a cmp $b } grep { /^$text/ } $c->attributes();
795 }
796  
797 0 ▶ if ($line=~m/^contact_\S+\s+\S*$/) { return _complete_contacts($ctx,$text); }
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^contact_\S+\s+\S*$/) 0 0 0
798  
799 0 ▶ if ($cmd eq 'contact_update')
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "contact_update") 0 0 0
800 {
801 0 ▶ return () unless (defined $ctx->{dri}->registry_name() && defined $ctx->{dri}->profile());
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ctx->{"dri"}->registry_name and defined $ctx->{"dri"}->profile 0 0 0
Condition0%0/3
defined $ctx->{"dri"}->registry_name and defined $ctx->{"dri"}->profile
!ll&&!rl&&r
000
MC/DC0%0/2
defined $ctx->{"dri"}->registry_name and defined $ctx->{"dri"}->profile
defined $ctx->{"dri"}->registry_name defined $ctx->{"dri"}->profile
Truth table0%0/3
A and B
A= defined $ctx->{"dri"}->registry_nameB= defined $ctx->{"dri"}->profile
ABresult
0X0
100
111
802 0 my $c=$ctx->{dri}->local_object('contact');
803 0 $text=~s/\+/[+]/g;
804 0 ▶ return map { $_.'=' } sort { $a cmp $b } grep { /^$text/ } (defined $c ? $c->attributes() : (),_complete_capa2list($capa,'contact_update'));
Branch: 1 branch
BranchTrueFalseTotal
defined $c ? : 0 0 0
805 }
806  
807 0 ▶ if ($line=~m/^host_\S+\s+\S*$/) { return _complete_hosts($ctx,$text); }
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^host_\S+\s+\S*$/) 0 0 0
808 0 ▶ if (my ($h)=($line=~m/^host_update_name_set\s+\S+\s+(\S*)$/)) { return _complete_hosts($ctx,$h); }
Branch: 1 branch
BranchTrueFalseTotal
if (my($h) = $line =~ /^host_update_name_set\s+\S+\s+(\S*)$/) 0 0 0
809 0 ▶ if ($cmd eq 'host_update')
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "host_update") 0 0 0
810 {
811 0 ▶ if (substr($line,$start-5,5) eq 'name=')
Branch: 2 branches
BranchTrueFalseTotal
if (substr($line, $start - 5, 5) eq 'name=') { } 0 0 0
elsif (substr($line, $start - 8, 8) =~ /^[-+]status=$/) { } 0 0 0
812 {
813 0 my ($ns)=($text=~m/name=(\S*)/);
814 0 ▶ $ns||='';
Condition0%0/2
$ns ||= ""
l!l
00
MC/DC0%0/1
$ns ||= ""
$ns
Truth table0%0/2
A
A= $ns
Aresult
11
00
815 0 return _complete_hosts($ctx,$ns);
816 } elsif ( substr($line,$start-8,8)=~m/^[-+]status=$/ )
817 {
818 0 my $o=$ctx->{dri}->local_object('status');
819 0 ▶ if (! defined $o) { return (); }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $o) 0 0 0
820 0 my ($s)=($text=~m/status=(\S*)/);
821 0 ▶ $s||='';
Condition0%0/2
$s ||= ""
l!l
00
MC/DC0%0/1
$s ||= ""
$s
Truth table0%0/2
A
A= $s
Aresult
11
00
822 0 my @r=sort { $a cmp $b } grep { /^$s/ } map { 'no'.$_ } $o->possible_no();
823 0 return @r;
824 } else
825 {
826 0 $text=~s/\+/[+]/g;
827 0 return map { $_.'=' } sort { $a cmp $b } grep { /^$text/ } (_complete_capa2list($capa,'host_update'));
828 }
829 }
830  
831 0 return ();
832 }
833  
834 sub _complete_capa2list
835 0 ▶{
Subroutine _complete_capa2list: not called CC=8 SCAR=42.8
836 0 my ($capa,$what)=@_;
837 0 ▶ return () unless (defined $capa && exists($capa->{$what}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $capa and exists $capa->{$what} 0 0 0
Condition0%0/3
defined $capa and exists $capa->{$what}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $capa and exists $capa->{$what}
defined $capa exists $capa->{$what}
Truth table0%0/3
A and B
A= defined $capaB= exists $capa->{$what}
ABresult
0X0
100
111
838 0 my @r;
839 0 ▶ while(my ($k,$ra)=each(%{$capa->{$what}}))
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$$capa{$what};}) 0 0 0
840 {
841 0 foreach my $t (@$ra)
842 {
843 0 ▶ if ($t eq 'add') { push @r,'+'.$k; } elsif ($t eq 'del') { push @r,'-'.$k; } elsif ($t eq 'set') { push @r,$k; }
Branch: 3 branches
BranchTrueFalseTotal
if ($t eq 'add') { } 0 0 0
elsif ($t eq 'del') { } 0 0 0
elsif ($t eq 'set') { } 0 0 0
844 }
845 }
846 0 return @r;
847 }
848  
849 0 ▶sub _complete_hosts { my ($ctx,$text)=@_; my @r=sort { $ctx->{completion}->{hosts}->{$b} <=> $ctx->{completion}->{hosts}->{$a} || $a cmp $b } grep { /^$text/ } keys(%{$ctx->{completion}->{hosts}}); return @r; }
Subroutine _complete_hosts: not called CC=2 SCAR=17.9
Condition0%0/3
$ctx->{'completion'}{'hosts'}{$b} <=> $ctx->{'completion'}{'hosts'}{$a} || $a cmp $b
l!l&&r!l&&!r
000
MC/DC0%0/2
$ctx->{'completion'}{'hosts'}{$b} <=> $ctx->{'completion'}{'hosts'}{$a} || $a cmp $b
$ctx->{'completion'}{'hosts'}{$b} <=> $ctx->{'completion'}{'hosts'}{$a} $a cmp $b
Truth table0%0/3
A || B
A= $ctx->{'completion'}{'hosts'}{$b} <=> $ctx->{'completion'}{'hosts'}{$a}B= $a cmp $b
ABresult
1X1
011
000
850 sub _complete_contacts
851 0 ▶{
Subroutine _complete_contacts: not called CC=4 SCAR=30.0
852 0 my ($ctx,$text)=@_;
853 0 my @c=grep { /^$text/ } keys(%{$ctx->{completion}->{contacts}});
854 0 my $creg=$ctx->{dri}->registry_name();
855 0 ▶ if (defined $creg) { @c=grep { defined $ctx->{completion}->{contacts}->{$_}->[1] && $ctx->{completion}->{contacts}->{$_}->[1] eq $creg } @c; } ## Filtering per registry
Branch: 1 branch
BranchTrueFalseTotal
if (defined $creg) 0 0 0
Condition0%0/3
defined $ctx->{'completion'}{'contacts'}{$_}[1] && $ctx->{'completion'}{'contacts'}{$_}[1] eq $creg
!ll&&!rl&&r
000
MC/DC0%0/2
defined $ctx->{'completion'}{'contacts'}{$_}[1] && $ctx->{'completion'}{'contacts'}{$_}[1] eq $creg
defined $ctx->{'completion'}{'contacts'}{$_}[1] $ctx->{'completion'}{'contacts'}{$_}[1] eq $creg
Truth table0%0/3
A && B
A= defined $ctx->{'completion'}{'contacts'}{$_}[1]B= $ctx->{'completion'}{'contacts'}{$_}[1] eq $creg
ABresult
0X0
100
111
856 0 ▶ my @r=sort { $ctx->{completion}->{contacts}->{$b}->[0] <=> $ctx->{completion}->{contacts}->{$a}->[0] || $a cmp $b } @c;
Condition0%0/3
$ctx->{'completion'}{'contacts'}{$b}[0] <=> $ctx->{'completion'}{'contacts'}{$a}[0] || $a cmp $b
l!l&&r!l&&!r
000
MC/DC0%0/2
$ctx->{'completion'}{'contacts'}{$b}[0] <=> $ctx->{'completion'}{'contacts'}{$a}[0] || $a cmp $b
$ctx->{'completion'}{'contacts'}{$b}[0] <=> $ctx->{'completion'}{'contacts'}{$a}[0] $a cmp $b
Truth table0%0/3
A || B
A= $ctx->{'completion'}{'contacts'}{$b}[0] <=> $ctx->{'completion'}{'contacts'}{$a}[0]B= $a cmp $b
ABresult
1X1
011
000
857 0 return @r;
858 }
859  
860 ## Trying to be smart with some values
861 sub _unserialize
862 0 ▶{
Subroutine _unserialize: not called CC=2 SCAR=17.9
863 0 my ($v)=@_;
864 0 ▶ if ($v=~m/^P(\d+)(Y|M)$/) ##hum, this looks like a duration…
Branch: 1 branch
BranchTrueFalseTotal
if ($v =~ /^P(\d+)(Y|M)$/) 0 0 0
865 {
866 0 state $rexpand = { qw/Y years M months/ };
867 0 $v=DateTime::Duration->new($rexpand->{$2} => $1);
868 }
869 0 return $v;
870 }
871  
872 sub process
873 0 ▶{
Subroutine process: not called CC=39 SCAR=72.9
Pod undocumented
874 0 my ($ctx,$wl)=@_;
875 0 my ($rc,$m);
876  
877 0 my ($cmd,$params)=split(/\s+/,$wl,2);
878 0 ▶ $params='' unless defined($params);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $params 0 0 0
879 0 my @p=split(/\s+/,$params);
880 0 my %p;
881 0 my @g=($params=~m/\s*([^= ]+)=(\S.*?)(?:\s(?=\s*\S+=)|\s*$)/g);
882 0 ▶ while (@g)
Branch: 1 branch
BranchTrueFalseTotal
if (@g) 0 0 0
883 {
884 0 my $n=shift(@g);
885 0 my $v=_unserialize(shift(@g));
886 0 ▶ if (exists($p{$n}))
Branch: 1 branch
BranchTrueFalseTotal
if (exists $p{$n}) { } 0 0 0
887 {
888 0 ▶ $p{$n}=[$p{$n}] unless (ref($p{$n}) eq 'ARRAY');
Branch: 1 branch
BranchTrueFalseTotal
unless ref $p{$n} eq "ARRAY" 0 0 0
889 0 push @{$p{$n}},$v;
890 } else
891 {
892 0 $p{$n}=$v;
893 }
894 }
895  
896 0 foreach my $k (sort { $a cmp $b } grep { /\./ } keys %p)
897 {
898 0 my ($tk,$sk)=split(/\./,$k,2);
899 0 ▶ $p{$tk}={} unless exists($p{$tk});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $p{$tk} 0 0 0
900 0 $p{$tk}->{$sk}=$p{$k};
901 0 delete($p{$k});
902 }
903  
904 0 ▶ return do_local($ctx,$cmd,\@p,\%p) if ($cmd=~m/^!/);
Branch: 1 branch
BranchTrueFalseTotal
if $cmd =~ /^!/ 0 0 0
905 0 ▶ return help($ctx,$cmd,\@p,\%p) if ($cmd eq 'help');
Branch: 1 branch
BranchTrueFalseTotal
if $cmd eq "help" 0 0 0
906 0 ▶ return handle_file($ctx,$p[0]) if ($cmd eq 'run');
Branch: 1 branch
BranchTrueFalseTotal
if $cmd eq "run" 0 0 0
907 0 ▶ return record($ctx,$p[0]) if ($cmd eq 'record');
Branch: 1 branch
BranchTrueFalseTotal
if $cmd eq "record" 0 0 0
908 0 ▶ return do_dri($ctx,$cmd,\@p,\%p) if ($cmd=~m/^message_(?:retrieve|delete)$/ || $cmd eq 'ping');
Branch: 1 branch
BranchTrueFalseTotal
if $cmd =~ /^message_(?:retrieve|delete)$/ or $cmd eq "ping" 0 0 0
Condition0%0/3
$cmd =~ /^message_(?:retrieve|delete)$/ or $cmd eq "ping"
l!l&&r!l&&!r
000
MC/DC0%0/2
$cmd =~ /^message_(?:retrieve|delete)$/ or $cmd eq "ping"
$cmd =~ /^message_(?:retrieve|delete)$/ $cmd eq "ping"
Truth table0%0/3
A or B
A= $cmd =~ /^message_(?:retrieve|delete)$/B= $cmd eq "ping"
ABresult
1X1
011
000
909 0 ▶ return do_domain($ctx,$cmd,\@p,\%p) if ($cmd=~m/^domain_(?:check)$/);
Branch: 1 branch
BranchTrueFalseTotal
if $cmd =~ /^domain_(?:check)$/ 0 0 0
910 0 ▶ return do_domain_transfer($ctx,$cmd,\@p,\%p) if ($cmd=~m/^domain_transfer_(?:start|stop|query|accept|refuse)$/);
Branch: 1 branch
BranchTrueFalseTotal
if $cmd =~ /^domain_transfer_(?:start|stop|query|accept|refuse)$/ 0 0 0
911 0 ▶ return do_domain_update($ctx,$cmd,\@p,\%p) if ($cmd eq 'domain_update');
Branch: 1 branch
BranchTrueFalseTotal
if $cmd eq "domain_update" 0 0 0
912 0 ▶ return do_domain_update_ns($ctx,$cmd,\@p,\%p) if ($cmd=~m/^domain_update_ns_(?:add|del|set)$/);
Branch: 1 branch
BranchTrueFalseTotal
if $cmd =~ /^domain_update_ns_(?:add|del|set)$/ 0 0 0
913 0 ▶ return do_domain_update_status($ctx,$cmd,\@p,\%p) if ($cmd=~m/^domain_update_status_(?:add|del|set)$/);
Branch: 1 branch
BranchTrueFalseTotal
if $cmd =~ /^domain_update_status_(?:add|del|set)$/ 0 0 0
914 0 ▶ return do_domain_update_contact($ctx,$cmd,\@p,\%p) if ($cmd=~m/^domain_update_contact_(?:add|del|set)$/);
Branch: 1 branch
BranchTrueFalseTotal
if $cmd =~ /^domain_update_contact_(?:add|del|set)$/ 0 0 0
915  
916 0 ▶ if ($cmd eq 'domain_info')
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "domain_info") 0 0 0
917 {
918 0 my @r=do_domain($ctx,$cmd,\@p,\%p);
919 0 ▶ if (defined $r[0] && $r[0]->is_success())
Branch: 1 branch
BranchTrueFalseTotal
if (defined $r[0] and $r[0]->is_success) 0 0 0
Condition0%0/3
defined $r[0] and $r[0]->is_success
!ll&&!rl&&r
000
MC/DC0%0/2
defined $r[0] and $r[0]->is_success
defined $r[0] $r[0]->is_success
Truth table0%0/3
A and B
A= defined $r[0]B= $r[0]->is_success
ABresult
0X0
100
111
920 {
921 0 my $ns=$ctx->{dri}->get_info('ns');
922 0 ▶ if (defined $ns) { foreach my $name ($ns->get_names()) { $ctx->{completion}->{hosts}->{$name}=time(); } }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ns) 0 0 0
923 0 $ns=$ctx->{dri}->get_info('host');
924 0 ▶ if (defined $ns) { foreach my $name ($ns->get_names()) { $ctx->{completion}->{hosts}->{$name}=time(); } }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ns) 0 0 0
925 0 my $cs=$ctx->{dri}->get_info('contact');
926 0 ▶ if (defined $cs)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cs) 0 0 0
927 {
928 0 foreach my $t ($cs->types())
929 {
930 0 foreach my $cc ($cs->get($t)) { $ctx->{completion}->{contacts}->{$cc->srid()}=[time(),$ctx->{dri}->registry_name()]; }
931 }
932 }
933 }
934 0 return @r;
935 }
936  
937 0 ▶ if ($cmd=~m/^host_(?:create|delete|info|check|update|update_(?:ip|status|name)_(?:add|del|set))$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^host_(?:create|delete|info|check|update|update_(?:ip|status|name)_(?:add|del|set))$/) 0 0 0
938 {
939 0 ▶ return (undef,'Registry does not support host objects') unless $ctx->{dri}->has_object('ns');
Branch: 1 branch
BranchTrueFalseTotal
unless $ctx->{"dri"}->has_object("ns") 0 0 0
940 0 return do_host($ctx,$cmd,\@p,\%p);
941 }
942  
943 0 ▶ if ($cmd=~m/^contact_(?:create|delete|info|check|update|update_status_(?:add|del|set)|transfer_(?:start|stop|query|accept|refuse))$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^contact_(?:create|delete|info|check|update|update_status_(?:add|del|set)|transfer_(?:start|stop|query|accept|refuse))$/) 0 0 0
944 {
945 0 ▶ return (undef,'Registry does not support contact objects') unless $ctx->{dri}->has_object('contact');
Branch: 1 branch
BranchTrueFalseTotal
unless $ctx->{"dri"}->has_object("contact") 0 0 0
946 0 my @r=do_contact($ctx,$cmd,\@p,\%p);
947 0 ▶ if ($cmd eq 'contact_create' && defined $r[0] && $r[0]->is_success())
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "contact_create" and defined $r[0] and $r[0]->is_success) 0 0 0
Condition0%0/6
$cmd eq "contact_create" and defined $r[0] and $r[0]->is_success
!ll&&!rl&&r
000
$cmd eq "contact_create" and defined $r[0]
!ll&&!rl&&r
000
MC/DC0%0/3
$cmd eq "contact_create" and defined $r[0] and $r[0]->is_success
$cmd eq "contact_create" defined $r[0] $r[0]->is_success
Truth table0%0/4
A and B and C
A= $cmd eq "contact_create"B= defined $r[0]C= $r[0]->is_success
ABCresult
0XX0
10X0
1100
1111
948 {
949 0 my $id=$ctx->{dri}->get_info('id');
950 0 ▶ if (defined $id) { $ctx->{completion}->{contacts}->{$id}=[time(),$ctx->{dri}->registry_name()]; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $id) 0 0 0
951 }
952 0 return @r;
953 }
954  
955 {
956 0 ▶ no strict 'refs'; ## no critic (ProhibitNoStrict)
Subroutine BEGIN: called CC=1 SCAR=0.2
957 0 my $sub='do_'.$cmd;
958 0 ▶ return $sub->($ctx,$cmd,\@p,\%p) if (exists(&$sub));
Branch: 1 branch
BranchTrueFalseTotal
if exists &$sub 0 0 0
959 }
960  
961 ## Fallback for all domain extension commands
962 0 ▶ return do_domain_extension($ctx,$cmd,\@p,\%p) if ($cmd=~m/^domain_\S+/);
Branch: 1 branch
BranchTrueFalseTotal
if $cmd =~ /^domain_\S+/ 0 0 0
963  
964 0 return (undef,'Unknown command '.$cmd);
965 }
966  
967 sub do_local
968 0 ▶{
Subroutine do_local: not called CC=2 SCAR=17.9
Pod undocumented
969 0 my ($ctx,$cmd,$ra,$rh)=@_;
970 0 $cmd=~s/^!//;
971 0 my $s=$cmd.' '.join(' ',@$ra);
972 0 my $out=qx($s);
973 0 ▶ return (undef,defined($out)? $out : 'Local command failed: '.$!);
Branch: 1 branch
BranchTrueFalseTotal
defined $out ? : 0 0 0
974 }
975  
976 sub help
977 0 ▶{
Subroutine help: not called CC=1 SCAR=6.9
Pod documented
978 0 my ($ctx,$cmd,$ra,$rh)=@_;
979 0 my $m=<<EOF;
980 Available commands (parameters after the first one can be in any order):
981  
982 help
983 add registry=REGISTRYNAME type=TYPE [client_id=YOURLOGIN]
984 add_registry registry=REGISTRYNAME [client_id=YOURLOGIN]
985 add_current_profile name=PROFILENAME type=TYPE client_login=YOURLOGIN client_password=YOURPASSWORD
986 get_info_all
987 show profiles
988 show tlds
989 show periods
990 show objects
991 show status
992 show config
993 set P=X
994 target X Y
995 run FILENAME
996 record FILENAME
997 quit
998 domain_create DOMAIN [duration=X] [ns=HOSTNAMEA IPA1 IPA2 ... HOSTNAMEB IPB1 IPB2 ...] [admin=SRID1] [registrant=SRID2] [billing=SRID3] [tech=SRID4] [auth=X]
999 domain_info DOMAIN
1000 domain_check DOMAIN
1001 domain_exist DOMAIN
1002 domain_transfer_start DOMAIN auth=AUTHCODE [duration=PERIOD]
1003 domain_transfer_stop DOMAIN [auth=AUTHCODE]
1004 domain_transfer_query DOMAIN [auth=AUTHCODE]
1005 domain_transfer_accept DOMAIN [auth=AUTHCODE]
1006 domain_transfer_refuse DOMAIN [auth=AUTHCODE]
1007 domain_update_ns_set DOMAIN HOSTNAMEA IPA1 IPA2 ... HOSTNAMEB IPB1 IPB2 ...
1008 domain_update_ns_add DOMAIN HOSTNAMEA IPA1 IPA2 ... HOSTNAMEB IPB1 IPB2 ...
1009 domain_update_ns_del DOMAIN HOSTNAMEA IPA1 IPA2 ... HOSTNAMEB IPB1 IPB2 ...
1010 domain_update_status_set DOMAIN STATUS1 STATUS2 ...
1011 domain_update_status_add DOMAIN STATUS1 STATUS2 ...
1012 domain_update_status_del DOMAIN STATUS1 STATUS2 ...
1013 domain_update_contact_set DOMAIN SRVID1 SRVID2 ...
1014 domain_update_contact_add DOMAIN SRVID2 SRVID2 ...
1015 domain_update_contact_del DOMAIN SRVID1 SRVID2 ...
1016 domain_update DOMAIN +status=S1 -status=S2 +admin=C1 -tech=C2 -billing=C3 registrant=C4 auth=A +ns=... -ns=...
1017 domain_renew DOMAIN [duration=X] [current_expiration=YYYY-MM-DD]
1018 domain_delete DOMAIN
1019 host_create HOSTNAME IP1 IP2 ...
1020 host_delete HOSTNAME
1021 host_info HOSTNAME
1022 host_check HOSTNAME
1023 host_update_ip_set HOSTNAME IP1 IP2 ...
1024 host_update_ip_add HOSTNAME IP1 IP2 ...
1025 host_update_ip_del HOSTNAME IP1 IP2 ...
1026 host_update_status_set HOSTNAME STATUS1 STATUS2 ...
1027 host_update_status_add HOSTNAME STATUS1 STATUS2 ...
1028 host_update_status_del HOSTNAME STATUS1 STATUS2 ...
1029 host_update_name_set HOSTNAME NEWNAME
1030 host_update HOSTNAME +ip=IP1 +ip=IP2 -ip=IP3 +status=STATUS1 -status=STATUS2 name=NEWNAME ...
1031 contact_create name=X org=Y street=Z1 street=Z2 email=A voice=B ...
1032 contact_delete SRID
1033 contact_info SRID
1034 contact_check SRID
1035 contact_update_status_set SRID STATUS1 STATUS2 ...
1036 contact_update_status_add SRID STATUS1 STATUS2 ...
1037 contact_update_status_del SRID STATUS1 STATUS2 ...
1038 contact_update SRID name=X org=Y ... +status=... -status=...
1039 contact_transfer_start SRID
1040 contact_transfer_stop SRID
1041 contact_transfer_query SRID
1042 contact_transfer_accept SRID
1043 contact_transfer_refuse SRID
1044 message_retrieve [ID]
1045 message_delete [ID]
1046 message_waiting
1047 message_count
1048 ping
1049 EOF
1050 0 return (undef,$m);
1051 }
1052  
1053 sub record
1054 0 ▶{
Subroutine record: not called CC=6 SCAR=37.4
Pod documented
1055 0 my ($ctx,$n)=@_;
1056 0 my $m='';
1057  
1058 ## Need to stop the current one in all cases ! (true record stop or a new record start)
1059 0 ▶ if (defined($ctx->{record_filehandle}))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ctx->{"record_filehandle"}) 0 0 0
1060 {
1061 0 close($ctx->{record_filehandle});
1062 0 $ctx->{record_filehandle}=undef;
1063 0 $m='Stopped recording session to '.$ctx->{record_filename}."\n";
1064 }
1065  
1066 0 ▶ if (defined($n) && $n)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $n and $n) 0 0 0
Condition0%0/3
defined $n and $n
!ll&&!rl&&r
000
MC/DC0%0/2
defined $n and $n
defined $n $n
Truth table0%0/3
A and B
A= defined $nB= $n
ABresult
0X0
100
111
1067 {
1068 0 $ctx->{completion}->{files}->{$n}=time();
1069 0 ▶ open(my $fh,'>:encoding(UTF-8)',$n) or return (undef,$m.'Unable to write local file '.$n.' : '.$!); ## no critic (InputOutput::RequireBriefOpen)
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">:encoding(UTF-8)", $n or return undef, $m . 'Unable to write local file ' . $n . ' : ' . $! 0 0 0
1070 0 $fh->autoflush(1); ## this is thanks to IO::Handle
1071 0 $ctx->{record_filehandle}=$fh;
1072 0 $ctx->{record_filename}=$n;
1073 0 $m.='Started recording session to '.$ctx->{record_filename};
1074 }
1075 0 ▶ return (undef,$m? $m : 'Usage: record FILENAME (to start recording session to local FILENAME) or record (to stop current recording)');
Branch: 1 branch
BranchTrueFalseTotal
$m ? : 0 0 0
1076 }
1077  
1078 ## For local options, like verbose
1079 sub do_set
1080 0 ▶{
Subroutine do_set: not called CC=1 SCAR=6.9
Pod undocumented
1081 0 my($ctx,$cmd,$ra,$rh)=@_;
1082 0 $ctx->{config}={ %{$ctx->{config}},%$rh };
1083 0 return;
1084 }
1085  
1086 sub do_add
1087 0 ▶{
Subroutine do_add: not called CC=7 SCAR=40.3
Pod undocumented
1088 0 my($ctx,$cmd,$ra,$rh)=@_;
1089 0 ▶ return (undef,'Usage: add registry=REGISTRYNAME type=PROTOCOLTYPE [client_id=ID] [name=PROFILENAME] [...]') unless (Net::DRI::Util::has_key($rh,'registry') && Net::DRI::Util::has_key($rh,'type'));
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rh, "registry") and Net::DRI::Util::has_key($rh, "type") 0 0 0
Condition0%0/3
Net::DRI::Util::has_key($rh, "registry") and Net::DRI::Util::has_key($rh, "type")
!ll&&!rl&&r
000
MC/DC0%0/2
Net::DRI::Util::has_key($rh, "registry") and Net::DRI::Util::has_key($rh, "type")
Net::DRI::Util::has_key($rh, "registry") Net::DRI::Util::has_key($rh, "type")
Truth table0%0/3
A and B
A= Net::DRI::Util::has_key($rh, "registry")B= Net::DRI::Util::has_key($rh, "type")
ABresult
0X0
100
111
1090 0 my %r=(registry => $rh->{registry}, client_id => $rh->{client_id});
1091 0 my @r=do_add_registry($ctx,'add_registry',$ra,\%r);
1092 0 ▶ if (! defined $r[0] || ! $r[0]->is_success()) { return @r; }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $r[0] and $r[0]->is_success) 0 0 0
Condition0%0/3
defined $r[0] and $r[0]->is_success
!ll&&!rl&&r
000
MC/DC0%0/2
defined $r[0] and $r[0]->is_success
defined $r[0] $r[0]->is_success
Truth table0%0/3
A and B
A= defined $r[0]B= $r[0]->is_success
ABresult
0X0
100
111
1093 0 ▶ unless (exists($rh->{name}) && defined($rh->{name}))
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $rh->{"name"} and defined $rh->{"name"}) 0 0 0
Condition0%0/3
exists $rh->{"name"} and defined $rh->{"name"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $rh->{"name"} and defined $rh->{"name"}
exists $rh->{"name"} defined $rh->{"name"}
Truth table0%0/3
A and B
A= exists $rh->{"name"}B= defined $rh->{"name"}
ABresult
0X0
100
111
1094 {
1095 0 my @p=$ctx->{dri}->available_profiles();
1096 0 $rh->{name}=lc($rh->{registry}).(1+@p);
1097 }
1098 0 delete($rh->{registry});
1099 0 delete($rh->{client_id});
1100 0 return do_add_current_profile($ctx,'add_current_profile',$ra,$rh);
1101 }
1102  
1103 sub do_add_registry
1104 0 ▶{
Subroutine do_add_registry: not called CC=3 SCAR=24.8
Pod undocumented
1105 0 my ($ctx,$cmd,$ra,$rh)=@_;
1106 0 ▶ return (undef,'Usage: add_registry registry=REGISTRYNAME [client_id=ID]') unless Net::DRI::Util::has_key($rh,'registry');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rh, "registry") 0 0 0
1107 0 my $reg=$rh->{registry};
1108 0 delete($rh->{registry});
1109 0 ▶ if (! grep { $reg eq $_ } $ctx->{dri}->available_registries() ) { $ctx->{dri}->add_registry($reg,$rh); }
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {$reg eq $_;} $ctx->{"dri"}->available_registries) 0 0 0
1110 0 $ctx->{dri}->target($reg);
1111 0 $ctx->{prompt}=$ctx->{dprompt}.'('.$reg.')';
1112 0 return (Net::DRI::Protocol::ResultStatus->new_success('Registry "'.$reg.'" added successfully'),undef);
1113 }
1114  
1115 sub do_target
1116 0 ▶{
Subroutine do_target: not called CC=1 SCAR=6.9
Pod undocumented
1117 0 my ($ctx,$cmd,$ra,$rh)=@_;
1118 0 $ctx->{dri}->target(@$ra);
1119 0 $ctx->{prompt}=$ctx->{dprompt}.'('.join(',',@$ra).')';
1120 0 return;
1121 }
1122  
1123 sub do_add_current_profile
1124 0 ▶{
Subroutine do_add_current_profile: not called CC=6 SCAR=37.4
Pod undocumented
1125 0 my ($ctx,$cmd,$ra,$rh)=@_;
1126 0 ▶ return (undef,'Usage: '.$cmd.' name=PROFILENAME type=SERVICENAME [client_login=YOURLOGIN] [client_password=YOURPASSWORD]') unless (Net::DRI::Util::has_key($rh,'name') && Net::DRI::Util::has_key($rh,'type'));
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rh, "name") and Net::DRI::Util::has_key($rh, "type") 0 0 0
Condition0%0/3
Net::DRI::Util::has_key($rh, "name") and Net::DRI::Util::has_key($rh, "type")
!ll&&!rl&&r
000
MC/DC0%0/2
Net::DRI::Util::has_key($rh, "name") and Net::DRI::Util::has_key($rh, "type")
Net::DRI::Util::has_key($rh, "name") Net::DRI::Util::has_key($rh, "type")
Truth table0%0/3
A and B
A= Net::DRI::Util::has_key($rh, "name")B= Net::DRI::Util::has_key($rh, "type")
ABresult
0X0
100
111
1127 0 my $name=$rh->{name};
1128 0 my $type=$rh->{type};
1129 0 ▶ my $rp=defined $rh->{protocol}? $rh->{protocol} : {};
Branch: 1 branch
BranchTrueFalseTotal
defined $rh->{'protocol'} ? : 0 0 0
1130 0 delete(@{$rh}{qw/name type protocol/});
1131 0 my $rc=$ctx->{dri}->$cmd($name,$type,$rh,$rp);
1132 0 ▶ if ($rc->is_success() && $cmd eq 'add_current_profile')
Branch: 1 branch
BranchTrueFalseTotal
if ($rc->is_success and $cmd eq "add_current_profile") 0 0 0
Condition0%0/3
$rc->is_success and $cmd eq "add_current_profile"
!ll&&!rl&&r
000
MC/DC0%0/2
$rc->is_success and $cmd eq "add_current_profile"
$rc->is_success $cmd eq "add_current_profile"
Truth table0%0/3
A and B
A= $rc->is_successB= $cmd eq "add_current_profile"
ABresult
0X0
100
111
1133 {
1134 0 my @t=$ctx->{dri}->registry();
1135 0 $ctx->{prompt}=$ctx->{dprompt}.'('.$t[0].','.$t[1]->profile().')';
1136 }
1137 0 return ($rc,undef);
1138 }
1139  
1140 0 ▶sub do_add_profile { return do_add_current_profile(@_); } ## no critic (Subroutines::RequireArgUnpacking)
Subroutine do_add_profile: not called CC=1 SCAR=6.9
Pod undocumented
1141  
1142 sub do_show
1143 0 ▶{
Subroutine do_show: not called CC=13 SCAR=52.0
Pod undocumented
1144 0 my ($ctx,$cmd,$ra,$rh)=@_;
1145 0 my $m='Usage: show profiles|tlds|periods|objects|types|status|config';
1146 0 ▶ return (undef,$m) unless @$ra;
Branch: 1 branch
BranchTrueFalseTotal
unless @$ra 0 0 0
1147 0 ▶ if ($ra->[0] eq 'profiles')
Branch: 7 branches
BranchTrueFalseTotal
if ($ra->[0] eq 'profiles') { } 0 0 0
elsif ($ra->[0] eq 'tlds') { } 0 0 0
elsif ($ra->[0] eq 'periods' or $ra->[0] eq 'durations') { } 0 0 0
elsif ($ra->[0] eq 'objects') { } 0 0 0
elsif ($ra->[0] eq 'types') { } 0 0 0
elsif ($ra->[0] eq 'status') { } 0 0 0
elsif ($ra->[0] eq 'config') { } 0 0 0
1148 {
1149 0 my $rp=$ctx->{dri}->available_registries_profiles(1);
1150 0 $m='';
1151 0 foreach my $reg (sort { $a cmp $b } keys %$rp)
1152 {
1153 0 $m.=$reg.': '.join(' ',@{$rp->{$reg}})."\n";
1154 }
1155 } elsif ($ra->[0] eq 'tlds')
1156 {
1157 0 $m=join("\n",$ctx->{dri}->registry()->driver()->tlds());
1158 ▶ } elsif ($ra->[0] eq 'periods' || $ra->[0] eq 'durations')
Condition0%0/3
$ra->[0] eq "periods" or $ra->[0] eq "durations"
l!l&&r!l&&!r
000
MC/DC0%0/2
$ra->[0] eq "periods" or $ra->[0] eq "durations"
$ra->[0] eq "periods" $ra->[0] eq "durations"
Truth table0%0/3
A or B
A= $ra->[0] eq "periods"B= $ra->[0] eq "durations"
ABresult
1X1
011
000
1159 {
1160 0 $m=join("\n",map { pretty_string($_,0); } $ctx->{dri}->registry()->driver()->periods());
1161 } elsif ($ra->[0] eq 'objects')
1162 {
1163 0 $m=join("\n",$ctx->{dri}->registry()->driver()->object_types());
1164 } elsif ($ra->[0] eq 'types')
1165 {
1166 0 $m=join("\n",$ctx->{dri}->registry()->driver()->profile_types());
1167 } elsif ($ra->[0] eq 'status')
1168 {
1169 0 my $o=$ctx->{dri}->local_object('status');
1170 0 ▶ $m=defined($o)? join("\n",map { 'no'.$_ } $o->possible_no()) : 'No status objects';
Branch: 1 branch
BranchTrueFalseTotal
defined $o ? : 0 0 0
1171 } elsif ($ra->[0] eq 'config')
1172 {
1173 0 $m='';
1174 0 foreach my $k (sort { $a cmp $b } keys %{$ctx->{config}})
1175 {
1176 0 $m.=$k.'='.$ctx->{config}->{$k}."\n";
1177 }
1178 }
1179 0 return (undef,$m);
1180 }
1181  
1182 sub do_get_info
1183 0 ▶{
Subroutine do_get_info: not called CC=1 SCAR=6.9
Pod undocumented
1184 0 my ($ctx,$cmd,$ra,$rh)=@_;
1185 0 my $m=$ctx->{dri}->get_info(@$ra);
1186 0 return (undef,pretty_string($m,0));
1187 }
1188  
1189 sub do_get_info_all
1190 0 ▶{
Subroutine do_get_info_all: not called CC=2 SCAR=17.9
Pod undocumented
1191 0 my ($ctx,$cmd,$ra,$rh)=@_;
1192 0 my $rp=$ctx->{dri}->get_info_all(@$ra);
1193 0 my $m='';
1194 0 foreach my $k (sort { $a cmp $b } keys %$rp)
1195 {
1196 0 $m.=$k.': '.pretty_string($rp->{$k},0)."\n";
1197 }
1198 0 return (undef,$m);
1199 }
1200  
1201 sub do_dri
1202 0 ▶{
Subroutine do_dri: not called CC=1 SCAR=6.9
Pod undocumented
1203 0 my ($ctx,$cmd,$ra,$rh)=@_;
1204 0 return ($ctx->{dri}->$cmd(@$ra),undef);
1205 }
1206  
1207 sub do_message_waiting
1208 0 ▶{
Subroutine do_message_waiting: not called CC=3 SCAR=24.8
Pod undocumented
1209 0 my ($ctx,$cmd,$ra,$rh)=@_;
1210 0 my $e=$ctx->{dri}->$cmd(@$ra);
1211 0 ▶ return (undef,'Unable to find if messages are waiting at the registry') unless defined($e);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $e 0 0 0
1212 0 ▶ return (undef,'Messages waiting at the registry? '.($e? 'YES' : 'NO'));
Branch: 1 branch
BranchTrueFalseTotal
$e ? : 0 0 0
1213 }
1214  
1215 sub do_message_count
1216 0 ▶{
Subroutine do_message_count: not called CC=2 SCAR=17.9
Pod undocumented
1217 0 my ($ctx,$cmd,$ra,$rh)=@_;
1218 0 my $e=$ctx->{dri}->$cmd(@$ra);
1219 0 ▶ return (undef,'Unable to find the number of messages waiting at the registry') unless defined($e);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $e 0 0 0
1220 0 return (undef,'Number of messages waiting at the registry: '.$e);
1221 }
1222  
1223 ## Try to handle all domain commands defined in extensions, with some heuristics
1224 sub do_domain_extension
1225 0 ▶{
Subroutine do_domain_extension: not called CC=4 SCAR=30.0
Pod undocumented
1226 0 my ($ctx,$cmd,$ra,$rh)=@_;
1227 0 my $dom=shift(@$ra);
1228 0 build_auth($rh);
1229 0 build_duration($ctx,$rh);
1230 0 ▶ $rh->{status}=build_status($ctx,ref $rh->{status}? $rh->{status} : [ $rh->{status} ] ) if exists($rh->{status});
Branch: 2 branches
BranchTrueFalseTotal
if exists $rh->{"status"} 0 0 0
ref $rh->{'status'} ? : 0 0 0
1231 0 ▶ $rh->{contact}=build_contactset($ctx,$rh->{contact}) if (exists $rh->{contact});
Branch: 1 branch
BranchTrueFalseTotal
if exists $rh->{"contact"} 0 0 0
1232 0 return wrap_command_domain($ctx,$cmd,$dom,$rh);
1233 }
1234  
1235 sub do_domain
1236 0 ▶{
Subroutine do_domain: not called CC=1 SCAR=6.9
Pod undocumented
1237 0 my ($ctx,$cmd,$ra,$rh)=@_;
1238 0 my $dom=shift(@$ra);
1239 0 return wrap_command_domain($ctx,$cmd,$dom,$rh);
1240 }
1241  
1242 sub do_domain_exist
1243 0 ▶{
Subroutine do_domain_exist: not called CC=3 SCAR=24.8
Pod undocumented
1244 0 my ($ctx,$cmd,$ra,$rh)=@_;
1245 0 my $dom=lc($ra->[0]);
1246 0 $ctx->{completion}->{domains}->{$dom}=time();
1247 0 my $e=$ctx->{dri}->$cmd($dom);
1248 0 ▶ return (undef,'Unable to find if domain name '.$dom.' exists') unless defined($e);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $e 0 0 0
1249 0 ▶ return (undef,'Does domain name '.$dom.' exists at registry? '.($e? 'YES' : 'NO'));
Branch: 1 branch
BranchTrueFalseTotal
$e ? : 0 0 0
1250 }
1251  
1252 sub do_domain_transfer
1253 0 ▶{
Subroutine do_domain_transfer: not called CC=2 SCAR=17.9
Pod undocumented
1254 0 my ($ctx,$cmd,$ra,$rh)=@_;
1255 0 build_auth($rh);
1256 0 build_duration($ctx,$rh);
1257 0 ▶ $rh->{contact}=build_contactset($ctx,$rh->{contact}) if exists $rh->{contact}; ## Some registries need contacts during transfer, this is not core EPP, but it does not create drawbacks, so we support it here
Branch: 1 branch
BranchTrueFalseTotal
if exists $rh->{"contact"} 0 0 0
1258 0 return wrap_command_domain($ctx,$cmd,$ra->[0],$rh);
1259 }
1260  
1261 sub do_domain_update
1262 0 ▶{
Subroutine do_domain_update: not called CC=4 SCAR=30.0
Pod undocumented
1263 0 my ($ctx,$cmd,$ra,$rh)=@_;
1264 0 my $dom=shift(@$ra);
1265 0 my $toc=$ctx->{dri}->local_object('changes');
1266 0 my ($radd,$rdel,$rset)=build_update($ctx,$rh);
1267 0 foreach my $k (sort { $a cmp $b } keys %$radd) { $toc->add($k,$radd->{$k}); }
1268 0 foreach my $k (sort { $a cmp $b } keys %$rdel) { $toc->del($k,$rdel->{$k}); }
1269 0 foreach my $k (sort { $a cmp $b } keys %$rset) { $toc->set($k,$rset->{$k}); }
1270 0 return wrap_command_domain($ctx,$cmd,$dom,$toc);
1271 }
1272  
1273 sub do_domain_update_ns
1274 0 ▶{
Subroutine do_domain_update_ns: not called CC=1 SCAR=6.9
Pod undocumented
1275 0 my ($ctx,$cmd,$ra,$rh)=@_;
1276 0 my $dom=shift(@$ra);
1277 0 my $ns=build_hosts($ctx,$ra);
1278 0 return wrap_command_domain($ctx,$cmd,$dom,$ns);
1279 }
1280  
1281 sub do_domain_update_status
1282 0 ▶{
Subroutine do_domain_update_status: not called CC=1 SCAR=6.9
Pod undocumented
1283 0 my ($ctx,$cmd,$ra,$rh)=@_;
1284 0 my $dom=shift(@$ra);
1285 0 my $s=build_status($ctx,$ra);
1286 0 return wrap_command_domain($ctx,$cmd,$dom,$s);
1287 }
1288  
1289 sub do_domain_update_contact
1290 0 ▶{
Subroutine do_domain_update_contact: not called CC=4 SCAR=30.0
Pod undocumented
1291 0 my ($ctx,$cmd,$ra,$rh)=@_;
1292 0 my $dom=shift(@$ra);
1293 0 my $cs=$ctx->{dri}->local_object('contactset');
1294 0 ▶ while(my ($type,$ids)=each(%$rh))
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$rh) 0 0 0
1295 {
1296 0 ▶ foreach my $id (ref($ids)? @$ids : ($ids))
Branch: 1 branch
BranchTrueFalseTotal
ref $ids ? : 0 0 0
1297 {
1298 0 $cs->add($ctx->{dri}->local_object('contact')->srid($id),$type);
1299 0 $ctx->{completion}->{contacts}->{$id}=[time(),$ctx->{dri}->registry_name()];
1300 }
1301 }
1302 0 return wrap_command_domain($ctx,$cmd,$dom,$cs);
1303 }
1304  
1305 sub do_domain_create
1306 0 ▶{
Subroutine do_domain_create: not called CC=8 SCAR=42.8
Pod undocumented
1307 0 my ($ctx,$cmd,$ra,$rh)=@_;
1308 0 my $dom=shift(@$ra);
1309 0 build_duration($ctx,$rh);
1310 0 build_auth($rh);
1311 0 ▶ $rh->{ns}=build_hosts($ctx,[split(/\s+/,ref $rh->{ns} ? join(' ',@{$rh->{ns}}) : $rh->{ns})]) if exists($rh->{ns});
Branch: 2 branches
BranchTrueFalseTotal
if exists $rh->{"ns"} 0 0 0
ref $rh->{'ns'} ? : 0 0 0
1312 0 my @ct=qw/registrant admin tech billing/; ## How to retrieve non core contact types ?
1313 0 ▶ @ct=('registrant',$ctx->{dri}->protocol()->core_contact_types()) if ($ctx->{dri}->protocol() && $ctx->{dri}->protocol()->can('core_contact_types'));
Branch: 1 branch
BranchTrueFalseTotal
if $ctx->{"dri"}->protocol and $ctx->{"dri"}->protocol->can("core_contact_types") 0 0 0
Condition0%0/3
$ctx->{"dri"}->protocol and $ctx->{"dri"}->protocol->can("core_contact_types")
!ll&&!rl&&r
000
MC/DC0%0/2
$ctx->{"dri"}->protocol and $ctx->{"dri"}->protocol->can("core_contact_types")
$ctx->{"dri"}->protocol $ctx->{"dri"}->protocol->can("core_contact_types")
Truth table0%0/3
A and B
A= $ctx->{"dri"}->protocolB= $ctx->{"dri"}->protocol->can("core_contact_types")
ABresult
0X0
100
111
1314 0 my %c;
1315 0 foreach my $t (@ct)
1316 {
1317 0 ▶ next unless exists $rh->{$t};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $rh->{$t} 0 0 0
1318 0 $c{$t}=$rh->{$t};
1319 0 delete $rh->{$t} ;
1320 }
1321 0 ▶ $rh->{contact}=build_contactset($ctx,\%c) if (%c);
Branch: 1 branch
BranchTrueFalseTotal
if %c 0 0 0
1322 0 $rh->{pure_create}=1;
1323 0 return wrap_command_domain($ctx,$cmd,$dom,$rh);
1324 }
1325  
1326 sub do_domain_renew
1327 0 ▶{
Subroutine do_domain_renew: not called CC=2 SCAR=17.9
Pod undocumented
1328 0 my ($ctx,$cmd,$ra,$rh)=@_;
1329 0 my $dom=shift(@$ra);
1330 0 build_duration($ctx,$rh);
1331 0 ▶ if (exists($rh->{current_expiration}))
Branch: 1 branch
BranchTrueFalseTotal
if (exists $rh->{"current_expiration"}) 0 0 0
1332 {
1333 0 my @t=split(/-/,$rh->{current_expiration});
1334 0 $rh->{current_expiration}=$ctx->{dri}->local_object('datetime','year' => $t[0], 'month' => $t[1], 'day' => $t[2]);
1335 }
1336 0 return wrap_command_domain($ctx,$cmd,$dom,$rh);
1337 }
1338  
1339 sub do_domain_delete
1340 0 ▶{
Subroutine do_domain_delete: not called CC=1 SCAR=6.9
Pod undocumented
1341 0 my ($ctx,$cmd,$ra,$rh)=@_;
1342 0 my $dom=shift(@$ra);
1343 0 $rh->{pure_delete}=1;
1344 0 return wrap_command_domain($ctx,$cmd,$dom,$rh);
1345 }
1346  
1347 sub do_host
1348 0 ▶{
Subroutine do_host: not called CC=17 SCAR=57.2
Pod undocumented
1349 0 my ($ctx,$cmd,$ra,$rh)=@_;
1350 0 my @p;
1351 0 ▶ if ($cmd eq 'host_create')
Branch: 4 branches
BranchTrueFalseTotal
if ($cmd eq 'host_create') { } 0 0 0
elsif ($cmd =~ /^host_update_ip_(?:add|del|set)$/) { } 0 0 0
elsif ($cmd =~ /^host_update_status_(?:add|del|set)$/) { } 0 0 0
elsif ($cmd eq 'host_update') { } 0 0 0
1352 {
1353 0 @p=build_hosts($ctx,$ra);
1354 } elsif ($cmd=~m/^host_update_ip_(?:add|del|set)$/)
1355 {
1356 0 my $h=shift(@$ra);
1357 0 @p=($h,build_hosts($ctx,[ $h, @$ra ]));
1358 } elsif ($cmd=~m/^host_update_status_(?:add|del|set)$/)
1359 {
1360 0 my $h=shift(@$ra);
1361 0 @p=($h,build_status($ctx,$ra));
1362 } elsif ($cmd eq 'host_update')
1363 {
1364 0 my $h=shift(@$ra);
1365 0 my $toc=$ctx->{dri}->local_object('changes');
1366 0 my ($radd,$rdel,$rset)=build_update($ctx,$rh);
1367 0 ▶ if (keys %$radd) { foreach my $k (sort { $a cmp $b } keys %$radd) { if ($k eq 'ip') { $radd->{$k}=build_hosts($ctx,[$h,ref $radd->{$k} ? @{$radd->{$k}} : ($radd->{$k})]); } $toc->add($k,$radd->{$k}); } }
Branch: 3 branches
BranchTrueFalseTotal
if (keys %$radd) 0 0 0
if ($k eq "ip") 0 0 0
ref $radd->{$k} ? : 0 0 0
1368 0 ▶ if (keys %$rdel) { foreach my $k (sort { $a cmp $b } keys %$rdel) { if ($k eq 'ip') { $rdel->{$k}=build_hosts($ctx,[$h,ref $rdel->{$k} ? @{$rdel->{$k}} : ($rdel->{$k})]); } $toc->del($k,$rdel->{$k}); } }
Branch: 3 branches
BranchTrueFalseTotal
if (keys %$rdel) 0 0 0
if ($k eq "ip") 0 0 0
ref $rdel->{$k} ? : 0 0 0
1369 0 ▶ if (keys %$rset) { foreach my $k (sort { $a cmp $b } keys %$rset) { $toc->set($k,$rset->{$k}); } }
Branch: 1 branch
BranchTrueFalseTotal
if (keys %$rset) 0 0 0
1370 0 ▶ $ctx->{completion}->{hosts}->{$rset->{'name'}}=time() if exists $rset->{'name'};
Branch: 1 branch
BranchTrueFalseTotal
if exists $rset->{"name"} 0 0 0
1371 0 @p=($h,$toc);
1372 } else
1373 {
1374 0 @p=@$ra;
1375 }
1376 0 $ctx->{completion}->{hosts}->{$p[0]}=time();
1377 0 ▶ $ctx->{completion}->{hosts}->{$p[1]}=time() if $cmd eq 'host_update_name_set';
Branch: 1 branch
BranchTrueFalseTotal
if $cmd eq "host_update_name_set" 0 0 0
1378 0 return ($ctx->{dri}->$cmd(@p),undef);
1379 }
1380  
1381 sub do_contact
1382 0 ▶{
Subroutine do_contact: not called CC=16 SCAR=56.1
Pod undocumented
1383 0 my ($ctx,$cmd,$ra,$rh)=@_;
1384 0 my @p;
1385 0 my $c=$ctx->{dri}->local_object('contact');
1386 0 build_auth($rh);
1387 0 ▶ if ($cmd eq 'contact_create')
Branch: 3 branches
BranchTrueFalseTotal
if ($cmd eq 'contact_create') { } 0 0 0
elsif ($cmd =~ /^contact_update_status_(?:add|del|set)$/) { } 0 0 0
elsif ($cmd eq 'contact_update') { } 0 0 0
1388 {
1389 0 ▶ $rh->{street}=[$rh->{street}] if (exists($rh->{street}) && !ref($rh->{street}));
Branch: 1 branch
BranchTrueFalseTotal
if exists $rh->{"street"} and not ref $rh->{"street"} 0 0 0
Condition0%0/3
exists $rh->{"street"} and not ref $rh->{"street"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $rh->{"street"} and not ref $rh->{"street"}
exists $rh->{"street"} not ref $rh->{"street"}
Truth table0%0/3
A and not(B)
A= exists $rh->{"street"}B= not ref $rh->{"street"}
ABresult
0X0
100
111
1390 0 ▶ $rh->{srid}=$rh->{id} if (exists($rh->{id}) && ! exists($rh->{srid}));
Branch: 1 branch
BranchTrueFalseTotal
if exists $rh->{"id"} and not exists $rh->{"srid"} 0 0 0
Condition0%0/3
exists $rh->{"id"} and not exists $rh->{"srid"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $rh->{"id"} and not exists $rh->{"srid"}
exists $rh->{"id"} not exists $rh->{"srid"}
Truth table0%0/3
A and not(B)
A= exists $rh->{"id"}B= not exists $rh->{"srid"}
ABresult
0X0
100
111
1391 0 ▶ $rh->{srid}=$ra->[0] if (@$ra && $ra->[0]!~m/=/ && ! exists $rh->{srid});
Branch: 1 branch
BranchTrueFalseTotal
if @$ra and not $ra->[0] =~ /=/ and not exists $rh->{"srid"} 0 0 0
Condition0%0/6
@$ra and not $ra->[0] =~ /=/ and not exists $rh->{"srid"}
!ll&&!rl&&r
000
@$ra and not $ra->[0] =~ /=/
!ll&&!rl&&r
000
MC/DC0%0/3
@$ra and not $ra->[0] =~ /=/ and not exists $rh->{"srid"}
@$ra not $ra->[0] =~ /=/ not exists $rh->{"srid"}
Truth table0%0/4
A and not(B) and not(C)
A= @$raB= not $ra->[0] =~ /=/C= not exists $rh->{"srid"}
ABCresult
0XX0
10X0
1100
1111
1392 0 build_contact($ctx,$c,$rh);
1393 } elsif ($cmd=~m/^contact_update_status_(?:add|del|set)$/)
1394 {
1395 0 my $id=shift(@$ra);
1396 0 $c->srid($id);
1397 0 $ctx->{completion}->{contacts}->{$id}=[time(),$ctx->{dri}->registry_name()];
1398 0 @p=(build_status($ctx,$ra));
1399 } elsif ($cmd eq 'contact_update')
1400 {
1401 0 my $id=shift(@$ra);
1402 0 $c->srid($id);
1403 0 $ctx->{completion}->{contacts}->{$id}=[time(),$ctx->{dri}->registry_name()];
1404 0 my ($radd,$rdel,$rset)=build_update($ctx,$rh);
1405 0 my $toc=$ctx->{dri}->local_object('changes');
1406 0 ▶ if (keys %$rset)
Branch: 1 branch
BranchTrueFalseTotal
if (keys %$rset) 0 0 0
1407 {
1408 0 my $c2=$ctx->{dri}->local_object('contact');
1409 0 build_contact($ctx,$c2,$rset);
1410 0 $toc->set('info',$c2);
1411 }
1412 0 ▶ if (keys %$radd) { foreach my $k (sort { $a cmp $b } keys %$radd) { $toc->add($k,$radd->{$k}); } }
Branch: 1 branch
BranchTrueFalseTotal
if (keys %$radd) 0 0 0
1413 0 ▶ if (keys %$rdel) { foreach my $k (sort { $a cmp $b } keys %$rdel) { $toc->del($k,$rdel->{$k}); } }
Branch: 1 branch
BranchTrueFalseTotal
if (keys %$rdel) 0 0 0
1414 0 @p=($toc);
1415 } else
1416 {
1417 0 my $id=shift(@$ra);
1418 0 $c->srid($id);
1419 0 $ctx->{completion}->{contacts}->{$id}=[time(),$ctx->{dri}->registry_name()];
1420 0 @p=@$ra;
1421 }
1422 0 return ($ctx->{dri}->$cmd($c,@p),undef);
1423 }
1424  
1425 ####################################################################################################
1426  
1427 sub wrap_command_domain
1428 0 ▶{
Subroutine wrap_command_domain: not called CC=28 SCAR=67.0
Pod undocumented
1429 0 my ($ctx,$cmd,$dom,@args)=@_;
1430 0 ▶ return (undef,'Undefined domain name') unless defined $dom && length $dom;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $dom and length $dom 0 0 0
Condition0%0/3
defined $dom and length $dom
!ll&&!rl&&r
000
MC/DC0%0/2
defined $dom and length $dom
defined $dom length $dom
Truth table0%0/3
A and B
A= defined $domB= length $dom
ABresult
0X0
100
111
1431  
1432 0 my ($fin,$fout,$res);
1433 0 ▶ if ($dom=~m/`.+`/) ## Local executable
Branch: 2 branches
BranchTrueFalseTotal
if ($dom =~ /`.+`/) { } 0 0 0
elsif ($dom =~ m[/]) { } 0 0 0
1434 {
1435 0 $dom=~s/`(.+)`/$1/;
1436 0 $res=$cmd.'.'.$$.'.'.time().'.results'; ## TODO choose a predictable filename ? if so, use an option
1437 0 ▶ open($fin,'-|',$dom) or return (undef,'Unable to execute local command '.$dom.' : '.$!); ## no critic (InputOutput::RequireBriefOpen)
Branch: 1 branch
BranchTrueFalseTotal
open $fin, "-|", $dom or return undef, 'Unable to execute local command ' . $dom . ' : ' . $! 0 0 0
1438 0 binmode($fin,':encoding(UTF-8)');
1439 0 ▶ open($fout,'>:encoding(UTF-8)',$res) or return (undef,'Unable to write (for results) local file '.$res.' : '.$!); ## no critic (InputOutput::RequireBriefOpen)
Branch: 1 branch
BranchTrueFalseTotal
open $fout, ">:encoding(UTF-8)", $res or return undef, 'Unable to write (for results) local file ' . $res . ' : ' . $! 0 0 0
1440 } elsif ($dom=~m!/!) ## Local file
1441 {
1442 0 ▶ return (undef,'Local file '.$dom.' does not exist or unreadable') unless (-e $dom && -r _);
Branch: 1 branch
BranchTrueFalseTotal
unless -e $dom and -r _ 0 0 0
Condition0%0/3
-e $dom and -r _
!ll&&!rl&&r
000
MC/DC0%0/2
-e $dom and -r _
-e $dom -r _
Truth table0%0/3
A and B
A= -e $domB= -r _
ABresult
0X0
100
111
1443 0 $res=$dom.'.'.$$.'.'.time().'.results'; ## see above
1444 0 ▶ open($fin,'<:encoding(UTF-8)',$dom) or return (undef,'Unable to read local file '.$dom.' : '.$!); ## no critic (InputOutput::RequireBriefOpen)
Branch: 1 branch
BranchTrueFalseTotal
open $fin, "<:encoding(UTF-8)", $dom or return undef, 'Unable to read local file ' . $dom . ' : ' . $! 0 0 0
1445 0 ▶ open($fout,'>:encoding(UTF-8)',$res) or return (undef,'Unable to write (for results) local file '.$res.' : '.$!); ## no critic (InputOutput::RequireBriefOpen)
Branch: 1 branch
BranchTrueFalseTotal
open $fout, ">:encoding(UTF-8)", $res or return undef, 'Unable to write (for results) local file ' . $res . ' : ' . $! 0 0 0
1446 }
1447  
1448 0 ▶ unless (defined $fin && defined $fout) ## Pure unique domain name
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fin and defined $fout) 0 0 0
Condition0%0/3
defined $fin and defined $fout
!ll&&!rl&&r
000
MC/DC0%0/2
defined $fin and defined $fout
defined $fin defined $fout
Truth table0%0/3
A and B
A= defined $finB= defined $fout
ABresult
0X0
100
111
1449 {
1450 0 $ctx->{completion}->{domains}->{$dom}=time();
1451 0 ▶ return (undef,'Invalid domain name: '.$dom) unless Net::DRI::Util::is_hostname($dom);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::is_hostname($dom) 0 0 0
1452 0 return ($ctx->{dri}->$cmd(lc($dom),@args),undef);
1453 }
1454  
1455 0 ▶ my $withinfo=($cmd eq 'domain_check' || $cmd eq 'domain_info')? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$cmd eq 'domain_check' || $cmd eq 'domain_info' ? : 0 0 0
Condition0%0/3
$cmd eq "domain_check" or $cmd eq "domain_info"
l!l&&r!l&&!r
000
MC/DC0%0/2
$cmd eq "domain_check" or $cmd eq "domain_info"
$cmd eq "domain_check" $cmd eq "domain_info"
Truth table0%0/3
A or B
A= $cmd eq "domain_check"B= $cmd eq "domain_info"
ABresult
1X1
011
000
1456 0 my @rc;
1457 0 my $tstart=Time::HiRes::time();
1458 0 ▶ while(defined(my $l=<$fin>))
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $l = readline $fin)) 0 0 0
1459 {
1460 0 chomp($l);
1461 0 my @r=($l);
1462 0 $ctx->{completion}->{domains}->{$l}=time();
1463 0 ▶ if (Net::DRI::Util::is_hostname($l))
Branch: 1 branch
BranchTrueFalseTotal
if (Net::DRI::Util::is_hostname($l)) { } 0 0 0
1464 {
1465 0 my $rc=$ctx->{dri}->$cmd(lc($l),@args);
1466 0 push @r,$rc->as_string(1);
1467 0 ▶ push @r,$ctx->{dri}->get_info_all() if $withinfo;
Branch: 1 branch
BranchTrueFalseTotal
if $withinfo 0 0 0
1468 } else
1469 {
1470 0 push @r,'Invalid domain name';
1471 }
1472 0 push @rc,\@r;
1473 0 output($ctx,'.');
1474 }
1475 0 my $tstop=Time::HiRes::time();
1476 0 output($ctx,"\n");
1477 0 close($fin);
1478  
1479 0 my %r;
1480 ## We write the whole file at the end for better performances (but we opened it right at the beginning to test its writability)
1481 0 foreach my $rc (@rc)
1482 {
1483 0 my $l=shift @$rc;
1484 0 my $rcm=shift @$rc;
1485 0 my ($rcms)=($rcm=~m/^([^\n]+)/);
1486 0 $rcm=~s/\n\t*/ /g;
1487 0 ▶ if ($cmd eq 'domain_check')
Branch: 2 branches
BranchTrueFalseTotal
if ($cmd eq 'domain_check') { } 0 0 0
elsif ($cmd eq 'domain_info') { } 0 0 0
1488 {
1489 0 my $rh=shift @$rc;
1490 0 ▶ $rcm.=' | exist='.(defined $rh->{exist} ? $rh->{exist} : '?').' exist_reason='.(defined $rh->{exist_reason} ? $rh->{exist_reason} : ''); ## exist should always be defined !
Branch: 2 branches
BranchTrueFalseTotal
defined $rh->{'exist'} ? : 0 0 0
defined $rh->{'exist_reason'} ? : 0 0 0
1491 } elsif ($cmd eq 'domain_info')
1492 {
1493 0 my $rh=shift @$rc;
1494 0 $rcm.=' | '.join(' ',map { $_.'=['.pretty_string($rh->{$_},0).']' } qw/clID crDate exDate contact ns status auth/);
1495 0 ▶ if (exists $rh->{ns}) { foreach my $nsname ($rh->{ns}->get_names()) { $ctx->{completion}->{hosts}->{$nsname}=time(); } }
Branch: 1 branch
BranchTrueFalseTotal
if (exists $rh->{"ns"}) 0 0 0
1496 0 ▶ if (exists $rh->{contact}) { foreach my $cid ($rh->{contact}->get_all()) { $ctx->{completion}->{contacts}->{$cid}=[time(),$ctx->{dri}->registry_name()]; } }
Branch: 1 branch
BranchTrueFalseTotal
if (exists $rh->{"contact"}) 0 0 0
1497 }
1498 0 print { $fout } $l,' ',$rcm,"\n";
1499 0 $r{$rcms}++;
1500 }
1501 0 close($fout);
1502  
1503 0 my $t=@rc;
1504 0 my $m=join("\n",map { sprintf('%d/%d (%.02f%%) : %s',$r{$_},$t,100*$r{$_}/$t,$_) } sort { $a cmp $b } keys(%r));
1505 0 $m.="\n".sprintf('%d operations in %d seconds, on average %.2f op/s = %.3f s/op',$t,$tstop-$tstart,$t/($tstop-$tstart),($tstop-$tstart)/$t); ## Warning, substring "on average" is used in handle_line(), do not change it
1506 0 $m.="\nResults in local file: $res";
1507 0 return (undef,$m);
1508 }
1509  
1510 ####################################################################################################
1511  
1512 sub build_contactset
1513 0 ▶{
Subroutine build_contactset: not called CC=4 SCAR=30.0
Pod undocumented
1514 0 my ($ctx,$rh)=@_;
1515 0 my $cs=$ctx->{dri}->local_object('contactset');
1516 0 ▶ while(my ($t,$ids)=each(%$rh))
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$rh) 0 0 0
1517 {
1518 0 ▶ foreach my $c (ref($ids)? @{$ids} : ($ids))
Branch: 1 branch
BranchTrueFalseTotal
ref $ids ? : 0 0 0
1519 {
1520 0 $cs->add($ctx->{dri}->local_object('contact')->srid($c),$t);
1521 0 $ctx->{completion}->{contacts}->{$c}=[time(),$ctx->{dri}->registry_name()];
1522 }
1523 }
1524 0 return $cs;
1525 }
1526  
1527 sub build_contact
1528 0 ▶{
Subroutine build_contact: not called CC=4 SCAR=30.0
Pod undocumented
1529 0 my ($ctx,$c,$rh)=@_;
1530 0 ▶ while(my ($m,$v)=each(%$rh))
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$rh) 0 0 0
1531 {
1532 0 $c->$m($v);
1533 }
1534 0 ▶ if (exists $rh->{srid}) { $ctx->{completion}->{contacts}->{$rh->{srid}}=[time(),$ctx->{dri}->registry_name()]; }
Branch: 1 branch
BranchTrueFalseTotal
if (exists $rh->{"srid"}) 0 0 0
1535 0 ▶ if (exists $rh->{id}) { $ctx->{completion}->{contacts}->{$rh->{id}} =[time(),$ctx->{dri}->registry_name()]; }
Branch: 1 branch
BranchTrueFalseTotal
if (exists $rh->{"id"}) 0 0 0
1536  
1537 0 return $c;
1538 }
1539  
1540 sub build_status
1541 0 ▶{
Subroutine build_status: not called CC=2 SCAR=17.9
Pod undocumented
1542 0 my ($ctx,$ra)=@_;
1543 0 my $s=$ctx->{dri}->local_object('status');
1544 0 foreach (@$ra) { s/^no//; $s->no($_); }
1545 0 return $s;
1546 }
1547  
1548 sub build_hosts
1549 0 ▶{
Subroutine build_hosts: not called CC=5 SCAR=34.0
Pod undocumented
1550 0 my ($ctx,$ra)=@_;
1551 0 my $ns=$ctx->{dri}->local_object('hosts');
1552 0 my $i=-1;
1553 0 my @r;
1554 0 foreach my $o (@$ra)
1555 {
1556 0 ▶ $r[++$i]=[] if ($o=~m/[a-z]/i); ## new hostname (safe since at least the TLD is not numeric)
Branch: 1 branch
BranchTrueFalseTotal
if $o =~ /[a-z]/i 0 0 0
1557 0 ▶ push @{$r[$i]},$o if $i >= 0; ## the test here makes us skip IP addresses at beginning before first name (a situation that should not happen anyway)
Branch: 1 branch
BranchTrueFalseTotal
if $i >= 0 0 0 0
1558 }
1559 0 foreach my $rns (@r)
1560 {
1561 0 my $name=shift(@$rns);
1562 0 $ns->add($name,$rns);
1563 0 $ctx->{completion}->{hosts}->{$name}=time();
1564 }
1565 0 return $ns;
1566 }
1567  
1568 sub build_auth
1569 0 ▶{
Subroutine build_auth: not called CC=3 SCAR=24.8
Pod undocumented
1570 0 my $rd=shift;
1571 0 ▶ return unless (exists($rd->{auth}) && ! ref($rd->{auth}));
Branch: 1 branch
BranchTrueFalseTotal
unless exists $rd->{"auth"} and not ref $rd->{"auth"} 0 0 0
Condition0%0/3
exists $rd->{"auth"} and not ref $rd->{"auth"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $rd->{"auth"} and not ref $rd->{"auth"}
exists $rd->{"auth"} not ref $rd->{"auth"}
Truth table0%0/3
A and not(B)
A= exists $rd->{"auth"}B= not ref $rd->{"auth"}
ABresult
0X0
100
111
1572 0 $rd->{auth}={ pw => $rd->{auth} };
1573 0 return;
1574 }
1575  
1576 sub build_duration
1577 0 ▶{
Subroutine build_duration: not called CC=6 SCAR=37.4
Pod undocumented
1578 0 my ($ctx,$rd)=@_;
1579 0 ▶ return unless exists($rd->{duration});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $rd->{"duration"} 0 0 0
1580 0 my ($v,$u)=($rd->{duration}=~m/^P?(\d+)(y(?:ears?)|m(?:onths?))$/i);
1581 0 ▶ die sprintf('Invalid duration specification "%s"',$rd->{duration}) unless defined $v && defined $u;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $v and defined $u 0 0 0
Condition0%0/3
defined $v and defined $u
!ll&&!rl&&r
000
MC/DC0%0/2
defined $v and defined $u
defined $v defined $u
Truth table0%0/3
A and B
A= defined $vB= defined $u
ABresult
0X0
100
111
1582 0 ▶ $rd->{duration}=$ctx->{dri}->local_object('duration','years' => $v) if ($u=~m/^y(?:ears?)?$/i);
Branch: 1 branch
BranchTrueFalseTotal
if $u =~ /^y(?:ears?)?$/i 0 0 0
1583 0 ▶ $rd->{duration}=$ctx->{dri}->local_object('duration','months' => $v) if ($u=~m/^m(?:onths?)?$/i);
Branch: 1 branch
BranchTrueFalseTotal
if $u =~ /^m(?:onths?)?$/i 0 0 0
1584 0 return;
1585 }
1586  
1587 sub build_update
1588 0 ▶{
Subroutine build_update: not called CC=13 SCAR=52.0
Pod undocumented
1589 0 my ($ctx,$rd)=@_;
1590 0 my (%add,%rem);
1591  
1592 ## Some normalizations
1593 0 ▶ foreach my $k (sort { $a cmp $b } grep { /^[+-]?status$/ } keys(%$rd)) { $rd->{$k}=build_status($ctx,ref $rd->{$k} ? $rd->{$k} : [ $rd->{$k} ]); }
Branch: 1 branch
BranchTrueFalseTotal
ref $rd->{$k} ? : 0 0 0
1594 0 ▶ foreach my $k (sort { $a cmp $b } grep { /^[+-]?ns$/ } keys(%$rd)) { $rd->{$k}=build_hosts($ctx,[ map { split(/\s+/,$_) } ref $rd->{$k} ? @{$rd->{$k}} : ($rd->{$k})]); }
Branch: 1 branch
BranchTrueFalseTotal
ref $rd->{$k} ? : 0 0 0
1595 0 build_auth($rd);
1596  
1597 0 my @ct=qw/admin tech billing/; ## How to retrieve non core contact types ?
1598 0 ▶ @ct=$ctx->{dri}->protocol()->core_contact_types() if ($ctx->{dri}->protocol() && $ctx->{dri}->protocol()->can('core_contact_types'));
Branch: 1 branch
BranchTrueFalseTotal
if $ctx->{"dri"}->protocol and $ctx->{"dri"}->protocol->can("core_contact_types") 0 0 0
Condition0%0/3
$ctx->{"dri"}->protocol and $ctx->{"dri"}->protocol->can("core_contact_types")
!ll&&!rl&&r
000
MC/DC0%0/2
$ctx->{"dri"}->protocol and $ctx->{"dri"}->protocol->can("core_contact_types")
$ctx->{"dri"}->protocol $ctx->{"dri"}->protocol->can("core_contact_types")
Truth table0%0/3
A and B
A= $ctx->{"dri"}->protocolB= $ctx->{"dri"}->protocol->can("core_contact_types")
ABresult
0X0
100
111
1599 0 my $ctr=join('|',@ct);
1600 0 foreach my $op (qw/+ -/)
1601 {
1602 0 my %c;
1603 0 foreach my $k (sort { $a cmp $b } grep { /^[${op}](?:${ctr})$/ } keys %$rd )
1604 {
1605 0 $c{substr($k,1)}=$rd->{$k};
1606 0 delete($rd->{$k});
1607 }
1608 0 ▶ next unless %c;
Branch: 1 branch
BranchTrueFalseTotal
unless %c 0 0 0
1609 0 $rd->{$op.'contact'}=build_contactset($ctx,\%c);
1610 }
1611 0 ▶ $rd->{registrant}=build_contact($ctx,$ctx->{dri}->local_object('contact'),{srid => $rd->{registrant}}) if exists $rd->{registrant};
Branch: 1 branch
BranchTrueFalseTotal
if exists $rd->{"registrant"} 0 0 0
1612  
1613 ## Now split in two hashes
1614 0 foreach my $k (sort { $a cmp $b } grep { /^\+/ } keys %$rd)
1615 {
1616 0 $add{substr($k,1)}=$rd->{$k};
1617 0 delete($rd->{$k});
1618 }
1619 0 foreach my $k (sort { $a cmp $b } grep { /^-/ } keys %$rd)
1620 {
1621 0 $rem{substr($k,1)}=$rd->{$k};
1622 0 delete($rd->{$k});
1623 }
1624  
1625 0 return (\%add,\%rem,$rd);
1626 }
1627  
1628 sub pretty_string
1629 0 ▶{
Subroutine pretty_string: not called CC=22 SCAR=62.3
Pod undocumented
1630 0 my ($v,$full)=@_;
1631 0 ▶ $full||=0;
Condition0%0/2
$full ||= 0
l!l
00
MC/DC0%0/1
$full ||= 0
$full
Truth table0%0/2
A
A= $full
Aresult
11
00
1632 0 ▶ unless(ref($v))
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $v) 0 0 0
1633 {
1634 0 ▶ return '<undef>' unless defined($v);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $v 0 0 0
1635 0 $v=~s/\s*$//;
1636 0 ▶ return $v unless ($v=~m/^<\?xml /);
Branch: 1 branch
BranchTrueFalseTotal
unless $v =~ /^<\?xml / 0 0 0
1637 0 my $vi=Net::DRI::Util::xml_indent($v);
1638 0 $vi=~s/\n/\n\t\t/g;
1639 0 return $vi;
1640 }
1641 0 ▶ return join(' ',@$v) if (ref($v) eq 'ARRAY');
Branch: 1 branch
BranchTrueFalseTotal
if ref $v eq "ARRAY" 0 0 0
1642 0 ▶ return join(' ',map { $_.'='.$v->{$_} } sort { $a cmp $b } keys(%$v)) if (ref($v) eq 'HASH');
Branch: 1 branch
BranchTrueFalseTotal
if ref $v eq "HASH" 0 0 0
1643 0 ▶ return ($full? "Ns:\n": '').$v->as_string(1) if ($v->isa('Net::DRI::Data::Hosts'));
Branch: 2 branches
BranchTrueFalseTotal
if $v->isa("Net::DRI::Data::Hosts") 0 0 0
$full ? : 0 0 0
1644 0 ▶ return ($full? "Contact:\n" : '').$v->as_string() if ($v->isa('Net::DRI::Data::Contact'));
Branch: 2 branches
BranchTrueFalseTotal
if $v->isa("Net::DRI::Data::Contact") 0 0 0
$full ? : 0 0 0
1645 0 ▶ if ($v->isa('Net::DRI::Data::ContactSet'))
Branch: 1 branch
BranchTrueFalseTotal
if ($v->isa("Net::DRI::Data::ContactSet")) 0 0 0
1646 {
1647 0 my @v;
1648 0 foreach my $t ($v->types())
1649 {
1650 0 push @v,$t.'='.join(',',map { pretty_string($_,$full) } $v->get($t));
1651 }
1652 0 ▶ return ($full? "ContactSet:\n" : '').join(' ',@v);
Branch: 1 branch
BranchTrueFalseTotal
$full ? : 0 0 0
1653 }
1654 0 ▶ return ($full? "Status:\n" : '').join(' + ',$v->list_status(1)) if ($v->isa('Net::DRI::Data::StatusList'));
Branch: 2 branches
BranchTrueFalseTotal
if $v->isa("Net::DRI::Data::StatusList") 0 0 0
$full ? : 0 0 0
1655 0 ▶ return ($full? "Command result:\n" : '').$v->as_string(1) if ($v->isa('Net::DRI::Protocol::ResultStatus'));
Branch: 2 branches
BranchTrueFalseTotal
if $v->isa("Net::DRI::Protocol::ResultStatus") 0 0 0
$full ? : 0 0 0
1656 0 ▶ return ($full? "Date:\n" : '').$v->set_time_zone('UTC')->strftime('%Y-%m-%d %T').' UTC' if ($v->isa('DateTime'));
Branch: 2 branches
BranchTrueFalseTotal
if $v->isa("DateTime") 0 0 0
$full ? : 0 0 0
1657 0 ▶ return ($full? "Duration:\n" : '').sprintf('P%dY%dM%dDT%dH%dM%dS',$v->in_units(qw/years months days hours minutes seconds/)) if ($v->isa('DateTime::Duration')); ## ISO8601
Branch: 2 branches
BranchTrueFalseTotal
if $v->isa("DateTime::Duration") 0 0 0
$full ? : 0 0 0
1658 0 return $v;
1659 }
1660  
1661 sub dump_info
1662 0 ▶{
Subroutine dump_info: not called CC=7 SCAR=40.3
Pod undocumented
1663 0 my ($ctx,$rh)=@_;
1664 0 my @r;
1665 0 foreach my $k1 (sort { $a cmp $b } keys %$rh)
1666 {
1667 0 foreach my $k2 (sort { $a cmp $b } keys %{$rh->{$k1}})
1668 {
1669 0 ▶ next if ($k1 eq 'session' && $k2 eq 'exchange' && $ctx->{config}->{verbose}==0);
Branch: 1 branch
BranchTrueFalseTotal
if $k1 eq "session" and $k2 eq "exchange" and $ctx->{"config"}{"verbose"} == 0 0 0 0
Condition0%0/6
$k1 eq "session" and $k2 eq "exchange" and $ctx->{"config"}{"verbose"} == 0
!ll&&!rl&&r
000
$k1 eq "session" and $k2 eq "exchange"
!ll&&!rl&&r
000
MC/DC0%0/3
$k1 eq "session" and $k2 eq "exchange" and $ctx->{"config"}{"verbose"} == 0
$k1 eq "session" $k2 eq "exchange" $ctx->{"config"}{"verbose"} == 0
Truth table0%0/4
A and B and C
A= $k1 eq "session"B= $k2 eq "exchange"C= $ctx->{"config"}{"verbose"} == 0
ABCresult
0XX0
10X0
1100
1111
1670 0 push @r,$k1.','.$k2;
1671 0 foreach my $k3 (sort { $a cmp $b } keys %{$rh->{$k1}->{$k2}})
1672 {
1673 0 push @r,"\t".$k3.': '.pretty_string($rh->{$k1}->{$k2}->{$k3},0);
1674 }
1675 0 push @r,'';
1676 }
1677 }
1678 0 return join("\n",@r);
1679 }
1680  
1681 ####################################################################################################
1682 1 1;
« DRI/Protocol/EPP/Extensions/NO/Contact.pm ↑ Summary DRI/Data/Contact/SWITCH.pm »