File tree 1 file changed +20
-0
lines changed
tests/unit/sagemaker/local
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -859,5 +859,25 @@ def test__aws_credentials_with_short_lived_credentials_and_ec2_metadata_service_
859
859
]
860
860
861
861
862
+ @patch ("sagemaker.local.image._aws_credentials_available_in_metadata_service" )
863
+ def test__aws_credentials_with_short_lived_credentials_and_ec2_metadata_service_having_credentials_override (
864
+ mock ,
865
+ ):
866
+ os .environ ["USE_SHORT_LIVED_CREDENTIALS" ] = "1"
867
+ credentials = Credentials (
868
+ access_key = _random_string (), secret_key = _random_string (), token = _random_string ()
869
+ )
870
+ session = Mock ()
871
+ session .get_credentials .return_value = credentials
872
+ mock .return_value = True
873
+ aws_credentials = _aws_credentials (session )
874
+
875
+ assert aws_credentials == [
876
+ "AWS_ACCESS_KEY_ID=%s" % credentials .access_key ,
877
+ "AWS_SECRET_ACCESS_KEY=%s" % credentials .secret_key ,
878
+ "AWS_SESSION_TOKEN=%s" % credentials .token ,
879
+ ]
880
+
881
+
862
882
def _random_string (size = 6 , chars = string .ascii_uppercase ):
863
883
return "" .join (random .choice (chars ) for x in range (size ))
You can’t perform that action at this time.
0 commit comments