SDK/AppConfiguration/Serializer.pm

filter: Statementstmt 98.9% 181 / 183 Branchbran 61.0% 61 / 100 Conditioncond 44.5% 65 / 146 MC/DCmcdc 6.6% 5 / 75 Subroutinesub 100% 32 / 32 Podpod 100% 8 / 8 totaltotal 64.7% 352 / 544 CC 111 SCAR 28.9
CC
111
Cov
72%
_setting_from_hash
44.5
serialize_snapshot
35.1
_normalize_etag
19.4
CRAP 18.1
« SDK/AppConfiguration/CreateSnapshotOperation.pm ↑ Summary SDK/AppConfiguration/ConfigurationSetting.pm »
1 2 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 2 ▶use feature 'class';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶no warnings 'experimental::class';
Subroutine BEGIN: called CC=1 SCAR=0.0
4
5 2 ▶use Azure::SDK::AppConfiguration::ConfigurationLabel;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Azure::SDK::AppConfiguration::ConfigurationLabelPage;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Azure::SDK::AppConfiguration::ConfigurationSnapshot;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Azure::SDK::AppConfiguration::ConfigurationSnapshotPage;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Azure::SDK::AppConfiguration::ConfigurationSetting;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Azure::SDK::AppConfiguration::ConfigurationSettingPage;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Azure::SDK::AppConfiguration::SnapshotFilter;
Subroutine BEGIN: called CC=1 SCAR=0.0
12
13 2 class Azure::SDK::AppConfiguration::Serializer {
14 2 ▶ use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶ use bytes ();
Subroutine BEGIN: called CC=1 SCAR=0.0
16 2 ▶ use JSON::PP ();
Subroutine BEGIN: called CC=1 SCAR=0.0
17 2 ▶ use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
18
19 2 ▶ use constant DEFAULT_MAX_BYTES => 8 * 1024 * 1024;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 2 ▶ use constant MAX_KEY_VALUE_BYTES => 10 * 1024;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 2 ▶ use constant MAX_PAGE_ITEMS => 10_000;
Subroutine BEGIN: called CC=1 SCAR=0.0
22
23 2 field $max_bytes :param :reader = DEFAULT_MAX_BYTES;
24 2 field $json = undef;
25
26 12 ▶ ADJUST {
Subroutine __ANON__: called CC=5 SCAR=21.9
27 12 ▶ croak 'App Configuration serializer max_bytes must be a positive integer'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $max_bytes and not ref $max_bytes and $max_bytes =~ /\A[0-9]+\z/u and $max_bytes > 0 0 12 12
Condition33%3/9
defined $max_bytes and not ref $max_bytes and $max_bytes =~ /\A[0-9]+\z/u and $max_bytes > 0
!ll&&!rl&&r
0012
defined $max_bytes and not ref $max_bytes and $max_bytes =~ /\A[0-9]+\z/u
!ll&&!rl&&r
0012
defined $max_bytes and not ref $max_bytes
!ll&&!rl&&r
0012
MC/DC0%0/4
defined $max_bytes and not ref $max_bytes and $max_bytes =~ /\A[0-9]+\z/u and $max_bytes > 0
defined $max_bytes not ref $max_bytes $max_bytes =~ /\A[0-9]+\z/u $max_bytes > 0
Truth table20%1/5
A and not(B) and C and D
A= defined $max_bytesB= not ref $max_bytesC= $max_bytes =~ /\A[0-9]+\z/uD= $max_bytes > 0
ABCDresult
0XXX0
10XX0
110X0
11100
11111
28 unless defined $max_bytes && !ref $max_bytes
29 && $max_bytes =~ /\A[0-9]+\z/ && $max_bytes > 0;
30 12 $json = JSON::PP->new->canonical->utf8->max_depth(32);
31 }
32
33 2 ▶ method serialize_setting ($setting) {
Subroutine serialize_setting: called CC=5 SCAR=16.1
Pod documented
34 2 _require_setting($setting);
35 2 my $payload = { value => $setting->value };
36 2 ▶ $payload->{content_type} = $setting->content_type
Branch: 1 branch
BranchTrueFalseTotal
if defined $setting->content_type 1 1 2
37 if defined $setting->content_type;
38 2 my $tags = $setting->tags;
39 2 ▶ $payload->{tags} = $tags if keys %{$tags};
Branch: 1 branch
BranchTrueFalseTotal
if keys %{$tags;} 1 1 2
40
41 2 my $body = $json->encode($payload);
42 2 ▶ my $combined_bytes = bytes::length($setting->key)
Condition50%1/2
$setting->label // ""
l!l
02
MC/DC0%0/1
$setting->label // ""
$setting->label
Truth table50%1/2
A
A= $setting->label
Aresult
11
00
43 + bytes::length($setting->label // '')
44 + bytes::length($body);
45 2 ▶ croak 'App Configuration key-value and attributes exceed 10 KiB'
Branch: 1 branch
BranchTrueFalseTotal
if $combined_bytes > 10240 1 1 2
46 if $combined_bytes > MAX_KEY_VALUE_BYTES;
47 1 return $body;
48 }
49
50 4 ▶ method parse_setting ($body, $header_etag = undef) {
Subroutine parse_setting: called CC=2 SCAR=6.9
Pod documented
51 4 my $data = $self->_decode_object($body);
52 4 return _setting_from_hash($data, $header_etag);
53 }
54
55 6 ▶ method parse_setting_page ($body) {
Subroutine parse_setting_page: called CC=9 SCAR=24.4
Pod documented
56 6 my $data = $self->_decode_object($body);
57 croak 'App Configuration list response items must be an array reference'
58 6 ▶ unless ref $data->{items} eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $data->{"items"} eq "ARRAY" 0 6 6
59 croak 'App Configuration list response exceeds 10000 items'
60 6 ▶ if @{$data->{items}} > MAX_PAGE_ITEMS;
Branch: 1 branch
BranchTrueFalseTotal
if @{$data->{"items"};} > 10000 0 6 6
61
62 6 my @items;
63 6 for my $item (@{$data->{items}}) {
64 2 ▶ croak 'App Configuration list item must be an object'
Branch: 1 branch
BranchTrueFalseTotal
unless ref $item eq "HASH" 0 2 2
65 unless ref $item eq 'HASH';
66 2 push @items, _setting_from_hash($item);
67 }
68
69 6 my $next_link = $data->{'@nextLink'};
70 6 ▶ croak 'App Configuration next link must be a scalar without control characters'
Branch: 1 branch
BranchTrueFalseTotal
if defined $next_link and ref $next_link || !length($next_link) || $next_link =~ /[\x00-\x1f\x7f]/u 0 6 6
Condition44%4/9
defined $next_link and ref $next_link || !length($next_link) || $next_link =~ /[\x00-\x1f\x7f]/u
!ll&&!rl&&r
420
ref $next_link or not length $next_link or $next_link =~ /[\x00-\x1f\x7f]/u
l!l&&r!l&&!r
002
ref $next_link or not length $next_link
l!l&&r!l&&!r
002
MC/DC0%0/4
defined $next_link and ref $next_link || !length($next_link) || $next_link =~ /[\x00-\x1f\x7f]/u
defined $next_link ref $next_link not length $next_link $next_link =~ /[\x00-\x1f\x7f]/u
Truth table40%2/5
A and B or not(C) or D
A= defined $next_linkB= ref $next_linkC= not length $next_linkD= $next_link =~ /[\x00-\x1f\x7f]/u
ABCDresult
0XXX0
10000
11XX1
101X1
10011
71 if defined $next_link
72 && (ref($next_link) || !length($next_link)
73 || $next_link =~ /[\x00-\x1f\x7f]/);
74 6 return Azure::SDK::AppConfiguration::ConfigurationSettingPage->new(
75 items => \@items,
76 continuation_token => $next_link,
77 );
78 }
79
80 2 ▶ method parse_label_page ($body) {
Subroutine parse_label_page: called CC=11 SCAR=28.4
Pod documented
81 2 my $data = $self->_decode_object($body);
82 croak 'App Configuration label response items must be an array reference'
83 2 ▶ unless ref $data->{items} eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $data->{"items"} eq "ARRAY" 0 2 2
84 croak 'App Configuration label response exceeds 10000 items'
85 2 ▶ if @{$data->{items}} > MAX_PAGE_ITEMS;
Branch: 1 branch
BranchTrueFalseTotal
if @{$data->{"items"};} > 10000 0 2 2
86
87 2 my @items;
88 2 for my $item (@{$data->{items}}) {
89 croak 'App Configuration label item must contain only a scalar name'
90 unless ref $item eq 'HASH'
91 && defined $item->{name}
92 2 ▶ && !ref $item->{name};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $item eq "HASH" and defined $item->{"name"} and not ref $item->{"name"} 0 2 2
Condition33%2/6
ref $item eq "HASH" and defined $item->{"name"} and not ref $item->{"name"}
!ll&&!rl&&r
002
ref $item eq "HASH" and defined $item->{"name"}
!ll&&!rl&&r
002
MC/DC0%0/3
ref $item eq "HASH" and defined $item->{"name"} and not ref $item->{"name"}
ref $item eq "HASH" defined $item->{"name"} not ref $item->{"name"}
Truth table25%1/4
A and B and not(C)
A= ref $item eq "HASH"B= defined $item->{"name"}C= not ref $item->{"name"}
ABCresult
0XX0
10X0
1100
1111
93 push @items, Azure::SDK::AppConfiguration::ConfigurationLabel->new(
94 name => $item->{name},
95 2 );
96 }
97
98 2 my $next_link = $data->{'@nextLink'};
99 2 ▶ croak 'App Configuration next link must be a scalar without control characters'
Branch: 1 branch
BranchTrueFalseTotal
if defined $next_link and ref $next_link || !length($next_link) || $next_link =~ /[\x00-\x1f\x7f]/u 0 2 2
Condition44%4/9
defined $next_link and ref $next_link || !length($next_link) || $next_link =~ /[\x00-\x1f\x7f]/u
!ll&&!rl&&r
110
ref $next_link or not length $next_link or $next_link =~ /[\x00-\x1f\x7f]/u
l!l&&r!l&&!r
001
ref $next_link or not length $next_link
l!l&&r!l&&!r
001
MC/DC0%0/4
defined $next_link and ref $next_link || !length($next_link) || $next_link =~ /[\x00-\x1f\x7f]/u
defined $next_link ref $next_link not length $next_link $next_link =~ /[\x00-\x1f\x7f]/u
Truth table40%2/5
A and B or not(C) or D
A= defined $next_linkB= ref $next_linkC= not length $next_linkD= $next_link =~ /[\x00-\x1f\x7f]/u
ABCDresult
0XXX0
10000
11XX1
101X1
10011
100 if defined $next_link
101 && (ref($next_link) || !length($next_link)
102 || $next_link =~ /[\x00-\x1f\x7f]/);
103 2 return Azure::SDK::AppConfiguration::ConfigurationLabelPage->new(
104 items => \@items,
105 continuation_token => $next_link,
106 );
107 }
108
109 6 ▶ method serialize_snapshot (%options) {
Subroutine serialize_snapshot: called CC=25 SCAR=35.6
Pod documented
110 6 my $filters = _snapshot_filters($options{filters});
111 4 ▶ my $composition = $options{composition_type} // 'key';
Condition100%2/2
$options{"composition_type"} // "key"
l!l
13
MC/DC100%1/1
$options{"composition_type"} // "key"
$options{"composition_type"}
Truth table100%2/2
A
A= $options{"composition_type"}
Aresult
11
00
112 4 ▶ croak 'App Configuration snapshot composition_type is invalid'
Branch: 1 branch
BranchTrueFalseTotal
unless $composition eq "key" or $composition eq "key_label" 0 4 4
Condition66%2/3
$composition eq "key" or $composition eq "key_label"
l!l&&r!l&&!r
310
MC/DC0%0/2
$composition eq "key" or $composition eq "key_label"
$composition eq "key" $composition eq "key_label"
Truth table66%2/3
A or B
A= $composition eq "key"B= $composition eq "key_label"
ABresult
1X1
011
000
113 unless $composition eq 'key' || $composition eq 'key_label';
114 4 ▶ if ($composition eq 'key') {
Branch: 1 branch
BranchTrueFalseTotal
if ($composition eq "key") 3 1 4
115 3 for my $filter (@{$filters}) {
116 3 ▶ croak 'App Configuration key-composed snapshot label cannot use multi-match filters'
Branch: 1 branch
BranchTrueFalseTotal
if defined $filter->label and $filter->label =~ /(?<!\\)[*,]/u 0 3 3
Condition33%1/3
defined $filter->label and $filter->label =~ /(?<!\\)[*,]/u
!ll&&!rl&&r
300
MC/DC0%0/2
defined $filter->label and $filter->label =~ /(?<!\\)[*,]/u
defined $filter->label $filter->label =~ /(?<!\\)[*,]/u
Truth table33%1/3
A and B
A= defined $filter->labelB= $filter->label =~ /(?<!\\)[*,]/u
ABresult
0X0
100
111
117 if defined $filter->label
118 && $filter->label =~ /(?<!\\)[*,]/;
119 }
120 }
121 4 my $retention = $options{retention_period};
122 4 ▶ croak 'App Configuration snapshot retention_period must be between 3600 and 7776000 seconds'
Branch: 1 branch
BranchTrueFalseTotal
if defined $retention and ref $retention || !($retention =~ /\A[0-9]+\z/u) || $retention < 3600 || $retention > 7776000 1 3 4
Condition66%8/12
defined $retention and ref $retention || !($retention =~ /\A[0-9]+\z/u) || $retention < 3600 || $retention > 7776000
!ll&&!rl&&r
211
ref $retention or not $retention =~ /\A[0-9]+\z/u or $retention < 3600 or $retention > 7776000
l!l&&r!l&&!r
101
ref $retention or not $retention =~ /\A[0-9]+\z/u or $retention < 3600
l!l&&r!l&&!r
011
ref $retention or not $retention =~ /\A[0-9]+\z/u
l!l&&r!l&&!r
002
MC/DC40%2/5
defined $retention and ref $retention || !($retention =~ /\A[0-9]+\z/u) || $retention < 3600 || $retention > 7776000
defined $retention ref $retention not $retention =~ /\A[0-9]+\z/u $retention < 3600 $retention > 7776000
Truth table50%3/6
A and B or not(C) or D or E
A= defined $retentionB= ref $retentionC= not $retention =~ /\A[0-9]+\z/uD= $retention < 3600E= $retention > 7776000
ABCDEresult
0XXXX0
100000
11XXX1
101XX1
1001X1
100011
123 if defined $retention
124 && (ref($retention) || $retention !~ /\A[0-9]+\z/
125 || $retention < 3600 || $retention > 7_776_000);
126 3 ▶ my $tags = $options{tags} // {};
Condition100%2/2
$options{"tags"} // {}
l!l
12
MC/DC100%1/1
$options{"tags"} // {}
$options{"tags"}
Truth table100%2/2
A
A= $options{"tags"}
Aresult
11
00
127 3 ▶ croak 'App Configuration snapshot tags must be a hash reference'
Branch: 1 branch
BranchTrueFalseTotal
unless ref $tags eq "HASH" 0 3 3
128 unless ref $tags eq 'HASH';
129 3 my %tags;
130 3 for my $name (keys %{$tags}) {
131 1 my $value = $tags->{$name};
132 1 ▶ croak 'App Configuration snapshot tag must use scalar name and value'
Branch: 1 branch
BranchTrueFalseTotal
if not length $name or $name =~ /[\x00-\x1f\x7f]/u or not defined $value or ref $value or $value =~ /[\x00-\x1f\x7f]/u 0 1 1
Condition33%4/12
not length $name or $name =~ /[\x00-\x1f\x7f]/u or not defined $value or ref $value or $value =~ /[\x00-\x1f\x7f]/u
l!l&&r!l&&!r
001
not length $name or $name =~ /[\x00-\x1f\x7f]/u or not defined $value or ref $value
l!l&&r!l&&!r
001
not length $name or $name =~ /[\x00-\x1f\x7f]/u or not defined $value
l!l&&r!l&&!r
001
not length $name or $name =~ /[\x00-\x1f\x7f]/u
l!l&&r!l&&!r
001
MC/DC0%0/5
not length $name or $name =~ /[\x00-\x1f\x7f]/u or not defined $value or ref $value or $value =~ /[\x00-\x1f\x7f]/u
not length $name $name =~ /[\x00-\x1f\x7f]/u not defined $value ref $value $value =~ /[\x00-\x1f\x7f]/u
Truth table16%1/6
not(A) or B or not(C) or D or E
A= not length $nameB= $name =~ /[\x00-\x1f\x7f]/uC= not defined $valueD= ref $valueE= $value =~ /[\x00-\x1f\x7f]/u
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
133 if !length($name) || $name =~ /[\x00-\x1f\x7f]/
134 || !defined($value) || ref($value)
135 || $value =~ /[\x00-\x1f\x7f]/;
136 1 $tags{$name} = "$value";
137 }
138 my $payload = {
139 filters => [map {
140 +{
141 3 ▶ key => $_->key,
Branch: 1 branch
BranchTrueFalseTotal
defined $_->label ? : 1 2 3
142 (defined $_->label ? (label => $_->label) : ()),
143 }
144 3 } @{$filters}],
145 composition_type => $composition,
146 };
147 3 ▶ $payload->{retention_period} = 0 + $retention if defined $retention;
Branch: 1 branch
BranchTrueFalseTotal
if defined $retention 1 2 3
148 3 ▶ $payload->{tags} = \%tags if keys %tags;
Branch: 1 branch
BranchTrueFalseTotal
if keys %tags 1 2 3
149 3 my $body = $json->encode($payload);
150 3 ▶ croak 'App Configuration snapshot request exceeds 64 KiB'
Branch: 1 branch
BranchTrueFalseTotal
if &bytes::length($body) > 65536 0 3 3
151 if bytes::length($body) > 64 * 1024;
152 3 return $body;
153 }
154
155 6 ▶ method parse_snapshot ($body, $header_etag = undef) {
Subroutine parse_snapshot: called CC=2 SCAR=6.9
Pod documented
156 6 return _snapshot_from_hash($self->_decode_object($body), $header_etag);
157 }
158
159 2 ▶ method parse_snapshot_page ($body) {
Subroutine parse_snapshot_page: called CC=8 SCAR=23.2
Pod documented
160 2 my $data = $self->_decode_object($body);
161 croak 'App Configuration snapshot response items must be an array reference'
162 2 ▶ unless ref $data->{items} eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $data->{"items"} eq "ARRAY" 0 2 2
163 croak 'App Configuration snapshot response exceeds 10000 items'
164 2 ▶ if @{$data->{items}} > MAX_PAGE_ITEMS;
Branch: 1 branch
BranchTrueFalseTotal
if @{$data->{"items"};} > 10000 0 2 2
165 my @items = map {
166 1 ▶ croak 'App Configuration snapshot list item must be an object'
Branch: 1 branch
BranchTrueFalseTotal
unless ref $_ eq "HASH" 0 1 1
167 unless ref $_ eq 'HASH';
168 1 _snapshot_from_hash($_)
169 2 } @{$data->{items}};
170 2 my $next_link = $data->{'@nextLink'};
171 2 ▶ croak 'App Configuration next link must be a scalar without control characters'
Branch: 1 branch
BranchTrueFalseTotal
if defined $next_link and ref $next_link || !length($next_link) || $next_link =~ /[\x00-\x1f\x7f]/u 0 2 2
Condition44%4/9
defined $next_link and ref $next_link || !length($next_link) || $next_link =~ /[\x00-\x1f\x7f]/u
!ll&&!rl&&r
110
ref $next_link or not length $next_link or $next_link =~ /[\x00-\x1f\x7f]/u
l!l&&r!l&&!r
001
ref $next_link or not length $next_link
l!l&&r!l&&!r
001
MC/DC0%0/4
defined $next_link and ref $next_link || !length($next_link) || $next_link =~ /[\x00-\x1f\x7f]/u
defined $next_link ref $next_link not length $next_link $next_link =~ /[\x00-\x1f\x7f]/u
Truth table40%2/5
A and B or not(C) or D
A= defined $next_linkB= ref $next_linkC= not length $next_linkD= $next_link =~ /[\x00-\x1f\x7f]/u
ABCDresult
0XXX0
10000
11XX1
101X1
10011
172 if defined $next_link
173 && (ref($next_link) || !length($next_link)
174 || $next_link =~ /[\x00-\x1f\x7f]/);
175 2 return Azure::SDK::AppConfiguration::ConfigurationSnapshotPage->new(
176 items => \@items,
177 continuation_token => $next_link,
178 );
179 }
180
181 2 ▶ method parse_snapshot_operation ($body) {
Subroutine parse_snapshot_operation: called CC=6 SCAR=21.4
Pod documented
182 2 my $data = $self->_decode_object($body);
183 croak 'App Configuration snapshot operation status is invalid'
184 unless defined $data->{status} && !ref $data->{status}
185 2 ▶ && $data->{status} =~ /\A(?:NotStarted|Running|Succeeded|Failed|Canceled)\z/i;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data->{"status"} and not ref $data->{"status"} and $data->{"status"} =~ /\A(?:NotStarted|Running|Succeeded|Failed|Canceled)\z/iu 0 2 2
Condition33%2/6
defined $data->{"status"} and not ref $data->{"status"} and $data->{"status"} =~ /\A(?:NotStarted|Running|Succeeded|Failed|Canceled)\z/iu
!ll&&!rl&&r
002
defined $data->{"status"} and not ref $data->{"status"}
!ll&&!rl&&r
002
MC/DC0%0/3
defined $data->{"status"} and not ref $data->{"status"} and $data->{"status"} =~ /\A(?:NotStarted|Running|Succeeded|Failed|Canceled)\z/iu
defined $data->{"status"} not ref $data->{"status"} $data->{"status"} =~ /\A(?:NotStarted|Running|Succeeded|Failed|Canceled)\z/iu
Truth table25%1/4
A and not(B) and C
A= defined $data->{"status"}B= not ref $data->{"status"}C= $data->{"status"} =~ /\A(?:NotStarted|Running|Succeeded|Failed|Canceled)\z/iu
ABCresult
0XX0
10X0
1100
1111
186 croak 'App Configuration snapshot operation error must be an object or null'
187 2 ▶ if defined $data->{error} && ref $data->{error} ne 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if defined $data->{"error"} and ref $data->{"error"} ne "HASH" 0 2 2
Condition66%2/3
defined $data->{"error"} and ref $data->{"error"} ne "HASH"
!ll&&!rl&&r
110
MC/DC0%0/2
defined $data->{"error"} and ref $data->{"error"} ne "HASH"
defined $data->{"error"} ref $data->{"error"} ne "HASH"
Truth table66%2/3
A and B
A= defined $data->{"error"}B= ref $data->{"error"} ne "HASH"
ABresult
0X0
100
111
188 2 return $data;
189 }
190
191 22 ▶ method _decode_object ($body) {
Subroutine _decode_object: called CC=6 SCAR=19.9
192 22 ▶ croak 'App Configuration response body is empty'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $body and length $body 0 22 22
Condition33%1/3
defined $body and length $body
!ll&&!rl&&r
0022
MC/DC0%0/2
defined $body and length $body
defined $body length $body
Truth table33%1/3
A and B
A= defined $bodyB= length $body
ABresult
0X0
100
111
193 unless defined $body && length $body;
194 22 ▶ croak 'App Configuration response body exceeds configured max_bytes'
Branch: 1 branch
BranchTrueFalseTotal
if &bytes::length($body) > $max_bytes 0 22 22
195 if bytes::length($body) > $max_bytes;
196 22 my $data = eval { $json->decode($body) };
197 22 ▶ croak 'App Configuration response body is not valid JSON'
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 22 22
198 if $@;
199 22 ▶ croak 'App Configuration response body must be a JSON object'
Branch: 1 branch
BranchTrueFalseTotal
unless ref $data eq "HASH" 0 22 22
200 unless ref $data eq 'HASH';
201 22 return $data;
202 }
203
204 6 ▶ sub _setting_from_hash ($data, $header_etag = undef) {
Subroutine _setting_from_hash: called CC=17 SCAR=38.0
205 croak 'App Configuration response key must be a scalar'
206 6 ▶ unless defined $data->{key} && !ref $data->{key};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data->{"key"} and not ref $data->{"key"} 0 6 6
Condition33%1/3
defined $data->{"key"} and not ref $data->{"key"}
!ll&&!rl&&r
006
MC/DC0%0/2
defined $data->{"key"} and not ref $data->{"key"}
defined $data->{"key"} not ref $data->{"key"}
Truth table33%1/3
A and not(B)
A= defined $data->{"key"}B= not ref $data->{"key"}
ABresult
0X0
100
111
207 croak 'App Configuration response value must be a scalar or null'
208 6 ▶ if exists $data->{value} && defined $data->{value} && ref $data->{value};
Branch: 1 branch
BranchTrueFalseTotal
if exists $data->{"value"} and defined $data->{"value"} and ref $data->{"value"} 0 6 6
Condition33%2/6
exists $data->{"value"} and defined $data->{"value"} and ref $data->{"value"}
!ll&&!rl&&r
060
exists $data->{"value"} and defined $data->{"value"}
!ll&&!rl&&r
006
MC/DC0%0/3
exists $data->{"value"} and defined $data->{"value"} and ref $data->{"value"}
exists $data->{"value"} defined $data->{"value"} ref $data->{"value"}
Truth table25%1/4
A and B and C
A= exists $data->{"value"}B= defined $data->{"value"}C= ref $data->{"value"}
ABCresult
0XX0
10X0
1100
1111
209 croak 'App Configuration response content_type must be a scalar or null'
210 6 ▶ if defined $data->{content_type} && ref $data->{content_type};
Branch: 1 branch
BranchTrueFalseTotal
if defined $data->{"content_type"} and ref $data->{"content_type"} 0 6 6
Condition33%1/3
defined $data->{"content_type"} and ref $data->{"content_type"}
!ll&&!rl&&r
060
MC/DC0%0/2
defined $data->{"content_type"} and ref $data->{"content_type"}
defined $data->{"content_type"} ref $data->{"content_type"}
Truth table33%1/3
A and B
A= defined $data->{"content_type"}B= ref $data->{"content_type"}
ABresult
0X0
100
111
211 croak 'App Configuration response label must be a scalar or null'
212 6 ▶ if defined $data->{label} && ref $data->{label};
Branch: 1 branch
BranchTrueFalseTotal
if defined $data->{"label"} and ref $data->{"label"} 0 6 6
Condition66%2/3
defined $data->{"label"} and ref $data->{"label"}
!ll&&!rl&&r
240
MC/DC0%0/2
defined $data->{"label"} and ref $data->{"label"}
defined $data->{"label"} ref $data->{"label"}
Truth table66%2/3
A and B
A= defined $data->{"label"}B= ref $data->{"label"}
ABresult
0X0
100
111
213 croak 'App Configuration response last_modified must be a scalar or null'
214 6 ▶ if defined $data->{last_modified} && ref $data->{last_modified};
Branch: 1 branch
BranchTrueFalseTotal
if defined $data->{"last_modified"} and ref $data->{"last_modified"} 0 6 6
Condition33%1/3
defined $data->{"last_modified"} and ref $data->{"last_modified"}
!ll&&!rl&&r
060
MC/DC0%0/2
defined $data->{"last_modified"} and ref $data->{"last_modified"}
defined $data->{"last_modified"} ref $data->{"last_modified"}
Truth table33%1/3
A and B
A= defined $data->{"last_modified"}B= ref $data->{"last_modified"}
ABresult
0X0
100
111
215 croak 'App Configuration response tags must be an object or null'
216 6 ▶ if defined $data->{tags} && ref $data->{tags} ne 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if defined $data->{"tags"} and ref $data->{"tags"} ne "HASH" 0 6 6
Condition33%1/3
defined $data->{"tags"} and ref $data->{"tags"} ne "HASH"
!ll&&!rl&&r
060
MC/DC0%0/2
defined $data->{"tags"} and ref $data->{"tags"} ne "HASH"
defined $data->{"tags"} ref $data->{"tags"} ne "HASH"
Truth table33%1/3
A and B
A= defined $data->{"tags"}B= ref $data->{"tags"} ne "HASH"
ABresult
0X0
100
111
217
218 6 my $etag = _normalize_etag($data->{etag}, $header_etag);
219 return Azure::SDK::AppConfiguration::ConfigurationSetting->new(
220 key => $data->{key},
221 label => $data->{label},
222 value => $data->{value},
223 content_type => $data->{content_type},
224 etag => $etag,
225 last_modified => $data->{last_modified},
226 tags => $data->{tags} // {},
227 6 ▶ locked => $data->{locked} // 0,
Condition50%2/4
$data->{"tags"} // {}
l!l
60
$data->{"locked"} // 0
l!l
60
MC/DC0%0/1
$data->{"tags"} // {}
$data->{"tags"}
MC/DC0%0/1
$data->{"locked"} // 0
$data->{"locked"}
Truth table50%1/2
A
A= $data->{"tags"}
Aresult
11
00
Truth table50%1/2
A
A= $data->{"locked"}
Aresult
11
00
228 );
229 }
230
231 13 ▶ sub _normalize_etag ($body_etag, $header_etag) {
Subroutine _normalize_etag: called CC=11 SCAR=29.7
232 13 ▶ croak 'App Configuration response body ETag is missing or invalid'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $body_etag and not ref $body_etag and length $body_etag and not $body_etag =~ /[\x00-\x1f\x7f]/u 0 13 13
Condition33%3/9
defined $body_etag and not ref $body_etag and length $body_etag and not $body_etag =~ /[\x00-\x1f\x7f]/u
!ll&&!rl&&r
0013
defined $body_etag and not ref $body_etag and length $body_etag
!ll&&!rl&&r
0013
defined $body_etag and not ref $body_etag
!ll&&!rl&&r
0013
MC/DC0%0/4
defined $body_etag and not ref $body_etag and length $body_etag and not $body_etag =~ /[\x00-\x1f\x7f]/u
defined $body_etag not ref $body_etag length $body_etag not $body_etag =~ /[\x00-\x1f\x7f]/u
Truth table20%1/5
A and not(B) and C and not(D)
A= defined $body_etagB= not ref $body_etagC= length $body_etagD= not $body_etag =~ /[\x00-\x1f\x7f]/u
ABCDresult
0XXX0
10XX0
110X0
11100
11111
233 unless defined $body_etag && !ref $body_etag && length $body_etag
234 && $body_etag !~ /[\x00-\x1f\x7f]/;
235 13 ▶ if (defined $header_etag) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $header_etag) 5 8 13
236 5 ▶ croak 'App Configuration response header ETag is invalid'
Branch: 1 branch
BranchTrueFalseTotal
if ref $header_etag or not length $header_etag or $header_etag =~ /[\x00-\x1f\x7f]/u 0 5 5
Condition33%2/6
ref $header_etag or not length $header_etag or $header_etag =~ /[\x00-\x1f\x7f]/u
l!l&&r!l&&!r
005
ref $header_etag or not length $header_etag
l!l&&r!l&&!r
005
MC/DC0%0/3
ref $header_etag or not length $header_etag or $header_etag =~ /[\x00-\x1f\x7f]/u
ref $header_etag not length $header_etag $header_etag =~ /[\x00-\x1f\x7f]/u
Truth table25%1/4
A or not(B) or C
A= ref $header_etagB= not length $header_etagC= $header_etag =~ /[\x00-\x1f\x7f]/u
ABCresult
1XX1
01X1
0011
0000
237 if ref($header_etag) || !length($header_etag)
238 || $header_etag =~ /[\x00-\x1f\x7f]/;
239 5 my $unquoted = $header_etag;
240 5 $unquoted =~ s/\AW\///;
241 5 $unquoted =~ s/\A"|"\z//g;
242 5 ▶ croak 'App Configuration response body and header ETags disagree'
Branch: 1 branch
BranchTrueFalseTotal
unless $unquoted eq $body_etag 0 5 5
243 unless $unquoted eq $body_etag;
244 5 return $header_etag;
245 }
246 8 ▶ return $body_etag =~ /\A(?:W\/)?"/ ? $body_etag : '"' . $body_etag . '"';
Branch: 1 branch
BranchTrueFalseTotal
$body_etag =~ m[\A(?:W/)?"]u ? : 0 8 8
247 }
248
249 13 ▶ sub _snapshot_filters ($filters) {
Subroutine _snapshot_filters: called CC=10 SCAR=24.5
250 13 ▶ croak 'App Configuration snapshot filters must be an array reference'
Branch: 1 branch
BranchTrueFalseTotal
unless ref $filters eq "ARRAY" 1 12 13
251 unless ref $filters eq 'ARRAY';
252 croak 'App Configuration snapshot must contain one to three filters'
253 12 ▶ unless @{$filters} >= 1 && @{$filters} <= 3;
Branch: 1 branch
BranchTrueFalseTotal
unless @{$filters;} >= 1 and @{$filters;} <= 3 1 11 12
Condition66%2/3
@{$filters;} >= 1 and @{$filters;} <= 3
!ll&&!rl&&r
0111
MC/DC50%1/2
@{$filters;} >= 1 and @{$filters;} <= 3
@{$filters;} >= 1 @{$filters;} <= 3
Truth table66%2/3
A and B
A= @{$filters;} >= 1B= @{$filters;} <= 3
ABresult
0X0
100
111
254 11 my @validated;
255 11 for my $filter (@{$filters}) {
256 11 ▶ if (blessed($filter)
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($filter) and $filter->isa("Azure::SDK::AppConfiguration::SnapshotFilter")) 0 11 11
Condition33%1/3
builtin::blessed($filter) and $filter->isa("Azure::SDK::AppConfiguration::SnapshotFilter")
!ll&&!rl&&r
1100
MC/DC0%0/2
builtin::blessed($filter) and $filter->isa("Azure::SDK::AppConfiguration::SnapshotFilter")
builtin::blessed($filter) $filter->isa("Azure::SDK::AppConfiguration::SnapshotFilter")
Truth table33%1/3
A and B
A= builtin::blessed($filter)B= $filter->isa("Azure::SDK::AppConfiguration::SnapshotFilter")
ABresult
0X0
100
111
257 && $filter->isa('Azure::SDK::AppConfiguration::SnapshotFilter')) {
258 0 push @validated, $filter;
259 0 next;
260 }
261 11 ▶ croak 'App Configuration snapshot filter must be a SnapshotFilter or hash reference'
Branch: 1 branch
BranchTrueFalseTotal
unless ref $filter eq "HASH" 0 11 11
262 unless ref $filter eq 'HASH';
263 11 ▶ my @unknown = grep { $_ ne 'key' && $_ ne 'label' } keys %{$filter};
Condition66%2/3
$_ ne 'key' && $_ ne 'label'
!ll&&!rl&&r
1180
MC/DC0%0/2
$_ ne 'key' && $_ ne 'label'
$_ ne 'key' $_ ne 'label'
Truth table66%2/3
A && B
A= $_ ne 'key'B= $_ ne 'label'
ABresult
0X0
100
111
264 11 ▶ croak 'Unknown App Configuration snapshot filter field(s): ' . join(', ', sort @unknown)
Branch: 1 branch
BranchTrueFalseTotal
if @unknown 0 11 11
265 if @unknown;
266 push @validated, Azure::SDK::AppConfiguration::SnapshotFilter->new(
267 key => $filter->{key},
268 label => $filter->{label},
269 11 );
270 }
271 11 return \@validated;
272 }
273
274 7 ▶ sub _snapshot_from_hash ($data, $header_etag = undef) {
Subroutine _snapshot_from_hash: called CC=5 SCAR=17.1
275 croak 'App Configuration snapshot filters must be an array reference'
276 7 ▶ unless ref $data->{filters} eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $data->{"filters"} eq "ARRAY" 0 7 7
277 7 my $filters = _snapshot_filters($data->{filters});
278 7 my $etag = _normalize_etag($data->{etag}, $header_etag);
279 return Azure::SDK::AppConfiguration::ConfigurationSnapshot->new(
280 name => $data->{name},
281 status => $data->{status},
282 filters => $filters,
283 composition_type => $data->{composition_type} // 'key',
284 created => $data->{created},
285 expires => $data->{expires},
286 retention_period => $data->{retention_period},
287 size => $data->{size},
288 items_count => $data->{items_count},
289 tags => $data->{tags} // {},
290 7 ▶ etag => $etag,
Condition50%2/4
$data->{"composition_type"} // "key"
l!l
70
$data->{"tags"} // {}
l!l
70
MC/DC0%0/1
$data->{"composition_type"} // "key"
$data->{"composition_type"}
MC/DC0%0/1
$data->{"tags"} // {}
$data->{"tags"}
Truth table50%1/2
A
A= $data->{"composition_type"}
Aresult
11
00
Truth table50%1/2
A
A= $data->{"tags"}
Aresult
11
00
291 );
292 }
293
294 2 ▶ sub _require_setting ($setting) {
Subroutine _require_setting: called CC=3 SCAR=14.2
295 2 ▶ croak 'App Configuration serializer requires a ConfigurationSetting'
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($setting) and $setting->isa("Azure::SDK::AppConfiguration::ConfigurationSetting") 0 2 2
Condition33%1/3
builtin::blessed($setting) and $setting->isa("Azure::SDK::AppConfiguration::ConfigurationSetting")
!ll&&!rl&&r
002
MC/DC0%0/2
builtin::blessed($setting) and $setting->isa("Azure::SDK::AppConfiguration::ConfigurationSetting")
builtin::blessed($setting) $setting->isa("Azure::SDK::AppConfiguration::ConfigurationSetting")
Truth table33%1/3
A and B
A= builtin::blessed($setting)B= $setting->isa("Azure::SDK::AppConfiguration::ConfigurationSetting")
ABresult
0X0
100
111
296 unless blessed($setting)
297 && $setting->isa('Azure::SDK::AppConfiguration::ConfigurationSetting');
298 }
299 }
300
301 2 1;
302
303 __END__
« SDK/AppConfiguration/CreateSnapshotOperation.pm ↑ Summary SDK/AppConfiguration/ConfigurationSetting.pm »