Ejemplo n.º 1
0
def test_EventCreator_create_duplicate():
    #  Setup tables for this event
    client = boto3.client('dynamodb')
    client.put_item(TableName=os.environ['SOCLESS_DEDUP_TABLE'],
                    Item=dict_to_item(
                        {
                            "dedup_hash": DEDUP_HASH_FOR_MOCK_EVENT,
                            "current_investigation_id": MOCK_INVESTIGATION_ID
                        },
                        convert_root=False))
    client.put_item(TableName=os.environ['SOCLESS_EVENTS_TABLE'],
                    Item=dict_to_item(
                        {
                            "id": MOCK_INVESTIGATION_ID,
                            'investigation_id': "already_running_id",
                            'status_': 'open'
                        },
                        convert_root=False))

    edited_event = deepcopy(MOCK_EVENT)
    edited_event['dedup_keys'] = ['username']

    event = EventCreator(edited_event)
    created_event = event.create()
    assert created_event['is_duplicate'] == True
Ejemplo n.º 2
0
def test_EventCreator_create():
    event = EventCreator(MOCK_EVENT)

    created_event = event.create()

    #check dedup table
    dedup_table = boto3.resource('dynamodb').Table(
        os.environ['SOCLESS_DEDUP_TABLE'])
    dedup_mapping = dedup_table.get_item(
        Key={'dedup_hash': DEDUP_HASH_FOR_MOCK_EVENT})['Item']

    assert dedup_mapping['current_investigation_id'] == created_event[
        'investigation_id']
    assert event.details == created_event['details']
    assert event.created_at == created_event['created_at']