DRI/Protocol/EPP/Extensions/Nomulus/Allocate.pm

filter: Statementstmt 30.7% 16 / 52 Branchbran 0.0% 0 / 24 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 55.5% 5 / 9 Podpod 0.0% 0 / 4 totaltotal 20.1% 21 / 104 CC 17 SCAR 53.4
CC
17
Cov
19%
build
306.0
register_commands
2.0
setup
2.0
CRAP 208.5
« DRI/Protocol/EPP/Extensions/ICANN/MarkSignedMark.pm ↑ Summary DRI/Protocol/EPP/Extensions/EURid/Sunrise.pm »
1 ## Domain Registry Interface, Nomulus Allocate Extension Mapping for EPP
2 ##
3 ## Copyright (c) 2017-2019 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::Protocol::EPP::Extensions::Nomulus::Allocate;
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 1 ▶use feature 'state';
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 ####################################################################################################
25  
26 sub register_commands
27 0 ▶{
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
28 0 my ($class,$version)=@_;
29 0 state $cmds = { 'domain' => { create => [ \&build, undef ] } };
30 0 return $cmds;
31 }
32  
33 sub setup
34 0 ▶{
Subroutine setup: not called CC=1 SCAR=6.9
Pod undocumented
35 0 my ($class,$po,$version)=@_;
36 0 state $ns = { 'allocate' => 'urn:google:params:xml:ns:allocate-1.0' };
37 0 $po->ns($ns);
38 0 return;
39 }
40  
41 0 ▶sub implements { return 'https://github.com/google/nomulus/blob/5012893c1d761d60591f165a1c5640624b28df9d/java/google/registry/xml/xsd/allocate.xsd'; }
Subroutine implements: not called CC=1 SCAR=6.9
Pod undocumented
42  
43 ####################################################################################################
44  
45 sub build
46 0 ▶{
Subroutine build: not called CC=17 SCAR=57.2
Pod undocumented
47 0 my ($epp,$domain,$rd)=@_;
48  
49 0 ▶ return unless Net::DRI::Util::has_key($rd, 'allocate') && ref $rd->{'allocate'} eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rd, "allocate") and ref $rd->{"allocate"} eq "HASH" 0 0 0
Condition0%0/3
Net::DRI::Util::has_key($rd, "allocate") and ref $rd->{"allocate"} eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
Net::DRI::Util::has_key($rd, "allocate") and ref $rd->{"allocate"} eq "HASH"
Net::DRI::Util::has_key($rd, "allocate") ref $rd->{"allocate"} eq "HASH"
Truth table0%0/3
A and B
A= Net::DRI::Util::has_key($rd, "allocate")B= ref $rd->{"allocate"} eq "HASH"
ABresult
0X0
100
111
50  
51 0 my $rh=$rd->{'allocate'};
52 0 my @data;
53 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('allocate.roid must be defined') unless Net::DRI::Util::has_key($rh, 'roid') && Net::DRI::Util::is_roid($rh->{'roid'});
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rh, "roid") and Net::DRI::Util::is_roid($rh->{"roid"}) 0 0 0
Condition0%0/3
Net::DRI::Util::has_key($rh, "roid") and Net::DRI::Util::is_roid($rh->{"roid"})
!ll&&!rl&&r
000
MC/DC0%0/2
Net::DRI::Util::has_key($rh, "roid") and Net::DRI::Util::is_roid($rh->{"roid"})
Net::DRI::Util::has_key($rh, "roid") Net::DRI::Util::is_roid($rh->{"roid"})
Truth table0%0/3
A and B
A= Net::DRI::Util::has_key($rh, "roid")B= Net::DRI::Util::is_roid($rh->{"roid"})
ABresult
0X0
100
111
54 0 push @data, ['allocate:applicationRoid', $rh->{'roid'}];
55 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('allocate.application_time must be a DateTime object') unless Net::DRI::Util::has_key($rh, 'application_time') && Net::DRI::Util::check_isa($rh->{application_time}, 'DateTime');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rh, "application_time") and Net::DRI::Util::check_isa($rh->{"application_time"}, "DateTime") 0 0 0
Condition0%0/3
Net::DRI::Util::has_key($rh, "application_time") and Net::DRI::Util::check_isa($rh->{"application_time"}, "DateTime")
!ll&&!rl&&r
000
MC/DC0%0/2
Net::DRI::Util::has_key($rh, "application_time") and Net::DRI::Util::check_isa($rh->{"application_time"}, "DateTime")
Net::DRI::Util::has_key($rh, "application_time") Net::DRI::Util::check_isa($rh->{"application_time"}, "DateTime")
Truth table0%0/3
A and B
A= Net::DRI::Util::has_key($rh, "application_time")B= Net::DRI::Util::check_isa($rh->{"application_time"}, "DateTime")
ABresult
0X0
100
111
56 0 push @data, ['allocate:applicationTime', $rh->{application_time}->clone()->set_time_zone('UTC')->strftime('%Y-%m-%dT%H:%M:%SZ')];
57 0 ▶ if (Net::DRI::Util::has_key($rh, 'smd'))
Branch: 1 branch
BranchTrueFalseTotal
if (Net::DRI::Util::has_key($rh, "smd")) 0 0 0
58 {
59 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('allocate.smd must be of type mark:idType') unless $rh->{smd}=~m/^\d+-\d+$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $rh->{"smd"} =~ /^\d+-\d+$/ 0 0 0
60 0 push @data, ['allocate:smdId', $rh->{smd}];
61 }
62 0 ▶ if (Net::DRI::Util::has_key($rh, 'notice'))
Branch: 1 branch
BranchTrueFalseTotal
if (Net::DRI::Util::has_key($rh, "notice")) 0 0 0
63 {
64 0 my $rn = $rh->{'notice'};
65 0 foreach my $param (qw/id expiration_date accepted_date/)
66 {
67 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters("allocate.notice.$param must be defined") unless Net::DRI::Util::has_key($rn, $param);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rn, $param) 0 0 0
68 }
69 0 my @notice;
70 my %attr;
71 0 ▶ if (Net::DRI::Util::has_key($rn, 'validator_id'))
Branch: 1 branch
BranchTrueFalseTotal
if (Net::DRI::Util::has_key($rn, "validator_id")) 0 0 0
72 {
73 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('allocate.notice.validator_id must be an XML token with at least 1 character') unless Net::DRI::Util::xml_is_token($rn->{validator_id}, 1);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($rn->{"validator_id"}, 1) 0 0 0
74 0 $attr{validatorID} = $rn->{validator_id};
75 }
76 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('allocate.notice.id must be an XML token with at least 1 character') unless Net::DRI::Util::xml_is_token($rn->{id}, 1);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($rn->{"id"}, 1) 0 0 0
77 0 push @notice, ['launch:noticeID', $rn->{id}, %attr];
78 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('allocate.notice.expiration_date must be a DateTime object') unless Net::DRI::Util::check_isa($rn->{expiration_date}, 'DateTime');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::check_isa($rn->{"expiration_date"}, "DateTime") 0 0 0
79 0 push @notice, ['launch:notAfter', $rn->{expiration_date}->clone()->set_time_zone('UTC')->strftime('%Y-%m-%dT%H:%M:%SZ')];
80 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('allocate.notice.accepted_date must be a DateTime object') unless Net::DRI::Util::check_isa($rn->{accepted_date}, 'DateTime');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::check_isa($rn->{"accepted_date"}, "DateTime") 0 0 0
81 0 push @notice, ['launch:acceptedDate', $rn->{accepted_date}->clone()->set_time_zone('UTC')->strftime('%Y-%m-%dT%H:%M:%SZ')];
82 0 push @data, ['allocate:notice', @notice];
83 }
84  
85 0 $epp->message()->command_extension('allocate', ['create', @data]);
86 0 return;
87 }
88  
89 ####################################################################################################
90 1 1;
91  
92 __END__
« DRI/Protocol/EPP/Extensions/ICANN/MarkSignedMark.pm ↑ Summary DRI/Protocol/EPP/Extensions/EURid/Sunrise.pm »