DRI/Protocol/RRP/Connection.pm

filter: Statementstmt 28.3% 19 / 67 Branchbran 0.0% 0 / 28 Conditioncond 0.0% 0 / 31 MC/DCmcdc 0.0% 0 / 18 Subroutinesub 37.5% 6 / 16 Podpod 0.0% 0 / 10 totaltotal 14.7% 25 / 170 CC 28 SCAR 34.7
CC
28
Cov
15%
parse_login
56.0
parse_logout
56.0
read_data
42.0
CRAP 32.2
« DRI/Protocol/EPP/Extensions/EURid/Notifications.pm ↑ Summary DRI/Protocol/EPP/Extensions/AllocationToken.pm »
1 ## Domain Registry Interface, RRP Connection handling
2 ##
3 ## Copyright (c) 2005,2007-2010 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::RRP::Connection;
16  
17 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 2 ▶use Net::DRI::Protocol::RRP::Message;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 2 ▶use Net::DRI::Protocol::ResultStatus;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 2 ▶use Net::DRI::Data::Raw;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 2 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 =pod
26  
27 =head1 NAME
28  
29 Net::DRI::Protocol::RRP::Connection - RRP Connection handling 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) 2005,2007-2010 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 login
68 0 ▶{
Subroutine login: not called CC=3 SCAR=24.8
Pod undocumented
69 0 my ($class,$cm,$id,$pass,$cltrid,$dr,$newpass)=@_;
70 0 my %h=(Id => $id, Password => $pass);
71 0 ▶ $h{NewPassword}=$newpass if (defined($newpass) && $newpass);
Branch: 1 branch
BranchTrueFalseTotal
if defined $newpass and $newpass 0 0 0
Condition0%0/3
defined $newpass and $newpass
!ll&&!rl&&r
000
MC/DC0%0/2
defined $newpass and $newpass
defined $newpass $newpass
Truth table0%0/3
A and B
A= defined $newpassB= $newpass
ABresult
0X0
100
111
72 0 my $mes=Net::DRI::Protocol::RRP::Message->new({ command => 'session', options => \%h});
73 0 return $mes;
74 }
75  
76 sub logout
77 0 ▶{
Subroutine logout: not called CC=1 SCAR=6.9
Pod undocumented
78 0 my ($class,$cm,$cltrid)=@_;
79 0 my $mes=Net::DRI::Protocol::RRP::Message->new({ command => 'quit' });
80 0 return $mes;
81 }
82  
83 sub keepalive
84 0 ▶{
Subroutine keepalive: not called CC=1 SCAR=6.9
Pod undocumented
85 0 my ($class,$cm,$cltrid)=@_;
86 0 my $mes=Net::DRI::Protocol::RRP::Message->new({ command => 'describe' });
87 0 return $mes;
88 }
89  
90 ####################################################################################################
91  
92 sub read_data
93 0 ▶{
Subroutine read_data: not called CC=6 SCAR=37.4
Pod undocumented
94 0 my ($class,$to,$sock)=@_;
95  
96 0 my (@l);
97 0 ▶ while(my $l=$sock->getline())
Branch: 1 branch
BranchTrueFalseTotal
if (my $l = $sock->getline) 0 0 0
98 {
99 0 push @l,$l;
100 0 ▶ last if ($l=~m/^\.\s*\n?$/);
Branch: 1 branch
BranchTrueFalseTotal
if $l =~ /^\.\s*\n?$/ 0 0 0
101 }
102 0 @l=map { Net::DRI::Util::decode_ascii($_); } @l;
103 0 ▶ die(Net::DRI::Protocol::ResultStatus->new_error('COMMAND_FAILED_CLOSING',@l? $l[0] : '<empty message from server>','en')) unless (@l && $l[-1]=~m/^\.\s*\n?$/);
Branch: 2 branches
BranchTrueFalseTotal
unless @l and $l[-1] =~ /^\.\s*\n?$/ 0 0 0
@l ? : 0 0 0
Condition0%0/3
@l and $l[-1] =~ /^\.\s*\n?$/
!ll&&!rl&&r
000
MC/DC0%0/2
@l and $l[-1] =~ /^\.\s*\n?$/
@l $l[-1] =~ /^\.\s*\n?$/
Truth table0%0/3
A and B
A= @lB= $l[-1] =~ /^\.\s*\n?$/
ABresult
0X0
100
111
104 0 return Net::DRI::Data::Raw->new_from_array(\@l);
105 }
106  
107 sub write_message
108 0 ▶{
Subroutine write_message: not called CC=1 SCAR=6.9
Pod undocumented
109 0 my ($self,$to,$msg)=@_;
110 0 return Net::DRI::Util::encode_ascii($msg);
111 }
112  
113 sub parse_greeting
114 0 ▶{
Subroutine parse_greeting: not called CC=5 SCAR=34.0
Pod undocumented
115 0 my ($class,$dc)=@_;
116 0 my ($code,$msg)=find_code($dc);
117 0 ▶ unless (defined($code) && ($code==0))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $code and $code == 0) { } 0 0 0
Condition0%0/3
defined $code and $code == 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $code and $code == 0
defined $code $code == 0
Truth table0%0/3
A and B
A= defined $codeB= $code == 0
ABresult
0X0
100
111
118 {
119 0 ▶ return Net::DRI::Protocol::ResultStatus->new_error('COMMAND_SYNTAX_ERROR',($msg || '?').' ('.($code || '?').')','en');
Condition0%0/4
$msg || '?'
l!l
00
$code || '?'
l!l
00
MC/DC0%0/1
$msg || '?'
$msg
MC/DC0%0/1
$code || '?'
$code
Truth table0%0/2
A
A= $msg
Aresult
11
00
Truth table0%0/2
A
A= $code
Aresult
11
00
120 } else
121 {
122 0 return Net::DRI::Protocol::ResultStatus->new_success('COMMAND_SUCCESSFUL','Greeting OK','en');
123 }
124 }
125  
126 sub parse_login
127 0 ▶{
Subroutine parse_login: not called CC=7 SCAR=40.3
Pod undocumented
128 0 my ($class,$dc)=@_;
129 0 my ($code,$msg)=find_code($dc);
130 0 ▶ unless (defined($code) && ($code==200))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $code and $code == 200) { } 0 0 0
Condition0%0/3
defined $code and $code == 200
!ll&&!rl&&r
000
MC/DC0%0/2
defined $code and $code == 200
defined $code $code == 200
Truth table0%0/3
A and B
A= defined $codeB= $code == 200
ABresult
0X0
100
111
131 {
132 0 ▶ my $eppcode=(defined($code))? Net::DRI::Protocol::RRP::Message::_eppcode($code) : 'COMMAND_SYNTAX_ERROR';
Branch: 1 branch
BranchTrueFalseTotal
defined $code ? : 0 0 0
133 0 ▶ return Net::DRI::Protocol::ResultStatus->new_error($eppcode,($msg || 'Login failed').' ('.($code || '?').')','en');
Condition0%0/4
$msg || 'Login failed'
l!l
00
$code || '?'
l!l
00
MC/DC0%0/1
$msg || 'Login failed'
$msg
MC/DC0%0/1
$code || '?'
$code
Truth table0%0/2
A
A= $msg
Aresult
11
00
Truth table0%0/2
A
A= $code
Aresult
11
00
134 } else
135 {
136 0 ▶ return Net::DRI::Protocol::ResultStatus->new_success('COMMAND_SUCCESSFUL',$msg || 'Login OK','en');
Condition0%0/2
$msg || 'Login OK'
l!l
00
MC/DC0%0/1
$msg || 'Login OK'
$msg
Truth table0%0/2
A
A= $msg
Aresult
11
00
137 }
138 }
139  
140 sub parse_logout
141 0 ▶{
Subroutine parse_logout: not called CC=7 SCAR=40.3
Pod undocumented
142 0 my ($class,$dc)=@_;
143 0 my ($code,$msg)=find_code($dc);
144 0 ▶ unless (defined($code) && ($code==220))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $code and $code == 220) { } 0 0 0
Condition0%0/3
defined $code and $code == 220
!ll&&!rl&&r
000
MC/DC0%0/2
defined $code and $code == 220
defined $code $code == 220
Truth table0%0/3
A and B
A= defined $codeB= $code == 220
ABresult
0X0
100
111
145 {
146 0 ▶ my $eppcode=(defined($code))? Net::DRI::Protocol::RRP::Message::_eppcode($code) : 'COMMAND_SYNTAX_ERROR';
Branch: 1 branch
BranchTrueFalseTotal
defined $code ? : 0 0 0
147 0 ▶ return Net::DRI::Protocol::ResultStatus->new_error($eppcode,($msg || 'Logout failed').' ('.($code || '?').')','en');
Condition0%0/4
$msg || 'Logout failed'
l!l
00
$code || '?'
l!l
00
MC/DC0%0/1
$msg || 'Logout failed'
$msg
MC/DC0%0/1
$code || '?'
$code
Truth table0%0/2
A
A= $msg
Aresult
11
00
Truth table0%0/2
A
A= $code
Aresult
11
00
148 } else
149 {
150 0 ▶ return Net::DRI::Protocol::ResultStatus->new_success('COMMAND_SUCCESSFUL_END',$msg || 'Logout OK','en');
Condition0%0/2
$msg || 'Logout OK'
l!l
00
MC/DC0%0/1
$msg || 'Logout OK'
$msg
Truth table0%0/2
A
A= $msg
Aresult
11
00
151 }
152 }
153  
154 sub find_code
155 0 ▶{
Subroutine find_code: not called CC=5 SCAR=34.0
Pod undocumented
156 0 my $dc=shift;
157 0 my @a=$dc->as_array();
158 0 ▶ return (0,'LOGIN') if ($a[0]=~m/^.+ RRP Server version/); ## initial login
Branch: 1 branch
BranchTrueFalseTotal
if $a[0] =~ /^.+ RRP Server version/ 0 0 0
159 0 ▶ return () unless $#a>0; ## at least 2 lines
Branch: 1 branch
BranchTrueFalseTotal
unless $#a > 0 0 0 0
160 0 ▶ return () unless $a[-1]=~m/^\.\s*\n?$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $a[-1] =~ /^\.\s*\n?$/ 0 0 0
161 0 ▶ return () unless $a[0]=~m/^(\d+) (\S.+)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $a[0] =~ /^(\d+) (\S.+)$/ 0 0 0
162 0 return (0+$1,$2);
163 }
164  
165 sub transport_default
166 0 ▶{
Subroutine transport_default: not called CC=1 SCAR=6.9
Pod undocumented
167 0 my ($self,$tname)=@_;
168 0 return (defer => 0, socktype => 'ssl', ssl_version => 'TLSv1', remote_port => 648);
169 }
170  
171 ####################################################################################################
172 2 1;
« DRI/Protocol/EPP/Extensions/EURid/Notifications.pm ↑ Summary DRI/Protocol/EPP/Extensions/AllocationToken.pm »