QRadarMirroringEventsStatus

This displays the mirrored events status in the offense.

python · IBM QRadar

Details

IDQRadarMirroringEventsStatus
Languagepython
From Version6.0.0
Docker Imagedemisto/python3:3.12.13.10116658
Tagsdynamic-section

README

This script displays the the mirroring events status in the offense.

Script Data


Name Description
Script Type python3
Tags dynamic-section
Cortex XSOAR Version 6.0.0

Inputs


There are no inputs for this script.

Outputs


There are no outputs for this script.

import demistomock as demisto
from QRadarMirroringEventsStatus import main


def test_main_success(mocker):
    """
    Given:
        - An incident that has a value in lastmirroredtimestamp.
    When:
        - Running QRadarMirroringEventsStatus script.
    Then:
        - Make sure that the correct message and date are in the returned value of the script.
    """
    mocker.patch.object(
        demisto,
        "incident",
        return_value={"CustomFields": {"lastmirroredtimestamp": "2023-02-15T13:30:00Z", "incomingmirrorerror": ""}},
    )
    result = main()

    assert "Not Started" in result["Contents"]
    assert "2023-02-15T13:30:00Z" in result["Contents"]


def test_main_in_progress(mocker):
    """
    Given:
        - An incident that has incomingmirrorerror of In queue.
    When:
        - Running QRadarMirroringEventsStatus script.
    Then:
        - Make sure that the correct message is in the returned value of the script.
    """
    mocker.patch.object(demisto, "incident", return_value={"CustomFields": {"incomingmirrorerror": "In queue."}})

    result = main()

    assert "In Progress" in result["Contents"]


def test_main_error(mocker):
    """
    Given:
        - An incident that has incomingmirrorerror of Error message.
    When:
        - Running QRadarMirroringEventsStatus script.
    Then:
        - Make sure that the correct message is in the returned value of the script.
    """
    mocker.patch.object(demisto, "incident", return_value={"CustomFields": {"incomingmirrorerror": "Error message"}})
    result = main()

    assert "Failure" in result["Contents"]


def test_main_completed_stopped(mocker):
    """
    Given:
        - An incident that has incomingmirrorerror of Fetching events has reached events limit in this incident..
    When:
        - Running QRadarMirroringEventsStatus script.
    Then:
        - Make sure that the correct message is in the returned value of the script.
    """
    mocker.patch.object(
        demisto,
        "incident",
        return_value={"CustomFields": {"incomingmirrorerror": "Fetching events has reached events limit in this incident."}},
    )
    result = main()

    assert "Completed and Stopped" in result["Contents"]


def test_main_completed(mocker):
    """
    Given:
        - An incident that has incomingmirrorerror of All available events in the offense were fetched..
    When:
        - Running QRadarMirroringEventsStatus script.
    Then:
        - Make sure that the correct message is in the returned value of the script.
    """
    mocker.patch.object(
        demisto,
        "incident",
        return_value={"CustomFields": {"incomingmirrorerror": "All available events in the offense were fetched."}},
    )
    result = main()

    assert "Completed" in result["Contents"]