blib/lib/Google/Auth/IAMCredentials.pm untested

filter: Statementstmt 0.0% 0 / 18 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 35 CC 7 SCAR 36.8
CC
7
Cov
0%
apply
56.0
BEGIN
2.0
BEGIN
2.0
CRAP 39.8
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::IAMCredentials;
16  
17 use strict;
18 use warnings;
19 use Moo;
20  
21 has selector => (
22 is => 'ro',
23 required => 0,
24 );
25  
26 has token => (
27 is => 'ro',
28 required => 0,
29 );
30  
31 sub apply {
32 my ($self, $req_or_headers) = @_;
33  
34 if (ref $req_or_headers eq 'HASH') {
35 $req_or_headers->{'x-goog-iam-authority-selector'} = $self->selector
36 if defined $self->selector;
37 $req_or_headers->{'x-goog-iam-authorization-token'} = $self->token
38 if defined $self->token;
39 } elsif (eval { $req_or_headers->isa('HTTP::Request') }) {
40 $req_or_headers->header('x-goog-iam-authority-selector' => $self->selector)
41 if defined $self->selector;
42 $req_or_headers->header('x-goog-iam-authorization-token' => $self->token)
43 if defined $self->token;
44 }
45 }
46  
47 1;