DRI/Protocol/EPP/Extensions/AT/Message.pm

filter: Statementstmt 14.2% 13 / 91 Branchbran 0.0% 0 / 48 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 44.4% 4 / 9 Podpod 0.0% 0 / 5 totaltotal 10.1% 17 / 168 CC 32 SCAR 66.5
CC
32
Cov
9%
parse_poll
992.0
pollreq
6.0
register_commands
2.0
CRAP 769.4
« DRI/Protocol/EPP/Extensions/PL/Message.pm ↑ Summary DRI/Protocol/EPP/Extensions/CAT/Domain.pm »
1 ## Domain Registry Interface, nic.at domain transactions extension
2 ## Contributed by Michael Braunoeder from NIC.AT <mib@nic.at>
3 ## Extended by Tonnerre Lombard
4 ##
5 ## Copyright (c) 2006-2008,2010,2013,2018 Patrick Mevzek <netdri@dotandco.com>. All rights reserved.
6 ##
7 ## This file is part of Net::DRI
8 ##
9 ## Net::DRI is free software; you can redistribute it and/or modify
10 ## it under the terms of the GNU General Public License as published by
11 ## the Free Software Foundation; either version 2 of the License, or
12 ## (at your option) any later version.
13 ##
14 ## See the LICENSE file that comes with this distribution for more details.
15 ####################################################################################################
16  
17 package Net::DRI::Protocol::EPP::Extensions::AT::Message;
18  
19 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use feature 'state';
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 =pod
26  
27 =head1 NAME
28  
29 Net::DRI::Protocol::EPP::Extensions::AT::Message - NIC.AT Message EPP Mapping for Net::DRI
30  
31 =head1 DESCRIPTION
32  
33 Please see the README file for details.
34  
35 =head1 SUPPORT
36  
37 For now, support questions should be sent to:
38  
39 E<lt>netdri@dotandco.comE<gt>
40  
41 Please also see the SUPPORT file in the distribution.
42  
43 =head1 SEE ALSO
44  
45 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
46  
47 =head1 AUTHOR
48  
49 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
50  
51 =head1 COPYRIGHT
52  
53 Copyright (c) 2006-2008,2010,2013,2018 Patrick Mevzek <netdri@dotandco.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 ($class,$version)=@_;
70  
71 0 my %tmp=(
72 atretrieve => [ \&pollreq, \&parse_poll ],
73 atdelete => [ \&pollack, undef ],
74 );
75  
76 0 return { 'message' => \%tmp };
77 }
78  
79 sub setup
80 0 ▶{
Subroutine setup: not called CC=1 SCAR=6.9
Pod undocumented
81 0 my ($class,$po,$version)=@_;
82  
83 0 state $ns = { 'at-ext-message' => 'http://www.nic.at/xsd/at-ext-message-1.0' };
84 0 $po->ns($ns);
85 0 return;
86 }
87  
88  
89 sub pollack
90 0 ▶{
Subroutine pollack: not called CC=1 SCAR=6.9
Pod undocumented
91 0 my ($epp,$msgid)=@_;
92 0 my $mes=$epp->message();
93 0 $mes->command([['poll',{op=>'ack',msgID=>$msgid}]]);
94 0 return;
95 }
96  
97 sub pollreq
98 0 ▶{
Subroutine pollreq: not called CC=2 SCAR=17.9
Pod undocumented
99 0 my ($epp,$msgid)=@_;
100 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('In EPP, you can not specify the message id you want to retrieve') if defined($msgid);
Branch: 1 branch
BranchTrueFalseTotal
if defined $msgid 0 0 0
101 0 my $mes=$epp->message();
102 0 $mes->command([['poll',{op=>'req'}]]);
103 0 return;
104 }
105  
106  
107 ## We take into account all parse functions, to be able to parse any result
108 sub parse_poll
109 0 ▶{
Subroutine parse_poll: not called CC=31 SCAR=69.0
Pod undocumented
110 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
111 0 my $mes=$po->message();
112 0 my $eppNS = $mes->ns('epp');
113 0 my $resNS = 'http://www.nic.at/xsd/at-ext-result-1.0';
114 0 my $msgNS = $mes->ns('at-ext-message');
115  
116 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
117 0 ▶ return if $mes->result_is('COMMAND_SUCCESSFUL_QUEUE_EMPTY');
Branch: 1 branch
BranchTrueFalseTotal
if $mes->result_is("COMMAND_SUCCESSFUL_QUEUE_EMPTY") 0 0 0
118  
119 0 my $msgid=$mes->msg_id();
120 0 $rinfo->{message}->{session}->{last_id}=$msgid;
121  
122 0 my $mesdata=$mes->get_response('at-ext-message','message');
123 0 $rinfo->{$otype}->{$oname}->{message}=$mesdata;
124 0 ▶ return unless $mesdata;
Branch: 1 branch
BranchTrueFalseTotal
unless $mesdata 0 0 0
125  
126 0 my ($epp,$rep,$ext,$ctag,@conds,@tags);
127 0 my $command=$mesdata->getAttribute('type');
128 0 @tags = $mesdata->getElementsByTagNameNS($msgNS, 'desc');
129  
130 0 ▶ $rinfo->{message}->{$msgid}->{content} = $tags[0]->getFirstChild()->getData() if @tags;
Branch: 1 branch
BranchTrueFalseTotal
if @tags 0 0 0
131 0 @tags = $mesdata->getElementsByTagNameNS($msgNS, 'data');
132 0 ▶ return unless @tags;
Branch: 1 branch
BranchTrueFalseTotal
unless @tags 0 0 0
133  
134 0 my $data = $tags[0];
135 0 @tags = $data->getElementsByTagNameNS($msgNS, 'entry');
136  
137 0 foreach my $entry (@tags)
138 {
139 0 ▶ next unless (defined($entry->getAttribute('name')));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $entry->getAttribute("name") 0 0 0
140  
141 0 ▶ if ($entry->getAttribute('name') eq 'objecttype')
Branch: 4 branches
BranchTrueFalseTotal
if ($entry->getAttribute('name') eq 'objecttype') { } 0 0 0
elsif ($entry->getAttribute('name') eq 'command') { } 0 0 0
elsif ($entry->getAttribute('name') eq 'objectname') { } 0 0 0
elsif ($entry->getAttribute('name') =~ /^(domain|contact|host)$/) { } 0 0 0
142 {
143 0 $rinfo->{message}->{$msgid}->{object_type} = $entry->getFirstChild()->getData();
144 }
145 elsif ($entry->getAttribute('name') eq 'command')
146 {
147 0 $rinfo->{message}->{$msgid}->{action} = $entry->getFirstChild()->getData();
148 }
149 elsif ($entry->getAttribute('name') eq 'objectname')
150 {
151 0 $rinfo->{message}->{$msgid}->{object_id} = $entry->getFirstChild()->getData();
152 }
153 elsif ($entry->getAttribute('name') =~ /^(domain|contact|host)$/)
154 {
155 0 my $text = $entry->getFirstChild();
156 0 $rinfo->{message}->{$msgid}->{object_type}=$1;
157 0 ▶ $rinfo->{message}->{$msgid}->{object_id} = $text->getData() if (defined($text));
Branch: 1 branch
BranchTrueFalseTotal
if defined $text 0 0 0
158 }
159 }
160  
161 0 ▶ $rinfo->{message}->{$msgid}->{action} ||= $command;
Condition0%0/3
$rinfo->{"message"}{$msgid}{"action"} ||= $command
l!l&&r!l&&!r
000
MC/DC0%0/2
$rinfo->{"message"}{$msgid}{"action"} ||= $command
$rinfo->{"message"}{$msgid}{"action"} $command
Truth table0%0/3
A ||= B
A= $rinfo->{"message"}{$msgid}{"action"}B= $command
ABresult
1X1
011
000
162 0 @tags = $data->getElementsByTagNameNS($eppNS, 'epp');
163 0 ▶ return unless (@tags);
Branch: 1 branch
BranchTrueFalseTotal
unless @tags 0 0 0
164 0 $epp = $tags[0];
165  
166 0 @tags = $epp->getElementsByTagNameNS($eppNS, 'response');
167 0 ▶ return unless (@tags);
Branch: 1 branch
BranchTrueFalseTotal
unless @tags 0 0 0
168 0 $rep = $tags[0];
169  
170 0 @tags = $rep->getElementsByTagNameNS($eppNS, 'extension');
171 0 ▶ return unless (@tags);
Branch: 1 branch
BranchTrueFalseTotal
unless @tags 0 0 0
172 0 $ext = $tags[0];
173  
174 0 foreach my $node ($ext->childNodes())
175 {
176 0 ▶ my $name = $node->localName() || $node->nodeName();
Condition0%0/3
$node->localName || $node->nodeName
l!l&&r!l&&!r
000
MC/DC0%0/2
$node->localName || $node->nodeName
$node->localName $node->nodeName
Truth table0%0/3
A || B
A= $node->localNameB= $node->nodeName
ABresult
1X1
011
000
177
178 0 ▶ if ($name eq 'conditions')
Branch: 2 branches
BranchTrueFalseTotal
if ($name eq 'conditions') { } 0 0 0
elsif ($name eq 'keydate') { } 0 0 0
179 {
180 0 @tags = $node->getElementsByTagNameNS($resNS, 'condition');
181  
182 0 foreach my $cond (@tags)
183 {
184 0 my %con;
185 0 my $c = $cond->getFirstChild();
186  
187 0 ▶ $con{code} = $cond->getAttribute('code') if ($cond->getAttribute('code'));
Branch: 1 branch
BranchTrueFalseTotal
if $cond->getAttribute("code") 0 0 0
188 0 ▶ $con{severity} = $cond->getAttribute('severity') if ($cond->getAttribute('severity'));
Branch: 1 branch
BranchTrueFalseTotal
if $cond->getAttribute("severity") 0 0 0
189  
190 0 ▶ while ($c)
Branch: 1 branch
BranchTrueFalseTotal
if ($c) 0 0 0
191 {
192 0 ▶ next unless ($c->nodeType() == 1); ## only for element nodes
Branch: 1 branch
BranchTrueFalseTotal
unless $c->nodeType == 1 0 0 0
193 0 ▶ my $cname = $c->localname() || $c->nodeName();
Condition0%0/3
$c->localname || $c->nodeName
l!l&&r!l&&!r
000
MC/DC0%0/2
$c->localname || $c->nodeName
$c->localname $c->nodeName
Truth table0%0/3
A || B
A= $c->localnameB= $c->nodeName
ABresult
1X1
011
000
194 0 ▶ next unless $cname;
Branch: 1 branch
BranchTrueFalseTotal
unless $cname 0 0 0
195
196 0 ▶ if ($cname =~ m/^(msg|details)$/)
Branch: 2 branches
BranchTrueFalseTotal
if ($cname =~ /^(msg|details)$/) { } 0 0 0
elsif ($cname eq 'attributes') { } 0 0 0
197 {
198 0 $con{$1} = $c->getFirstChild()->getData();
199 }
200 elsif ($cname eq 'attributes')
201 {
202 0 foreach my $attr ($c->getChildrenByTagNameNS($msgNS,'attr'))
203 {
204 0 my $attrname = $attr->getAttribute('name');
205 0 $con{'attr ' . $attrname} = $attr->getFirstChild()->getData();
206 }
207 }
208 0 } continue { $c = $c->getNextSibling(); }
209  
210 0 push(@conds, \%con);
211 }
212 }
213 elsif ($name eq 'keydate')
214 {
215 0 $rinfo->{message}->{$msgid}->{keydate} = $node->getFirstChild()->getData();
216 }
217 }
218  
219 0 $rinfo->{message}->{$msgid}->{conditions} = \@conds;
220 0 return;
221 }
222  
223 ####################################################################################################
224 1 1;
« DRI/Protocol/EPP/Extensions/PL/Message.pm ↑ Summary DRI/Protocol/EPP/Extensions/CAT/Domain.pm »