DRI/Protocol/IRIS/DCHK/Domain.pm

filter: Statementstmt 23.6% 22 / 93 Branchbran 0.0% 0 / 48 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 58.3% 7 / 12 Podpod 0.0% 0 / 5 totaltotal 16.7% 29 / 173 CC 33 SCAR 54.7
CC
33
Cov
15%
info_parse
462.0
build_command
56.0
parse_status
56.0
CRAP 238.6
« DRI/DRD.pm ↑ Summary DRI/Data/Contact/COZA.pm »
1 ## Domain Registry Interface, IRIS DCHK (RFC5144)
2 ##
3 ## Copyright (c) 2008,2010-2011,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::IRIS::DCHK::Domain;
16  
17 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use Net::DRI::Protocol::IRIS::Core;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 =pod
28  
29 =head1 NAME
30  
31 Net::DRI::Protocol::IRIS::DCHK::Domain - IRIS DCHK (RFC5144) Domain Commands for Net::DRI
32  
33 =head1 DESCRIPTION
34  
35 Please see the README file for details.
36  
37 =head1 SUPPORT
38  
39 For now, support questions should be sent to:
40  
41 E<lt>netdri@dotandco.comE<gt>
42  
43 Please also see the SUPPORT file in the distribution.
44  
45 =head1 SEE ALSO
46  
47 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
48  
49 =head1 AUTHOR
50  
51 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
52  
53 =head1 COPYRIGHT
54  
55 Copyright (c) 2008,2010-2011,2013 Patrick Mevzek <netdri@dotandco.com>.
56 All rights reserved.
57  
58 This program is free software; you can redistribute it and/or modify
59 it under the terms of the GNU General Public License as published by
60 the Free Software Foundation; either version 2 of the License, or
61 (at your option) any later version.
62  
63 See the LICENSE file that comes with this distribution for more details.
64  
65 =cut
66  
67 ####################################################################################################
68  
69 sub register_commands
70 {
71 0 ▶ my ($class,$version)=@_;
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
72 0 my %tmp=( info => [ \&info, \&info_parse ] );
73 ## $tmp{info_multi}=$tmp{info};
74 0 return { 'domain' => \%tmp };
75 }
76  
77 sub build_command
78 {
79 0 ▶ my ($ns,$domain)=@_;
Subroutine build_command: not called CC=7 SCAR=40.3
Pod undocumented
80 0 ▶ my @dom=ref $domain ? @$domain : ($domain);
Branch: 1 branch
BranchTrueFalseTotal
ref $domain ? : 0 0 0
81 0 ▶ Net::DRI::Exception->die(1,'protocol/IRIS',2,'Domain name needed') unless @dom;
Branch: 1 branch
BranchTrueFalseTotal
unless @dom 0 0 0
82 0 foreach my $d (@dom)
83 {
84 0 ▶ Net::DRI::Exception->die(1,'protocol/IRIS',2,'Domain name needed') unless defined $d && $d;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $d and $d 0 0 0
Condition0%0/3
defined $d and $d
!ll&&!rl&&r
000
MC/DC0%0/2
defined $d and $d
defined $d $d
Truth table0%0/3
A and B
A= defined $dB= $d
ABresult
0X0
100
111
85 0 ▶ Net::DRI::Exception->die(1,'protocol/IRIS',10,'Invalid domain name: '.$d) unless Net::DRI::Util::is_hostname($d);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::is_hostname($d) 0 0 0
86 }
87  
88 ## TODO: entityClass may also be IDN for Unicode domain names ## §3.1.2
89 ##return [ map { { registryType => $ns, entityClass => 'domain-name', entityName => $_ } } @dom ] ;
90 0 return [ map { { registryType => 'dchk1', entityClass => 'domain-name', entityName => $_ } } @dom ] ; ## Both registryType forms should work, but currently only this one works
91 }
92  
93 sub info
94 {
95 0 ▶ my ($p,$domain)=@_;
Subroutine info: not called CC=1 SCAR=6.9
Pod undocumented
96 0 my $mes=$p->message();
97 0 $mes->search(build_command($mes->ns('dchk1'),$domain));
98 0 return;
99 }
100  
101 sub info_parse
102 {
103 0 ▶ my ($po,$otype,$oaction,$oname,$rinfo)=@_;
Subroutine info_parse: not called CC=21 SCAR=61.4
Pod undocumented
104 0 my $mes=$po->message();
105 0 ▶ return unless $mes->is_success(); ## ?
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
106 0 ▶ return unless $mes->results(); ## a nodeList of resultSet nodes
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->results 0 0 0
107  
108 0 foreach my $cd ($mes->results()->get_nodelist())
109 {
110 0 ▶ carp('For domain '.$oname.' got a node <additional>, please report') if $cd->getChildrenByTagNameNS($mes->ns('iris1'),'additional')->size(); ## TODO
Branch: 1 branch
BranchTrueFalseTotal
if $cd->getChildrenByTagNameNS($mes->ns("iris1"), "additional")->size 0 0 0
111 0 $rinfo->{domain}->{$oname}->{result_status}=Net::DRI::Protocol::IRIS::Core::parse_error($cd); ## a ResultStatus instance, either a generic success, or a specific error
112 0 $rinfo->{domain}->{$oname}->{action}='info';
113 0 $rinfo->{domain}->{$oname}->{exist}=0;
114  
115 0 my $c=$cd->getChildrenByTagNameNS($mes->ns('iris1'),'answer');
116 0 ▶ next unless $c->size();
Branch: 1 branch
BranchTrueFalseTotal
unless $c->size 0 0 0
117 0 $c=$c->get_node(1)->getChildrenByTagNameNS($mes->ns('dchk1'),'domain');
118 0 ▶ next unless $c->size();
Branch: 1 branch
BranchTrueFalseTotal
unless $c->size 0 0 0
119 ## We do not parse attributes authority/entityClass/entityName/registryType, they should be the same as what we sent
120 0 $c=$c->get_node(1);
121 0 ▶ my $temp=$c->hasAttribute('temporaryReference')? Net::DRI::Util::xml_parse_boolean($c->getAttribute('temporaryReference')) : 0;
Branch: 1 branch
BranchTrueFalseTotal
$c->hasAttribute('temporaryReference') ? : 0 0 0
122  
123 0 my ($domain,@s);
124 0 foreach my $el (Net::DRI::Util::xml_list_children($c))
125 {
126 0 my ($n,$c)=@$el;
127 0 ▶ if ($n eq 'domainName') ## we do not use <idn> for now
Branch: 8 branches
BranchTrueFalseTotal
if ($n eq 'domainName') { } 0 0 0
elsif ($n eq 'status') { } 0 0 0
elsif ($n eq 'registrationReference') { } 0 0 0
elsif ($n eq 'createdDateTime') { } 0 0 0
elsif ($n eq 'initialDelegationDateTime') { } 0 0 0
elsif ($n eq 'expirationDateTime') { } 0 0 0
elsif ($n eq 'lastDatabaseUpdateDateTime') { } 0 0 0
elsif ($n eq 'seeAlso' or $n eq 'iris:seeAlso') { } 0 0 0
128 {
129 0 $domain=lc($c->textContent());
130 0 $rinfo->{domain}->{$domain}->{action}='info';
131 } elsif ($n eq 'status')
132 {
133 ## We take everything below as a status node, which allows us to handle all non RFC5144 defined statuses
134 0 foreach my $el (Net::DRI::Util::xml_list_children($c))
135 {
136 0 my ($nn,$cc)=@$el;
137 0 push @s,parse_status($po,$cc);
138 }
139 } elsif ($n eq 'registrationReference')
140 {
141 0 carp('For domain '.$domain.' got a node <registrationReference>, please report');
142 } elsif ($n eq 'createdDateTime')
143 {
144 0 $rinfo->{domain}->{$domain}->{crDate}=$po->parse_iso8601($c->textContent());
145 } elsif ($n eq 'initialDelegationDateTime')
146 {
147 0 $rinfo->{domain}->{$domain}->{idDate}=$po->parse_iso8601($c->textContent());
148 } elsif ($n eq 'expirationDateTime')
149 {
150 0 $rinfo->{domain}->{$domain}->{exDate}=$po->parse_iso8601($c->textContent());
151 } elsif ($n eq 'lastDatabaseUpdateDateTime')
152 {
153 0 $rinfo->{domain}->{$domain}->{duDate}=$po->parse_iso8601($c->textContent());
154 ▶ } elsif ($n eq 'seeAlso' || $n eq 'iris:seeAlso')
Condition0%0/3
$n eq "seeAlso" or $n eq "iris:seeAlso"
l!l&&r!l&&!r
000
MC/DC0%0/2
$n eq "seeAlso" or $n eq "iris:seeAlso"
$n eq "seeAlso" $n eq "iris:seeAlso"
Truth table0%0/3
A or B
A= $n eq "seeAlso"B= $n eq "iris:seeAlso"
ABresult
1X1
011
000
155 {
156 0 carp('For domain '.$domain.' got a node <'.$n.'>, please report');
157 }
158 }
159  
160 0 $rinfo->{domain}->{$domain}->{temporary}=$temp;
161 0 $rinfo->{domain}->{$domain}->{status}=$po->create_local_object('status')->add(@s);
162 0 ▶ $rinfo->{domain}->{$domain}->{exist}=1 if $rinfo->{domain}->{$oname}->{result_status}->is_success() && $rinfo->{domain}->{$domain}->{status}->has_any(qw/active inactive/);
Branch: 1 branch
BranchTrueFalseTotal
if $rinfo->{"domain"}{$oname}{"result_status"}->is_success and $rinfo->{"domain"}{$domain}{"status"}->has_any("active", "inactive") 0 0 0
Condition0%0/3
$rinfo->{"domain"}{$oname}{"result_status"}->is_success and $rinfo->{"domain"}{$domain}{"status"}->has_any("active", "inactive")
!ll&&!rl&&r
000
MC/DC0%0/2
$rinfo->{"domain"}{$oname}{"result_status"}->is_success and $rinfo->{"domain"}{$domain}{"status"}->has_any("active", "inactive")
$rinfo->{"domain"}{$oname}{"result_status"}->is_success $rinfo->{"domain"}{$domain}{"status"}->has_any("active", "inactive")
Truth table0%0/3
A and B
A= $rinfo->{"domain"}{$oname}{"result_status"}->is_successB= $rinfo->{"domain"}{$domain}{"status"}->has_any("active", "inactive")
ABresult
0X0
100
111
163 } ## end of foreach on each resultSet
164 0 return;
165 }
166  
167 sub parse_status ## §3.1.1.1
168 {
169 0 ▶ my ($po,$node)=@_;
Subroutine parse_status: not called CC=7 SCAR=40.3
Pod undocumented
170 0 my %tmp=(name => $node->localname() );
171 0 my $ns=$node->namespaceURI();
172  
173 0 my $c=$node->getChildrenByTagNameNS($ns,'appliedDate'); ## 0..1
174 0 ▶ $tmp{applied_date}=$po->parse_iso8601($c->get_node(1)->textContent()) if $c->size();
Branch: 1 branch
BranchTrueFalseTotal
if $c->size 0 0 0
175  
176 0 $c=$node->getChildrenByTagNameNS($ns,'ticket'); ## 0..unbounded
177 0 ▶ $tmp{tickets}=[ map { $_->textContent() } $c->get_nodelist() ] if $c->size();
Branch: 1 branch
BranchTrueFalseTotal
if $c->size 0 0 0
178  
179 0 $c=$node->getChildrenByTagNameNS($ns,'description'); ## 0..unbounded
180 0 ▶ if ($c->size())
Branch: 1 branch
BranchTrueFalseTotal
if ($c->size) 0 0 0
181 {
182 0 my @t=map { { lang => $_->getAttribute('language'), msg => $_->textContent() } } $c->get_nodelist();
183 0 $tmp{description}=\@t;
184  
185 ## Useful fallback to mimick EPP ?
186 0 $tmp{lang}=$t[0]->{lang};
187 0 $tmp{msg}=$t[0]->{msg};
188 }
189  
190 0 $c=$node->getChildrenByTagNameNS($ns,'subStatus'); ## 0..unbounded ; not defined by RFC5144
191 0 ▶ $tmp{substatus}=[ map { { authority => $_->getAttribute('authority'), content => $_->textContent() } } $c->get_nodelist() ] if $c->size();
Branch: 1 branch
BranchTrueFalseTotal
if $c->size 0 0 0
192  
193 0 foreach my $a (qw/actor disposition scope/)
194 {
195 0 ▶ next unless $node->hasAttribute($a);
Branch: 1 branch
BranchTrueFalseTotal
unless $node->hasAttribute($a) 0 0 0
196 0 $tmp{$a}=$node->getAttribute($a);
197 }
198  
199 0 return \%tmp;
200 }
201  
202 ####################################################################################################
203 1 1;
« DRI/DRD.pm ↑ Summary DRI/Data/Contact/COZA.pm »