IbmConvertAttachmentsToTable

This script is used to convert IBM QRadar SOAR attachments to a markdown table.

python · IBM Security QRadar SOAR

Details

IDIbmConvertAttachmentsToTable
Languagepython
From Version6.10.0
Docker Imagedemisto/python3:3.12.13.10404775
Tagsdynamic-section

README

This script is used to format IBM QRadar SOAR attachments into a mark-down table.

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
import pytest
from IbmConvertAttachmentsToTable import convert_to_table


def test_convert_to_table_no_incident(mocker):
    import re

    mocker.patch.object(demisto, "incident", return_value=None)
    with pytest.raises(
        ValueError,
        match=re.escape("Error - demisto.incident() expected to return current incident from context but returned None"),
    ):
        convert_to_table()


def test_convert_to_table_no_attachments(mocker):
    mock_incident = {"CustomFields": {}}
    mocker.patch.object(demisto, "incident", return_value=mock_incident)
    result = convert_to_table()
    assert result.readable_output == "No attachments were found for this incident"


def test_convert_to_table_with_attachments(mocker):
    mock_attachments = ['{"name": "file1.txt", "size": 1024}', '{"name": "file2.pdf", "size": 2048}']
    mock_incident = {"CustomFields": {"ibmsecurityqradarsoarattachments": mock_attachments}}
    mocker.patch.object(demisto, "incident", return_value=mock_incident)
    convert_to_table()