Beispiel #1
0
def test_create_random_hunt_incident_find_indicators_error(mocker):
    """
    Given: Errors in findIndicators
    When: Running create_random_hunt_incident command.
    Then: An exception is thrown
    """
    from CyrenThreatInDepthRandomHunt import create_random_hunt_incident

    mocker.patch.object(demisto,
                        "executeCommand",
                        side_effect=executeCommand(findIndicatorsError=True))
    with pytest.raises(DemistoException):
        create_random_hunt_incident(dict())
Beispiel #2
0
def test_create_random_hunt_incident_create_new_incident_error(mocker):
    """
    Given: Creating the incident will produce an error
    When: Running create_random_hunt_incident command.
    Then: An exception is thrown
    """
    from CyrenThreatInDepthRandomHunt import create_random_hunt_incident

    mocker.patch.object(
        demisto,
        "executeCommand",
        side_effect=executeCommand(createNewIncidentError=True))

    with pytest.raises(DemistoException):
        create_random_hunt_incident(dict())
Beispiel #3
0
def test_create_random_hunt_incident_find_indicators_empty(mocker):
    """
    Given: No indicators according to query
    When: Running create_random_hunt_incident command.
    Then: An error message is printed
    """
    from CyrenThreatInDepthRandomHunt import create_random_hunt_incident

    mocker.patch.object(
        demisto,
        "executeCommand",
        side_effect=executeCommand(findIndicatorsResult=FIND_INDICATORS_EMPTY))
    result = create_random_hunt_incident(dict())

    assert "Could not find any indicators for " in result.readable_output
Beispiel #4
0
def test_create_random_hunt_incident_get_current_user_error(mocker):
    """
    Given: Getting current user produces an error
    When: Running create_random_hunt_incident command.
    Then: Incident is still created
    """
    from CyrenThreatInDepthRandomHunt import create_random_hunt_incident

    mocker.patch.object(demisto,
                        "executeCommand",
                        side_effect=executeCommand(getUsersError=True))
    result = create_random_hunt_incident(dict())

    assert result.readable_output == (
        "Successfully created incident Cyren Threat InDepth Threat Hunt.\n"
        "Click here to investigate: [1234](#/incident/1234).")
Beispiel #5
0
def test_create_random_hunt_incident(mocker, args, expected_incident):
    """
    Given: Different arg input
    When: Running create_random_hunt_incident command.
    Then: An incident has been created and a link is posted
    """
    from CyrenThreatInDepthRandomHunt import create_random_hunt_incident

    mocker.patch.object(demisto,
                        "executeCommand",
                        side_effect=executeCommand())
    result = create_random_hunt_incident(args)

    demisto.executeCommand.assert_any_call("createNewIncident",
                                           expected_incident)
    assert result.readable_output == (
        "Successfully created incident Cyren Threat InDepth Threat Hunt.\n"
        "Click here to investigate: [1234](#/incident/1234).")