EPP/CoreNic.pm

filter: Statementstmt 8.2% 13 / 158 Branchbran 0.0% 0 / 54 Conditioncond 0.0% 0 / 13 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 33.3% 4 / 12 Podpod 100% 8 / 8 totaltotal 9.8% 25 / 253 SCAR 75.0
CC
46
Cov
6%
make_request
182.0
get_domain_info_rdata
156.0
cont_from_xml
110.0
CRAP 1816.0
« EPP/Test/VerisignCore.pm ↑ Summary EPP/Flexireg.pm »
1 package IO::EPP::CoreNic;
2  
3 =encoding utf8
4  
5 =head1 NAME
6  
7 IO::EPP::CoreNic
8  
9 =head1 SYNOPSIS
10  
11 use IO::EPP::CoreNic;
12  
13 # Parameters for IO::Socket::SSL
14 my %sock_params = (
15 PeerHost => 'epp.nic.xn--80aswg',
16 PeerPort => 700,
17 # without certificate
18 Timeout => 30,
19 );
20  
21 # Create object, get greeting and call login()
22 my $conn = IO::EPP::CoreNic->new( {
23 user => 'login',
24 pass => 'xxxx',
25 sock_params => \%sock_params,
26 test_mode => 0, # real connect
27 } );
28  
29 # Check domain
30 my ( $answ, $code, $msg ) = $conn->check_domains( { domains => [ 'xn--d1acufc.xn--80aswg' ] } );
31  
32 # Call logout() and destroy object
33 undef $conn;
34  
35 =head1 DESCRIPTION
36  
37 Module for work with CoreNic domains
38  
39 Feature: in all responses incomplete xml schemas, for example, instead of C<< <domain:update> >> is written C<< <update> >>
40  
41 =cut
42  
43 1 ▶use IO::EPP::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 1 ▶use parent qw( IO::EPP::Base );
Subroutine BEGIN: called CC=1 SCAR=0.0
45  
46 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
48  
49  
50 sub make_request {
51 0 ▶ my ( $action, $params ) = @_;
Subroutine make_request: not called CC=13 SCAR=52.0
Pod documented
52  
53 0 $params = IO::EPP::Base::recursive_utf8_unflaged( $params );
54  
55 0 ▶ if ( !$params->{tld} && $params->{dname} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $params->{"tld"} and $params->{"dname"}) 0 0 0
Condition0%0/3
not $params->{"tld"} and $params->{"dname"}
!ll&&!rl&&r
000
MC/DC0%0/2
not $params->{"tld"} and $params->{"dname"}
not $params->{"tld"} $params->{"dname"}
Truth table0%0/3
not(A) and B
A= not $params->{"tld"}B= $params->{"dname"}
ABresult
0X0
100
111
56 0 ( $params->{tld} ) = $params->{dname} =~ /^[0-9a-z\-]+\.(.+)$/;
57 }
58  
59 0 my ( $self, $code, $msg, $answ );
60  
61 0 ▶ unless ( $params->{conn} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{'conn'}) { } 0 0 0
62 0 ▶ $params->{sock_params}{PeerHost} ||= 'epp.nic.xn--80aswg';
Condition0%0/2
$params->{"sock_params"}{"PeerHost"} ||= "epp.nic.xn--80aswg"
l!l
00
MC/DC0%0/1
$params->{"sock_params"}{"PeerHost"} ||= "epp.nic.xn--80aswg"
$params->{"sock_params"}{"PeerHost"}
Truth table0%0/2
A
A= $params->{"sock_params"}{"PeerHost"}
Aresult
11
00
63 0 ▶ $params->{sock_params}{PeerPort} ||= 700;
Condition0%0/2
$params->{"sock_params"}{"PeerPort"} ||= 700
l!l
00
MC/DC0%0/1
$params->{"sock_params"}{"PeerPort"} ||= 700
$params->{"sock_params"}{"PeerPort"}
Truth table0%0/2
A
A= $params->{"sock_params"}{"PeerPort"}
Aresult
11
00
64  
65 0 ( $self, $code, $msg ) = __PACKAGE__->new( $params );
66  
67 0 ▶ unless ( $code and $code == 1000 ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code and $code == 1000) 0 0 0
Condition0%0/3
$code and $code == 1000
!ll&&!rl&&r
000
MC/DC0%0/2
$code and $code == 1000
$code $code == 1000
Truth table0%0/3
A and B
A= $codeB= $code == 1000
ABresult
0X0
100
111
68 0 goto END_MR;
69 }
70 }
71 else {
72 0 $self = $params->{conn};
73 }
74  
75  
76 0 $self->{critical_error} = '';
77  
78 0 ▶ if ( $self->can( $action ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can($action)) { } 0 0 0
79 0 ( $answ, $code, $msg ) = $self->$action( $params );
80 }
81 else {
82 0 $msg = "undefined command <$action>, request cancelled";
83 0 $code = 0;
84 }
85  
86  
87 END_MR:
88  
89 0 ▶ $msg .= '; ' . $self->{critical_error} if $self->{critical_error};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"critical_error"} 0 0 0
90  
91 0 my $full_answ = "code: $code\nmsg: $msg";
92  
93 0 ▶ $answ = {} unless $answ && ref $answ;
Branch: 1 branch
BranchTrueFalseTotal
unless $answ and ref $answ 0 0 0
Condition0%0/3
$answ and ref $answ
!ll&&!rl&&r
000
MC/DC0%0/2
$answ and ref $answ
$answ ref $answ
Truth table0%0/3
A and B
A= $answB= ref $answ
ABresult
0X0
100
111
94  
95 0 $answ->{code} = $code;
96 0 $answ->{msg} = $msg;
97  
98 0 ▶ return wantarray ? ( $answ, $full_answ, $self ) : $answ;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
99 }
100  
101  
102 =head1 METHODS
103  
104 Next, those functions are redefined in which the provider has additions to the EPP
105  
106 =head2 login
107  
108 Ext params for login,
109  
110 INPUT: new password for change
111  
112 =cut
113  
114 sub login {
115 0 ▶ my ( $self, $pw ) = @_;
Subroutine login: not called CC=1 SCAR=6.9
Pod documented
116  
117 0 my ( $svcs, $extension );
118  
119 0 $svcs = '
120 <objURI>urn:ietf:params:xml:ns:host-1.0</objURI>
121 <objURI>urn:ietf:params:xml:ns:domain-1.0</objURI>
122 <objURI>urn:ietf:params:xml:ns:contact-1.0</objURI>';
123 0 $extension = '
124 <extURI>urn:ietf:params:xml:ns:rgp-1.0</extURI>
125 <extURI>http://xmlns.corenic.net/epp/idn-1.0</extURI>
126 <extURI>urn:ietf:params:xml:ns:launch-1.0</extURI>
127 <extURI>urn:ietf:params:xml:ns:secDNS-1.1</extURI>';
128  
129 # <extURI>http://xmlns.corenic.net/epp/auction-1.0</extURI>
130  
131 0 return $self->SUPER::login( $pw, $svcs, $extension );
132 }
133  
134  
135 sub cont_from_xml {
136 0 ▶ my ( undef, $rdata ) = @_;
Subroutine cont_from_xml: not called CC=10 SCAR=47.0
Pod documented
137  
138 0 my %cont;
139  
140 0 ( $cont{cont_id} ) = $rdata =~ /<id>([^<>]+)<\/id>/;
141  
142 0 ( $cont{roid} ) = $rdata =~ /<roid>([^<>]+)<\/roid>/;
143  
144 0 my @atypes = ( 'int', 'loc' );
145 0 foreach my $atype ( @atypes ) {
146 0 my ( $postal ) = $rdata =~ /<postalInfo type="$atype">(.+?)<\/postalInfo>/;
147  
148 0 ▶ next unless $postal;
Branch: 1 branch
BranchTrueFalseTotal
unless $postal 0 0 0
149  
150 0 ( $cont{$atype}{name} ) = $postal =~ /<name>([^<>]+)<\/name>/;
151  
152 0 ( $cont{$atype}{company} ) = $rdata =~ /<org>([^<>]*)<\/org>/;
153  
154 0 $cont{$atype}{addr} = join(', ', $postal =~ /<street>([^<>]*)<\/street>/ );
155  
156 0 ( $cont{$atype}{city} ) = $postal =~ /<city>([^<>]*)<\/city>/;
157  
158 0 ( $cont{$atype}{'state'} ) = $postal =~ /<sp>([^<>]*)<\/sp>/;
159  
160 0 ( $cont{$atype}{postcode} ) = $postal =~ /<pc>([^<>]*)<\/pc>/;
161  
162 0 ( $cont{$atype}{country_code} ) = $postal =~ /<cc>([A-Z]+)<\/cc>/;
163 }
164  
165 0 ( $cont{phone} ) = $rdata =~ /<voice[^<>]*>([0-9+.]*)<\/voice>/;
166  
167 0 ( $cont{fax} ) = $rdata =~ /<fax[^<>]*>([0-9+.]*)<\/fax>/;
168  
169 0 ( $cont{email} ) = $rdata =~ /<email>([^<>]+)<\/email>/;
170  
171 # <status s="linked"/>
172 0 my @ss = $rdata =~ /<status s="([^"]+)"\/>/g;
173 0 $cont{statuses}{$_} = '+' for @ss;
174  
175 0 ▶ if ( $rdata =~ /<authInfo><pw>(.+?)<\/pw>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rdata =~ m[<authInfo><pw>(.+?)</pw>]) 0 0 0
176 0 $cont{authinfo} = $1;
177 }
178  
179 0 my ( $visible ) = $rdata =~ /<contact:disclose flag=['"](\d)['"]>/;
180 0 ▶ $cont{pp_flag} = $visible ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$visible ? : 0 0 0
181  
182 0 my %id = %IO::EPP::Base::id;
183 0 foreach my $k ( keys %id ) {
184 0 ▶ if ( $rdata =~ /<$k>([^<>]+)<\/$k>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rdata =~ m[<$k>([^<>]+)</$k>]) 0 0 0
185 0 $cont{$id{$k}} = $1;
186 }
187 }
188  
189 0 my %dt = %IO::EPP::Base::dt;
190 0 foreach my $k ( keys %dt ) {
191 0 ▶ if ( $rdata =~ /<$k>([^<>]+)<\/$k>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rdata =~ m[<$k>([^<>]+)</$k>]) 0 0 0
192 0 $cont{$dt{$k}} = $1;
193  
194 0 $cont{$dt{$k}} =~ s/T/ /;
195 0 $cont{$dt{$k}} =~ s/\.\d+Z$//;
196 }
197 }
198  
199 0 return \%cont;
200 }
201  
202  
203 sub update_contact {
204 0 ▶ my ( $self, $params ) = @_;
Subroutine update_contact: not called CC=2 SCAR=17.9
Pod documented
205  
206 0 ▶ if ( $params->{chg} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{"chg"}) 0 0 0
207 0 $params->{chg}{need_name} = 1;
208 0 $params->{chg}{authinfo} = IO::EPP::Base::gen_pw( 12 );
209 }
210  
211 0 return $self->SUPER::update_contact( $params );
212 }
213  
214 sub get_ns_info_rdata {
215 0 ▶ my ( undef, $rdata ) = @_;
Subroutine get_ns_info_rdata: not called CC=6 SCAR=37.4
Pod documented
216  
217 0 my %ns;
218  
219 0 ( $ns{name} ) = $rdata =~ /<name>([^<>]+)<\/name>/;
220 0 $ns{name} = lc $ns{name};
221  
222 0 ( $ns{roid} ) = $rdata =~ /<roid>([^<>]+)<\/roid>/;
223  
224 # <host:status s="ok"/>
225 0 my @ss = $rdata =~ /<status s="([^"]+)"\s*\/>/g;
226 0 $ns{statuses}{$_} = '+' for @ss;
227  
228 0 $ns{addrs} = [ $rdata =~ /<addr ip="v\d">([0-9A-Fa-f.:]+)<\/addr>/g ];
229  
230 0 my %id = %IO::EPP::Base::id;
231 0 foreach my $k ( keys %id ) {
232 0 ▶ if ( $rdata =~ /<$k>([^<>]+)<\/$k>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rdata =~ m[<$k>([^<>]+)</$k>]) 0 0 0
233 0 $ns{$id{$k}} = $1;
234 }
235 }
236  
237 0 my %dt = %IO::EPP::Base::dt;
238 0 foreach my $k ( keys %dt ) {
239 0 ▶ if ( $rdata =~ /<$k>([^<>]+)<\/$k>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rdata =~ m[<$k>([^<>]+)</$k>]) 0 0 0
240 0 $ns{$dt{$k}} = $1;
241  
242 0 $ns{$dt{$k}} =~ s/T/ /;
243 0 $ns{$dt{$k}} =~ s/\.\d+Z$//;
244 }
245 }
246  
247 0 return \%ns;
248 }
249  
250  
251 sub check_domains_rdata {
252 0 ▶ my ( undef, $rdata ) = @_;
Subroutine check_domains_rdata: not called CC=5 SCAR=34.0
Pod documented
253  
254 0 my @aa = $rdata =~ /<cd>(<name avail="[a-z]+">[^<>]+<\/name>(?:<reason>[^<>]+<\/reason>)?)<\/cd>/sg;
255  
256 0 my %domlist;
257 0 foreach my $a ( @aa ) {
258 0 ▶ if ( $a =~ /<name avail="(true|false)">([^<>]+)<\/name>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a =~ m[<name avail="(true|false)">([^<>]+)</name>]) 0 0 0
259 0 my $dm = lc($2);
260 0 ▶ $domlist{$dm} = { avail => ( $1 eq 'true' ? 1 : 0 ) }; # no utf8, puny only
Branch: 1 branch
BranchTrueFalseTotal
$1 eq 'true' ? : 0 0 0
261  
262 0 ▶ if ( $a =~ /<reason>([^<>]+)<\/reason>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a =~ m[<reason>([^<>]+)</reason>]) 0 0 0
263 0 $domlist{$dm}{reason} = $1;
264 }
265 }
266 }
267  
268 0 return \%domlist;
269 }
270  
271  
272 sub get_domain_info_rdata {
273 0 ▶ my ( undef, $rdata ) = @_;
Subroutine get_domain_info_rdata: not called CC=12 SCAR=50.5
Pod documented
274  
275 0 my $info = {};
276  
277 0 ( $info->{dname} ) = $rdata =~ /<name>([^<>]+)<\/name>/;
278 0 $info->{dname} = lc $info->{dname};
279  
280 # <domain:status s="ok"/>
281 0 my @ss = $rdata =~ /<status s=['"]([^'"]+)['"]\s*\/?>/g;
282 0 $info->{statuses}{$_} = '+' for @ss;
283  
284 0 ( $info->{reg_id} ) = $rdata =~ /<registrant>([^<>]+)<\/registrant>/;
285  
286 0 my @cc = $rdata =~ /<contact type=['"][^'"]+['"]>[^<>]+<\/contact>/g;
287 0 foreach my $row ( @cc ) {
288 0 ▶ if ( $row =~ /<contact type=['"]([^'"]+)['"]>([^<>]+)<\/contact>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($row =~ m[<contact type=['"]([^'"]+)['"]>([^<>]+)</contact>]) 0 0 0
289 0 $info->{ lc($1) . '_id' } = $2;
290 }
291 }
292  
293 0 ▶ if ( $rdata =~ /<hostObj>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rdata =~ /<hostObj>/) 0 0 0
294 0 $info->{nss} = [ $rdata =~ /<hostObj>([^<>]+)<\/hostObj>/g ];
295 }
296  
297 0 ▶ if ( $info->{nss} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($info->{"nss"}) 0 0 0
298 0 $info->{nss} = [ map{ lc $_ } @{$info->{nss}} ];
299 }
300  
301 # domain-based nss
302 0 ▶ if ( $rdata =~ /<host>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rdata =~ /<host>/) 0 0 0
303 0 $info->{hosts} = [ $rdata =~ /<host>([^<>]+)<\/host>/g ];
304 0 $info->{hosts} = [ map{ lc $_ } @{$info->{hosts}} ];
305 }
306  
307 0 my %id = %IO::EPP::Base::id;
308 0 foreach my $k ( keys %id ) {
309 0 ▶ if ( $rdata =~ /<$k>([^<>]+)<\/$k>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rdata =~ m[<$k>([^<>]+)</$k>]) 0 0 0
310 0 $info->{$id{$k}} = $1;
311 }
312 }
313  
314 0 my %dt = %IO::EPP::Base::dt;
315 0 foreach my $k ( keys %dt ) {
316 0 ▶ if ( $rdata =~ /<$k>([^<>]+)<\/$k>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rdata =~ m[<$k>([^<>]+)</$k>]) 0 0 0
317 0 $info->{$dt{$k}} = $1;
318  
319 0 $info->{$dt{$k}} =~ s/T/ /;
320 0 $info->{$dt{$k}} =~ s/\.\d+Z$//;
321 }
322 }
323  
324 0 ▶ if ( $rdata =~ /authInfo.+<pw>([^<>]+)<\/pw>.+authInfo/s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rdata =~ m[authInfo.+<pw>([^<>]+)</pw>.+authInfo]s) 0 0 0
325 0 ( $info->{authinfo} ) = $1;
326  
327 #$info->{authinfo} =~ s/&gt;/>/g;
328 #$info->{authinfo} =~ s/&lt;/</g;
329 #$info->{authinfo} =~ s/&amp;/&/g;
330 }
331  
332 0 return $info;
333 }
334  
335  
336 sub req_poll_rdata {
337 0 ▶ my ( $self, $rdata, undef ) = @_;
Subroutine req_poll_rdata: not called CC=4 SCAR=30.0
Pod documented
338  
339 0 my %info;
340  
341 0 ▶ if ( $rdata =~ /^<trnData[^<>]*>(.+)<\/trnData>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rdata =~ m[^<trnData[^<>]*>(.+)</trnData>]) { } 0 0 0
342 0 my $trn = $1;
343 0 $info{transfer} = {};
344 0 ( $info{transfer}{dname} ) = $trn =~ /<name>([^<>]+)<\/name>/;
345 0 ( $info{transfer}{status} ) = $trn =~ /<trStatus>([^<>]+)<\/trStatus>/;
346  
347 0 my %id = %IO::EPP::Base::id;
348 0 foreach my $k ( keys %id ) {
349 0 ▶ if ( $rdata =~ /<domain:$k>([^<>]+)<\/domain:$k>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rdata =~ m[<domain:$k>([^<>]+)</domain:$k>]) 0 0 0
350 0 $info{transfer}{$id{$k}} = $1;
351 }
352 }
353 }
354 else {
355 0 return ( 0, 'New CoreNic message type!' );
356 }
357  
358 0 return ( \%info, '' );
359 }
360  
361  
362 1 1;
363  
364  
365 __END__
« EPP/Test/VerisignCore.pm ↑ Summary EPP/Flexireg.pm »