@@ -315,6 +315,31 @@ def test_get_caller_identity_arn_from_describe_notebook_instance(boto_session):
315315 )
316316
317317
318+ @patch (
319+ "six.moves.builtins.open" ,
320+ mock_open (
321+ read_data = '{"ResourceName": "SageMakerInstance", '
322+ '"DomainId": "d-kbnw5yk6tg8j", '
323+ '"UserProfileName": "default-1617915559064"}'
324+ ),
325+ )
326+ @patch ("os.path.exists" , side_effect = mock_exists (NOTEBOOK_METADATA_FILE , True ))
327+ def test_get_caller_identity_arn_from_describe_user_profile (boto_session ):
328+ sess = Session (boto_session )
329+ expected_role = "arn:aws:iam::369233609183:role/service-role/SageMakerRole-20171129T072388"
330+ sess .sagemaker_client .describe_user_profile .return_value = {
331+ "UserSettings" : {"ExecutionRole" : expected_role }
332+ }
333+
334+ actual = sess .get_caller_identity_arn ()
335+
336+ assert actual == expected_role
337+ sess .sagemaker_client .describe_user_profile .assert_called_once_with (
338+ DomainId = "d-kbnw5yk6tg8j" ,
339+ UserProfileName = "default-1617915559064" ,
340+ )
341+
342+
318343@patch ("six.moves.builtins.open" , mock_open (read_data = '{"ResourceName": "SageMakerInstance"}' ))
319344@patch ("os.path.exists" , side_effect = mock_exists (NOTEBOOK_METADATA_FILE , True ))
320345@patch ("sagemaker.session.sts_regional_endpoint" , return_value = STS_ENDPOINT )
0 commit comments