예제 #1
0
def test_get_role_orchestration(test_iam):
    """Tests the get_group orchestration."""
    from cloudaux.orchestration.aws.iam.role import get_role

    # Don't pass in the RoleName:
    with pytest.raises(MissingFieldException, match='Cannot extract item name from input: {}'):
        get_role({}, force_client=test_iam)

    result = get_role({'RoleName': 'testRoleCloudAuxName'}, force_client=test_iam)
    assert result['RoleName'] == 'testRoleCloudAuxName'
    assert isinstance(result['CreateDate'], str)
    assert len(result['InstanceProfiles']) == 1
    assert isinstance(result['InstanceProfiles'][0]['CreateDate'], str)
예제 #2
0
    def process_role(self, role, **kwargs):
        app.logger.debug("Slurping {index} ({name}) from {account}/{region}".format(
            index=self.i_am_singular,
            name=role['RoleName'],
            account=kwargs["conn_dict"]["account_number"],
            region=kwargs["conn_dict"]["region"]))

        # Need to send a copy, since we don't want to alter the total list!
        return get_role(dict(role), **kwargs["conn_dict"])
예제 #3
0
 def _fetch(self, arn: str) -> IAMEntry:
     logger.info("getting role data for role %s", arn)
     conn = copy.deepcopy(self.config["connection_iam"])
     conn["account_number"] = arn.split(":")[4]
     role = {"RoleName": arn.split("/")[-1]}
     role_info = get_role(role, flags=FLAGS.INLINE_POLICIES, **conn)
     self._arn_to_id[arn] = role_info["RoleId"]
     if not role_info:
         raise NotFoundError
     self._data[arn] = role_info["InlinePolicies"]
     return role_info["InlinePolicies"]  # type: ignore
예제 #4
0
    def get_method(self, item, **kwargs):
        # This is not needed for IAM Role:
        item.pop("Region")

        return get_role(dict(item), **kwargs)
    def get_method(self, item, **kwargs):
        # This is not needed for IAM Role:
        item.pop("Region")

        return get_role(dict(item), **kwargs)
예제 #6
0
 def get_method(self, item, **kwargs):
     return get_role(dict(item), **kwargs)
예제 #7
0
 def process_role(self, role, **kwargs):
     app.logger.debug("Slurping {index} ({name}) from {account}".format(
         index=self.i_am_singular,
         name=role['RoleName'],
         account=kwargs['account_number']))
     return get_role(role, **kwargs)