DRI/Data/Contact/DENIC.pm

filter: Statementstmt 39.2% 20 / 51 Branchbran 0.0% 0 / 32 Conditioncond 0.0% 0 / 54 MC/DCmcdc 0.0% 0 / 29 Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 1 totaltotal 14.9% 26 / 174 CC 37 SCAR 71.0
CC
37
Cov
15%
validate
1406.0
BEGIN
1.0
BEGIN
1.0
CRAP 1210.0
« DRI/Data/Contact/SWITCH.pm ↑ Summary DRI/Protocol/EPP/Extensions/VeriSign/Suggestion.pm »
1 ## Domain Registry Interface, Handling of contact data for .DE
2 ##
3 ## Copyright (c) 2007,2008,2013 Tonnerre Lombard <tonnerre.lombard@sygroup.ch>. 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::Data::Contact::DENIC;
16  
17 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 ▶use base qw/Net::DRI::Data::Contact/;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use Email::Valid;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 1 __PACKAGE__->register_attributes(qw(type sip remarks));
26  
27 =pod
28  
29 =head1 NAME
30  
31 Net::DRI::Data::Contact::DENIC - Handle .DE contact data for Net::DRI
32  
33 =head1 DESCRIPTION
34  
35 This subclass of Net::DRI::Data::Contact adds accessors and validation for
36 .DE specific data.
37  
38 =head1 METHODS
39  
40 The following accessors/mutators can be called in chain, as they all return the object itself.
41  
42 =head2 type()
43  
44 The type of the contact (Person, Organization, whatever).
45  
46 =head2 sip()
47  
48 The SIP telephone number of the contact.
49  
50 =head2 remarks()
51  
52 Remarks regarding the contact.
53  
54 =head1 SUPPORT
55  
56 For now, support questions should be sent to:
57  
58 E<lt>tonnerre.lombard@sygroup.chE<gt>
59  
60 Please also see the SUPPORT file in the distribution.
61  
62 =head1 SEE ALSO
63  
64 http://oss.bsdprojects.net/projects/netdri/
65  
66 =head1 AUTHOR
67  
68 Tonnerre Lombard E<lt>tonnerre.lombard@sygroup.chE<gt>
69  
70 =head1 COPYRIGHT
71  
72 Copyright (c) 2007,2008,2013 Tonnerre Lombard <tonnerre.lombard@sygroup.ch>.
73 All rights reserved.
74  
75 This program is free software; you can redistribute it and/or modify
76 it under the terms of the GNU General Public License as published by
77 the Free Software Foundation; either version 2 of the License, or
78 (at your option) any later version.
79  
80 See the LICENSE file that comes with this distribution for more details.
81  
82 =cut
83  
84 ####################################################################################################
85  
86 sub validate ## See DENIC-11
87 {
88 0 ▶ my ($self, $change) = @_;
Subroutine validate: not called CC=37 SCAR=72.5
Pod undocumented
89 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
90 0 my @errs;
91  
92 0 ▶ if (!$change)
Branch: 1 branch
BranchTrueFalseTotal
unless ($change) 0 0 0
93 {
94 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Invalid contact information: name/city/cc/srid mandatory')
Branch: 1 branch
BranchTrueFalseTotal
unless scalar $self->name and scalar $self->city and scalar $self->cc and $self->srid 0 0 0
Condition0%0/7
scalar $self->name and scalar $self->city and scalar $self->cc and $self->srid
!ll&&!rl&&r
000
scalar $self->name and scalar $self->city and scalar $self->cc
!ll
00
scalar $self->name and scalar $self->city
!ll
00
MC/DC0%0/2
scalar $self->name and scalar $self->city and scalar $self->cc and $self->srid
scalar $self->name $self->srid
Truth table0%0/3
A and B
A= scalar $self->nameB= $self->srid
ABresult
0X0
100
111
95 unless (scalar($self->name()) && scalar($self->city())
96 && scalar($self->cc()) && $self->srid());
97 0 ▶ push @errs,'srid'
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($self->srid, 3, 32) 0 0 0
98 unless Net::DRI::Util::xml_is_token($self->srid(),
99 3, 32);
100 }
101  
102 ## TODO: convert that to a test on srid(), testing roid() is useless
103 ## \w includes _ in Perl
104 0 ▶ push(@errs,'roid') if ($self->roid() &&
Branch: 1 branch
BranchTrueFalseTotal
if $self->roid and not $self->roid =~ /^\w{1,80}-\w{1,8}$/ 0 0 0
Condition0%0/3
$self->roid and not $self->roid =~ /^\w{1,80}-\w{1,8}$/
!ll&&!rl&&r
000
MC/DC0%0/2
$self->roid and not $self->roid =~ /^\w{1,80}-\w{1,8}$/
$self->roid not $self->roid =~ /^\w{1,80}-\w{1,8}$/
Truth table0%0/3
A and not(B)
A= $self->roidB= not $self->roid =~ /^\w{1,80}-\w{1,8}$/
ABresult
0X0
100
111
105 $self->roid() !~ m/^\w{1,80}-\w{1,8}$/);
106  
107 push(@errs,'name') if ($self->name() &&
108 0 ▶ grep { !Net::DRI::Util::xml_is_normalizedstring($_,1,255) }
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
109 ($self->name()));
110 push(@errs,'org') if ($self->org() &&
111 0 ▶ grep { !Net::DRI::Util::xml_is_normalizedstring($_,undef,255) }
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
112 ($self->org()));
113  
114 0 my @rs = ($self->street());
115 0 foreach my $i (0,1)
116 {
117 0 ▶ next unless $rs[$i];
Branch: 1 branch
BranchTrueFalseTotal
unless $rs[$i] 0 0 0
118 push(@errs,'street') if ((ref($rs[$i]) ne 'ARRAY') ||
119 0 (@{$rs[$i]} > 3) ||
120 0 (grep { !Net::DRI::Util::xml_is_normalizedstring($_,
121 0 ▶ 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
122 }
123  
124 push(@errs,'city') if ($self->city() &&
125 0 ▶ grep { !Net::DRI::Util::xml_is_normalizedstring($_,1,255) }
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
126 ($self->city()));
127 push(@errs,'pc') if ($self->pc() &&
128 0 ▶ grep { !Net::DRI::Util::xml_is_normalizedstring($_,undef,16) }
Branch: 1 branch
BranchTrueFalseTotal
if $self->pc and grep {not Net::DRI::Util::xml_is_normalizedstring($_, undef, 16);} $self->pc 0 0 0
Condition0%0/3
$self->pc and grep {not Net::DRI::Util::xml_is_normalizedstring($_, undef, 16);} $self->pc
!ll&&!rl&&r
000
MC/DC0%0/2
$self->pc and grep {not Net::DRI::Util::xml_is_normalizedstring($_, undef, 16);} $self->pc
$self->pc grep {not Net::DRI::Util::xml_is_normalizedstring($_, undef, 16);} $self->pc
Truth table0%0/3
A and B
A= $self->pcB= grep {not Net::DRI::Util::xml_is_normalizedstring($_, undef, 16);} $self->pc
ABresult
0X0
100
111
129 ($self->pc()));
130 push(@errs,'cc') if ($self->cc() &&
131 0 ▶ grep { !Net::DRI::Util::xml_is_normalizedstring($_,2,2) }
Branch: 1 branch
BranchTrueFalseTotal
if $self->cc and grep {not Net::DRI::Util::xml_is_normalizedstring($_, 2, 2);} $self->cc 0 0 0
Condition0%0/3
$self->cc and grep {not Net::DRI::Util::xml_is_normalizedstring($_, 2, 2);} $self->cc
!ll&&!rl&&r
000
MC/DC0%0/2
$self->cc and grep {not Net::DRI::Util::xml_is_normalizedstring($_, 2, 2);} $self->cc
$self->cc grep {not Net::DRI::Util::xml_is_normalizedstring($_, 2, 2);} $self->cc
Truth table0%0/3
A and B
A= $self->ccB= grep {not Net::DRI::Util::xml_is_normalizedstring($_, 2, 2);} $self->cc
ABresult
0X0
100
111
132 ($self->cc()));
133 push(@errs,'cc') if ($self->cc() &&
134 0 ▶ 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
135  
136 0 ▶ push(@errs,'voice') if ($self->voice() &&
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
137 !Net::DRI::Util::xml_is_token($self->voice(),undef,17) &&
138 $self->voice() !~ m/^\+[0-9]{1,3}\.[0-9]{1,14}(?:x\d+)?$/);
139 0 ▶ push(@errs,'fax') if ($self->fax() &&
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
140 !Net::DRI::Util::xml_is_token($self->fax(),undef,17) &&
141 $self->fax() !~ m/^\+[0-9]{1,3}\.[0-9]{1,14}(?:x\d+)?$/);
142 0 ▶ push(@errs,'email') if ($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
143 !Net::DRI::Util::xml_is_token($self->email(),1,undef) &&
144 !Email::Valid->rfc822($self->email()));
145  
146 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Invalid contact information: ' .
Branch: 1 branch
BranchTrueFalseTotal
if @errs 0 0 0
147 join('/', @errs)) if (@errs);
148  
149 0 return 1; ## everything ok.
150 }
151  
152 ####################################################################################################
153 1 1;
« DRI/Data/Contact/SWITCH.pm ↑ Summary DRI/Protocol/EPP/Extensions/VeriSign/Suggestion.pm »