Example #1
0
 def test_parse_arn_base_resource_sub_resouce(self):
     test_arn = "arn:partition:service:region:account-id:resource/resource"
     should_be = {
         'arn': 'arn',
         'partition': 'partition',
         'service': 'service',
         'region': 'region',
         'account-id': 'account-id',
         'resource': 'resource/resource'
     }
     result = Misc.parse_arn(arn=test_arn)
     self.assertDictEqual(should_be, result)
Example #2
0
 def get_account_id(self):
     """
     This functions extracts the AWS account id from the user object
     :return: the AWs account id
     :rtype: int
     """
     user_data = self.get_user()
     if 'Arn' in user_data:
         arn = user_data['Arn']
         ret = Misc.parse_arn(arn=arn)['account-id']
     else:
         logger.error("Can not determine the Account ID, User has no ARN")
         raise ValueError
     return ret
Example #3
0
 def get_account_id(self):
     """
     This functions extracts the AWS account id from the user object
     :return: the AWs account id
     :rtype: int
     """
     user_data = self.get_user()
     if 'Arn' in user_data:
         arn = user_data['Arn']
         ret = Misc.parse_arn(arn=arn)['account-id']
     else:
         logger.error("Can not determine the Account ID, User has no ARN")
         raise ValueError
     return ret
Example #4
0
 def test_parse_arn_base_resource_invalid_arn(self):
     test_arn = "yes"
     should_be = None
     result = Misc.parse_arn(arn=test_arn)
     self.assertEqual(should_be, result)
Example #5
0
 def test_parse_arn_base_resource_extra_column(self):
     test_arn = "arn:partition:service:region:account-id:resource:resource_sub"
     should_be = {'arn': 'arn', 'partition': 'partition', 'service': 'service', 'region': 'region',
                  'account-id': 'account-id', 'resource': 'resource', 'resource_sub': 'resource_sub'}
     result = Misc.parse_arn(arn=test_arn)
     self.assertDictEqual(should_be, result)
Example #6
0
 def test_parse_arn_base_resource_invalid_arn(self):
     test_arn = "yes"
     should_be = None
     result = Misc.parse_arn(arn=test_arn)
     self.assertEqual(should_be, result)