DRI/Data/Contact/SWITCH.pm

filter: Statementstmt 32.2% 19 / 59 Branchbran 0.0% 0 / 40 Conditioncond 0.0% 0 / 66 MC/DCmcdc 0.0% 0 / 35 Subroutinesub 75.0% 6 / 8 Podpod 0.0% 0 / 2 totaltotal 11.9% 25 / 210 CC 45 SCAR 71.4
CC
45
Cov
12%
validate
1640.0
init
42.0
BEGIN
1.0
CRAP 1266.5
« DRI/Shell.pm ↑ Summary DRI/Data/Contact/DENIC.pm »
1 ## Domain Registry Interface, Handling of contact data for .CH/.LI
2 ##
3 ## Copyright (c) 2008,2009,2013 Tonnerre Lombard <tonnerre.lombard@sygroup.ch>.
4 ## All rights reserved.
5 ##
6 ## This file is part of Net::DRI
7 ##
8 ## Net::DRI is free software; you can redistribute it and/or modify
9 ## it under the terms of the GNU General Public License as published by
10 ## the Free Software Foundation; either version 2 of the License, or
11 ## (at your option) any later version.
12 ##
13 ## See the LICENSE file that comes with this distribution for more details.
14 #########################################################################################
15  
16 package Net::DRI::Data::Contact::SWITCH;
17  
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 1 ▶use base qw/Net::DRI::Data::Contact/;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use Email::Valid;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 =pod
27  
28 =head1 NAME
29  
30 Net::DRI::Data::Contact::SWITCH - Handle .CH/.LI contact data for Net::DRI
31  
32 =head1 DESCRIPTION
33  
34 This subclass of Net::DRI::Data::Contact adds accessors and validation for
35 .CH/.LI specific data.
36  
37 =head1 SUPPORT
38  
39 For now, support questions should be sent to:
40  
41 E<lt>tonnerre.lombard@sygroup.chE<gt>
42  
43 Please also see the SUPPORT file in the distribution.
44  
45 =head1 SEE ALSO
46  
47 http://oss.bsdprojects.net/projects/netdri/ or
48 http://www.dotandco.com/services/software/Net-DRI/
49  
50 =head1 AUTHOR
51  
52 Tonnerre Lombard, E<lt>tonnerre.lombard@sygroup.chE<gt>
53  
54 =head1 COPYRIGHT
55  
56 Copyright (c) 2008,2009,2013 Tonnerre Lombard <tonnerre.lombard@sygroup.ch>.
57 All rights reserved.
58  
59 This program is free software; you can redistribute it and/or modify
60 it under the terms of the GNU General Public License as published by
61 the Free Software Foundation; either version 2 of the License, or
62 (at your option) any later version.
63  
64 See the LICENSE file that comes with this distribution for more details.
65  
66 =cut
67  
68 ####################################################################################################
69  
70 sub validate
71 {
72 0 ▶ my ($self,$change)=@_;
Subroutine validate: not called CC=40 SCAR=74.0
Pod undocumented
73 0 ▶ $change||=0;
Condition0%0/2
$change ||= 0
l!l
00
MC/DC0%0/1
$change ||= 0
$change
Truth table0%0/2
A
A= $change
Aresult
11
00
74 0 my @errs;
75  
76 0 ▶ if (!$change)
Branch: 1 branch
BranchTrueFalseTotal
unless ($change) 0 0 0
77 {
78 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Invalid contact information: name/city/cc/email/srid mandatory') unless (scalar(($self->name())[1]) && scalar(($self->city())[1]) && scalar(($self->cc())[1]) && $self->email() && $self->srid());
Branch: 1 branch
BranchTrueFalseTotal
unless scalar(($self->name)[1]) and scalar(($self->city)[1]) and scalar(($self->cc)[1]) and $self->email and $self->srid 0 0 0
Condition0%0/10
scalar(($self->name)[1]) and scalar(($self->city)[1]) and scalar(($self->cc)[1]) and $self->email and $self->srid
!ll&&!rl&&r
000
scalar(($self->name)[1]) and scalar(($self->city)[1]) and scalar(($self->cc)[1]) and $self->email
!ll&&!rl&&r
000
scalar(($self->name)[1]) and scalar(($self->city)[1]) and scalar(($self->cc)[1])
!ll
00
scalar(($self->name)[1]) and scalar(($self->city)[1])
!ll
00
MC/DC0%0/3
scalar(($self->name)[1]) and scalar(($self->city)[1]) and scalar(($self->cc)[1]) and $self->email and $self->srid
scalar(($self->name)[1]) $self->email $self->srid
Truth table0%0/4
A and B and C
A= scalar(($self->name)[1])B= $self->emailC= $self->srid
ABCresult
0XX0
10X0
1100
1111
79  
80 0 ▶ push @errs,'srid' unless Net::DRI::Util::xml_is_token($self->srid(),3,16);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($self->srid, 3, 16) 0 0 0
81 }
82  
83 0 ▶ push @errs,'srid' if ($self->srid() && $self->srid()!~m/^\w{1,80}-\w{1,8}$/); ## \w includes _ in Perl
Branch: 1 branch
BranchTrueFalseTotal
if $self->srid and not $self->srid =~ /^\w{1,80}-\w{1,8}$/ 0 0 0
Condition0%0/3
$self->srid and not $self->srid =~ /^\w{1,80}-\w{1,8}$/
!ll&&!rl&&r
000
MC/DC0%0/2
$self->srid and not $self->srid =~ /^\w{1,80}-\w{1,8}$/
$self->srid not $self->srid =~ /^\w{1,80}-\w{1,8}$/
Truth table0%0/3
A and not(B)
A= $self->sridB= not $self->srid =~ /^\w{1,80}-\w{1,8}$/
ABresult
0X0
100
111
84 0 ▶ push @errs,'name' if ($self->name() && grep { !Net::DRI::Util::xml_is_normalizedstring($_,1,255) } ($self->name()));
Branch: 1 branch
BranchTrueFalseTotal
if $self->name and grep {not Net::DRI::Util::xml_is_normalizedstring($_, 1, 255);} $self->name 0 0 0
Condition0%0/3
$self->name and grep {not Net::DRI::Util::xml_is_normalizedstring($_, 1, 255);} $self->name
!ll&&!rl&&r
000
MC/DC0%0/2
$self->name and grep {not Net::DRI::Util::xml_is_normalizedstring($_, 1, 255);} $self->name
$self->name grep {not Net::DRI::Util::xml_is_normalizedstring($_, 1, 255);} $self->name
Truth table0%0/3
A and B
A= $self->nameB= grep {not Net::DRI::Util::xml_is_normalizedstring($_, 1, 255);} $self->name
ABresult
0X0
100
111
85 0 ▶ push @errs,'org' if ($self->org() && grep { !Net::DRI::Util::xml_is_normalizedstring($_,undef,255) } ($self->org()));
Branch: 1 branch
BranchTrueFalseTotal
if $self->org and grep {not Net::DRI::Util::xml_is_normalizedstring($_, undef, 255);} $self->org 0 0 0
Condition0%0/3
$self->org and grep {not Net::DRI::Util::xml_is_normalizedstring($_, undef, 255);} $self->org
!ll&&!rl&&r
000
MC/DC0%0/2
$self->org and grep {not Net::DRI::Util::xml_is_normalizedstring($_, undef, 255);} $self->org
$self->org grep {not Net::DRI::Util::xml_is_normalizedstring($_, undef, 255);} $self->org
Truth table0%0/3
A and B
A= $self->orgB= grep {not Net::DRI::Util::xml_is_normalizedstring($_, undef, 255);} $self->org
ABresult
0X0
100
111
86  
87 0 my @rs=($self->street());
88 0 foreach my $i (0,1)
89 {
90 0 ▶ next unless $rs[$i];
Branch: 1 branch
BranchTrueFalseTotal
unless $rs[$i] 0 0 0
91 0 ▶ push @errs,'street' if ((ref($rs[$i]) ne 'ARRAY') || (@{$rs[$i]} > 3) || (grep { !Net::DRI::Util::xml_is_normalizedstring($_,undef,255) } @{$rs[$i]}));
Branch: 1 branch
BranchTrueFalseTotal
if ref $rs[$i] ne "ARRAY" or @{$rs[$i];} > 3 or grep {not Net::DRI::Util::xml_is_normalizedstring($_, undef, 255);} @{$rs[$i];} 0 0 0
Condition0%0/6
ref $rs[$i] ne "ARRAY" or @{$rs[$i];} > 3 or grep {not Net::DRI::Util::xml_is_normalizedstring($_, undef, 255);} @{$rs[$i];}
l!l&&r!l&&!r
000
ref $rs[$i] ne "ARRAY" or @{$rs[$i];} > 3
l!l&&r!l&&!r
000
MC/DC0%0/3
ref $rs[$i] ne "ARRAY" or @{$rs[$i];} > 3 or grep {not Net::DRI::Util::xml_is_normalizedstring($_, undef, 255);} @{$rs[$i];}
ref $rs[$i] ne "ARRAY" @{$rs[$i];} > 3 grep {not Net::DRI::Util::xml_is_normalizedstring($_, undef, 255);} @{$rs[$i];}
Truth table0%0/4
A or B or C
A= ref $rs[$i] ne "ARRAY"B= @{$rs[$i];} > 3C= grep {not Net::DRI::Util::xml_is_normalizedstring($_, undef, 255);} @{$rs[$i];}
ABCresult
1XX1
01X1
0011
0000
92 }
93  
94 0 ▶ push @errs,'city' if ($self->city() && grep { !Net::DRI::Util::xml_is_normalizedstring($_,1,255) } ($self->city()));
Branch: 1 branch
BranchTrueFalseTotal
if $self->city and grep {not Net::DRI::Util::xml_is_normalizedstring($_, 1, 255);} $self->city 0 0 0
Condition0%0/3
$self->city and grep {not Net::DRI::Util::xml_is_normalizedstring($_, 1, 255);} $self->city
!ll&&!rl&&r
000
MC/DC0%0/2
$self->city and grep {not Net::DRI::Util::xml_is_normalizedstring($_, 1, 255);} $self->city
$self->city grep {not Net::DRI::Util::xml_is_normalizedstring($_, 1, 255);} $self->city
Truth table0%0/3
A and B
A= $self->cityB= grep {not Net::DRI::Util::xml_is_normalizedstring($_, 1, 255);} $self->city
ABresult
0X0
100
111
95 0 ▶ push @errs,'sp' if ($self->sp() && grep { !Net::DRI::Util::xml_is_normalizedstring($_,undef,255) } ($self->sp()));
Branch: 1 branch
BranchTrueFalseTotal
if $self->sp and grep {not Net::DRI::Util::xml_is_normalizedstring($_, undef, 255);} $self->sp 0 0 0
Condition0%0/3
$self->sp and grep {not Net::DRI::Util::xml_is_normalizedstring($_, undef, 255);} $self->sp
!ll&&!rl&&r
000
MC/DC0%0/2
$self->sp and grep {not Net::DRI::Util::xml_is_normalizedstring($_, undef, 255);} $self->sp
$self->sp grep {not Net::DRI::Util::xml_is_normalizedstring($_, undef, 255);} $self->sp
Truth table0%0/3
A and B
A= $self->spB= grep {not Net::DRI::Util::xml_is_normalizedstring($_, undef, 255);} $self->sp
ABresult
0X0
100
111
96 0 ▶ push @errs,'pc' if ($self->pc() && grep { !Net::DRI::Util::xml_is_token($_,undef,16) } ($self->pc()));
Branch: 1 branch
BranchTrueFalseTotal
if $self->pc and grep {not Net::DRI::Util::xml_is_token($_, undef, 16);} $self->pc 0 0 0
Condition0%0/3
$self->pc and grep {not Net::DRI::Util::xml_is_token($_, undef, 16);} $self->pc
!ll&&!rl&&r
000
MC/DC0%0/2
$self->pc and grep {not Net::DRI::Util::xml_is_token($_, undef, 16);} $self->pc
$self->pc grep {not Net::DRI::Util::xml_is_token($_, undef, 16);} $self->pc
Truth table0%0/3
A and B
A= $self->pcB= grep {not Net::DRI::Util::xml_is_token($_, undef, 16);} $self->pc
ABresult
0X0
100
111
97 0 ▶ push @errs,'cc' if ($self->cc() && grep { !Net::DRI::Util::xml_is_token($_,2,2) } ($self->cc()));
Branch: 1 branch
BranchTrueFalseTotal
if $self->cc and grep {not Net::DRI::Util::xml_is_token($_, 2, 2);} $self->cc 0 0 0
Condition0%0/3
$self->cc and grep {not Net::DRI::Util::xml_is_token($_, 2, 2);} $self->cc
!ll&&!rl&&r
000
MC/DC0%0/2
$self->cc and grep {not Net::DRI::Util::xml_is_token($_, 2, 2);} $self->cc
$self->cc grep {not Net::DRI::Util::xml_is_token($_, 2, 2);} $self->cc
Truth table0%0/3
A and B
A= $self->ccB= grep {not Net::DRI::Util::xml_is_token($_, 2, 2);} $self->cc
ABresult
0X0
100
111
98 0 ▶ push @errs,'cc' if ($self->cc() && grep { !exists($Net::DRI::Util::CCA2{uc($_)}) } ($self->cc()));
Branch: 1 branch
BranchTrueFalseTotal
if $self->cc and grep {not exists $Net::DRI::Util::CCA2{uc $_};} $self->cc 0 0 0
Condition0%0/3
$self->cc and grep {not exists $Net::DRI::Util::CCA2{uc $_};} $self->cc
!ll&&!rl&&r
000
MC/DC0%0/2
$self->cc and grep {not exists $Net::DRI::Util::CCA2{uc $_};} $self->cc
$self->cc grep {not exists $Net::DRI::Util::CCA2{uc $_};} $self->cc
Truth table0%0/3
A and B
A= $self->ccB= grep {not exists $Net::DRI::Util::CCA2{uc $_};} $self->cc
ABresult
0X0
100
111
99  
100 0 ▶ push @errs,'voice' if ($self->voice() && !Net::DRI::Util::xml_is_token($self->voice(),undef,17) && $self->voice()!~m/^\+[0-9]{1,3}\.[0-9]{1,14}(?:x\d+)?$/);
Branch: 1 branch
BranchTrueFalseTotal
if $self->voice and not Net::DRI::Util::xml_is_token($self->voice, undef, 17) and not $self->voice =~ /^\+[0-9]{1,3}\.[0-9]{1,14}(?:x\d+)?$/ 0 0 0
Condition0%0/6
$self->voice and not Net::DRI::Util::xml_is_token($self->voice, undef, 17) and not $self->voice =~ /^\+[0-9]{1,3}\.[0-9]{1,14}(?:x\d+)?$/
!ll&&!rl&&r
000
$self->voice and not Net::DRI::Util::xml_is_token($self->voice, undef, 17)
!ll&&!rl&&r
000
MC/DC0%0/3
$self->voice and not Net::DRI::Util::xml_is_token($self->voice, undef, 17) and not $self->voice =~ /^\+[0-9]{1,3}\.[0-9]{1,14}(?:x\d+)?$/
$self->voice not Net::DRI::Util::xml_is_token($self->voice, undef, 17) not $self->voice =~ /^\+[0-9]{1,3}\.[0-9]{1,14}(?:x\d+)?$/
Truth table0%0/4
A and not(B) and not(C)
A= $self->voiceB= not Net::DRI::Util::xml_is_token($self->voice, undef, 17)C= not $self->voice =~ /^\+[0-9]{1,3}\.[0-9]{1,14}(?:x\d+)?$/
ABCresult
0XX0
10X0
1100
1111
101 0 ▶ push @errs,'fax' if ($self->fax() && !Net::DRI::Util::xml_is_token($self->fax(),undef,17) && $self->fax()!~m/^\+[0-9]{1,3}\.[0-9]{1,14}(?:x\d+)?$/);
Branch: 1 branch
BranchTrueFalseTotal
if $self->fax and not Net::DRI::Util::xml_is_token($self->fax, undef, 17) and not $self->fax =~ /^\+[0-9]{1,3}\.[0-9]{1,14}(?:x\d+)?$/ 0 0 0
Condition0%0/6
$self->fax and not Net::DRI::Util::xml_is_token($self->fax, undef, 17) and not $self->fax =~ /^\+[0-9]{1,3}\.[0-9]{1,14}(?:x\d+)?$/
!ll&&!rl&&r
000
$self->fax and not Net::DRI::Util::xml_is_token($self->fax, undef, 17)
!ll&&!rl&&r
000
MC/DC0%0/3
$self->fax and not Net::DRI::Util::xml_is_token($self->fax, undef, 17) and not $self->fax =~ /^\+[0-9]{1,3}\.[0-9]{1,14}(?:x\d+)?$/
$self->fax not Net::DRI::Util::xml_is_token($self->fax, undef, 17) not $self->fax =~ /^\+[0-9]{1,3}\.[0-9]{1,14}(?:x\d+)?$/
Truth table0%0/4
A and not(B) and not(C)
A= $self->faxB= not Net::DRI::Util::xml_is_token($self->fax, undef, 17)C= not $self->fax =~ /^\+[0-9]{1,3}\.[0-9]{1,14}(?:x\d+)?$/
ABCresult
0XX0
10X0
1100
1111
102 0 ▶ push @errs,'email' if ($self->email() && !Net::DRI::Util::xml_is_token($self->email(),1,undef) && !Email::Valid->rfc822($self->email()));
Branch: 1 branch
BranchTrueFalseTotal
if $self->email and not Net::DRI::Util::xml_is_token($self->email, 1, undef) and not "Email::Valid"->rfc822($self->email) 0 0 0
Condition0%0/6
$self->email and not Net::DRI::Util::xml_is_token($self->email, 1, undef) and not "Email::Valid"->rfc822($self->email)
!ll&&!rl&&r
000
$self->email and not Net::DRI::Util::xml_is_token($self->email, 1, undef)
!ll&&!rl&&r
000
MC/DC0%0/3
$self->email and not Net::DRI::Util::xml_is_token($self->email, 1, undef) and not "Email::Valid"->rfc822($self->email)
$self->email not Net::DRI::Util::xml_is_token($self->email, 1, undef) not "Email::Valid"->rfc822($self->email)
Truth table0%0/4
A and not(B) and not(C)
A= $self->emailB= not Net::DRI::Util::xml_is_token($self->email, 1, undef)C= not "Email::Valid"->rfc822($self->email)
ABCresult
0XX0
10X0
1100
1111
103  
104 0 $self->auth({pw => ''});
105  
106 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Invalid contact information: '.join('/',@errs)) if @errs;
Branch: 1 branch
BranchTrueFalseTotal
if @errs 0 0 0
107  
108 0 return 1; ## everything ok.
109 }
110  
111 sub init
112 {
113 0 ▶ my ($self,$what,$ndr)=@_;
Subroutine init: not called CC=6 SCAR=37.4
Pod undocumented
114  
115 0 ▶ if ($what eq 'create')
Branch: 1 branch
BranchTrueFalseTotal
if ($what eq "create") 0 0 0
116 {
117 0 my $a=$self->auth();
118 0 ▶ $self->auth({pw=>''}) unless ($a && (ref($a) eq 'HASH') && exists($a->{pw})); ## Mandatory in EPP, not used by .CH/.LI
Branch: 1 branch
BranchTrueFalseTotal
unless $a and ref $a eq "HASH" and exists $a->{"pw"} 0 0 0
Condition0%0/6
$a and ref $a eq "HASH" and exists $a->{"pw"}
!ll&&!rl&&r
000
$a and ref $a eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/3
$a and ref $a eq "HASH" and exists $a->{"pw"}
$a ref $a eq "HASH" exists $a->{"pw"}
Truth table0%0/4
A and B and C
A= $aB= ref $a eq "HASH"C= exists $a->{"pw"}
ABCresult
0XX0
10X0
1100
1111
119 0 ▶ $self->srid('auto') unless defined($self->srid()); ## we can not choose the ID
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->srid 0 0 0
120 }
121 0 return;
122 }
123  
124 ####################################################################################################
125 1 1;
« DRI/Shell.pm ↑ Summary DRI/Data/Contact/DENIC.pm »