RiskIQDigitalFootprintAssetDetailsWidgetScript

Shows the detailed information of an asset identified as a "RiskIQAsset" type of indicator in the layout of the indicator.

python · RiskIQ Digital Footprint

Details

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

README

Shows the detailed information of an asset identified as a “RiskIQAsset” type of indicator in the layout of the indicator.

Script Data


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

Dependencies


This script uses the following commands and scripts.

  • df-get-asset

Inputs


There are no inputs for this script.

Outputs


There are no outputs for this script.

from unittest.mock import patch

import demistomock as demisto
import RiskIQDigitalFootprintAssetDetailsWidgetScript


def test_main_success(mocker):
    """
    When main function is called, set_arguments_for_widget_view should be called.
    """

    mocker.patch.object(
        RiskIQDigitalFootprintAssetDetailsWidgetScript,
        "set_arguments_for_widget_view",
        return_value='Please provide value in the "RiskIQAsset Type" field to fetch detailed information of the asset.',
    )
    RiskIQDigitalFootprintAssetDetailsWidgetScript.main()
    assert RiskIQDigitalFootprintAssetDetailsWidgetScript.set_arguments_for_widget_view.called


@patch("RiskIQDigitalFootprintAssetDetailsWidgetScript.return_error")
def test_main_failure(mock_return_error, mocker):
    """
    When main function gets some exception then valid message should be printed.
    """

    mocker.patch.object(RiskIQDigitalFootprintAssetDetailsWidgetScript, "set_arguments_for_widget_view", side_effect=Exception)
    mocker.patch.object(demisto, "error", return_value="")
    RiskIQDigitalFootprintAssetDetailsWidgetScript.main()

    mock_return_error.assert_called_once_with("Could not load widget:\n")


def test_set_arguments_for_widget_view_when_riskiqassettype_is_empty():
    """
    When riskiqassettpye indicator field is kept empty,
    set_arguments_for_widget_view should return a validation message.
    """

    # set arguments for command
    indicator_data = {"indicator_type": "RiskIQAsset", "value": "dummy domain", "CustomFields": {}}

    # Execute
    arguments = RiskIQDigitalFootprintAssetDetailsWidgetScript.set_arguments_for_widget_view(indicator_data)
    # Assert
    assert arguments == 'Please provide value in the "RiskIQAsset Type" field to fetch detailed information of the asset.'


def test_set_arguments_for_widget_view_when_riskiqassettype_is_valid():
    """
    When riskiqassettpye indicator field has valid value,
    set_arguments_for_widget_view should set the arguments successfully.
    """

    # set argument for command
    indicator_data = {"indicator_type": "RiskIQAsset", "value": "dummy domain", "CustomFields": {"riskiqassettype": "Domain"}}
    # set expected output
    expected_arguments = {"name": "dummy domain", "type": "Domain"}
    # Execute
    arguments = RiskIQDigitalFootprintAssetDetailsWidgetScript.set_arguments_for_widget_view(indicator_data)
    # Assert
    assert expected_arguments == arguments