| 1 | package Amazon::Credentials::Provider; | ||||||||||||
| 2 | |||||||||||||
| 3 | 18 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 18 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | |||||||||||||
| 6 | 18 | ▶ | use 5.010; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | |||||||||||||
| 8 | 18 | ▶ | use parent qw(Class::Accessor::Fast); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | |||||||||||||
| 10 | 18 | __PACKAGE__->follow_best_practice; | |||||||||||
| 11 | |||||||||||||
| 12 | 18 | __PACKAGE__->mk_accessors( | |||||||||||
| 13 | qw( | ||||||||||||
| 14 | created_at | ||||||||||||
| 15 | debug | ||||||||||||
| 16 | last_refreshed | ||||||||||||
| 17 | logger | ||||||||||||
| 18 | profile | ||||||||||||
| 19 | expiration | ||||||||||||
| 20 | region | ||||||||||||
| 21 | source | ||||||||||||
| 22 | timeout | ||||||||||||
| 23 | user_agent | ||||||||||||
| 24 | ) | ||||||||||||
| 25 | ); | ||||||||||||
| 26 | |||||||||||||
| 27 | 18 | ▶ | use Carp; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 28 | |||||||||||||
| 29 | ######################################################################## | ||||||||||||
| 30 | 92 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||
| 31 | ######################################################################## | ||||||||||||
| 32 | 92 | my ( $class, @args ) = @_; | |||||||||||
| 33 | |||||||||||||
| 34 | 92 | ▶ | my $options = ref $args[0] ? { %{ $args[0] } } : {@args}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 35 | |||||||||||||
| 36 | croak 'aws_access_key_id is required' | ||||||||||||
| 37 | 92 | ▶ | if !$options->{aws_access_key_id}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 38 | |||||||||||||
| 39 | croak 'aws_secret_access_key is required' | ||||||||||||
| 40 | 92 | ▶ | if !$options->{aws_secret_access_key}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 41 | |||||||||||||
| 42 | 92 | my $aws_access_key_id = delete $options->{aws_access_key_id}; | |||||||||||
| 43 | 92 | my $aws_secret_access_key = delete $options->{aws_secret_access_key}; | |||||||||||
| 44 | 92 | my $token = delete $options->{token}; | |||||||||||
| 45 | |||||||||||||
| 46 | 92 | ▶ | $options->{created_at} //= time; | ||||||||||
|
Condition50%1/2
$options->{"created_at"} //= time
MC/DC0%0/1
$options->{"created_at"} //= time
$options->{"created_at"}
Truth table50%1/2
A
A= $options->{"created_at"}
| |||||||||||||
| 47 | |||||||||||||
| 48 | 92 | my $self = $class->SUPER::new($options); | |||||||||||
| 49 | |||||||||||||
| 50 | 92 | $self->set_aws_access_key_id($aws_access_key_id); | |||||||||||
| 51 | 92 | $self->set_aws_secret_access_key($aws_secret_access_key); | |||||||||||
| 52 | 92 | $self->set_token($token); | |||||||||||
| 53 | |||||||||||||
| 54 | 92 | return $self; | |||||||||||
| 55 | } | ||||||||||||
| 56 | |||||||||||||
| 57 | ######################################################################## | ||||||||||||
| 58 | 12 | ▶ | sub credentials { | ||||||||||
|
Subroutine
credentials: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||
| 59 | ######################################################################## | ||||||||||||
| 60 | 12 | my ($self) = @_; | |||||||||||
| 61 | |||||||||||||
| 62 | 12 | my $credentials = { | |||||||||||
| 63 | aws_access_key_id => $self->get_aws_access_key_id, | ||||||||||||
| 64 | aws_secret_access_key => $self->get_aws_secret_access_key, | ||||||||||||
| 65 | source => $self->get_source, | ||||||||||||
| 66 | }; | ||||||||||||
| 67 | |||||||||||||
| 68 | 12 | ▶ | $credentials->{token} = $self->get_token | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 69 | if defined $self->get_token; | ||||||||||||
| 70 | |||||||||||||
| 71 | 12 | ▶ | $credentials->{expiration} = $self->get_expiration | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 72 | if defined $self->get_expiration; | ||||||||||||
| 73 | |||||||||||||
| 74 | 12 | ▶ | $credentials->{region} = $self->get_region | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 75 | if defined $self->get_region; | ||||||||||||
| 76 | |||||||||||||
| 77 | 12 | return $credentials; | |||||||||||
| 78 | } | ||||||||||||
| 79 | |||||||||||||
| 80 | ######################################################################## | ||||||||||||
| 81 | 2 | ▶ | sub is_refreshable { | ||||||||||
|
Subroutine
is_refreshable: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 82 | ######################################################################## | ||||||||||||
| 83 | 2 | return 0; | |||||||||||
| 84 | } | ||||||||||||
| 85 | |||||||||||||
| 86 | ######################################################################## | ||||||||||||
| 87 | 1 | ▶ | sub refresh_credentials { | ||||||||||
|
Subroutine
refresh_credentials: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 88 | ######################################################################## | ||||||||||||
| 89 | 1 | my ($self) = @_; | |||||||||||
| 90 | |||||||||||||
| 91 | 1 | croak sprintf '%s does not support credential refresh', ref $self; | |||||||||||
| 92 | } | ||||||||||||
| 93 | |||||||||||||
| 94 | ######################################################################## | ||||||||||||
| 95 | 76 | ▶ | sub get_aws_access_key_id { | ||||||||||
|
Subroutine
get_aws_access_key_id: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 96 | ######################################################################## | ||||||||||||
| 97 | 76 | my ($self) = @_; | |||||||||||
| 98 | |||||||||||||
| 99 | 76 | return $self->{_access_key_id}->(); | |||||||||||
| 100 | } | ||||||||||||
| 101 | |||||||||||||
| 102 | ######################################################################## | ||||||||||||
| 103 | 106 | ▶ | sub set_aws_access_key_id { | ||||||||||
|
Subroutine
set_aws_access_key_id: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 104 | ######################################################################## | ||||||||||||
| 105 | 106 | my ( $self, $value ) = @_; | |||||||||||
| 106 | |||||||||||||
| 107 | 106 | ▶ | $self->{_access_key_id} = sub {$value}; | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 108 | |||||||||||||
| 109 | 106 | return; | |||||||||||
| 110 | } | ||||||||||||
| 111 | |||||||||||||
| 112 | ######################################################################## | ||||||||||||
| 113 | 57 | ▶ | sub get_aws_secret_access_key { | ||||||||||
|
Subroutine
get_aws_secret_access_key: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 114 | ######################################################################## | ||||||||||||
| 115 | 57 | my ($self) = @_; | |||||||||||
| 116 | |||||||||||||
| 117 | 57 | return $self->{_secret_access_key}->(); | |||||||||||
| 118 | } | ||||||||||||
| 119 | |||||||||||||
| 120 | ######################################################################## | ||||||||||||
| 121 | 106 | ▶ | sub set_aws_secret_access_key { | ||||||||||
|
Subroutine
set_aws_secret_access_key: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 122 | ######################################################################## | ||||||||||||
| 123 | 106 | my ( $self, $value ) = @_; | |||||||||||
| 124 | |||||||||||||
| 125 | 106 | ▶ | $self->{_secret_access_key} = sub {$value}; | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 126 | |||||||||||||
| 127 | 106 | return; | |||||||||||
| 128 | } | ||||||||||||
| 129 | |||||||||||||
| 130 | ######################################################################## | ||||||||||||
| 131 | 63 | ▶ | sub get_token { | ||||||||||
|
Subroutine
get_token: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 132 | ######################################################################## | ||||||||||||
| 133 | 63 | my ($self) = @_; | |||||||||||
| 134 | |||||||||||||
| 135 | 63 | return $self->{_session_token}->(); | |||||||||||
| 136 | } | ||||||||||||
| 137 | |||||||||||||
| 138 | ######################################################################## | ||||||||||||
| 139 | 106 | ▶ | sub set_token { | ||||||||||
|
Subroutine
set_token: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 140 | ######################################################################## | ||||||||||||
| 141 | 106 | my ( $self, $value ) = @_; | |||||||||||
| 142 | |||||||||||||
| 143 | 106 | ▶ | $self->{_session_token} = sub {$value}; | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 144 | |||||||||||||
| 145 | 106 | return; | |||||||||||
| 146 | } | ||||||||||||
| 147 | |||||||||||||
| 148 | 18 | 1; | |||||||||||