SekoiaXDRAddComment

Script to add a comment to an alert in Sekoia, including the name of the person who made the comment.

python · SekoiaXDR

Details

IDSekoiaXDRAddComment
Languagepython
From Version6.10.0
Docker Imagedemisto/python3:3.12.13.10116658
Tagsincident-action-button

README

Script to add a comment to an alert in Sekoia, including the name of the person who made the comment.

Script Data


Name Description
Script Type python3
Tags incident-action-button
Cortex XSOAR Version 6.10.0

Inputs


Argument Name Description
short_id The short ID of the alert.
comment The comment you want to send to an alert.

Outputs


There are no outputs for this script.

import demistomock as demisto
from SekoiaXDRAddComment import get_username, post_comment, main  # type: ignore


def test_get_username(mocker):
    output_data = [{"Type": 3, "Contents": [{"name": "admin", "PrettyRoles": "Administrator"}]}]
    mocker.patch.object(demisto, "executeCommand", return_value=output_data)
    assert get_username() == "admin"


def test_post_comment(mocker):
    output_data = [{"Type": 3, "Contents": [{"id": "1", "comment": "test", "author": "admin"}]}]
    mocker.patch.object(demisto, "executeCommand", return_value=output_data)
    assert not post_comment("1", "test", "admin")


def test_main(mocker):
    mocker.patch.object(demisto, "args", return_value={"short_id": "1", "comment": "test"})
    mocker.patch("SekoiaXDRAddComment.get_username", return_value="admin")
    mocker.patch("SekoiaXDRAddComment.post_comment", return_value=None)
    mocker.patch.object(demisto, "results")

    main()
    assert demisto.results.call_args[0][0]["HumanReadable"] == "### Comment added by admin:\n test"