EPP/TCI.pm

filter: Statementstmt 13.2% 14 / 106 Branchbran 0.0% 0 / 42 Conditioncond 0.0% 0 / 16 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 36.3% 4 / 11 Podpod 85.7% 6 / 7 totaltotal 12.5% 24 / 192 SCAR 67.6
CC
33
Cov
9%
make_request
132.0
contact_ext
110.0
get_contact_ext
72.0
CRAP 866.2
« EPP/DrsUa.pm ↑ Summary EPP/Taeping.pm »
1 package IO::EPP::TCI;
2  
3 =encoding utf8
4  
5 =head1 NAME
6  
7 IO::EPP::TCI
8  
9 =head1 SYNOPSIS
10  
11 use IO::EPP::TCI;
12  
13 # Parameters for IO::Socket::SSL
14 my %sock_params = (
15 PeerHost => 'uap.tcinet.ru',
16 PeerPort => 8130, # .дети 8130, .tatar 8131
17 SSL_key_file => 'key_file.pem',
18 SSL_cert_file => 'cert_file.pem',
19 Timeout => 30,
20 );
21  
22 # Create object, get greeting and call login()
23 my $conn = IO::EPP::TCI->new( {
24 user => 'XXX-DETI',
25 pass => 'XXXXXXXX',
26 sock_params => \%sock_params,
27 server => 'afilias', # or pir, ...
28 test_mode => 0, # real connect
29 } );
30  
31 # Check domain
32 my ( $answ, $code, $msg ) = $conn->check_domains( { domains => [ 'xn--80akfym3e.xn--d1acj3b' ] } );
33  
34 # Call logout() and destroy object
35 undef $conn;
36  
37 =head1 DESCRIPTION
38  
39 Work with normal TCI EPP API
40  
41 .дети/.xn--d1acj3b documents:
42 L<http://dotdeti.ru/foruser/docs/>, L<https://tcinet.ru/documents/deti/2TechPolitDeti.pdf>
43  
44 .tatar documents:
45 L<http://domain.tatar/to-registars/documents.php>, L<https://tcinet.ru/documents/deti/2TechPolitTatar.pdf>
46  
47 =cut
48  
49 1 ▶use IO::EPP::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
50 1 ▶use parent qw( IO::EPP::Base );
Subroutine BEGIN: called CC=1 SCAR=0.0
51  
52 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
54  
55 1 my $cont_ext =
56 'xmlns:contact="http://www.tcinet.ru/epp/tci-contact-ext-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.tcinet.ru/epp/tci-contact-ext-1.0 tci-contact-ext-1.0.xsd"';
57  
58 sub make_request {
59 0 ▶ my ( $action, $params ) = @_;
Subroutine make_request: not called CC=11 SCAR=48.8
Pod documented
60  
61 0 my ( $self, $code, $msg, $answ );
62  
63 0 ▶ unless ( $params->{conn} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{'conn'}) { } 0 0 0
64 0 ▶ $params->{sock_params}{PeerHost} ||= 'uap.tcinet.ru';
Condition0%0/2
$params->{"sock_params"}{"PeerHost"} ||= "uap.tcinet.ru"
l!l
00
MC/DC0%0/1
$params->{"sock_params"}{"PeerHost"} ||= "uap.tcinet.ru"
$params->{"sock_params"}{"PeerHost"}
Truth table0%0/2
A
A= $params->{"sock_params"}{"PeerHost"}
Aresult
11
00
65 0 ▶ $params->{sock_params}{PeerPort} ||= 8130; # .дети, for .tatar need 8131
Condition0%0/2
$params->{"sock_params"}{"PeerPort"} ||= 8130
l!l
00
MC/DC0%0/1
$params->{"sock_params"}{"PeerPort"} ||= 8130
$params->{"sock_params"}{"PeerPort"}
Truth table0%0/2
A
A= $params->{"sock_params"}{"PeerPort"}
Aresult
11
00
66  
67 0 ( $self, $code, $msg ) = __PACKAGE__->new( $params );
68  
69 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
70 0 goto END_MR;
71 }
72 }
73 else {
74 0 $self = $params->{conn};
75 }
76  
77  
78 0 $self->{critical_error} = '';
79  
80 0 ▶ if ( $self->can( $action ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can($action)) { } 0 0 0
81 0 ( $answ, $code, $msg ) = $self->$action( $params );
82 }
83 else {
84 0 $msg = "undefined command <$action>, request cancelled";
85 0 $code = 0;
86 }
87  
88  
89 END_MR:
90  
91 0 ▶ $msg .= '; ' . $self->{critical_error} if $self->{critical_error};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"critical_error"} 0 0 0
92  
93 0 my $full_answ = "code: $code\nmsg: $msg";
94  
95 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
96  
97 0 $answ->{code} = $code;
98 0 $answ->{msg} = $msg;
99  
100 0 ▶ return wantarray ? ( $answ, $full_answ, $self ) : $answ;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
101 }
102  
103 =head1 METHODS
104  
105 Further overlap functions where the provider has features
106  
107 =head2 login
108  
109 Ext params for login,
110  
111 INPUT: new password for change
112  
113 =cut
114  
115 sub login {
116 0 ▶ my ( $self, $pw ) = @_;
Subroutine login: not called CC=1 SCAR=6.9
Pod documented
117  
118 0 my $svcs = '
119 <objURI>urn:ietf:params:xml:ns:epp-1.0</objURI>
120 <objURI>urn:ietf:params:xml:ns:eppcom-1.0</objURI>
121 <objURI>urn:ietf:params:xml:ns:contact-1.0</objURI>
122 <objURI>urn:ietf:params:xml:ns:domain-1.0</objURI>
123 <objURI>urn:ietf:params:xml:ns:host-1.0</objURI>';
124 0 my $extension = '
125 <extURI>http://www.tcinet.ru/epp/tci-contact-ext-1.0</extURI>
126 <extURI>http://www.tcinet.ru/epp/tci-domain-ext-1.0</extURI>
127 <extURI>urn:ietf:params:xml:ns:launch-1.0</extURI>
128 <extURI>urn:ietf:params:xml:ns:secDNS-1.1</extURI>
129 <extURI>urn:ietf:params:xml:ns:rgp-1.0</extURI>
130 <extURI>http://www.tcinet.ru/epp/tci-billing-1.0</extURI>';
131  
132 0 return $self->SUPER::login( $pw, $svcs, $extension );
133 }
134  
135  
136 sub contact_ext {
137 0 ▶ my ( undef, $params ) = @_;
Subroutine contact_ext: not called CC=10 SCAR=47.0
Pod undocumented
138  
139 0 my $ext = '';
140  
141 0 ▶ if ( $params->{birthday} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{"birthday"}) 0 0 0
142 0 $ext .= " <contact:person>\n";
143  
144 0 foreach my $f ( 'birthday', 'passport', 'TIN' ) {
145 0 ▶ $ext .= " <contact:$f>$$params{$f}</contact:$f>\n" if $$params{$f};
Branch: 1 branch
BranchTrueFalseTotal
if $params->{$f} 0 0 0
146 }
147  
148 0 $ext .= " </contact:person>";
149 }
150  
151 0 ▶ if ( $params->{legal} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{"legal"}) 0 0 0
152 0 $ext .= " <contact:organization>\n";
153 0 foreach my $type ( 'int', 'loc' ) {
154 0 $ext .= qq| <contact:legalAddr type="$type">\n|;
155  
156 0 ▶ $$params{legal}{$type}{addr} = [ $$params{legal}{$type}{addr} ] unless ref $$params{legal}{$type}{addr};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $params->{"legal"}{$type}{"addr"} 0 0 0
157  
158 0 foreach my $s ( @{$$params{legal}{$type}{addr}} ) {
159 0 $ext .= " <contact:street>$s</contact:street>\n";
160 }
161  
162 0 $ext .= " <contact:city>$$params{legal}{$type}{city}</contact:city>\n";
163 0 ▶ $ext .= ( $$params{legal}{$type}{'state'} ? " <contact:sp>$$params{legal}{$type}{state}</contact:sp>\n" : " <contact:sp/>\n" );
Branch: 1 branch
BranchTrueFalseTotal
$params->{'legal'}{$type}{'state'} ? : 0 0 0
164 0 ▶ $ext .= ( $$params{legal}{$type}{postcode} ? " <contact:pc>$$params{legal}{$type}{postcode}</contact:pc>\n" : " <contact:pc/>\n" );
Branch: 1 branch
BranchTrueFalseTotal
$params->{'legal'}{$type}{'postcode'} ? : 0 0 0
165 0 $ext .= " <contact:cc>$$params{legal}{$type}{country_code}</contact:cc>\n";
166  
167 0 $ext .= " </contact:legalAddr>\n";
168 }
169 0 $ext .= " <contact:TIN>$$params{TIN}</contact:TIN>\n";
170 0 $ext .= " </contact:organization>";
171 }
172  
173 0 return $ext;
174 }
175  
176  
177 =head2 create_contact
178  
179 When registering a contact, you must specify both int type data and loc type data, and if the domain owner has passport data in Cyrillic,
180 then loc type data must be entered in Cyrillic.
181 This is mandatory for citizens and legal entities of Russia, Ukraine, Belarus and other countries that have the Cyrillic alphabet.
182  
183 In addition, the owner must provide additional information.
184  
185 For individuals:
186  
187 C<birthday> -- date of birth;
188  
189 C<passport> -- passport series and number, by whom and when it was issued;
190  
191 C<TIN> -- TIN for individual entrepreneurs.
192  
193 For legal entities:
194  
195 hashref C<legal>, that contains the legal address, it also needs to specify two types: C<int> and C<loc>, consisting of the fields C<addr>, C<city>, C<state>, C<postcode>, C<country_code>.
196  
197 You also need to specify the C<TIN> field.
198  
199 An Example:
200  
201 Individuals:
202  
203 my %cont = (
204 int => {
205 first_name => 'Igor',
206 patronymic => 'Igorevich',
207 last_name => 'Igorev',
208 org => '',
209 addr => 'Igoreva str, 129',
210 city => 'Igorevsk',
211 state => 'Ogorevskaya obl.',
212 postcode => '699001',
213 country_code => 'RU',
214 },
215 loc => {
216 first_name => 'Игорь',
217 patronymic => 'Игоревич',
218 last_name => 'Игорев',
219 org => '',
220 addr => 'ул. Игорева, 129',
221 city => 'Игоревск',
222 state => 'Игоревская обл.',
223 postcode => '699001',
224 country_code => 'RU',
225 },
226 birthday => '1909-01-14',
227 passport => '11.11.2011, выдан Отделом УФМС России по Игоревской области в г.Игоревске, 2211 446622',
228 phone => '+7.9012345678',
229 fax => '',
230 email => 'igor@i.ru',
231 TIN => '',
232 };
233  
234 my ( $answ, $msg, $conn ) = make_request( 'create_contact', \%cont );
235  
236 Legal entities:
237  
238 my %cont = (
239 int => {
240 first_name => 'Igor',
241 patronymic => 'Igorevich',
242 last_name => 'Igorev',
243 org => 'Igor and Co',
244 addr => 'Igoreva str, 129',
245 city => 'Igorevsk',
246 state => 'Igorevskaya obl.',
247 postcode => '699001',
248 country_code => 'RU',
249 },
250 loc => {
251 first_name => 'Игорь',
252 patronymic => 'Игоревич',
253 last_name => 'Игорев',
254 org => 'Игорь и Ко',
255 addr => 'ул. Игорева, 129',
256 city => 'Игоревск',
257 state => 'Игоревская обл.',
258 postcode => '699001',
259 country_code => 'RU',
260 },
261 legal => {
262 int => {
263 addr => 'Company str, 1',
264 city => 'Igorevsk',
265 state => 'Igorevskaya obl.',
266 postcode => '699002',
267 country_code => 'RU',
268 },
269 loc => {
270 addr => 'ул. Компаний, 1',
271 city => 'Игоревск',
272 state => 'Игоревская обл.',
273 postcode => '699002',
274 country_code => 'RU',
275 }
276 }
277 };
278  
279 my ( $answ, $code, $msg ) = $conn->create_contact( \%cont );
280  
281 =cut
282  
283 sub create_contact {
284 0 ▶ my ( $self, $params ) = @_;
Subroutine create_contact: not called CC=3 SCAR=24.8
Pod documented
285  
286 0 ▶ $params->{cont_id} ||= IO::EPP::Base::gen_id( 16 );
Condition0%0/3
$params->{"cont_id"} ||= IO::EPP::Base::gen_id(16)
l!l&&r!l&&!r
000
MC/DC0%0/2
$params->{"cont_id"} ||= IO::EPP::Base::gen_id(16)
$params->{"cont_id"} IO::EPP::Base::gen_id(16)
Truth table0%0/3
A ||= B
A= $params->{"cont_id"}B= IO::EPP::Base::gen_id(16)
ABresult
1X1
011
000
287  
288 0 $params->{authinfo} = IO::EPP::Base::gen_pw( 16 );
289  
290 0 my $extension = $self->contact_ext( $params );
291  
292 0 ▶ if ( $extension ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($extension) 0 0 0
293 0 $params->{extension} = " <contact:create $cont_ext>\n$extension </contact:create>\n";
294 }
295  
296 0 return $self->SUPER::create_contact( $params );
297 }
298  
299  
300 sub get_contact_ext {
301 0 ▶ my ( undef, $ext ) = @_;
Subroutine get_contact_ext: not called CC=8 SCAR=42.8
Pod documented
302  
303 0 my %cont;
304  
305 0 ▶ if ( $ext =~ m|<contact:infData[^<>]+tci-contact-ext-1[^<>]+>(.+?)</contact:infData>|s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ext =~ m[<contact:infData[^<>]+tci-contact-ext-1[^<>]+>(.+?)</contact:infData>]s) 0 0 0
306 0 my $data = $1;
307  
308 0 ▶ if ( $data =~ m|<contact:person>(.+)</contact:person>|s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ m[<contact:person>(.+)</contact:person>]s) 0 0 0
309 0 my $person_data = $1;
310  
311 0 my @rows = $person_data =~ m|(<contact:[A-Za-z]+>[^<>]+)</contact:[A-Za-z]+>|gs;
312  
313 0 foreach my $row ( @rows ) {
314 0 ▶ if ( $row =~ m|<contact:([A-Za-z]+)>([^<>]+)| ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($row =~ /<contact:([A-Za-z]+)>([^<>]+)/) 0 0 0
315 0 $cont{$1} = $2;
316 }
317 }
318 }
319  
320 0 ▶ if ( $data =~ m|<contact:organization>(.+)</contact:organization>|s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ m[<contact:organization>(.+)</contact:organization>]s) 0 0 0
321 0 my $org_data = $1;
322  
323 0 ( $cont{TIN} ) = $org_data =~ /<contact:TIN>([^<>]+)<\/contact:TIN>/;
324  
325 0 my @atypes = ( 'int', 'loc' );
326 0 foreach my $atype ( @atypes ) {
327 0 my ( $postal ) = $org_data =~ m|<contact:legalAddr type="$atype">(.+?)</contact:legalAddr>|s;
328  
329 0 ▶ next unless $postal;
Branch: 1 branch
BranchTrueFalseTotal
unless $postal 0 0 0
330  
331 0 $cont{legal}{$atype}{addr} = join(' ', $postal =~ /<contact:street>([^<>]*)<\/contact:street>/ );
332  
333 0 ( $cont{legal}{$atype}{city} ) = $postal =~ /<contact:city>([^<>]*)<\/contact:city>/;
334  
335 0 ( $cont{legal}{$atype}{'state'} ) = $postal =~ /<contact:sp>([^<>]*)<\/contact:sp>/;
336  
337 0 ( $cont{legal}{$atype}{postcode} ) = $postal =~ /<contact:pc>([^<>]*)<\/contact:pc>/;
338  
339 0 ( $cont{legal}{$atype}{country_code} ) = $postal =~ /<contact:cc>([A-Z]+)<\/contact:cc>/;
340 }
341 }
342 }
343  
344 0 return \%cont;
345 }
346  
347  
348 =head2 create_domain
349  
350 Has an optional C<description> field.
351  
352 For .дети tld automatically adds the idn extension with lang C<ru-RU>.
353  
354 =cut
355  
356 sub create_domain {
357 0 ▶ my ( $self, $params ) = @_;
Subroutine create_domain: not called CC=4 SCAR=30.0
Pod documented
358  
359 0 ▶ $params->{authinfo} ||= IO::EPP::Base::gen_pw( 16 );
Condition0%0/3
$params->{"authinfo"} ||= IO::EPP::Base::gen_pw(16)
l!l&&r!l&&!r
000
MC/DC0%0/2
$params->{"authinfo"} ||= IO::EPP::Base::gen_pw(16)
$params->{"authinfo"} IO::EPP::Base::gen_pw(16)
Truth table0%0/3
A ||= B
A= $params->{"authinfo"}B= IO::EPP::Base::gen_pw(16)
ABresult
1X1
011
000
360  
361 0 my $extension = '';
362  
363 0 ▶ if ( $params->{dname} =~ /\.xn--80adxhks$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{"dname"} =~ /\.xn--80adxhks$/) 0 0 0
364 # .москва support RU lang only
365 0 $extension .= qq| <idn:data xmlns:idn="urn:ietf:params:xml:ns:idn-1.0">\n|;
366 0 $extension .= " <idn:table>ru-RU</idn:table>\n";
367 0 $extension .= " </idn:data>\n";
368 }
369  
370 0 ▶ $params->{extension} = $extension if $extension;
Branch: 1 branch
BranchTrueFalseTotal
if $extension 0 0 0
371  
372 0 return $self->SUPER::create_domain( $params );
373 }
374  
375 =head2 get_domain_spec_ext
376  
377 Processes the additional description field.
378  
379 =cut
380  
381 sub get_domain_spec_ext {
382 0 ▶ my ( undef, $ext ) = @_;
Subroutine get_domain_spec_ext: not called CC=2 SCAR=17.9
Pod documented
383  
384 0 my %info;
385  
386 0 ▶ if ( $ext =~ m|<domain:infData[^<>]+tci-domain-ext-1[^<>]+>(.+?)</domain:infData>|s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ext =~ m[<domain:infData[^<>]+tci-domain-ext-1[^<>]+>(.+?)</domain:infData>]s) 0 0 0
387 0 my $tciinfo = $1;
388  
389 0 ( $info{descr} ) = $tciinfo =~ m|<domain:description>([^<>]+)</domain:description>|;
390 }
391  
392 0 return \%info;
393 }
394  
395  
396 1 1;
397  
398 __END__
« EPP/DrsUa.pm ↑ Summary EPP/Taeping.pm »