Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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)
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)
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)