Exemplo n.º 1
0
def test_EventBatch_execute_playbook_failure():
    edited_event = deepcopy(MOCK_EVENT_BATCH)
    edited_event['playbook'] = 'bad_playbook'

    batched_event = EventBatch(edited_event, MockLambdaContext())
    result = batched_event.execute_playbook(
        convert_empty_strings_to_none(MOCK_EVENT))

    assert result['status'] == False
Exemplo n.º 2
0
def test_EventBatch_execute_playbook():
    # setup playbook
    iam_client = boto3.client("iam", region_name="us-east-1")
    sts_client = boto3.client("sts", region_name="us-east-1")
    iam_role_name = "new-user"
    iam_role_arn = iam_client.role_arn = iam_client.create_role(
        RoleName=iam_role_name,
        AssumeRolePolicyDocument=json.dumps(iam_trust_policy_document),
    )["Role"]["Arn"]

    client = boto3.client("stepfunctions")
    sm = client.create_state_machine(name="ParamsToStateMachineTester",
                                     definition=str(playbook_definition),
                                     roleArn=iam_role_arn)

    batched_event = EventBatch(MOCK_EVENT_BATCH, MockLambdaContext())
    result = batched_event.execute_playbook(
        convert_empty_strings_to_none(MOCK_EVENT))

    assert result['status'] == True
    assert isinstance(result['message']['execution_id'], str)
    assert isinstance(result['message']['investigation_id'], str)