DRI/Protocol/EPP/Extensions/Nominet/Notifications.pm

filter: Statementstmt 10.8% 13 / 120 Branchbran 0.0% 0 / 74 Conditioncond 0.0% 0 / 18 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 36.3% 4 / 11 Podpod 0.0% 0 / 7 totaltotal 7.0% 17 / 242 CC 50 SCAR 63.5
CC
50
Cov
6%
parse
1056.0
parse_contact
42.0
parse_domainlist
30.0
CRAP 574.4
« DRI/Protocol/EPP/Extensions/NO/Message.pm ↑ Summary DRI/Protocol/EPP/Core/RegistryMessage.pm »
1 ## Domain Registry Interface, .UK EPP Notifications
2 ##
3 ## Copyright (c) 2008,2009,2013,2015 Patrick Mevzek <netdri@dotandco.com>. All rights reserved.
4 ## (c) 2013 Michael Holloway <michael@thedarkwinter.com>. All rights reserved.
5 ##
6 ## This file is part of Net::DRI
7 ##
8 ## Net::DRI is free software; you can redistribute it and/or modify
9 ## it under the terms of the GNU General Public License as published by
10 ## the Free Software Foundation; either version 2 of the License, or
11 ## (at your option) any later version.
12 ##
13 ## See the LICENSE file that comes with this distribution for more details.
14 ####################################################################################################
15  
16 package Net::DRI::Protocol::EPP::Extensions::Nominet::Notifications;
17  
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 Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use Net::DRI::Protocol::EPP::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 =pod
25  
26 =head1 NAME
27  
28 Net::DRI::Protocol::EPP::Extensions::Nominet::Notifications - .UK EPP Notifications for Net::DRI
29  
30 =head1 DESCRIPTION
31  
32 Please see the README file for details.
33  
34 =head1 SUPPORT
35  
36 For now, support questions should be sent to:
37  
38 E<lt>netdri@dotandco.comE<gt>
39  
40 Please also see the SUPPORT file in the distribution.
41  
42 =head1 SEE ALSO
43  
44 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
45  
46 =head1 AUTHOR
47  
48 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
49  
50 =head1 COPYRIGHT
51  
52 Copyright (c) 2008,2009,2013,2015 Patrick Mevzek <netdri@dotandco.com>.
53 (c) 2013 Michael Holloway <michael@thedarkwinter.com>.
54 All rights reserved.
55  
56 This program is free software; you can redistribute it and/or modify
57 it under the terms of the GNU General Public License as published by
58 the Free Software Foundation; either version 2 of the License, or
59 (at your option) any later version.
60  
61 See the LICENSE file that comes with this distribution for more details.
62  
63 =cut
64  
65 ####################################################################################################
66  
67 sub register_commands
68 0 ▶{
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
69 0 my %tmp=( notification => [ undef, \&parse ] );
70 0 return { 'message' => \%tmp };
71 }
72  
73 ####################################################################################################
74  
75 # Contact::info_parse fails so we do a small parse here and create the contact object
76 sub parse_contact
77 0 ▶{
Subroutine parse_contact: not called CC=6 SCAR=37.4
Pod undocumented
78 0 my ($po,$data,$ns,$rinfo) = @_;
79 0 ▶ return unless $data;
Branch: 1 branch
BranchTrueFalseTotal
unless $data 0 0 0
80 0 my $nsc=$po->message()->ns('contact');
81 0 my $id = Net::DRI::Util::xml_child_content($data,$ns,'id');
82 0 ▶ return unless $id;
Branch: 1 branch
BranchTrueFalseTotal
unless $id 0 0 0
83 0 my $cont = $po->create_local_object('contact')->srid($id);
84 0 my $pi = {};
85 0 Net::DRI::Protocol::EPP::Util::parse_postalinfo($po,$data->getChildrenByTagNameNS($ns,'postalInfo')->shift(),$pi);
86 0 foreach ($cont->attributes()) {
87 0 ▶ next if $_ eq 'srid';
Branch: 1 branch
BranchTrueFalseTotal
if $_ eq "srid" 0 0 0
88 0 $cont->$_(Net::DRI::Util::xml_child_content($data,$ns,$_));
89 0 ▶ $cont->$_($pi->{$_}) if $pi->{$_};
Branch: 1 branch
BranchTrueFalseTotal
if $pi->{$_} 0 0 0
90 }
91 0 return $cont;
92 }
93  
94 sub parse_domainlist
95 0 ▶{
Subroutine parse_domainlist: not called CC=5 SCAR=34.0
Pod undocumented
96 0 my ($po,$data,$ns,$rinfo) = @_;
97 0 ▶ return unless $data;
Branch: 1 branch
BranchTrueFalseTotal
unless $data 0 0 0
98 0 my @d;
99 0 ▶ return unless my $dl = $data->getChildrenByTagNameNS($ns,'domainListData')->shift();
Branch: 1 branch
BranchTrueFalseTotal
unless my $dl = $data->getChildrenByTagNameNS($ns, "domainListData")->shift 0 0 0
100 0 foreach my $el (Net::DRI::Util::xml_list_children($dl))
101 {
102 0 my ($name,$c)=@$el;
103 0 ▶ push @d,$c->textContent() if $name eq 'domainName';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "domainName" 0 0 0
104 }
105 0 return \@d;
106 }
107  
108 sub parse_rcdomainlist
109 0 ▶{
Subroutine parse_rcdomainlist: not called CC=4 SCAR=30.0
Pod undocumented
110 0 my ($po,$data,$ns,$rinfo) = @_;
111 0 ▶ return unless $data;
Branch: 1 branch
BranchTrueFalseTotal
unless $data 0 0 0
112 0 my $mes = $po->message();
113 0 my $nsd=$mes->ns('domain');
114 0 ▶ return unless my $dl =$data->getChildrenByTagNameNS($ns,'domainListData')->shift();
Branch: 1 branch
BranchTrueFalseTotal
unless my $dl = $data->getChildrenByTagNameNS($ns, "domainListData")->shift 0 0 0
115 0 my (@d,$clid);
116 0 foreach my $d ($dl->getChildrenByTagNameNS($nsd,'infData'))
117 {
118 0 push @d,Net::DRI::Util::xml_child_content($d,$nsd,'name');
119 0 $clid=Net::DRI::Util::xml_child_content($d,$nsd,'clID');
120 ## TODO : parse other keys, using Domain::info_parse stuff extracted into some sort of parse_infdata
121 }
122 0 return ($clid,\@d);
123 }
124  
125 sub parse_hostlist
126 0 ▶{
Subroutine parse_hostlist: not called CC=5 SCAR=34.0
Pod undocumented
127 0 my ($po,$data,$ns,$rinfo) = @_;
128 0 ▶ return unless $data;
Branch: 1 branch
BranchTrueFalseTotal
unless $data 0 0 0
129 0 my @h;
130 0 ▶ return unless my $hl = $data->getChildrenByTagNameNS($ns,'hostListData')->shift();
Branch: 1 branch
BranchTrueFalseTotal
unless my $hl = $data->getChildrenByTagNameNS($ns, "hostListData")->shift 0 0 0
131 0 foreach my $el (Net::DRI::Util::xml_list_children($hl))
132 {
133 0 my ($name,$c)=@$el;
134 0 ▶ next unless $name eq 'hostObj';
Branch: 1 branch
BranchTrueFalseTotal
unless $name eq "hostObj" 0 0 0
135 0 my $ho = $c->textContent();
136 0 $ho =~ s/\.$//; # remove trailing .
137 0 push @h,$ho;
138 }
139 0 return \@h;
140 }
141  
142 ####################################################################################################
143  
144 sub parse
145 0 ▶{
Subroutine parse: not called CC=32 SCAR=69.6
Pod undocumented
146 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
147 0 my $mes=$po->message();
148 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
149 0 my $msgid=$oname=$mes->msg_id();
150 0 ▶ return unless (defined($msgid) && $msgid);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $msgid and $msgid 0 0 0
Condition0%0/3
defined $msgid and $msgid
!ll&&!rl&&r
000
MC/DC0%0/2
defined $msgid and $msgid
defined $msgid $msgid
Truth table0%0/3
A and B
A= defined $msgidB= $msgid
ABresult
0X0
100
111
151  
152 0 my ($n,$nsstr,$data);
153 0 my %actions=(
154 hosts_cancelled => { n=>'hostCancData' },
155 contact_deleted => { n=>'contactDelData' },
156 registrar_change => { n=> 'rcData'}, # also handshake_request, changed later
157 registrant_change=> { n=> 'trnData'},
158 registrant_change_auth_request => { n=> 'trnAuthData'}, # should probably be dealt with as a handshake_request, but no change of Tag
159 domains_released => { n=> 'relData'}, # also handshake_rejected, changed later
160 domains_suspended => { n=> 'suspData'},
161 cancelled => { n=> 'cancData', ot=>'domain'},
162 fail => { n=> 'domainFailData', ot=>'domain'},
163 poor_quality => { n=> 'processData'},
164 abuse => { n=> 'infData', ns=>'nom-abuse-feed'},
165 #info => { n=> 'infData', ns =>'contact', ot => 'contact'},# this is processed correctly by contact::info_parse so dont need to do anything here
166 #create => {n => 'creData', ns => 'domain', 'ot => 'domain'}, # this is processed correctly by domain::create_parse so dont need to do anything here
167 );
168  
169 0 ▶ while (my ($ac, $nd) = each(%actions))
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %actions) 0 0 0
170 {
171 0 $n = $nd->{n};
172 0 ▶ $nsstr = ($nd->{ns})?$nd->{ns}:'std-notifications';
Branch: 1 branch
BranchTrueFalseTotal
$nd->{'ns'} ? : 0 0 0
173 0 ▶ $otype = ($nd->{ot}) ? ($nd->{ot}):'message';
Branch: 1 branch
BranchTrueFalseTotal
$nd->{'ot'} ? : 0 0 0
174 0 ▶ next unless ( ($data=$mes->get_response($nsstr,$n)) && (my $ns=$mes->ns($nsstr)));
Branch: 1 branch
BranchTrueFalseTotal
unless $data = $mes->get_response($nsstr, $n) and my $ns = $mes->ns($nsstr) 0 0 0
Condition0%0/3
$data = $mes->get_response($nsstr, $n) and my $ns = $mes->ns($nsstr)
!ll&&!rl&&r
000
MC/DC0%0/2
$data = $mes->get_response($nsstr, $n) and my $ns = $mes->ns($nsstr)
$data = $mes->get_response($nsstr, $n) my $ns = $mes->ns($nsstr)
Truth table0%0/3
A and B
A= $data = $mes->get_response($nsstr, $n)B= my $ns = $mes->ns($nsstr)
ABresult
0X0
100
111
175  
176 # abuse feed seems to come from an old Nominet EPP schema and has to be treated differently - this is likely to change some day
177 0 ▶ if ($ac eq 'abuse')
Branch: 1 branch
BranchTrueFalseTotal
if ($ac eq "abuse") 0 0 0
178 {
179 0 $oaction = $rinfo->{$otype}->{$oname}->{action}=$ac;
180 0 foreach my $f (qw/key activity source hostname url date ip nameserver dnsAdmin target wholeDomain/)
181 0 { $rinfo->{$otype}->{$oname}->{$f}=Net::DRI::Util::xml_child_content($data,$ns,$f); }
182 0 return;
183 }
184  
185 # set oname/exist for domain
186 0 ▶ if ($otype eq 'domain')
Branch: 1 branch
BranchTrueFalseTotal
if ($otype eq "domain") 0 0 0
187 {
188 0 $oname=Net::DRI::Util::xml_child_content($data,$ns,'domainName');
189 0 $rinfo->{$otype}->{$oname}->{exist}=0;
190 }
191  
192 # action
193 0 $oaction = $rinfo->{$otype}->{$oname}->{action}=$ac;
194  
195 # plain text fields
196 0 $rinfo->{$otype}->{$oname}->{orig}=Net::DRI::Util::xml_child_content($data,$ns,'orig');
197 0 $rinfo->{$otype}->{$oname}->{reason}=Net::DRI::Util::xml_child_content($data,$ns,'reason');
198 0 $rinfo->{$otype}->{$oname}->{registrar_to}=Net::DRI::Util::xml_child_content($data,$ns,'registrarTag');
199 0 $rinfo->{$otype}->{$oname}->{contact} = Net::DRI::Util::xml_child_content($data,$ns,'contactId');
200 0 $rinfo->{$otype}->{$oname}->{account_from}=Net::DRI::Util::xml_child_content($data,$ns,'oldAccountId');
201 0 $rinfo->{$otype}->{$oname}->{account_to}=Net::DRI::Util::xml_child_content($data,$ns,'accountId');
202 0 $rinfo->{$otype}->{$oname}->{process_type} = Net::DRI::Util::xml_child_content($data,$ns,'processType');
203 0 ▶ $rinfo->{$otype}->{$oname}->{poor_quality_stage}=$data->getAttribute('stage') if $data->hasAttribute('stage');
Branch: 1 branch
BranchTrueFalseTotal
if $data->hasAttribute("stage") 0 0 0
204 0 $rinfo->{$otype}->{$oname}->{case_id}=Net::DRI::Util::xml_child_content($data,$ns,'caseId');
205  
206  
207 # relData (release/handshake rejected has account data)
208 0 ▶ if (($n eq 'relData') && (my $acid=$data->getChildrenByTagNameNS($ns,'accountId')->shift()))
Branch: 1 branch
BranchTrueFalseTotal
if ($n eq "relData" and my $acid = $data->getChildrenByTagNameNS($ns, "accountId")->shift) 0 0 0
Condition0%0/3
$n eq "relData" and my $acid = $data->getChildrenByTagNameNS($ns, "accountId")->shift
!ll&&!rl&&r
000
MC/DC0%0/2
$n eq "relData" and my $acid = $data->getChildrenByTagNameNS($ns, "accountId")->shift
$n eq "relData" my $acid = $data->getChildrenByTagNameNS($ns, "accountId")->shift
Truth table0%0/3
A and B
A= $n eq "relData"B= my $acid = $data->getChildrenByTagNameNS($ns, "accountId")->shift
ABresult
0X0
100
111
209 {
210 0 $rinfo->{$otype}->{$oname}->{account_id}=$acid->textContent();
211 0 ▶ $rinfo->{$otype}->{$oname}->{action}='handshake_rejected' unless $acid->hasAttribute('moved'); # NOT VERIFIED - but since we don't have the message content <msg> we cant determine the action here
Branch: 1 branch
BranchTrueFalseTotal
unless $acid->hasAttribute("moved") 0 0 0
212 0 ▶ $rinfo->{$otype}->{$oname}->{account_moved}=$acid->getAttribute('moved') eq 'Y'? 1 : 0 if $acid->hasAttribute('moved');
Branch: 2 branches
BranchTrueFalseTotal
if $acid->hasAttribute("moved") 0 0 0
$acid->getAttribute('moved') eq 'Y' ? : 0 0 0
213 0 $rinfo->{$otype}->{$oname}->{registrar_from}=Net::DRI::Util::xml_child_content($data,$ns,'from');
214 }
215  
216 # if casId then this is a handshake_request
217 0 ▶ if ( ($n eq 'rcData') && ($data->getChildrenByTagNameNS($ns,'caseId')->size()) )
Branch: 1 branch
BranchTrueFalseTotal
if ($n eq "rcData" and $data->getChildrenByTagNameNS($ns, "caseId")->size) 0 0 0
Condition0%0/3
$n eq "rcData" and $data->getChildrenByTagNameNS($ns, "caseId")->size
!ll&&!rl&&r
000
MC/DC0%0/2
$n eq "rcData" and $data->getChildrenByTagNameNS($ns, "caseId")->size
$n eq "rcData" $data->getChildrenByTagNameNS($ns, "caseId")->size
Truth table0%0/3
A and B
A= $n eq "rcData"B= $data->getChildrenByTagNameNS($ns, "caseId")->size
ABresult
0X0
100
111
218 {
219 0 $rinfo->{$otype}->{$oname}->{action}='handshake_request';
220 0 $rinfo->{$otype}->{$oname}->{case_id}=Net::DRI::Util::xml_child_content($data,$ns,'caseId');
221 }
222 # rcData return different data structures
223 0 ▶ ($rinfo->{$otype}->{$oname}->{registrar_from},$rinfo->{$otype}->{$oname}->{domains}) = parse_rcdomainlist($po,$data,$ns,$rinfo) if ($n eq 'rcData');
Branch: 1 branch
BranchTrueFalseTotal
if $n eq "rcData" 0 0 0
224  
225 # domain / host lists
226 0 ▶ $rinfo->{$otype}->{$oname}->{domains}=parse_domainlist($po,$data,$ns,$rinfo) unless ($n eq 'rcData');
Branch: 1 branch
BranchTrueFalseTotal
unless $n eq "rcData" 0 0 0
227 0 $rinfo->{$otype}->{$oname}->{hosts}=parse_hostlist($po,$data,$ns,$rinfo);
228  
229 # contact data
230 0 my $nsc=$mes->ns('contact');
231 0 ▶ if (my $cont=parse_contact($po,$data->getChildrenByTagNameNS($nsc,'infData')->shift(),$nsc,$rinfo))
Branch: 1 branch
BranchTrueFalseTotal
if (my $cont = parse_contact($po, $data->getChildrenByTagNameNS($nsc, "infData")->shift, $nsc, $rinfo)) 0 0 0
232 {
233 0 $rinfo->{$otype}->{$oname}->{contact}=$cont->srid();
234 0 ▶ $rinfo->{$otype}->{$oname}->{contact_data}=$cont if $n eq 'rcData';
Branch: 1 branch
BranchTrueFalseTotal
if $n eq "rcData" 0 0 0
235 0 ▶ $rinfo->{message}->{$msgid}->{poor_quality_account}=$cont if $n eq 'processData';
Branch: 1 branch
BranchTrueFalseTotal
if $n eq "processData" 0 0 0
236 }
237  
238 # dates
239 0 my $d;
240 0 ▶ if ( ($d=$data->getChildrenByTagNameNS($ns,'cancelDate')) && ($d->size()) )
Branch: 1 branch
BranchTrueFalseTotal
if ($d = $data->getChildrenByTagNameNS($ns, "cancelDate") and $d->size) 0 0 0
Condition0%0/3
$d = $data->getChildrenByTagNameNS($ns, "cancelDate") and $d->size
!ll&&!rl&&r
000
MC/DC0%0/2
$d = $data->getChildrenByTagNameNS($ns, "cancelDate") and $d->size
$d = $data->getChildrenByTagNameNS($ns, "cancelDate") $d->size
Truth table0%0/3
A and B
A= $d = $data->getChildrenByTagNameNS($ns, "cancelDate")B= $d->size
ABresult
0X0
100
111
241 {
242 0 ▶ $rinfo->{$otype}->{$msgid}->{poor_quality_cancel}=$po->parse_iso8601($d->get_node(1)->textContent()) if $oaction eq 'poor_quality';
Branch: 1 branch
BranchTrueFalseTotal
if $oaction eq "poor_quality" 0 0 0
243 0 $rinfo->{$otype}->{$msgid}->{cancel_date}=$po->parse_iso8601($d->get_node(1)->textContent());
244 }
245 0 ▶ if ( ($d=$data->getChildrenByTagNameNS($ns,'suspendDate')) && ($d->size()) )
Branch: 1 branch
BranchTrueFalseTotal
if ($d = $data->getChildrenByTagNameNS($ns, "suspendDate") and $d->size) 0 0 0
Condition0%0/3
$d = $data->getChildrenByTagNameNS($ns, "suspendDate") and $d->size
!ll&&!rl&&r
000
MC/DC0%0/2
$d = $data->getChildrenByTagNameNS($ns, "suspendDate") and $d->size
$d = $data->getChildrenByTagNameNS($ns, "suspendDate") $d->size
Truth table0%0/3
A and B
A= $d = $data->getChildrenByTagNameNS($ns, "suspendDate")B= $d->size
ABresult
0X0
100
111
246 {
247 0 $rinfo->{$otype}->{$msgid}->{poor_quality_suspend}=$po->parse_iso8601($d->get_node(1)->textContent());
248 }
249  
250 # cleanup
251 0 my %onames = %{$rinfo->{$otype}->{$oname}};
252 0 foreach ( keys %onames)
253 {
254 0 ▶ delete $rinfo->{$otype}->{$oname}->{$_} unless defined $rinfo->{$otype}->{$oname}->{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $rinfo->{$otype}{$oname}{$_} 0 0 0
255 }
256 }
257 0 return;
258 }
259  
260  
261 sub ammed_account
262 0 ▶{
Subroutine ammed_account: not called CC=3 SCAR=24.8
Pod undocumented
263 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
264 0 my $mes=$po->message();
265 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
266 0 my $infdata=$mes->get_response('nom-abuse-feed','infData');
267 0 ▶ return unless defined $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $infdata 0 0 0
268 0 return;
269 }
270  
271 ####################################################################################################
272 1 1;
« DRI/Protocol/EPP/Extensions/NO/Message.pm ↑ Summary DRI/Protocol/EPP/Core/RegistryMessage.pm »