blib/lib/Paws/Credential/AssumeRoleWithSAML.pm untested

filter: Statementstmt 0.0% 0 / 39 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 57 CC 4 SCAR 21.5
CC
4
Cov
0%
_refresh
20.0
access_key
2.0
secret_key
2.0
CRAP 8.5
1 package Paws::Credential::AssumeRoleWithSAML;
2 use Moose;
3 use DateTime::Format::ISO8601;
4 use Paws::Credential::None;
5  
6 with 'Paws::Credential';
7  
8 has expiration => (
9 is => 'rw',
10 isa => 'Int',
11 lazy => 1,
12 default => sub { 0 }
13 );
14  
15 has actual_creds => (is => 'rw');
16  
17 sub access_key {
18 my $self = shift;
19 $self->_refresh;
20 $self->actual_creds->AccessKeyId;
21 }
22  
23 sub secret_key {
24 my $self = shift;
25 $self->_refresh;
26 $self->actual_creds->SecretAccessKey;
27 }
28  
29 sub session_token {
30 my $self = shift;
31 $self->_refresh;
32 $self->actual_creds->SessionToken;
33 }
34  
35 has sts_region => (is => 'ro', isa => 'Str|Undef', default => sub { undef });
36  
37 has sts => (is => 'ro', isa => 'Paws::STS', lazy => 1, default => sub {
38 my $self = shift;
39 Paws->service('STS', region => $self->sts_region, credentials => Paws::Credential::None->new);
40 });
41  
42 has DurationSeconds => (is => 'rw', isa => 'Maybe[Int]');
43 has Policy => (is => 'rw', isa => 'Maybe[Str]');
44  
45 has RoleArn => (is => 'rw', isa => 'Str', required => 1);
46 has PrincipalArn => (is => 'rw', isa => 'Str', required => 1);
47 has SAMLAssertion => (is => 'rw', isa => 'Str', required => 1);
48  
49 sub _refresh {
50 my $self = shift;
51  
52 return if $self->expiration >= time;
53  
54 my $result = $self->sts->AssumeRoleWithSAML(
55 RoleArn => $self->RoleArn,
56 PrincipalArn => $self->PrincipalArn,
57 SAMLAssertion => $self->SAMLAssertion,
58 (defined $self->DurationSeconds) ? (DurationSeconds => $self->DurationSeconds) : (),
59 (defined $self->Policy) ? (Policy => $self->Policy) : (),
60 );
61  
62 my $creds = $self->actual_creds($result->Credentials);
63  
64 $self->expiration(DateTime::Format::ISO8601->parse_datetime($result->Credentials->Expiration)->epoch);
65 }
66  
67 no Moose;
68  
69 1;