def test_vt_ip_check(self): vt_api = os.environ["VT_API"] self.assertIsNone(ub.vt_ip_check('asdf', vt_api)) vt_ip_data = ub.vt_ip_check("192.30.252.130", vt_api) self.assertIsInstance(vt_ip_data, dict) self.assertIn('detected_urls', vt_ip_data) self.assertIn('country', vt_ip_data) self.assertEqual(vt_ip_data['country'], 'US') self.assertIn('resolutions', vt_ip_data) is_gh = False for resolution in vt_ip_data['resolutions']: if resolution['hostname'] == "github.com": is_gh = True self.assertTrue(is_gh) time.sleep(15) # VT rate limiting
def test_vt_rate_limiting(self): vt_api = os.environ["VT_API"] # Exceed 4x in 60 seconds data = ub.vt_hash_check("d41d8cd98f00b204e9800998ecf8427e", vt_api) self.assertIsInstance(data, dict) data = ub.vt_hash_check("d41d8cd98f00b204e9800998ecf8427e", vt_api) data = ub.vt_hash_check("d41d8cd98f00b204e9800998ecf8427e", vt_api) data = ub.vt_hash_check("d41d8cd98f00b204e9800998ecf8427e", vt_api) data = ub.vt_name_check("example.org", vt_api) self.assertIsNone(data) data = ub.vt_ip_check("192.30.252.130", vt_api) self.assertIsNone(data) data = ub.vt_hash_check("d41d8cd98f00b204e9800998ecf8427e", vt_api) self.assertIsNone(data) time.sleep(15)