File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -751,7 +751,7 @@ def expand_role(self, role):
751
751
def get_caller_identity_arn (self ):
752
752
"""Returns the ARN user or role whose credentials are used to call the API.
753
753
Returns:
754
- (str): The ARN uer or role
754
+ (str): The ARN user or role
755
755
"""
756
756
assumed_role = self .boto_session .client ('sts' ).get_caller_identity ()['Arn' ]
757
757
@@ -766,7 +766,8 @@ def get_caller_identity_arn(self):
766
766
try :
767
767
role = self .boto_session .client ('iam' ).get_role (RoleName = role_name )['Role' ]['Arn' ]
768
768
except ClientError :
769
- LOGGER .warning ("Couldn't call 'get_role' to get Role ARN from role name {}." .format (role_name ))
769
+ LOGGER .warning ("Couldn't call 'get_role' to get Role ARN from role name {} to get Role path."
770
+ .format (role_name ))
770
771
771
772
return role
772
773
Original file line number Diff line number Diff line change @@ -69,14 +69,17 @@ def test_get_caller_identity_arn_from_an_user(boto_session):
69
69
assert actual == 'arn:aws:iam::369233609183:user/mia'
70
70
71
71
72
- def test_get_caller_identity_arn_from_an_user_without_permissions (boto_session ):
72
+ @patch ('logging.Logger.warning' )
73
+ def test_get_caller_identity_arn_from_an_user_without_permissions (boto_session , mock_logger ):
73
74
sess = Session (boto_session )
74
75
arn = 'arn:aws:iam::369233609183:user/mia'
75
76
sess .boto_session .client ('sts' ).get_caller_identity .return_value = {'Arn' : arn }
76
77
sess .boto_session .client ('iam' ).get_role .side_effect = ClientError ('Bad permissions!' , {})
77
78
79
+
78
80
actual = sess .get_caller_identity_arn ()
79
81
assert actual == 'arn:aws:iam::369233609183:user/mia'
82
+ mock_logger .assert_called_once ()
80
83
81
84
82
85
def test_get_caller_identity_arn_from_a_role (boto_session ):
You can’t perform that action at this time.
0 commit comments