ServerLogs

Uses the ssh integration to grab the host server logs. This script is supported only on Cortex XSOAR on-prem (version 6.X).

python · Common Scripts

Details

IDServerLogs
Languagepython
From Version6.0.0
Docker Imagedemisto/python3:3.12.13.10404775
Tagswidget

README

Uses the ssh integration to grab the host server logs
This script is supported only on Cortex XSOAR on-prem (version 6.X).

Script Data


Name Description
Script Type python3
Tags widget
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


def test_main(mocker):
    """
    Given:
        - Valid response from ssh command
    When:
        - Running the script
    Then:
        - Ensure results function is called with the expected output
    """
    from ServerLogs import main

    mocker.patch.object(demisto, "executeCommand", return_value=[{"Contents": {"output": "output"}}])
    return_results = mocker.patch.object(demisto, "results")
    main()
    return_results.assert_called_with("File: /var/log/demisto/server.log\noutput")


def raise_value_error():
    raise ValueError("error")


def test_main_fail(mocker):
    """
    Given:
        - Invalid response from ssh command
    When:
        - Running the script
    Then:
        - Ensure return_error function is called with the expected output
    """
    from ServerLogs import main

    mocker.patch.object(demisto, "executeCommand", side_effect=raise_value_error)
    with pytest.raises(Exception):
        main()