Exemplo n.º 1
0
def test_censysconnector_get_results_error(
    censys_id_value: str, censys_secret_value: str
) -> None:
    """
    Raise CensysConnector error and check output of it
    :param censys_id_value: censys id
    :param censys_secret_value: censys secret
    :return: None
    """
    api = CensysConnector(api_id=censys_id_value, api_secret=censys_secret_value)
    api.search(query="", max_records=10)
    with patch(
        "grinder.censysconnector.CensysConnector.get_results",
        side_effect=CensysConnectorGetResultsError("test"),
    ):
        with raises(Exception) as init_err:
            api.get_results()
        assert "Error occured in Censys Connector module" in str(init_err.value)
Exemplo n.º 2
0
def test_censysconnector_get_results(censys_id_value: str,
                                     censys_secret_value: str) -> None:
    """
    Check results parser
    :param censys_id_value: censys id
    :param censys_secret_value: censys secret
    :return: None
    """
    api = CensysConnector(api_id=censys_id_value,
                          api_secret=censys_secret_value)
    api.search(query="", max_records=10)
    results = api.get_results()
    assert len(results) == 10
    for result in results:
        assert sorted(result.keys()) == sorted(
            ["ip", "country", "lat", "lng", "port", "proto"])