How to use the passivetotal.common.exceptions.INVALID_FIELD_TYPE function in passivetotal

To help you get started, we’ve selected a few passivetotal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github passivetotal / python_api / tests / test_ssl.py View on Github external
def test_ssl_certificate_search_bad_field(self):
        """Test sending a bad field in a search."""
        with pytest.raises(INVALID_FIELD_TYPE) as excinfo:
            def invalid_field():
                payload = {'query': 'www.passivetotal.org', 'field': '_'}
                self.client.search_ssl_certificate_by_field(**payload)
            invalid_field()
        assert 'must be one of the following' in str(excinfo.value)
github passivetotal / python_api / tests / test_whois.py View on Github external
def test_whois_search_bad_field(self):
        """Test sending a bad field in a search."""
        with pytest.raises(INVALID_FIELD_TYPE) as excinfo:
            def invalid_field():
                payload = {'query': '18772064254', 'field': '_'}
                self.client.search_whois_by_field(**payload)
            invalid_field()
        assert 'must be one of the following' in str(excinfo.value)
github passivetotal / python_api / passivetotal / libs / whois.py View on Github external
def search_whois_by_field(self, **kwargs):
        """Search WHOIS details based on query value and field.

        Reference: https://api.passivetotal.org/api/docs/#api-WHOIS-GetV2WhoisSearchQueryField

        :param str query: Query value to use when making the request for data
        :param str compact_record: Return the record in a compact format
        :param str field: Field to run the query against
        :return: WHOIS records matching the query
        """
        if 'field' not in kwargs:
            raise MISSING_FIELD("Field value is required.")
        if kwargs['field'] not in WHOIS_VALID_FIELDS:
            raise INVALID_FIELD_TYPE("Field must be one of the following: %s"
                                     % ', '.join(WHOIS_VALID_FIELDS))
        return self._get('whois', 'search', **kwargs)
github passivetotal / python_api / passivetotal / libs / ssl.py View on Github external
def search_ssl_certificate_by_field(self, **kwargs):
        """Search SSL certificate details based on query value and field.

        Reference: https://api.passivetotal.org/api/docs/#api-SSL_Certificates-GetSslCertificateSearchQueryField

        :param str query: Query value to use when making the request for data
        :param str compact_record: Return the record in a compact format
        :param str field: Field to run the query against
        :param str type: Type of search to conduct
        :return: SSL certificates matching the query
        """
        if 'field' not in kwargs:
            raise MISSING_FIELD("Field value is required.")
        if kwargs['field'] not in SSL_VALID_FIELDS:
            raise INVALID_FIELD_TYPE("Field must be one of the following: %s"
                                     % ', '.join(SSL_VALID_FIELDS))
        return self._get('ssl-certificate', 'search', **kwargs)