def testConnectionWithCustomProtocolParameters(self): connection = client.Client(protocol=common.HTTPS_PROTOCOL) api_key_test, protocol_test, host_test = connection.GetConnectionData() self.assertEqual(api_key_test, None) self.assertEqual(protocol_test, common.HTTPS_PROTOCOL) self.assertEqual(host_test, common.DEFAULT_HOST) connection = client.Client(protocol=common.HTTP_PROTOCOL) api_key_test, protocol_test, host_test = connection.GetConnectionData() self.assertEqual(api_key_test, None) self.assertEqual(protocol_test, common.HTTP_PROTOCOL) self.assertEqual(host_test, common.DEFAULT_HOST)
def testASPrivateIPAddressConnectionApiKey(self): api_key_sample = TEST_KEY_SAMPLE ip_sample = '10.0.0.1' connection = client.Client(api_key=api_key_sample) dto = connection.GetASbyIP(ip_sample) self.assertEqual(dto.status_code, requests.codes.not_found) self.assertEqual(dto.asystem, None)
def testASPrivateIPAddressConnectionAnonymous(self): ip_sample = '10.0.0.1' connection = client.Client() dto = connection.GetASbyIP(ip_sample) self.assertEqual(dto.status_code, requests.codes.not_found) self.assertEqual(dto.asystem, None) time.sleep(10)
def testConnectionWithAPIKEYParameters(self): api_key_sample = TEST_WRONG_KEY_SAMPLE connection = client.Client(api_key=api_key_sample) api_key_test, protocol_test, host_test = connection.GetConnectionData() self.assertEqual(api_key_test, api_key_sample) self.assertEqual(protocol_test, common.HTTPS_PROTOCOL) self.assertEqual(host_test, common.DEFAULT_HOST)
def testConnectionWithCustomHostParameters(self): host_sample = 'google.com' connection = client.Client(host=host_sample) api_key_test, protocol_test, host_test = connection.GetConnectionData() self.assertEqual(api_key_test, None) self.assertEqual(protocol_test, common.HTTPS_PROTOCOL) self.assertEqual(host_test, host_sample)
def testCheckBadIPAddressConnectionApiKey(self): api_key_sample = TEST_KEY_SAMPLE ip_sample = '1.2.3.4' connection = client.Client(api_key=api_key_sample) dto = connection.CheckIP(ip_sample) self.assertEqual(dto.status_code, requests.codes.ok) self.assertEqual(dto.error, None) self.assertNotEqual(dto.blacklists, [])
def testGeoPrivateIPAddressConnectionAnonymous(self): ip_sample = '10.0.0.1' connection = client.Client() dto = connection.GetGeoIP(ip_sample) self.assertEqual(dto.status_code, requests.codes.ok) self.assertEqual(dto.error, None) self.assertEqual(dto.geoip, None) time.sleep(10)
def testCheckBadIPAddressConnectionApiKeyJSON(self): api_key_sample = TEST_KEY_SAMPLE ip_sample = '1.2.3.4' connection = client.Client(api_key=api_key_sample) dto = connection.CheckIP(ip_sample) self.assertEqual(dto.status_code, requests.codes.ok) self.assertEqual(dto.error, None) self.assertIn('QUARANTINE-IP', dto.json['response'])
def testCheckGoodIPAddressConnectionAnonymous(self): ip_sample = '8.8.8.8' connection = client.Client() dto = connection.CheckIP(ip_sample) self.assertEqual(dto.status_code, requests.codes.not_found) self.assertEqual(dto.error, None) self.assertEqual(dto.blacklists, []) time.sleep(10)
def testCheckBadIPAddressConnectionAnonymous(self): ip_sample = '1.2.3.4' connection = client.Client() dto = connection.CheckIP(ip_sample) self.assertEqual(dto.status_code, requests.codes.ok) self.assertEqual(dto.error, None) self.assertNotEqual(dto.blacklists, []) time.sleep(10)
def testCheckBadBatchIPAddressesConnectionAnonymous(self): ip_sample = ['1.2.3.4', '114.223.63.139', '114.224.29.97'] connection = client.Client() dto = connection.CheckBatchIP(ip_sample) self.assertEqual(dto.status_code, requests.codes.ok) self.assertEqual(dto.error, None) self.assertNotEqual(dto.ipblacklists_set, None) time.sleep(10)
def testCheckGoodBatchIPAddressesConnectionAnonymous(self): ip_sample = ['8.8.8.8', '9.9.9.9', '8.8.4.4'] connection = client.Client() dto = connection.CheckBatchIP(ip_sample) self.assertEqual(dto.status_code, requests.codes.ok) self.assertEqual(dto.error, None) self.assertNotEqual(dto.ipblacklists_set, None) time.sleep(10)
def testCheckBadBatchIPAddressConnectionApiKey(self): api_key_sample = TEST_KEY_SAMPLE ip_sample = ['1.2.3.4', '114.223.63.139', '114.224.29.97'] connection = client.Client(api_key=api_key_sample) dto = connection.CheckBatchIP(ip_sample) self.assertEqual(dto.status_code, requests.codes.ok) self.assertEqual(dto.error, None) self.assertNotEqual(dto.ipblacklists_set, None)
def testASBatchNumConnectionAnonymous(self): asn_sample = [15169, 19281] connection = client.Client() dto = connection.GetASBatchByNum(asn_sample) self.assertEqual(dto.status_code, requests.codes.ok) self.assertEqual(dto.error, None) self.assertEqual(dto.asystem_asn_list[0].asystem.asn, '15169') self.assertEqual(dto.asystem_asn_list[1].asystem.asn, '19281') time.sleep(10)
def testASNumConnectionAnonymous(self): asnum_sample = 15169 connection = client.Client() dto = connection.GetASbyNum(asnum_sample) self.assertEqual(dto.status_code, requests.codes.ok) self.assertEqual(dto.error, None) self.assertEqual(dto.asystem.name, 'Google LLC') self.assertEqual(dto.asystem.asn, '15169') time.sleep(10)
def testASIPAddressConnectionApiKey(self): api_key_sample = TEST_KEY_SAMPLE ip_sample = '8.8.8.8' connection = client.Client(api_key=api_key_sample) dto = connection.GetASbyIP(ip_sample) self.assertEqual(dto.status_code, requests.codes.ok) self.assertEqual(dto.error, None) self.assertEqual(dto.asystem.name, 'Google LLC') self.assertEqual(dto.asystem.asn, '15169')
def testASBatchNumConnectionApiKey(self): api_key_sample = TEST_KEY_SAMPLE asn_sample = [15169, 19281] connection = client.Client(api_key=api_key_sample) dto = connection.GetASBatchByNum(asn_sample) self.assertEqual(dto.status_code, requests.codes.ok) self.assertEqual(dto.error, None) self.assertIn(dto.asystem_asn_list[0].asystem.asn, ['15169', '19281']) self.assertIn(dto.asystem_asn_list[1].asystem.asn, ['15169', '19281'])
def testASNumConnectionApiKeyJSON(self): api_key_sample = TEST_KEY_SAMPLE asnum_sample = 15169 connection = client.Client(api_key=api_key_sample) dto = connection.GetASbyNum(asnum_sample) self.assertEqual(dto.status_code, requests.codes.ok) self.assertEqual(dto.error, None) self.assertEqual(dto.asystem.name, 'Google LLC') self.assertEqual(dto.asystem.asn, '15169')
def testHistoryEmailConnectionApiKey(self): api_key_sample = TEST_KEY_SAMPLE email = '*****@*****.**' connection = client.Client(api_key=api_key_sample) dto = connection.GetHistoryEmail(email) self.assertEqual(dto.status_code, requests.codes.ok) self.assertEqual(dto.error, None) self.assertEqual(dto.history[0].email, '*****@*****.**') self.assertEqual(len(dto.history[0].blacklist_change) > 0, True)
def testConnectionWithCustomBadProtocolParameters(self): protocol_sample = 'TCP' try: connection = client.Client(protocol=protocol_sample) api_key_test, protocol_test, host_test = connection.GetConnectionData( ) self.assertEqual(protocol_sample, common.HTTPS_PROTOCOL) except: self.assertNotEqual(protocol_sample, common.HTTPS_PROTOCOL)
def testHistoryIPAddressConnectionApiKey(self): api_key_sample = TEST_KEY_SAMPLE ip_sample = '1.2.3.4' connection = client.Client(api_key=api_key_sample) dto = connection.GetHistoryIP(ip_sample) self.assertEqual(dto.status_code, requests.codes.ok) self.assertEqual(dto.error, None) self.assertEqual(dto.history[0].ip, '1.2.3.4') self.assertEqual(len(dto.history[0].blacklist_change) > 0, True)
def testWhoisIPAddressConnectionApiKey(self): api_key_sample = TEST_KEY_SAMPLE ip_sample = '9.9.9.9' connection = client.Client(api_key=api_key_sample) dto = connection.GetWhoisIP(ip_sample) self.assertEqual(dto.status_code, requests.codes.ok) self.assertEqual(dto.error, None) self.assertEqual(dto.whois.entities[0], 'CLEAN-97') self.assertEqual(dto.whois.asn, '19281')
def testWhoisIPAddressConnectionAnonymous(self): ip_sample = '8.8.8.8' connection = client.Client() dto = connection.GetWhoisIP(ip_sample) self.assertEqual(dto.status_code, requests.codes.ok) self.assertEqual(dto.error, None) self.assertEqual(dto.whois.entities[0], 'GOGL') self.assertEqual(dto.whois.asn, '15169') time.sleep(10)
def testASIPAddressConnectionAnonymous(self): ip_sample = '8.8.8.8' connection = client.Client() dto = connection.GetASbyIP(ip_sample) self.assertEqual(dto.status_code, requests.codes.ok) self.assertEqual(dto.error, None) self.assertEqual(dto.asystem.name, 'Google LLC') self.assertEqual(dto.asystem.asn, '15169') time.sleep(10)
def testGeoIPAddressConnectionAnonymous(self): ip_sample = '8.8.8.8' connection = client.Client() dto = connection.GetGeoIP(ip_sample) self.assertEqual(dto.status_code, requests.codes.ok) self.assertEqual(dto.error, None) self.assertEqual(dto.geoip.address, '8.8.8.8') self.assertEqual(dto.geoip.asystem.asn, '15169') time.sleep(10)
def testASBatchIPAddressesConnectionApiKey(self): api_key_sample = TEST_KEY_SAMPLE ip_sample = ['8.8.8.8', '9.9.9.9', '8.8.4.4'] connection = client.Client(api_key=api_key_sample) dto = connection.GetASBatchByIP(ip_sample) self.assertEqual(dto.status_code, requests.codes.ok) self.assertEqual(dto.error, None) self.assertIn(dto.asystem_ip_list[0].asystem.asn, ['15169', '19281']) self.assertIn(dto.asystem_ip_list[1].asystem.asn, ['15169', '19281']) self.assertIn(dto.asystem_ip_list[2].asystem.asn, ['15169', '19281'])
def testHistoryDomainConnectionApiKeyJSON(self): api_key_sample = TEST_KEY_SAMPLE domain = 'mailinator.com' connection = client.Client(api_key=api_key_sample) dto = connection.GetHistoryDomain(domain) self.assertEqual(dto.status_code, requests.codes.ok) self.assertEqual(dto.error, None) self.assertEqual(dto.history[0].domain, 'mailinator.com') self.assertEqual(len(dto.history[0].blacklist_change) > 0, True) self.assertGreater(len(dto.json['changes_domain']), 0)
def testCheckGoodDomainConnectionApiKey(self): api_key_sample = TEST_KEY_SAMPLE domain_sample = 'google.com' connection = client.Client(api_key=api_key_sample) dto = connection.CheckDomain(domain_sample) self.assertEqual(dto.status_code, requests.codes.ok) self.assertEqual(dto.error, None) self.assertEqual(dto.response.score, 0) self.assertEqual('ns1.google.com' in dto.response.domain.ns, True) self.assertEqual('aspmx.l.google.com' in dto.response.domain.mx, True)
def testCheckGoodDomainConnectionAnonymous(self): domain_sample = 'google.com' connection = client.Client() dto = connection.CheckDomain(domain_sample) self.assertEqual(dto.status_code, requests.codes.ok) self.assertEqual(dto.error, None) self.assertEqual(dto.response.score, 0) self.assertEqual('ns1.google.com' in dto.response.domain.ns, True) self.assertEqual('aspmx.l.google.com' in dto.response.domain.mx, True) time.sleep(10)
def testASBatchIPAddressesConnectionAnonymous(self): ip_sample = ['8.8.8.8', '9.9.9.9', '8.8.4.4'] connection = client.Client() dto = connection.GetASBatchByIP(ip_sample) self.assertEqual(dto.status_code, requests.codes.ok) self.assertEqual(dto.error, None) self.assertEqual(dto.asystem_ip_list[0].asystem.asn, '15169') self.assertEqual(dto.asystem_ip_list[1].asystem.asn, '19281') self.assertEqual(dto.asystem_ip_list[2].asystem.asn, '15169') time.sleep(10)