lib/OpenSearch/PPLQuery/Config.pm

filter: Statementstmt 95.2% 140 / 147 Branchbran 75.4% 80 / 106 Conditioncond 50.0% 34 / 68 MC/DCmcdc 26.1% 11 / 42 Subroutinesub 100% 22 / 22 Podpod 0.0% 0 / 7 totaltotal 73.2% 287 / 392 CC 79 SCAR 29.8
CC
79
Cov
79%
default_path
34.0
_validate
33.6
_validate_endpoint
26.1
CRAP 19.7
« script/pplquery ↑ Summary
1 package OpenSearch::PPLQuery::Config;
2 22 $OpenSearch::PPLQuery::Config::VERSION = '1.0.0';
3 # Reader and validator for the named-connection JSON file. The file format is
4 # documented for users in PPLQuery.pod under "NAMED CONNECTIONS"; this module's
5 # interface is described here in comments because it is internal to the
6 # pplquery command.
7 #
8 # Interface, for maintainers:
9 #
10 # ->load($path) parse and fully validate, or throw; returns an object
11 # ->default_path platform location (APPDATA on Windows, else XDG)
12 # ->path absolute path of the loaded file
13 # ->default_name name of the declared default connection, or undef
14 # ->names configured connection names, sorted
15 # ->connection($n) a shallow copy of one connection's normalized settings
16 # ->descriptions all connections in the shape --list-connections prints
17 #
18 # Validation is strict and happens entirely in _validate at load time, so a
19 # malformed file is rejected before any network call rather than producing a
20 # confusing failure later. Unknown properties are errors, not warnings: a
21 # misspelled key that was ignored would leave the user believing a security
22 # setting had been applied when it had not.
23 #
24 # ->connection returns a copy because bin/pplquery deletes the password-source
25 # keys from what it gets back before merging the rest into client options.
26 #
27 # Passwords are never read here. The file names a password *source*; resolving
28 # it belongs to the command, which is where the CLI and environment overrides
29 # that outrank it also live.
30  
31 22 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 22 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
33  
34 22 ▶use B ();
Subroutine BEGIN: called CC=1 SCAR=0.0
35 22 ▶use Cpanel::JSON::XS ();
Subroutine BEGIN: called CC=1 SCAR=0.0
36 22 ▶use File::Basename qw(dirname);
Subroutine BEGIN: called CC=1 SCAR=0.0
37 22 ▶use File::Spec ();
Subroutine BEGIN: called CC=1 SCAR=0.0
38 22 ▶use OpenSearch::PPLQuery ();
Subroutine BEGIN: called CC=1 SCAR=0.0
39 22 ▶use URI ();
Subroutine BEGIN: called CC=1 SCAR=0.0
40  
41 22 my $JSON = Cpanel::JSON::XS->new->utf8(0)->canonical(1);
42  
43 sub load {
44 23 ▶ my ($class, $path) = @_;
Subroutine load: called CC=7 SCAR=20.1
Pod undocumented
45 23 ▶ die "Connection configuration path is required\n" if !defined($path) || $path eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $path or $path eq "" 0 23 23
Condition33%1/3
not defined $path or $path eq ""
l!l&&r!l&&!r
0023
MC/DC0%0/2
not defined $path or $path eq ""
not defined $path $path eq ""
Truth table33%1/3
not(A) or B
A= not defined $pathB= $path eq ""
ABresult
1X1
011
000
46  
47 23 ▶ open my $handle, '<:encoding(UTF-8)', $path or die "Cannot open connection configuration $path: $!\n";
Branch: 1 branch
BranchTrueFalseTotal
open my $handle, "<:encoding(UTF-8)", $path or die "Cannot open connection configuration ${path}: $!\n" 0 23 23
48 23 local $/;
49 23 ▶ my $text = <$handle> // '';
Condition50%1/2
readline $handle // ""
l!l
230
MC/DC0%0/1
readline $handle // ""
readline $handle
Truth table50%1/2
A
A= readline $handle
Aresult
11
00
50 23 ▶ close $handle or die "Cannot close connection configuration $path: $!\n";
Branch: 1 branch
BranchTrueFalseTotal
close $handle or die "Cannot close connection configuration ${path}: $!\n" 0 23 23
51  
52 23 my $document;
53 {
54 23 local $@;
55 23 $document = eval { $JSON->decode($text) };
56 23 ▶ die "Connection configuration $path is not valid JSON: $@" if $@ ne '';
Branch: 1 branch
BranchTrueFalseTotal
if $@ ne "" 1 22 23
57 }
58 22 my $absolute_path = File::Spec->rel2abs($path);
59 22 my $self = bless {path => $absolute_path}, $class;
60 22 $self->_validate($document);
61 9 return $self;
62 }
63  
64 sub default_path {
65 1 ▶ if ($^O eq 'MSWin32') {
Subroutine default_path: called CC=8 SCAR=35.3
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq "MSWin32") 0 1 1
66 0 my $appdata = _environment_text('APPDATA');
67 0 ▶ die "APPDATA is required to locate the default connection configuration\n" if !defined($appdata) || $appdata eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $appdata or $appdata eq "" 0 0 0
Condition0%0/3
not defined $appdata or $appdata eq ""
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $appdata or $appdata eq ""
not defined $appdata $appdata eq ""
Truth table0%0/3
not(A) or B
A= not defined $appdataB= $appdata eq ""
ABresult
1X1
011
000
68 0 return File::Spec->catfile($appdata, 'pplquery', 'connections.json');
69 }
70 1 my $base = _environment_text('XDG_CONFIG_HOME');
71 1 ▶ if (!defined($base) || $base eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $base or $base eq "") 0 1 1
Condition33%1/3
not defined $base or $base eq ""
l!l&&r!l&&!r
001
MC/DC0%0/2
not defined $base or $base eq ""
not defined $base $base eq ""
Truth table33%1/3
not(A) or B
A= not defined $baseB= $base eq ""
ABresult
1X1
011
000
72 0 my $home = _environment_text('HOME');
73 0 ▶ die "HOME is required to locate the default connection configuration\n" if !defined($home) || $home eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $home or $home eq "" 0 0 0
Condition0%0/3
not defined $home or $home eq ""
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $home or $home eq ""
not defined $home $home eq ""
Truth table0%0/3
not(A) or B
A= not defined $homeB= $home eq ""
ABresult
1X1
011
000
74 0 $base = File::Spec->catdir($home, '.config');
75 }
76 1 return File::Spec->catfile($base, 'pplquery', 'connections.json');
77 }
78  
79 2 ▶sub path { return $_[0]{path}; }
Subroutine path: called CC=1 SCAR=0.0
Pod undocumented
80 4 ▶sub default_name { return $_[0]{default}; }
Subroutine default_name: called CC=1 SCAR=0.0
Pod undocumented
81 4 ▶sub names { return sort keys %{$_[0]{connections}}; }
Subroutine names: called CC=1 SCAR=0.0
Pod undocumented
82  
83 sub connection {
84 11 ▶ my ($self, $name) = @_;
Subroutine connection: called CC=4 SCAR=14.5
Pod undocumented
85 11 ▶ die "Connection name is required\n" if !defined($name) || $name eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $name or $name eq "" 0 11 11
Condition33%1/3
not defined $name or $name eq ""
l!l&&r!l&&!r
0011
MC/DC0%0/2
not defined $name or $name eq ""
not defined $name $name eq ""
Truth table33%1/3
not(A) or B
A= not defined $nameB= $name eq ""
ABresult
1X1
011
000
86 11 ▶ die "Connection '$name' does not exist in $self->{path}\n" if !exists $self->{connections}{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"connections"}{$name} 1 10 11
87 10 return {%{$self->{connections}{$name}}};
88 }
89  
90 sub descriptions {
91 3 ▶ my ($self) = @_;
Subroutine descriptions: called CC=6 SCAR=17.9
Pod undocumented
92 return [map {
93 3 my $connection = $self->{connections}{$_};
94 +{
95 name => $_,
96 url => $connection->{url},
97 authentication => {
98 type => $connection->{auth_type},
99 ($connection->{auth_type} eq 'basic' ? (username => $connection->{user}) : ()),
100 (defined($connection->{password_environment}) ? (passwordEnvironment => $connection->{password_environment}) : ()),
101 (defined($connection->{password_file}) ? (passwordFile => $connection->{password_file}) : ()),
102 },
103 tls => {
104 verify => $connection->{insecure} ? Cpanel::JSON::XS::false : Cpanel::JSON::XS::true,
105 (defined($connection->{ca_file}) ? (caFile => $connection->{ca_file}) : ()),
106 },
107 timeoutSeconds => $connection->{timeout},
108 }
109 6 ▶ } $self->names];
Branch: 5 branches
BranchTrueFalseTotal
$connection->{'auth_type'} eq 'basic' ? : 3 3 6
defined $connection->{'password_environment'} ? : 1 5 6
defined $connection->{'password_file'} ? : 1 5 6
$connection->{'insecure'} ? : 0 6 6
defined $connection->{'ca_file'} ? : 1 5 6
110 }
111  
112 sub _validate {
113 22 ▶ my ($self, $document) = @_;
Subroutine _validate: called CC=33 SCAR=35.1
114 22 _object($document, 'Connection configuration');
115 22 _keys($document, 'Connection configuration', qw(default connections));
116 20 _object($document->{connections}, 'Connection configuration connections');
117 20 ▶ die "Connection configuration must define at least one connection\n" if !keys %{$document->{connections}};
Branch: 1 branch
BranchTrueFalseTotal
unless keys %{$$document{"connections"};} 0 20 20
118  
119 20 my %connections;
120 20 my $directory = dirname($self->{path});
121 20 for my $name (keys %{$document->{connections}}) {
122 29 ▶ die "Connection name '$name' is invalid\n" if $name !~ /\A[A-Za-z0-9][A-Za-z0-9._-]*\z/;
Branch: 1 branch
BranchTrueFalseTotal
unless $name =~ /\A[A-Za-z0-9][A-Za-z0-9._-]*\z/u 1 28 29
123 28 my $input = $document->{connections}{$name};
124 28 _object($input, "Connection '$name'");
125 28 _keys($input, "Connection '$name'", qw(url authentication tls timeoutSeconds));
126 27 my $url = _nonempty_string($input->{url}, "Connection '$name' url");
127  
128 27 my $authentication = $input->{authentication};
129 27 _object($authentication, "Connection '$name' authentication");
130 27 _keys($authentication, "Connection '$name' authentication", qw(type username passwordEnvironment passwordFile));
131 27 my $auth_type = _nonempty_string($authentication->{type}, "Connection '$name' authentication type");
132 27 ▶ die "Connection '$name' authentication type must be 'none' or 'basic'\n" if $auth_type ne 'none' && $auth_type ne 'basic';
Branch: 1 branch
BranchTrueFalseTotal
if $auth_type ne "none" and $auth_type ne "basic" 0 27 27
Condition66%2/3
$auth_type ne "none" and $auth_type ne "basic"
!ll&&!rl&&r
17100
MC/DC0%0/2
$auth_type ne "none" and $auth_type ne "basic"
$auth_type ne "none" $auth_type ne "basic"
Truth table66%2/3
A and B
A= $auth_type ne "none"B= $auth_type ne "basic"
ABresult
0X0
100
111
133 27 my ($user, $password_environment, $password_file);
134 27 ▶ if ($auth_type eq 'basic') {
Branch: 3 branches
BranchTrueFalseTotal
if ($auth_type eq 'basic') { } 10 17 27
elsif (exists $authentication->{'username'}) { } 0 17 17
elsif (exists $authentication->{'passwordEnvironment'} or exists $authentication->{'passwordFile'}) { } 1 16 17
135 10 $user = _nonempty_string($authentication->{username}, "Connection '$name' authentication username");
136 10 ▶ die "Connection '$name' authentication username must contain only ASCII characters\n" if $user =~ /[^\x00-\x7f]/;
Branch: 1 branch
BranchTrueFalseTotal
if $user =~ /[^\x00-\x7f]/u 0 10 10
137 die "Connection '$name' authentication cannot specify both passwordEnvironment and passwordFile\n"
138 10 ▶ if exists($authentication->{passwordEnvironment}) && exists($authentication->{passwordFile});
Branch: 1 branch
BranchTrueFalseTotal
if exists $authentication->{"passwordEnvironment"} and exists $authentication->{"passwordFile"} 1 9 10
Condition100%3/3
exists $authentication->{"passwordEnvironment"} and exists $authentication->{"passwordFile"}
!ll&&!rl&&r
361
MC/DC100%2/2
exists $authentication->{"passwordEnvironment"} and exists $authentication->{"passwordFile"}
exists $authentication->{"passwordEnvironment"} exists $authentication->{"passwordFile"}
Truth table100%3/3
A and B
A= exists $authentication->{"passwordEnvironment"}B= exists $authentication->{"passwordFile"}
ABresult
0X0
100
111
139 9 ▶ if (exists $authentication->{passwordEnvironment}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $authentication->{"passwordEnvironment"}) 6 3 9
140 6 $password_environment = _nonempty_string($authentication->{passwordEnvironment}, "Connection '$name' authentication passwordEnvironment");
141 6 ▶ die "Connection '$name' authentication passwordEnvironment is not a valid environment variable name\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $password_environment =~ /\A[A-Za-z_][A-Za-z0-9_]*\z/u 1 5 6
142 if $password_environment !~ /\A[A-Za-z_][A-Za-z0-9_]*\z/;
143 }
144 8 ▶ if (exists $authentication->{passwordFile}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $authentication->{"passwordFile"}) 1 7 8
145 1 $password_file = _nonempty_string($authentication->{passwordFile}, "Connection '$name' authentication passwordFile");
146 1 $password_file = File::Spec->rel2abs($password_file, $directory);
147 }
148 } elsif (exists $authentication->{username}) {
149 0 die "Connection '$name' authentication username requires basic authentication\n";
150 ▶ } elsif (exists($authentication->{passwordEnvironment}) || exists($authentication->{passwordFile})) {
Condition66%2/3
exists $authentication->{"passwordEnvironment"} or exists $authentication->{"passwordFile"}
l!l&&r!l&&!r
0116
MC/DC50%1/2
exists $authentication->{"passwordEnvironment"} or exists $authentication->{"passwordFile"}
exists $authentication->{"passwordEnvironment"} exists $authentication->{"passwordFile"}
Truth table66%2/3
A or B
A= exists $authentication->{"passwordEnvironment"}B= exists $authentication->{"passwordFile"}
ABresult
1X1
011
000
151 1 die "Connection '$name' authentication password source requires basic authentication\n";
152 }
153  
154 24 my ($ca_file, $insecure);
155 24 ▶ if (exists $input->{tls}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $input->{"tls"}) 4 20 24
156 4 my $tls = $input->{tls};
157 4 _object($tls, "Connection '$name' tls");
158 4 _keys($tls, "Connection '$name' tls", qw(verify caFile));
159 4 ▶ if (exists $tls->{verify}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $tls->{"verify"}) 4 0 4
160 4 ▶ die "Connection '$name' tls verify must be a JSON boolean\n" if !Cpanel::JSON::XS::is_bool($tls->{verify});
Branch: 1 branch
BranchTrueFalseTotal
unless &Cpanel::JSON::XS::is_bool($tls->{"verify"}) 1 3 4
161 3 ▶ $insecure = $tls->{verify} ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$tls->{'verify'} ? : 2 1 3
162 }
163 3 ▶ if (exists $tls->{caFile}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $tls->{"caFile"}) 2 1 3
164 2 $ca_file = _nonempty_string($tls->{caFile}, "Connection '$name' tls caFile");
165 2 $ca_file = File::Spec->rel2abs($ca_file, $directory);
166 }
167 3 ▶ die "Connection '$name' tls caFile cannot be used when verification is disabled\n" if defined($ca_file) && $insecure;
Branch: 1 branch
BranchTrueFalseTotal
if defined $ca_file and $insecure 1 2 3
Condition100%3/3
defined $ca_file and $insecure
!ll&&!rl&&r
111
MC/DC100%2/2
defined $ca_file and $insecure
defined $ca_file $insecure
Truth table100%3/3
A and B
A= defined $ca_fileB= $insecure
ABresult
0X0
100
111
168 }
169  
170 22 my $timeout = 60;
171 22 ▶ if (exists $input->{timeoutSeconds}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $input->{"timeoutSeconds"}) 2 20 22
172 2 $timeout = $input->{timeoutSeconds};
173 2 ▶ die "Connection '$name' timeoutSeconds must be a positive integer\n" if !_json_integer($timeout) || $timeout <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if not _json_integer($timeout) or $timeout <= 0 1 1 2
Condition66%2/3
not _json_integer($timeout) or $timeout <= 0
l!l&&r!l&&!r
101
MC/DC50%1/2
not _json_integer($timeout) or $timeout <= 0
not _json_integer($timeout) $timeout <= 0
Truth table66%2/3
not(A) or B
A= not _json_integer($timeout)B= $timeout <= 0
ABresult
1X1
011
000
174 }
175 21 _validate_endpoint($name, $url, $auth_type, defined($input->{tls}), $ca_file, $insecure);
176 19 ▶ $connections{$name} = {
Branch: 5 branches
BranchTrueFalseTotal
defined $user ? : 7 12 19
defined $password_environment ? : 5 14 19
defined $password_file ? : 1 18 19
defined $ca_file ? : 1 18 19
$insecure ? : 0 19 19
177 url => $url, auth_type => $auth_type, (defined($user) ? (user => $user) : ()),
178 (defined($password_environment) ? (password_environment => $password_environment) : ()),
179 (defined($password_file) ? (password_file => $password_file) : ()),
180 (defined($ca_file) ? (ca_file => $ca_file) : ()), insecure => $insecure ? 1 : 0, timeout => 0 + $timeout,
181 };
182 }
183  
184 10 ▶ if (exists $document->{default}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $document->{"default"}) 7 3 10
185 7 my $default = _nonempty_string($document->{default}, 'Connection configuration default');
186 7 ▶ die "Default connection '$default' does not exist\n" if !exists $connections{$default};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $connections{$default} 1 6 7
187 6 $self->{default} = $default;
188 }
189 9 $self->{connections} = \%connections;
190 }
191  
192 sub _object {
193 101 ▶ my ($value, $label) = @_;
Subroutine _object: called CC=2 SCAR=7.2
194 101 ▶ die "$label must be a JSON object\n" if ref($value) ne 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $value ne "HASH" 0 101 101
195 }
196  
197 sub _keys {
198 81 ▶ my ($value, $label, @allowed) = @_;
Subroutine _keys: called CC=3 SCAR=11.0
199 81 my %allowed = map { $_ => 1 } @allowed;
200 81 for my $key (keys %$value) {
201 146 ▶ die "$label contains unknown property '$key'\n" if !$allowed{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless $allowed{$key} 3 143 146
202 }
203 }
204  
205 sub _nonempty_string {
206 80 ▶ my ($value, $label) = @_;
Subroutine _nonempty_string: called CC=4 SCAR=17.1
207 80 ▶ die "$label must be a nonempty JSON string\n" if !defined($value) || ref($value) || $value eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $value or ref $value or $value eq "" 0 80 80
Condition33%2/6
not defined $value or ref $value or $value eq ""
l!l&&r!l&&!r
0080
not defined $value or ref $value
l!l&&r!l&&!r
0080
MC/DC0%0/3
not defined $value or ref $value or $value eq ""
not defined $value ref $value $value eq ""
Truth table25%1/4
not(A) or B or C
A= not defined $valueB= ref $valueC= $value eq ""
ABCresult
1XX1
01X1
0011
0000
208 80 return $value;
209 }
210  
211 sub _json_integer {
212 2 ▶ my ($value) = @_;
Subroutine _json_integer: called CC=4 SCAR=15.2
213 2 ▶ return 0 if !defined($value) || ref($value);
Branch: 1 branch
BranchTrueFalseTotal
if not defined $value or ref $value 0 2 2
Condition33%1/3
not defined $value or ref $value
l!l&&r!l&&!r
002
MC/DC0%0/2
not defined $value or ref $value
not defined $value ref $value
Truth table33%1/3
not(A) or B
A= not defined $valueB= ref $value
ABresult
1X1
011
000
214 2 my $flags = B::svref_2object(\$value)->FLAGS;
215 2 ▶ return ($flags & B::SVp_IOK) && !($flags & (B::SVp_NOK | B::SVp_POK));
Condition66%2/3
$flags & 4096 && !($flags & 24576)
!ll&&!rl&&r
101
MC/DC50%1/2
$flags & 4096 && !($flags & 24576)
$flags & 4096 !($flags & 24576)
Truth table66%2/3
A && not(B)
A= $flags & 4096B= !($flags & 24576)
ABresult
0X0
100
111
216 }
217  
218 sub _validate_endpoint {
219 21 ▶ my ($name, $url, $auth_type, $has_tls, $ca_file, $insecure) = @_;
Subroutine _validate_endpoint: called CC=16 SCAR=32.6
220 21 ▶ die "Connection '$name' url must contain only ASCII characters\n" if $url =~ /[^\x00-\x7f]/;
Branch: 1 branch
BranchTrueFalseTotal
if $url =~ /[^\x00-\x7f]/u 0 21 21
221 21 my $uri = URI->new($url);
222 21 ▶ die "Connection '$name' url must use http or https\n" if !defined($uri->scheme) || ($uri->scheme ne 'http' && $uri->scheme ne 'https');
Branch: 1 branch
BranchTrueFalseTotal
if not defined $uri->scheme or $uri->scheme ne "http" and $uri->scheme ne "https" 0 21 21
Condition50%3/6
not defined $uri->scheme or $uri->scheme ne "http" and $uri->scheme ne "https"
l!l&&r!l&&!r
0021
$uri->scheme ne "http" and $uri->scheme ne "https"
!ll&&!rl&&r
1470
MC/DC0%0/3
not defined $uri->scheme or $uri->scheme ne "http" and $uri->scheme ne "https"
not defined $uri->scheme $uri->scheme ne "http" $uri->scheme ne "https"
Truth table25%1/4
not(A) or B and C
A= not defined $uri->schemeB= $uri->scheme ne "http"C= $uri->scheme ne "https"
ABCresult
1XX1
0111
00X0
0100
223 21 ▶ die "Connection '$name' url must include a host\n" if !defined($uri->host) || $uri->host eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $uri->host or $uri->host eq "" 0 21 21
Condition33%1/3
not defined $uri->host or $uri->host eq ""
l!l&&r!l&&!r
0021
MC/DC0%0/2
not defined $uri->host or $uri->host eq ""
not defined $uri->host $uri->host eq ""
Truth table33%1/3
not(A) or B
A= not defined $uri->hostB= $uri->host eq ""
ABresult
1X1
011
000
224 21 ▶ die "Connection '$name' url must not include credentials, a query, or a fragment\n" if defined($uri->userinfo) || defined($uri->query) || defined($uri->fragment);
Branch: 1 branch
BranchTrueFalseTotal
if defined $uri->userinfo or defined $uri->query or defined $uri->fragment 0 21 21
Condition33%2/6
defined $uri->userinfo or defined $uri->query or defined $uri->fragment
l!l&&r!l&&!r
0021
defined $uri->userinfo or defined $uri->query
l!l&&r!l&&!r
0021
MC/DC0%0/3
defined $uri->userinfo or defined $uri->query or defined $uri->fragment
defined $uri->userinfo defined $uri->query defined $uri->fragment
Truth table25%1/4
A or B or C
A= defined $uri->userinfoB= defined $uri->queryC= defined $uri->fragment
ABCresult
1XX1
01X1
0011
0000
225 21 ▶ die "Connection '$name' url must be a base URL without a path\n" if $uri->path ne '' && $uri->path ne '/';
Branch: 1 branch
BranchTrueFalseTotal
if $uri->path ne "" and $uri->path ne "/" 0 21 21
Condition33%1/3
$uri->path ne "" and $uri->path ne "/"
!ll&&!rl&&r
2100
MC/DC0%0/2
$uri->path ne "" and $uri->path ne "/"
$uri->path ne "" $uri->path ne "/"
Truth table33%1/3
A and B
A= $uri->path ne ""B= $uri->path ne "/"
ABresult
0X0
100
111
226 21 ▶ die "Connection '$name' basic authentication requires an https URL\n" if $auth_type eq 'basic' && $uri->scheme ne 'https';
Branch: 1 branch
BranchTrueFalseTotal
if $auth_type eq "basic" and $uri->scheme ne "https" 1 20 21
Condition100%3/3
$auth_type eq "basic" and $uri->scheme ne "https"
!ll&&!rl&&r
1371
MC/DC100%2/2
$auth_type eq "basic" and $uri->scheme ne "https"
$auth_type eq "basic" $uri->scheme ne "https"
Truth table100%3/3
A and B
A= $auth_type eq "basic"B= $uri->scheme ne "https"
ABresult
0X0
100
111
227 20 ▶ die "Connection '$name' tls settings require an https URL\n" if $has_tls && $uri->scheme ne 'https';
Branch: 1 branch
BranchTrueFalseTotal
if $has_tls and $uri->scheme ne "https" 1 19 20
Condition100%3/3
$has_tls and $uri->scheme ne "https"
!ll&&!rl&&r
1811
MC/DC100%2/2
$has_tls and $uri->scheme ne "https"
$has_tls $uri->scheme ne "https"
Truth table100%3/3
A and B
A= $has_tlsB= $uri->scheme ne "https"
ABresult
0X0
100
111
228 }
229  
230 sub _environment_text {
231 1 ▶ my ($name) = @_;
Subroutine _environment_text: called CC=2 SCAR=7.1
232 1 ▶ return undef if !exists $ENV{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $ENV{$name} 0 1 1
233 1 return OpenSearch::PPLQuery::decode_utf8($ENV{$name}, "environment variable $name");
234 }
235  
236 22 1;
237  
238 __END__
« script/pplquery ↑ Summary