blib/lib/Paws/Credential/File.pm

filter: Statementstmt 98.2% 56 / 57 Branchbran 92.8% 13 / 14 Conditioncond 75.0% 3 / 4 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 17 / 17 Podpod 0.0% 0 / 3 totaltotal 92.7% 90 / 97 CC 10 SCAR 5.4
CC
10
Cov
96%
session_token
2.3
__ANON__
2.1
__ANON__
2.0
CRAP 1.7
« blib/lib/Paws/API/JSONAttribute.pm ↑ Summary blib/lib/Paws/LexRuntime.pm »
1 package Paws::Credential::File;
2 1 ▶ use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶ use Config::AWS qw/read_file/;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶ use File::HomeDir;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶ use JSON::MaybeXS qw/decode_json/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶ use Paws::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶ use Paws::Credential::CredProcess;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 7 ▶ has profile => (is => 'ro', default => sub { $ENV{ AWS_DEFAULT_PROFILE } or 'default' });
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$ENV{"AWS_DEFAULT_PROFILE"} or "default" 1 6 7
10  
11 10 ▶ has credentials_file => (is => 'ro', lazy => 1, default => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
12 10 my $self = shift;
13 10 ▶ if (defined $ENV{AWS_CONFIG_FILE}){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ENV{'AWS_CONFIG_FILE'}) { } 1 9 10
14 1 return $ENV{AWS_CONFIG_FILE};
15 } else {
16 9 return $self->path . '/' . $self->file_name;
17 }
18 1 });
19  
20 5 ▶ has file_name => (is => 'ro', default => sub { 'credentials' });
Subroutine __ANON__: called CC=1 SCAR=0.0
21 3 ▶ has path => (is => 'ro', default => sub {
Subroutine __ANON__: called CC=2 SCAR=7.6
22 3 ▶ return (File::HomeDir->my_home || '') . '/.aws/';
Condition50%1/2
'File::HomeDir'->my_home || ''
l!l
30
MC/DC0%0/1
'File::HomeDir'->my_home || ''
'File::HomeDir'->my_home
Truth table50%1/2
A
A= 'File::HomeDir'->my_home
Aresult
11
00
23 1 });
24  
25 11 ▶ has _ini_contents => (is => 'ro', isa => 'HashRef', lazy => 1, default => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
26 11 my $self = shift;
27 11 my $ini_file = $self->credentials_file;
28 11 ▶ return {} if (not -e $ini_file);
Branch: 1 branch
BranchTrueFalseTotal
unless -e $ini_file 2 9 11
29 9 my $ini = read_file($ini_file);
30 9 return $ini;
31 1 });
32  
33 11 ▶ has _profile => (is => 'ro', isa => 'HashRef', lazy => 1, default => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
34 11 my $self = shift;
35 11 my $profile = $self->profile;
36 11 ▶ return $self->_ini_contents->{ $profile } || {};
Condition100%2/2
$self->_ini_contents->{$profile} || {}
l!l
92
MC/DC100%1/1
$self->_ini_contents->{$profile} || {}
$self->_ini_contents->{$profile}
Truth table100%2/2
A
A= $self->_ini_contents->{$profile}
Aresult
11
00
37 1 });
38  
39 11 ▶ has credential_process => (is => 'ro', lazy => 1, default => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
40 11 my $self = shift;
41 11 ▶ return undef if (not defined $self->_profile->{ credential_process });
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->_profile->{"credential_process"} 7 4 11
42 return Paws::Credential::CredProcess->new(
43 credential_process => $self->_profile->{ credential_process },
44 4 );
45 1 });
46  
47 18 ▶ sub access_key {
Subroutine access_key: called CC=2 SCAR=6.9
Pod undocumented
48 18 my $self = shift;
49  
50 18 ▶ return $self->credential_process->access_key if (defined $self->credential_process);
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->credential_process 6 12 18
51 12 return $self->_profile->{ aws_access_key_id };
52 }
53  
54 12 ▶ sub secret_key {
Subroutine secret_key: called CC=2 SCAR=6.9
Pod undocumented
55 12 my $self = shift;
56  
57 12 ▶ return $self->credential_process->secret_key if (defined $self->credential_process);
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->credential_process 2 10 12
58 10 return $self->_profile->{ aws_secret_access_key };
59 }
60  
61 1 ▶ sub session_token {
Subroutine session_token: called CC=2 SCAR=8.1
Pod undocumented
62 1 my $self = shift;
63  
64 1 ▶ return $self->credential_process->session_token if (defined $self->credential_process);
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->credential_process 1 0 1
65 0 return $self->_profile->{ aws_session_token };
66 }
67  
68 1 with 'Paws::Credential';
69  
70 1 ▶ no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
71 1 1;
72 ### main pod documentation begin ###
73  
74 =encoding UTF-8
75  
76 =head1 NAME
77  
78 Paws::Credential::File
79  
80 =head1 SYNOPSIS
81  
82 use Paws::Credential::File;
83  
84 my $paws = Paws->new(config => {
85 credentials => Paws::Credential::File->new(
86 profile => 'profile1',
87 credentials_file => '/etc/aws_system_credentials',
88 )
89 });
90 # will open /etc/aws_system_credentials
91  
92
93 my $paws = Paws->new(config => {
94 credentials => Paws::Credential::File->new(
95 profile => 'profile1',
96 file_name => 'my_creds',
97 )
98 });
99 # will open $HOME/.aws/my_creds
100  
101 my $paws = Paws->new(config => {
102 credentials => Paws::Credential::File->new(
103 profile => 'profile1',
104 path => '/etc/',
105 )
106 });
107 # will open /etc/credentials
108  
109  
110 =head1 DESCRIPTION
111  
112 The File credential provider is to read credentials from AWS SDK config files
113  
114 =head2 profile: Str
115  
116 The section in the ini file where credentials will be looked up:
117  
118 Defaults to the environment variable C<AWS_DEFAULT_PROFILE>, and if that is not defined, to "default"
119  
120 =head2 credentials_file: Str
121  
122 The path of the ini file to open
123  
124 Defaults to the path + file_name (C<$HOME/.aws/credentials> by default) if the environment variable AWS_CONFIG_FILE doesn't exist
125  
126 =head2 path: Str
127  
128 Path to the ini file
129  
130 Defaults to C<$HOME/.aws>
131  
132 =head2 file_name: Str
133  
134 Name of the ini file
135  
136 Defaults to C<credentials>
137  
138 =cut
« blib/lib/Paws/API/JSONAttribute.pm ↑ Summary blib/lib/Paws/LexRuntime.pm »