DRI/Data/Contact/CIRA.pm

filter: Statementstmt 39.5% 17 / 43 Branchbran 0.0% 0 / 30 Conditioncond 0.0% 0 / 53 MC/DCmcdc 0.0% 0 / 27 Subroutinesub 71.4% 5 / 7 Podpod 0.0% 0 / 2 totaltotal 13.5% 22 / 162 CC 34 SCAR 65.5
CC
34
Cov
13%
validate
930.0
init
30.0
BEGIN
1.0
CRAP 701.4
« DRI/Data/Contact.pm ↑ Summary DRI/Protocol/EPP/Core/Session.pm »
1 ## Domain Registry Interface, Handling of contact data for CIRA
2 ##
3 ## Copyright (c) 2010,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::CIRA;
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::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 1 __PACKAGE__->register_attributes(qw(legal_form lang is_individual ip_address agreement reseller_id whois_display));
26  
27 ####################################################################################################
28  
29 sub validate
30 {
31 0 ▶ my ($self,$change)=@_;
Subroutine validate: not called CC=30 SCAR=68.4
Pod undocumented
32 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
33  
34 0 $self->SUPER::validate(1); ## will trigger an Exception if problem
35  
36 0 my @errs;
37 0 ▶ if (!$change)
Branch: 1 branch
BranchTrueFalseTotal
unless ($change) 0 0 0
38 {
39 0 ▶ my @missing=grep { my $r=scalar $self->$_(); (defined $r && length $r)? 0 : 1 } qw/name cc lang srid auth/;
Branch: 1 branch
BranchTrueFalseTotal
defined $r && length $r ? : 0 0 0
Condition0%0/3
defined $r and length $r
!ll&&!rl&&r
000
MC/DC0%0/2
defined $r and length $r
defined $r length $r
Truth table0%0/3
A and B
A= defined $rB= length $r
ABresult
0X0
100
111
40 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Mandatory contact information missing: '.join('/',@missing)) if @missing;
Branch: 1 branch
BranchTrueFalseTotal
if @missing 0 0 0
41 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
42 }
43  
44 0 ▶ push @errs,'sp' if (defined $self->sp() && defined $self->cc() && $self->cc() eq 'CA' && $self->sp()!~m/^(?:AB|BC|MB|NB|NL|NT|NS|NU|ON|PE|QC|SK|YT)$/);
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->sp and defined $self->cc and $self->cc eq "CA" and not $self->sp =~ /^(?:AB|BC|MB|NB|NL|NT|NS|NU|ON|PE|QC|SK|YT)$/ 0 0 0
Condition0%0/9
defined $self->sp and defined $self->cc and $self->cc eq "CA" and not $self->sp =~ /^(?:AB|BC|MB|NB|NL|NT|NS|NU|ON|PE|QC|SK|YT)$/
!ll&&!rl&&r
000
defined $self->sp and defined $self->cc and $self->cc eq "CA"
!ll&&!rl&&r
000
defined $self->sp and defined $self->cc
!ll&&!rl&&r
000
MC/DC0%0/4
defined $self->sp and defined $self->cc and $self->cc eq "CA" and not $self->sp =~ /^(?:AB|BC|MB|NB|NL|NT|NS|NU|ON|PE|QC|SK|YT)$/
defined $self->sp defined $self->cc $self->cc eq "CA" not $self->sp =~ /^(?:AB|BC|MB|NB|NL|NT|NS|NU|ON|PE|QC|SK|YT)$/
Truth table0%0/5
A and B and C and not(D)
A= defined $self->spB= defined $self->ccC= $self->cc eq "CA"D= not $self->sp =~ /^(?:AB|BC|MB|NB|NL|NT|NS|NU|ON|PE|QC|SK|YT)$/
ABCDresult
0XXX0
10XX0
110X0
11100
11111
45  
46 0 ▶ push @errs,'legal_form' if (defined $self->legal_form() && $self->legal_form()!~m!^(?:CCO|CCT|RES|GOV|EDU|ASS|HOP|PRT|TDM|TRD|PLT|LAM|TRS|ABO|INB|LGR|OMK|MAJ)$!);
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->legal_form and not $self->legal_form =~ /^(?:CCO|CCT|RES|GOV|EDU|ASS|HOP|PRT|TDM|TRD|PLT|LAM|TRS|ABO|INB|LGR|OMK|MAJ)$/ 0 0 0
Condition0%0/3
defined $self->legal_form and not $self->legal_form =~ /^(?:CCO|CCT|RES|GOV|EDU|ASS|HOP|PRT|TDM|TRD|PLT|LAM|TRS|ABO|INB|LGR|OMK|MAJ)$/
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->legal_form and not $self->legal_form =~ /^(?:CCO|CCT|RES|GOV|EDU|ASS|HOP|PRT|TDM|TRD|PLT|LAM|TRS|ABO|INB|LGR|OMK|MAJ)$/
defined $self->legal_form not $self->legal_form =~ /^(?:CCO|CCT|RES|GOV|EDU|ASS|HOP|PRT|TDM|TRD|PLT|LAM|TRS|ABO|INB|LGR|OMK|MAJ)$/
Truth table0%0/3
A and not(B)
A= defined $self->legal_formB= not $self->legal_form =~ /^(?:CCO|CCT|RES|GOV|EDU|ASS|HOP|PRT|TDM|TRD|PLT|LAM|TRS|ABO|INB|LGR|OMK|MAJ)$/
ABresult
0X0
100
111
47 0 ▶ push @errs,'lang' if (defined $self->lang() && $self->lang()!~m/^(?:fr|en)$/o);
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->lang and not $self->lang =~ /^(?:fr|en)$/o 0 0 0
Condition0%0/3
defined $self->lang and not $self->lang =~ /^(?:fr|en)$/o
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->lang and not $self->lang =~ /^(?:fr|en)$/o
defined $self->lang not $self->lang =~ /^(?:fr|en)$/o
Truth table0%0/3
A and not(B)
A= defined $self->langB= not $self->lang =~ /^(?:fr|en)$/o
ABresult
0X0
100
111
48 0 ▶ push @errs,'ip_address' if (defined $self->ip_address() && !Net::DRI::Util::is_ipv4($self->ip_address(),1) && !Net::DRI::Util::is_ipv6($self->ip_address(),1));
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->ip_address and not Net::DRI::Util::is_ipv4($self->ip_address, 1) and not Net::DRI::Util::is_ipv6($self->ip_address, 1) 0 0 0
Condition0%0/6
defined $self->ip_address and not Net::DRI::Util::is_ipv4($self->ip_address, 1) and not Net::DRI::Util::is_ipv6($self->ip_address, 1)
!ll&&!rl&&r
000
defined $self->ip_address and not Net::DRI::Util::is_ipv4($self->ip_address, 1)
!ll&&!rl&&r
000
MC/DC0%0/3
defined $self->ip_address and not Net::DRI::Util::is_ipv4($self->ip_address, 1) and not Net::DRI::Util::is_ipv6($self->ip_address, 1)
defined $self->ip_address not Net::DRI::Util::is_ipv4($self->ip_address, 1) not Net::DRI::Util::is_ipv6($self->ip_address, 1)
Truth table0%0/4
A and not(B) and not(C)
A= defined $self->ip_addressB= not Net::DRI::Util::is_ipv4($self->ip_address, 1)C= not Net::DRI::Util::is_ipv6($self->ip_address, 1)
ABCresult
0XX0
10X0
1100
1111
49 0 ▶ if (defined $self->agreement())
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->agreement) 0 0 0
50 {
51 0 my $ra=$self->agreement();
52 0 ▶ push @errs,'agreement' if (ref($ra) ne 'HASH' || 2!=keys(%$ra) || !exists($ra->{version}) || !exists($ra->{signed}) || length($ra->{version}) > 4 || $ra->{signed}!~m/^(?:0|1)$/);
Branch: 1 branch
BranchTrueFalseTotal
if ref $ra ne "HASH" or 2 != keys %$ra or not exists $ra->{"version"} or not exists $ra->{"signed"} or length $ra->{"version"} > 4 or not $ra->{"signed"} =~ /^(?:0|1)$/ 0 0 0
Condition0%0/15
ref $ra ne "HASH" or 2 != keys %$ra or not exists $ra->{"version"} or not exists $ra->{"signed"} or length $ra->{"version"} > 4 or not $ra->{"signed"} =~ /^(?:0|1)$/
l!l&&r!l&&!r
000
ref $ra ne "HASH" or 2 != keys %$ra or not exists $ra->{"version"} or not exists $ra->{"signed"} or length $ra->{"version"} > 4
l!l&&r!l&&!r
000
ref $ra ne "HASH" or 2 != keys %$ra or not exists $ra->{"version"} or not exists $ra->{"signed"}
l!l&&r!l&&!r
000
ref $ra ne "HASH" or 2 != keys %$ra or not exists $ra->{"version"}
l!l&&r!l&&!r
000
ref $ra ne "HASH" or 2 != keys %$ra
l!l&&r!l&&!r
000
MC/DC0%0/6
ref $ra ne "HASH" or 2 != keys %$ra or not exists $ra->{"version"} or not exists $ra->{"signed"} or length $ra->{"version"} > 4 or not $ra->{"signed"} =~ /^(?:0|1)$/
ref $ra ne "HASH" 2 != keys %$ra not exists $ra->{"version"} not exists $ra->{"signed"} length $ra->{"version"} > 4 not $ra->{"signed"} =~ /^(?:0|1)$/
Truth table0%0/7
A or B or not(C) or not(D) or E or not(F)
A= ref $ra ne "HASH"B= 2 != keys %$raC= not exists $ra->{"version"}D= not exists $ra->{"signed"}E= length $ra->{"version"} > 4F= not $ra->{"signed"} =~ /^(?:0|1)$/
ABCDEFresult
1XXXXX1
01XXXX1
001XXX1
0001XX1
00001X1
0000011
0000000
53 }
54 0 ▶ push @errs,'reseller_id' if (defined $self->reseller_id() && length($self->reseller_id()) > 255);
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->reseller_id and length $self->reseller_id > 255 0 0 0
Condition0%0/3
defined $self->reseller_id and length $self->reseller_id > 255
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->reseller_id and length $self->reseller_id > 255
defined $self->reseller_id length $self->reseller_id > 255
Truth table0%0/3
A and B
A= defined $self->reseller_idB= length $self->reseller_id > 255
ABresult
0X0
100
111
55 0 ▶ push @errs,'whois_display' if (defined $self->whois_display() && $self->whois_display()!~m/^(?:FULL|PRIVATE)$/o);
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->whois_display and not $self->whois_display =~ /^(?:FULL|PRIVATE)$/o 0 0 0
Condition0%0/3
defined $self->whois_display and not $self->whois_display =~ /^(?:FULL|PRIVATE)$/o
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->whois_display and not $self->whois_display =~ /^(?:FULL|PRIVATE)$/o
defined $self->whois_display not $self->whois_display =~ /^(?:FULL|PRIVATE)$/o
Truth table0%0/3
A and not(B)
A= defined $self->whois_displayB= not $self->whois_display =~ /^(?:FULL|PRIVATE)$/o
ABresult
0X0
100
111
56  
57 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Invalid contact information: '.join('/',@errs)) if @errs;
Branch: 1 branch
BranchTrueFalseTotal
if @errs 0 0 0
58 0 return 1; ## everything ok.
59 }
60  
61 sub init
62 {
63 0 ▶ my ($self,$what,$ndr)=@_;
Subroutine init: not called CC=5 SCAR=34.0
Pod undocumented
64 0 ▶ if ($what eq 'create')
Branch: 1 branch
BranchTrueFalseTotal
if ($what eq "create") 0 0 0
65 {
66 0 my $a=$self->auth();
67 0 ▶ $self->auth({pw=>''}) unless ($a && (ref($a) eq 'HASH') && exists($a->{pw})); ## authInfo is not used
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
68 }
69 0 return;
70 }
71  
72 ####################################################################################################
73 1 1;
74  
75 __END__
76  
77 =pod
78  
79 =head1 NAME
80  
81 Net::DRI::Data::Contact::CIRA - Handle CIRA (.CA) contact data for Net::DRI
82  
83 =head1 SYNOPSIS
84  
85 This module is not used directly, but objects will be created in this class
86 automatically when needed.
87  
88 =head1 DESCRIPTION
89  
90 This subclass of Net::DRI::Data::Contact adds accessors and validation for
91 CIRA specific data.
92  
93 =head1 METHODS
94  
95 The following accessors/mutators can be called in chain, as they all return the object itself.
96  
97 =head2 legal_form()
98  
99 legal form (see registry list of possible CPR values), mandatory for registrant contacts, otherwise optional
100  
101 =head2 lang()
102  
103 contact preferred language, either 'fr' or 'en'
104  
105 =head2 ip_address()
106  
107 (optional) registrant originating IP address (v4 or v6)
108  
109 =head2 agreement()
110  
111 ref hash with keys version and signed (value being 1 or 0); optional for non registrant contacts
112 registry also adds a third key, 'timestamp'
113  
114 =head2 reseller_id()
115  
116 (optional) ID of the registrar reseller
117  
118 =head2 whois_display()
119  
120 for registrant contacts, either FULL or PRIVATE
121  
122 =head1 SUPPORT
123  
124 For now, support questions should be sent to:
125  
126 E<lt>netdri@dotandco.comE<gt>
127  
128 Please also see the SUPPORT file in the distribution.
129  
130 =head1 SEE ALSO
131  
132 http://www.dotandco.com/services/software/Net-DRI/
133  
134 =head1 AUTHOR
135  
136 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
137  
138 =head1 COPYRIGHT
139  
140 Copyright (c) 2010,2013 Patrick Mevzek <netdri@dotandco.com>.
141 All rights reserved.
142  
143 This program is free software; you can redistribute it and/or modify
144 it under the terms of the GNU General Public License as published by
145 the Free Software Foundation; either version 2 of the License, or
146 (at your option) any later version.
147  
148 See the LICENSE file that comes with this distribution for more details.
149  
150 =cut
« DRI/Data/Contact.pm ↑ Summary DRI/Protocol/EPP/Core/Session.pm »