Beispiel #1
0
def test_discovery_search_command_ip_host_exception():
    with raises(
            DemistoException,
            match=
            'ip and hostname are mutually exclusive. Please specify just one parameter'
    ):
        discovery_search_command(client,
                                 ip='192.168.1.1',
                                 hostname='host.acme.com')
Beispiel #2
0
def test_discovery_search_command_ip_fail(mocker):
    mocker.patch.object(
        client,
        'discovery_search',
        return_value=util_load_json(
            'test_data/discovery_search_fail_192.168.11.1_resp.json'))
    kind = 'SNMPManagedDevice'
    ip = '192.168.11.1'
    results = discovery_search_command(client, kind=kind, ip=ip)
    assert results.outputs.get('count') == 0
Beispiel #3
0
def test_discovery_search_command_hostname_multiple(mocker):
    mocker.patch.object(
        client,
        'discovery_search',
        return_value=util_load_json(
            'test_data/discovery_search_success_multi_ais-blade_resp.json'))
    kind = 'Host'
    hostname = 'ais-blade'
    results = discovery_search_command(client, kind=kind, hostname=hostname)
    assert results.outputs['data'][1][
        'local_fqdn'] == 'ais-bladedr-02.calbro.com'
Beispiel #4
0
def test_discovery_search_command_ip_success(mocker):
    mocker.patch.object(
        client,
        'discovery_search',
        return_value=util_load_json(
            'test_data/discovery_search_single_success_192.168.11.1_resp.json')
    )
    kind = 'Host'
    ip = '192.168.11.1'
    results = discovery_search_command(client, kind=kind, ip=ip)
    assert results.outputs.get('data')[0].get(
        'hostname') == 'agent-id-pcfdev-0'
Beispiel #5
0
def test_discovery_search_command_invalid_ip_exception():
    with raises(DemistoException,
                match='Specified ip address doesn\'t look valid'):
        discovery_search_command(client, ip='host.acme.com')
Beispiel #6
0
def test_discovery_search_command_no_response(mocker):
    mocker.patch.object(client, 'discovery_search', return_value=None)
    with raises(DemistoException, match='Search command failed'):
        discovery_search_command(client)
Beispiel #7
0
def test_discovery_search_command_no_ip_exception():
    with raises(DemistoException,
                match='Please specify ip or hostname parameter'):
        discovery_search_command(client)