@@ -701,6 +701,38 @@ def test_envvars_empty_string(self):
701
701
creds = provider .load ()
702
702
self .assertIsNone (creds )
703
703
704
+ def test_expiry_omitted_if_envvar_empty (self ):
705
+ environ = {
706
+ 'AWS_ACCESS_KEY_ID' : 'foo' ,
707
+ 'AWS_SECRET_ACCESS_KEY' : 'bar' ,
708
+ 'AWS_SESSION_TOKEN' : 'baz' ,
709
+ 'AWS_CREDENTIAL_EXPIRATION' : '' ,
710
+ }
711
+ provider = credentials .EnvProvider (environ )
712
+ creds = provider .load ()
713
+ # Because we treat empty env vars the same as not being provided,
714
+ # we should return static credentials and not a refreshable
715
+ # credential.
716
+ self .assertNotIsInstance (creds , credentials .RefreshableCredentials )
717
+ self .assertEqual (creds .access_key , 'foo' )
718
+ self .assertEqual (creds .secret_key , 'bar' )
719
+ self .assertEqual (creds .token , 'baz' )
720
+
721
+ def test_error_when_expiry_required_but_empty (self ):
722
+ expiry_time = datetime .now (tzlocal ()) - timedelta (hours = 1 )
723
+ environ = {
724
+ 'AWS_ACCESS_KEY_ID' : 'foo' ,
725
+ 'AWS_SECRET_ACCESS_KEY' : 'bar' ,
726
+ 'AWS_CREDENTIAL_EXPIRATION' : expiry_time .isoformat (),
727
+ }
728
+ provider = credentials .EnvProvider (environ )
729
+ creds = provider .load ()
730
+
731
+ del environ ['AWS_CREDENTIAL_EXPIRATION' ]
732
+
733
+ with self .assertRaises (botocore .exceptions .PartialCredentialsError ):
734
+ creds .get_frozen_credentials ()
735
+
704
736
def test_can_override_env_var_mapping (self ):
705
737
# We can change the env var provider to
706
738
# use our specified env var names.
0 commit comments