Beispiel #1
0
def test_ip(requests_mock):
    requests_mock.get(f'{MOCK_BASE_URL}/ipr/{MOCK_IP}', json=MOCK_IP_RESP)

    client = Client(MOCK_BASE_URL, MOCK_API_KEY, MOCK_PASSWORD, True, False)
    args = {'ip': MOCK_IP}
    _, outputs, _ = ip_command(client, args)

    assert outputs[outputPaths['ip']][0]['Address'] == MOCK_IP
Beispiel #2
0
def test_ip(requests_mock):
    """
    Given: Arguments for ip command

    When: The server response is complete

    Then: validates the outputs

    """
    requests_mock.get(f'{MOCK_BASE_URL}/ipr/{MOCK_IP}', json=MOCK_IP_RESP)

    client = Client(MOCK_BASE_URL, MOCK_API_KEY, MOCK_PASSWORD, True, False)
    args = {
        'ip': MOCK_IP
    }
    _, outputs, _ = ip_command(client, args)

    assert outputs[outputPaths['ip']][0]['Address'] == MOCK_IP
    assert outputs[DBOT_SCORE_KEY][0] == MOCK_IP_RESP[DBOT_SCORE_KEY]
Beispiel #3
0
def test_ip_with_invalid_resp(requests_mock):
    """
    Given: Arguments for ip command

    When: The server response is not complete and some data fields are empty

    Then: validates the outputs

    """
    requests_mock.get(f'{MOCK_BASE_URL}/ipr/{MOCK_IP}', json=MOCK_INVALID_IP_RESP)

    client = Client(MOCK_BASE_URL, MOCK_API_KEY, MOCK_PASSWORD, True, False)
    args = {
        'ip': MOCK_IP
    }
    md, outputs, reports = ip_command(client, args)

    assert outputs[outputPaths['ip']][0]['Address'] == MOCK_IP
    assert reports[0] == {'ip': '8.8.8.8', 'history': [], 'subnets': [], 'cats': {}, 'score': 1, 'tags': []}
    assert md == """### X-Force IP Reputation for: 8.8.8.8