Exemple #1
0
def test_get_host_pairs_command_invalid_value_for_direction(client):
    """
        When invalid value is provided for direction argument in 'pt-get-host-pairs' then error message should match.
    """
    from PassiveTotal_v2 import get_host_pairs_command

    # Configure
    args = {'query': 'dummy domain', 'direction': 'invalid direction'}

    # Execute
    with pytest.raises(ValueError) as e:
        get_host_pairs_command(client, args)

    # Assert
    assert 'The given value for direction is invalid. Supported values: children, parents.' == str(
        e.value)
Exemple #2
0
def test_get_host_pairs_command_success(mocker_http_request, client):
    """
        When "pt-get-host-pairs" command executes successfully then context output and response should match.
    """
    from PassiveTotal_v2 import get_host_pairs_command

    # Fetch the expected response from file
    with open('test_data/HostAttribute/Host_Pair/host_pair_resp.json',
              encoding='utf-8') as f:
        json_file = json.load(f)
    expected_res = json_file.get('success')
    mocker_http_request.return_value = expected_res

    # Fetch the expected custom entry context from file
    with open('test_data/HostAttribute/Host_Pair/host_pair_ec.json',
              encoding='utf-8') as f:
        json_file = json.load(f)
    expected_custom_ec = json_file.get('success')

    # Fetch the expected human readable details from file
    with open('test_data/HostAttribute/Host_Pair/host_pair_hr.md') as f:
        expected_hr = f.read()

    result = get_host_pairs_command(client, HOST_ATTRIBUTE_ARGS['host_pair'])

    assert result.raw_response == expected_res
    assert result.outputs == expected_custom_ec
    assert result.readable_output == expected_hr
    assert result.outputs_key_field == ''
    assert result.outputs_prefix == 'PassiveTotal.HostPair'
Exemple #3
0
def test_get_host_pairs_command_no_record_found(mocker_http_request, client):
    """
        When no records found from Host Pairs response then result string should match.
    """
    from PassiveTotal_v2 import get_host_pairs_command

    # Fetch the expected response from file
    with open('test_data/HostAttribute/Host_Pair/host_pair_resp.json',
              encoding='utf-8') as f:
        json_file = json.load(f)
    expected_res = json_file.get('emptyContent')
    mocker_http_request.return_value = expected_res

    result = get_host_pairs_command(client, HOST_ATTRIBUTE_ARGS['host_pair'])
    assert result == 'No host pair(s) were found for the given argument(s).'