blib/lib/Google/Auth/ClientId.pm

filter: Statementstmt 88.4% 23 / 26 Branchbran 37.5% 3 / 8 Conditioncond 16.6% 1 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 2 totaltotal 62.7% 32 / 51 CC 7 SCAR 18.7
CC
7
Cov
68%
from_hash
11.8
from_file
3.1
BEGIN
1.0
CRAP 6.5
« blib/lib/Google/Auth/ImpersonatedServiceAccountCredentials.pm ↑ Summary blib/lib/Google/Auth/IDTokens/KeySources.pm »
1 # Copyright 2022 Google LLC and contributors
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14  
15 package Google::Auth::ClientId;
16  
17 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶use JSON::MaybeXS;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 2 ▶use Google::Auth::Exceptions;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 2 has id => (
22 is => 'ro',
23 required => 1,
24 );
25  
26 2 has secret => (
27 is => 'ro',
28 required => 1,
29 );
30  
31 2 ▶sub from_hash {
Subroutine from_hash: called CC=5 SCAR=24.7
Pod undocumented
32 2 my ($class, $hash) = @_;
33  
34 2 ▶ my $config = $hash->{installed} // $hash->{web};
Condition33%1/3
$hash->{"installed"} // $hash->{"web"}
l!l&&r!l&&!r
200
MC/DC0%0/2
$hash->{"installed"} // $hash->{"web"}
$hash->{"installed"} $hash->{"web"}
Truth table33%1/3
A // B
A= $hash->{"installed"}B= $hash->{"web"}
ABresult
1X1
011
000
35  
36 2 ▶ if ($config) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config) 2 0 2
37 return $class->new(
38 id => $config->{client_id},
39 secret => $config->{client_secret},
40 2 );
41 }
42  
43 0 ▶ if ($hash->{client_id} && $hash->{client_secret}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hash->{"client_id"} and $hash->{"client_secret"}) 0 0 0
Condition0%0/3
$hash->{"client_id"} and $hash->{"client_secret"}
!ll&&!rl&&r
000
MC/DC0%0/2
$hash->{"client_id"} and $hash->{"client_secret"}
$hash->{"client_id"} $hash->{"client_secret"}
Truth table0%0/3
A and B
A= $hash->{"client_id"}B= $hash->{"client_secret"}
ABresult
0X0
100
111
44 return $class->new(
45 id => $hash->{client_id},
46 secret => $hash->{client_secret},
47 0 );
48 }
49  
50 0 Google::Auth::Error->throw("Invalid format for client ID configuration");
51 }
52  
53 2 ▶sub from_file {
Subroutine from_file: called CC=3 SCAR=11.2
Pod undocumented
54 2 my ($class, $file) = @_;
55  
56 2 ▶ open my $fh, '<', $file or die "Cannot open $file: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $file or die "Cannot open ${file}: $!" 2 0 2
57 2 local $/;
58 2 my $json = <$fh>;
59 2 ▶ close $fh or die "Cannot close $file: $!";
Branch: 1 branch
BranchTrueFalseTotal
close $fh or die "Cannot close ${file}: $!" 2 0 2
60  
61 2 my $hash = decode_json($json);
62 2 return $class->from_hash($hash);
63 }
64  
65 2 1;
« blib/lib/Google/Auth/ImpersonatedServiceAccountCredentials.pm ↑ Summary blib/lib/Google/Auth/IDTokens/KeySources.pm »