ShowCampaignLastIncidentOccurred

Displays the occurrence date of the last campaign incident.

python · Phishing Campaign

Details

IDShowCampaignLastIncidentOccurred
Languagepython
From Version5.5.0
Docker Imagedemisto/python3:3.12.13.10116658
Tagsdynamic-section

README

Displays the occurrence date of the last campaign incident.

Script Data


Name Description
Script Type python3
Tags dynamic-section
Cortex XSOAR Version 5.5.0 and later

Inputs


There are no inputs for this script.

Outputs


There are no outputs for this script.

import demistomock as demisto
import pytest
import ShowCampaignLastIncidentOccurred

INCIDENT_IDS = [{"id": "1"}, {"id": "2"}, {"id": "3"}]
MULTIPLE_INCIDENT_CREATED = [
    {
        "Contents": '[{"created": "2021-07-27T15:09:35.269187268Z"}, {"created": "2021-07-28T15:06:33.100736309Z"}, \
                      {"created": "2021-07-29T14:42:38.945010982Z"}, {"created": "2021-07-29T14:09:22.708160443Z"}]',
        "Type": 3,
    }
]
ONE_INCIDENT_CREATED = [{"Contents": '[{"created": "2021-07-28T15:06:33.100736309Z"}]', "Type": 3}]


@pytest.mark.parametrize(
    "incident_created, expected_result, pixels",
    [
        (MULTIPLE_INCIDENT_CREATED, "July 29, 2021", "24"),
        (ONE_INCIDENT_CREATED, "July 28, 2021", "24"),
        ([{"Contents": "[]", "Type": 3}], "No last incident occurred found.", "24"),
    ],
)
def test_show_last_incident_occurred(mocker, incident_created, expected_result, pixels):
    """
    Given:
        - Campaign incidents.
    When:
        - Running the show last incident occurred script main function.
    Then:
        - Ensure the correct last incident occurred is appear in the html format.
    """
    mocker.patch.object(demisto, "get", return_value=INCIDENT_IDS)
    mocker.patch.object(demisto, "executeCommand", return_value=incident_created)
    mocker.patch.object(demisto, "results")

    ShowCampaignLastIncidentOccurred.main()

    res = demisto.results.call_args[0][0]["Contents"]
    expected_result = (
        f"<div style='text-align:center; font-size:17px; padding: 15px;'>Last Incident Occurred</br> "
        f"<div style='font-size:{pixels}px;'> {expected_result} </div></div>"
    )

    assert expected_result == res