DRI/Protocol/BookMyName/WS/Domain.pm

filter: Statementstmt 13.9% 13 / 93 Branchbran 0.0% 0 / 58 Conditioncond 0.0% 0 / 15 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 36.3% 4 / 11 Podpod 0.0% 0 / 7 totaltotal 8.8% 17 / 193 CC 38 SCAR 50.7
CC
38
Cov
8%
parse_status
306.0
info_parse
156.0
check_parse
56.0
CRAP 158.9
« DRI/Protocol/EPP/Extensions/EURid/Domain.pm ↑ Summary DRI/Protocol/RRI/Domain.pm »
1 ## Domain Registry Interface, BookMyName Web Services Domain commands
2 ##
3 ## Copyright (c) 2008,2009,2013 Patrick Mevzek <netdri@dotandco.com>. All rights reserved.
4 ##
5 ## This file is part of Net::DRI
6 ##
7 ## Net::DRI is free software; you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation; either version 2 of the License, or
10 ## (at your option) any later version.
11 ##
12 ## See the LICENSE file that comes with this distribution for more details.
13 ####################################################################################################
14  
15 package Net::DRI::Protocol::BookMyName::WS::Domain;
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  
20 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 =pod
24  
25 =head1 NAME
26  
27 Net::DRI::Protocol::BookMyName::WS::Domain - BookMyName Web Services Domain commands for Net::DRI
28  
29 =head1 DESCRIPTION
30  
31 Please see the README file for details.
32  
33 =head1 SUPPORT
34  
35 For now, support questions should be sent to:
36  
37 E<lt>netdri@dotandco.comE<gt>
38  
39 Please also see the SUPPORT file in the distribution.
40  
41 =head1 SEE ALSO
42  
43 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
44  
45 =head1 AUTHOR
46  
47 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
48  
49 =head1 COPYRIGHT
50  
51 Copyright (c) 2008,2009,2013 Patrick Mevzek <netdri@dotandco.com>.
52 All rights reserved.
53  
54 This program is free software; you can redistribute it and/or modify
55 it under the terms of the GNU General Public License as published by
56 the Free Software Foundation; either version 2 of the License, or
57 (at your option) any later version.
58  
59 See the LICENSE file that comes with this distribution for more details.
60  
61 =cut
62  
63 ####################################################################################################
64  
65 sub register_commands
66 {
67 0 ▶ my ($class,$version)=@_;
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
68 0 my %tmp=(
69 info => [\&info, \&info_parse ],
70 check => [\&check, \&check_parse ],
71 );
72  
73 0 return { 'domain' => \%tmp };
74 }
75  
76 ## From http://api.doc.free.org/revendeur-de-nom-de-domaine#status
77 sub parse_status
78 {
79 0 ▶ my $s=shift;
Subroutine parse_status: not called CC=17 SCAR=57.2
Pod undocumented
80 0 my @s;
81 0 ▶ push @s,'clientDeleteProhibited' if ($s & 0x01);
Branch: 1 branch
BranchTrueFalseTotal
if $s & 1 0 0 0
82 0 ▶ push @s,'serverDeleteProhibited' if ($s & 0x02);
Branch: 1 branch
BranchTrueFalseTotal
if $s & 2 0 0 0
83 0 ▶ push @s,'clientHold' if ($s & 0x04);
Branch: 1 branch
BranchTrueFalseTotal
if $s & 4 0 0 0
84 0 ▶ push @s,'serverHold' if ($s & 0x08);
Branch: 1 branch
BranchTrueFalseTotal
if $s & 8 0 0 0
85 0 ▶ push @s,'clientRenewProhibited' if ($s & 0x10);
Branch: 1 branch
BranchTrueFalseTotal
if $s & 16 0 0 0
86 0 ▶ push @s,'serverRenewProhibited' if ($s & 0x20);
Branch: 1 branch
BranchTrueFalseTotal
if $s & 32 0 0 0
87 0 ▶ push @s,'clientTransferProhibited' if ($s & 0x40);
Branch: 1 branch
BranchTrueFalseTotal
if $s & 64 0 0 0
88 0 ▶ push @s,'serverTransferProhibited' if ($s & 0x80);
Branch: 1 branch
BranchTrueFalseTotal
if $s & 128 0 0 0
89 0 ▶ push @s,'clientUpdateProhibited' if ($s & 0x100);
Branch: 1 branch
BranchTrueFalseTotal
if $s & 256 0 0 0
90 0 ▶ push @s,'serverUpdateProhibited' if ($s & 0x200);
Branch: 1 branch
BranchTrueFalseTotal
if $s & 512 0 0 0
91 0 ▶ push @s,'pendingCreate' if ($s & 0x400);
Branch: 1 branch
BranchTrueFalseTotal
if $s & 1024 0 0 0
92 0 ▶ push @s,'pendingDelete' if ($s & 0x800);
Branch: 1 branch
BranchTrueFalseTotal
if $s & 2048 0 0 0
93 0 ▶ push @s,'pendingRenew' if ($s & 0x1000);
Branch: 1 branch
BranchTrueFalseTotal
if $s & 4096 0 0 0
94 0 ▶ push @s,'pendingTransfer' if ($s & 0x2000);
Branch: 1 branch
BranchTrueFalseTotal
if $s & 8192 0 0 0
95 0 ▶ push @s,'pendingUpdate' if ($s &0x4000);
Branch: 1 branch
BranchTrueFalseTotal
if $s & 16384 0 0 0
96 0 ▶ return @s? @s : ('ok');
Branch: 1 branch
BranchTrueFalseTotal
@s ? : 0 0 0
97 }
98  
99 sub build_msg
100 {
101 0 ▶ my ($msg,$command,$domain)=@_;
Subroutine build_msg: not called CC=5 SCAR=34.0
Pod undocumented
102 0 ▶ Net::DRI::Exception->die(1,'protocol/bookmyname/ws',2,'Domain name needed') unless defined($domain) && $domain;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $domain and $domain 0 0 0
Condition0%0/3
defined $domain and $domain
!ll&&!rl&&r
000
MC/DC0%0/2
defined $domain and $domain
defined $domain $domain
Truth table0%0/3
A and B
A= defined $domainB= $domain
ABresult
0X0
100
111
103 0 ▶ Net::DRI::Exception->die(1,'protocol/bookmyname/ws',10,'Invalid domain name') unless Net::DRI::Util::is_hostname($domain);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::is_hostname($domain) 0 0 0
104  
105 0 ▶ $msg->method($command) if defined($command);
Branch: 1 branch
BranchTrueFalseTotal
if defined $command 0 0 0
106 0 return;
107 }
108  
109 sub info
110 {
111 0 ▶ my ($po,$domain)=@_;
Subroutine info: not called CC=1 SCAR=6.9
Pod undocumented
112 0 my $msg=$po->message();
113 0 build_msg($msg,'domain_info',$domain);
114 0 $msg->params([ $domain ]);
115 0 return;
116 }
117  
118 sub info_parse
119 {
120 0 ▶ my ($po,$otype,$oaction,$oname,$rinfo)=@_;
Subroutine info_parse: not called CC=12 SCAR=50.5
Pod undocumented
121 0 my $mes=$po->message();
122 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
123  
124 0 my $r=$mes->result();
125 0 ▶ Net::DRI::Exception->die(1,'protocol/bookmyname/ws',1,'Unexpected reply for domain_info: '.$r) unless (ref($r) eq 'HASH');
Branch: 1 branch
BranchTrueFalseTotal
unless ref $r eq "HASH" 0 0 0
126  
127 0 my %r=%$r;
128 0 $oname=lc($r{domain});
129 0 $rinfo->{domain}->{$oname}->{action}='info';
130 0 $rinfo->{domain}->{$oname}->{exist}=1;
131 0 $rinfo->{domain}->{$oname}->{roid}=$r{id};
132 0 my %d=(registrar_creation => 'crDate', lastupdate => 'upDate', registrar_expiration => 'exDate');
133 0 ▶ while (my ($k,$v)=each(%d))
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %d) 0 0 0
134 {
135 0 ▶ next unless exists($r{$k});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $r{$k} 0 0 0
136 0 $rinfo->{domain}->{$oname}->{$v}=$po->parse_iso8601($r{$k});
137 }
138 0 $rinfo->{domain}->{$oname}->{upIP}=$r{lastupdate_ip};
139 0 my %c=(owner_id => 'registrant', admin_id => 'admin', tech_id => 'tech', bill_id => 'billing');
140 0 my $cs=$po->create_local_object('contactset');
141 0 ▶ while (my ($k,$v)=each(%d))
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %d) 0 0 0
142 {
143 0 ▶ next unless exists($r{$k});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $r{$k} 0 0 0
144 0 my $c=$po->create_local_object('contact')->srid($r{$k});
145 0 $cs->add($c,$v);
146 }
147 0 $rinfo->{domain}->{$oname}->{contact}=$cs;
148 0 $rinfo->{domain}->{$oname}->{auth}={pw => $r{authinfo}};
149  
150 0 foreach my $k (qw/service ip_dns_master/)
151 {
152 0 ▶ $rinfo->{domain}->{$oname}->{$k}=$r{$k} if (exists($r{$k}) && defined($r{$k}));
Branch: 1 branch
BranchTrueFalseTotal
if exists $r{$k} and defined $r{$k} 0 0 0
Condition0%0/3
exists $r{$k} and defined $r{$k}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $r{$k} and defined $r{$k}
exists $r{$k} defined $r{$k}
Truth table0%0/3
A and B
A= exists $r{$k}B= defined $r{$k}
ABresult
0X0
100
111
153 }
154 0 my $sl=$po->create_local_object('status');
155 0 foreach my $s (parse_status($r{registry_status})) { $sl->add($s); }
156 0 $rinfo->{domain}->{$oname}->{status}=$sl;
157 ## $r{status} is not used, what is it ?
158  
159 0 my $ns=$po->create_local_object('hosts');
160 0 foreach my $nsk (sort { ($a=~m/^ns(\d+)/)[0] <=> ($b=~m/^ns(\d+)/)[0] } grep { /^ns\d+$/ } keys(%r)) { $ns->add($r{$nsk}); }
161 0 $rinfo->{domain}->{$oname}->{ns}=$ns;
162 0 return;
163 }
164  
165 sub check
166 {
167 0 ▶ my ($po,$domain)=@_;
Subroutine check: not called CC=1 SCAR=6.9
Pod undocumented
168 0 my $msg=$po->message();
169 0 build_msg($msg,'domain_check',$domain);
170 0 $msg->params([ $domain ]);
171 0 return;
172 }
173  
174 sub check_parse
175 {
176 0 ▶ my ($po,$otype,$oaction,$oname,$rinfo)=@_;
Subroutine check_parse: not called CC=7 SCAR=40.3
Pod undocumented
177 0 my $mes=$po->message();
178  
179 0 ▶ if ($mes->retcode()==-1 && ($mes->retval()==-2 || $mes->retval()==-4)) ## domain does not exist
Branch: 1 branch
BranchTrueFalseTotal
if ($mes->retcode == -1 and $mes->retval == -2 || $mes->retval == -4) 0 0 0
Condition0%0/6
$mes->retcode == -1 and $mes->retval == -2 || $mes->retval == -4
!ll&&!rl&&r
000
$mes->retval == -2 or $mes->retval == -4
l!l&&r!l&&!r
000
MC/DC0%0/3
$mes->retcode == -1 and $mes->retval == -2 || $mes->retval == -4
$mes->retcode == -1 $mes->retval == -2 $mes->retval == -4
Truth table0%0/4
A and B or C
A= $mes->retcode == -1B= $mes->retval == -2C= $mes->retval == -4
ABCresult
0XX0
1000
11X1
1011
180 {
181 0 $mes->retcode(1); ## fake a success
182 }
183 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
184  
185 0 $rinfo->{domain}->{$oname}->{action}='check';
186 0 ▶ $rinfo->{domain}->{$oname}->{exist}=($mes->retcode()==1 && $mes->retval()==1)? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$mes->retcode == 1 && $mes->retval == 1 ? : 0 0 0
Condition0%0/3
$mes->retcode == 1 and $mes->retval == 1
!ll&&!rl&&r
000
MC/DC0%0/2
$mes->retcode == 1 and $mes->retval == 1
$mes->retcode == 1 $mes->retval == 1
Truth table0%0/3
A and B
A= $mes->retcode == 1B= $mes->retval == 1
ABresult
0X0
100
111
187 0 return;
188 }
189  
190 ####################################################################################################
191 1 1;
« DRI/Protocol/EPP/Extensions/EURid/Domain.pm ↑ Summary DRI/Protocol/RRI/Domain.pm »