DRI/Protocol/IRIS/Message.pm

filter: Statementstmt 40.0% 26 / 65 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 53.3% 8 / 15 Podpod 14.2% 1 / 7 totaltotal 31.5% 35 / 111 CC 11 SCAR 21.4
CC
11
Cov
31%
ns
20.0
new
12.0
nsattrs
12.0
CRAP 8.5
« DRI/DRD/IIS.pm ↑ Summary DRI/Protocol/EPP/Extensions/NeuLevel/UIN.pm »
1 ## Domain Registry Interface, IRIS Message
2 ##
3 ## Copyright (c) 2008-2010,2013,2018 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::Message;
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 XML::LibXML ();
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 1 ▶use Net::DRI::Protocol::ResultStatus;
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::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 1 ▶use base qw(Class::Accessor::Chained::Fast Net::DRI::Protocol::Message);
Subroutine BEGIN: called CC=1 SCAR=0.0
28 1 __PACKAGE__->mk_accessors(qw/version tid authority options search results/);
29  
30 =pod
31  
32 =head1 NAME
33  
34 Net::DRI::Protocol::IRIS::Message - IRIS Message for Net::DRI
35  
36 =head1 DESCRIPTION
37  
38 Please see the README file for details.
39  
40 =head1 SUPPORT
41  
42 For now, support questions should be sent to:
43  
44 E<lt>netdri@dotandco.comE<gt>
45  
46 Please also see the SUPPORT file in the distribution.
47  
48 =head1 SEE ALSO
49  
50 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
51  
52 =head1 AUTHOR
53  
54 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
55  
56 =head1 COPYRIGHT
57  
58 Copyright (c) 2008-2010,2013,2018 Patrick Mevzek <netdri@dotandco.com>.
59 All rights reserved.
60  
61 This program is free software; you can redistribute it and/or modify
62 it under the terms of the GNU General Public License as published by
63 the Free Software Foundation; either version 2 of the License, or
64 (at your option) any later version.
65  
66 See the LICENSE file that comes with this distribution for more details.
67  
68 =cut
69  
70 ####################################################################################################
71  
72 sub new
73 0 ▶{
Subroutine new: not called CC=3 SCAR=24.8
Pod documented
74 0 my $class=shift;
75 0 my $trid=shift;
76  
77 0 my $self={ ns => {}, options => {} };
78 0 bless($self,$class);
79  
80 0 ▶ $self->tid($trid) if defined $trid && length $trid;
Branch: 1 branch
BranchTrueFalseTotal
if defined $trid and length $trid 0 0 0
Condition0%0/3
defined $trid and length $trid
!ll&&!rl&&r
000
MC/DC0%0/2
defined $trid and length $trid
defined $trid length $trid
Truth table0%0/3
A and B
A= defined $tridB= length $trid
ABresult
0X0
100
111
81 0 return $self;
82 }
83  
84 sub ns
85 0 ▶{
Subroutine ns: not called CC=4 SCAR=30.0
Pod undocumented
86 0 my ($self,$what)=@_;
87 0 ▶ return $self->{ns} unless defined $what;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $what 0 0 0
88  
89 0 ▶ if (ref $what eq 'HASH')
Branch: 1 branch
BranchTrueFalseTotal
if (ref $what eq "HASH") 0 0 0
90 {
91 0 $self->{ns}=$what;
92 0 return $what;
93 }
94 0 ▶ return unless exists $self->{ns}->{$what};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"ns"}{$what} 0 0 0
95 0 return $self->{ns}->{$what}->[0];
96 }
97  
98 sub nsattrs
99 0 ▶{
Subroutine nsattrs: not called CC=3 SCAR=24.8
Pod undocumented
100 0 my ($self,$what)=@_;
101 0 ▶ return unless defined $what && exists $self->{ns}->{$what};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $what and exists $self->{"ns"}{$what} 0 0 0
Condition0%0/3
defined $what and exists $self->{"ns"}{$what}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $what and exists $self->{"ns"}{$what}
defined $what exists $self->{"ns"}{$what}
Truth table0%0/3
A and B
A= defined $whatB= exists $self->{"ns"}{$what}
ABresult
0X0
100
111
102 0 my @n=@{$self->{ns}->{$what}};
103 0 return ($n[0],$n[0],$n[1]);
104 }
105  
106 0 ▶sub is_success { return 1; } ## TODO
Subroutine is_success: not called CC=1 SCAR=6.9
Pod undocumented
107  
108 0 ▶sub result_status { return Net::DRI::Protocol::ResultStatus->new_success(); }; ## There is no message-level result_status, only at resultSet level, hence global success
Subroutine result_status: not called CC=1 SCAR=6.9
Pod undocumented
109  
110 sub as_string
111 0 ▶{
Subroutine as_string: not called CC=3 SCAR=24.8
Pod undocumented
112 0 my ($self)=@_;
113  
114 ## TODO : handle other top nodes, see RFC4991, + control node in <request>
115 0 ▶ Net::DRI::Exception::err_assert('Net::DRI::Protocol::IRIS::Message can only handle <request> operations for now') unless defined $self->search();
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->search 0 0 0
116 0 my @d;
117 0 push @d,'<?xml version="1.0" encoding="UTF-8" standalone="no"?>';
118 0 push @d,sprintf('<request xmlns="%s">',$self->nsattrs('iris1'));
119  
120 0 foreach my $search (@{$self->search()}) ## $search is a refhash comme il faut
121 {
122 0 push @d,'<searchSet>';
123 ## We do not handle bags for now
124 ## Only lookupEntity is supported for now
125 0 push @d,Net::DRI::Util::xml_write(['lookupEntity',$search]);
126 0 push @d,'</searchSet>';
127 }
128  
129 0 push @d,'</request>';
130 0 return join('',@d);
131 }
132  
133 # RFC3981 §4.2
134 sub parse
135 0 ▶{
Subroutine parse: not called CC=2 SCAR=17.9
Pod undocumented
136 0 my ($self,$dc,$rinfo)=@_;
137  
138 0 my $parser=XML::LibXML->new();
139 0 my $doc=$parser->parse_string($dc->as_string());
140 0 my $root=$doc->getDocumentElement();
141 ## TODO: handle RFC4991 other types of responses
142 0 ▶ Net::DRI::Exception->die(0,'protocol/IRIS',1,'Unsuccessfull parse, root element is not response') unless ($root->localname() eq 'response');
Branch: 1 branch
BranchTrueFalseTotal
unless $root->localname eq "response" 0 0 0
143  
144 ## We currently do not parse the <reaction> node (in reply to a <control> which we do never send for now, see §4.3.8) and <bags> (see §4.4)
145 ## We take care only of the <resultSet> nodes
146 0 $self->results(scalar($root->getChildrenByTagNameNS($self->ns('iris1'),'resultSet')));
147 0 return;
148 }
149  
150 ####################################################################################################
151 1 1;
« DRI/DRD/IIS.pm ↑ Summary DRI/Protocol/EPP/Extensions/NeuLevel/UIN.pm »