DRI/Data/Contact/EURid.pm

filter: Statementstmt 45.4% 20 / 44 Branchbran 0.0% 0 / 28 Conditioncond 0.0% 0 / 47 MC/DCmcdc 0.0% 0 / 26 Subroutinesub 75.0% 6 / 8 Podpod 0.0% 0 / 2 totaltotal 16.7% 26 / 155 CC 31 SCAR 61.9
CC
31
Cov
17%
validate
702.0
init
42.0
BEGIN
1.0
CRAP 487.1
« DRI/Protocol/EPP/Extensions/TCI/Registrar.pm ↑ Summary DRI/Protocol/RRI/RegistryMessage.pm »
1 ## Domain Registry Interface, Handling of contact data for EURid
2 ##
3 ## Copyright (c) 2005-2009,2012,2013 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::Data::Contact::EURid;
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  
22 1 ▶use Net::DRI::DRD::EURid;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 1 __PACKAGE__->register_attributes(qw(type vat lang));
27  
28 =pod
29  
30 =head1 NAME
31  
32 Net::DRI::Data::Contact::EURid - Handle EURid contact data for Net::DRI
33  
34 =head1 DESCRIPTION
35  
36 This subclass of Net::DRI::Data::Contact adds accessors and validation for
37 EURid specific data.
38  
39 =head1 METHODS
40  
41 The following accessors/mutators can be called in chain, as they all return the object itself.
42  
43 =head2 type()
44  
45 type of contact : billing, tech, registrant or onsite (mandatory)
46  
47 =head2 vat()
48  
49 vat number of contact
50  
51 =head1 SUPPORT
52  
53 For now, support questions should be sent to:
54  
55 E<lt>netdri@dotandco.comE<gt>
56  
57 Please also see the SUPPORT file in the distribution.
58  
59 =head1 SEE ALSO
60  
61 http://www.dotandco.com/services/software/Net-DRI/
62  
63 =head1 AUTHOR
64  
65 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
66  
67 =head1 COPYRIGHT
68  
69 Copyright (c) 2005-2009,2012,2013 Patrick Mevzek <netdri@dotandco.com>.
70 All rights reserved.
71  
72 This program is free software; you can redistribute it and/or modify
73 it under the terms of the GNU General Public License as published by
74 the Free Software Foundation; either version 2 of the License, or
75 (at your option) any later version.
76  
77 See the LICENSE file that comes with this distribution for more details.
78  
79 =cut
80  
81 ####################################################################################################
82  
83 sub validate
84 {
85 0 ▶ my ($self,$change)=@_;
Subroutine validate: not called CC=26 SCAR=65.5
Pod undocumented
86 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
87 0 my @errs;
88  
89 0 $self->SUPER::validate($change); ## will trigger an Exception if problem
90  
91 0 ▶ if (!$change)
Branch: 1 branch
BranchTrueFalseTotal
unless ($change) 0 0 0
92 {
93 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Invalid contact information: voice/type/lang mandatory') unless ($self->voice() && $self->type() && $self->lang());
Branch: 1 branch
BranchTrueFalseTotal
unless $self->voice and $self->type and $self->lang 0 0 0
Condition0%0/6
$self->voice and $self->type and $self->lang
!ll&&!rl&&r
000
$self->voice and $self->type
!ll&&!rl&&r
000
MC/DC0%0/3
$self->voice and $self->type and $self->lang
$self->voice $self->type $self->lang
Truth table0%0/4
A and B and C
A= $self->voiceB= $self->typeC= $self->lang
ABCresult
0XX0
10X0
1100
1111
94 }
95  
96 ## Lower limits than in EPP (other checks already done in superclass)
97 0 ▶ push @errs,'name' if ($self->name() && grep { length($_) > 50 } ($self->name()));
Branch: 1 branch
BranchTrueFalseTotal
if $self->name and grep {length $_ > 50;} $self->name 0 0 0
Condition0%0/3
$self->name and grep {length $_ > 50;} $self->name
!ll&&!rl&&r
000
MC/DC0%0/2
$self->name and grep {length $_ > 50;} $self->name
$self->name grep {length $_ > 50;} $self->name
Truth table0%0/3
A and B
A= $self->nameB= grep {length $_ > 50;} $self->name
ABresult
0X0
100
111
98 0 ▶ push @errs,'org' if ($self->org() && grep { length($_) > 100 } ($self->org()));
Branch: 1 branch
BranchTrueFalseTotal
if $self->org and grep {length $_ > 100;} $self->org 0 0 0
Condition0%0/3
$self->org and grep {length $_ > 100;} $self->org
!ll&&!rl&&r
000
MC/DC0%0/2
$self->org and grep {length $_ > 100;} $self->org
$self->org grep {length $_ > 100;} $self->org
Truth table0%0/3
A and B
A= $self->orgB= grep {length $_ > 100;} $self->org
ABresult
0X0
100
111
99  
100  
101 0 ▶ push @errs,'type' if ($self->type() && $self->type()!~m/^(?:billing|tech|registrant|onsite)$/);
Branch: 1 branch
BranchTrueFalseTotal
if $self->type and not $self->type =~ /^(?:billing|tech|registrant|onsite)$/ 0 0 0
Condition0%0/3
$self->type and not $self->type =~ /^(?:billing|tech|registrant|onsite)$/
!ll&&!rl&&r
000
MC/DC0%0/2
$self->type and not $self->type =~ /^(?:billing|tech|registrant|onsite)$/
$self->type not $self->type =~ /^(?:billing|tech|registrant|onsite)$/
Truth table0%0/3
A and not(B)
A= $self->typeB= not $self->type =~ /^(?:billing|tech|registrant|onsite)$/
ABresult
0X0
100
111
102 0 ▶ push @errs,'vat' if ($self->vat() && !Net::DRI::Util::xml_is_token($self->vat(),1,20));
Branch: 1 branch
BranchTrueFalseTotal
if $self->vat and not Net::DRI::Util::xml_is_token($self->vat, 1, 20) 0 0 0
Condition0%0/3
$self->vat and not Net::DRI::Util::xml_is_token($self->vat, 1, 20)
!ll&&!rl&&r
000
MC/DC0%0/2
$self->vat and not Net::DRI::Util::xml_is_token($self->vat, 1, 20)
$self->vat not Net::DRI::Util::xml_is_token($self->vat, 1, 20)
Truth table0%0/3
A and not(B)
A= $self->vatB= not Net::DRI::Util::xml_is_token($self->vat, 1, 20)
ABresult
0X0
100
111
103 0 ▶ push @errs,'lang' if ($self->lang() && !exists($Net::DRI::DRD::EURid::LANGA2_EU{lc($self->lang())}));
Branch: 1 branch
BranchTrueFalseTotal
if $self->lang and not exists $Net::DRI::DRD::EURid::LANGA2_EU{lc $self->lang} 0 0 0
Condition0%0/3
$self->lang and not exists $Net::DRI::DRD::EURid::LANGA2_EU{lc $self->lang}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->lang and not exists $Net::DRI::DRD::EURid::LANGA2_EU{lc $self->lang}
$self->lang not exists $Net::DRI::DRD::EURid::LANGA2_EU{lc $self->lang}
Truth table0%0/3
A and not(B)
A= $self->langB= not exists $Net::DRI::DRD::EURid::LANGA2_EU{lc $self->lang}
ABresult
0X0
100
111
104  
105 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Invalid contact information: '.join('/',@errs)) if @errs;
Branch: 1 branch
BranchTrueFalseTotal
if @errs 0 0 0
106  
107 ## if eurid:type is billing or tech, contact:org is mandatory
108 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Org is mandatory for billing or tech contacts') if ($self->type() && $self->type()=~m/^(?:type|billing)$/ && !$self->org());
Branch: 1 branch
BranchTrueFalseTotal
if $self->type and $self->type =~ /^(?:type|billing)$/ and not $self->org 0 0 0
Condition0%0/6
$self->type and $self->type =~ /^(?:type|billing)$/ and not $self->org
!ll&&!rl&&r
000
$self->type and $self->type =~ /^(?:type|billing)$/
!ll&&!rl&&r
000
MC/DC0%0/3
$self->type and $self->type =~ /^(?:type|billing)$/ and not $self->org
$self->type $self->type =~ /^(?:type|billing)$/ not $self->org
Truth table0%0/4
A and B and not(C)
A= $self->typeB= $self->type =~ /^(?:type|billing)$/C= not $self->org
ABCresult
0XX0
10X0
1100
1111
109  
110 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Fax is mandatory for billing contacts') if (defined($self->type()) && ($self->type() eq 'billing') && !$self->fax());
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->type and $self->type eq "billing" and not $self->fax 0 0 0
Condition0%0/6
defined $self->type and $self->type eq "billing" and not $self->fax
!ll&&!rl&&r
000
defined $self->type and $self->type eq "billing"
!ll&&!rl&&r
000
MC/DC0%0/3
defined $self->type and $self->type eq "billing" and not $self->fax
defined $self->type $self->type eq "billing" not $self->fax
Truth table0%0/4
A and B and not(C)
A= defined $self->typeB= $self->type eq "billing"C= not $self->fax
ABCresult
0XX0
10X0
1100
1111
111  
112 ## For registrants, country must be in EU
113 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Registrant contact must be in EU') if ($self->type() && ($self->type() eq 'registrant') && !exists($Net::DRI::DRD::EURid::CCA2_EU{uc($self->cc())}));
Branch: 1 branch
BranchTrueFalseTotal
if $self->type and $self->type eq "registrant" and not exists $Net::DRI::DRD::EURid::CCA2_EU{uc $self->cc} 0 0 0
Condition0%0/6
$self->type and $self->type eq "registrant" and not exists $Net::DRI::DRD::EURid::CCA2_EU{uc $self->cc}
!ll&&!rl&&r
000
$self->type and $self->type eq "registrant"
!ll&&!rl&&r
000
MC/DC0%0/3
$self->type and $self->type eq "registrant" and not exists $Net::DRI::DRD::EURid::CCA2_EU{uc $self->cc}
$self->type $self->type eq "registrant" not exists $Net::DRI::DRD::EURid::CCA2_EU{uc $self->cc}
Truth table0%0/4
A and B and not(C)
A= $self->typeB= $self->type eq "registrant"C= not exists $Net::DRI::DRD::EURid::CCA2_EU{uc $self->cc}
ABCresult
0XX0
10X0
1100
1111
114  
115 0 return 1; ## everything ok.
116 }
117  
118 sub init
119 {
120 0 ▶ my ($self,$what,$ndr)=@_;
Subroutine init: not called CC=6 SCAR=37.4
Pod undocumented
121 0 ▶ if ($what eq 'create')
Branch: 1 branch
BranchTrueFalseTotal
if ($what eq "create") 0 0 0
122 {
123 0 my $a=$self->auth();
124 0 ▶ $self->auth({pw=>''}) unless ($a && (ref($a) eq 'HASH') && exists($a->{pw}));
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
125 0 ▶ $self->srid('ABCD') unless defined $self->srid(); ## we can not choose the ID
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->srid 0 0 0
126 }
127 0 return;
128 }
129  
130 ####################################################################################################
131 1 1;
« DRI/Protocol/EPP/Extensions/TCI/Registrar.pm ↑ Summary DRI/Protocol/RRI/RegistryMessage.pm »