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