Ejemplo n.º 1
0
 def test_known_threat(self):
     """
         This will test an ip address that is a known threat
     """
     data = http_call(self.SERVER + self.THREAT_URL%self.THREAT_IP)
     self.validate_threat(threat=data)
     assert data['activities'], 'This should have activities since it is a known threat'
Ejemplo n.º 2
0
 def test_traffic(self):
     """
         This will test the get method for /api/traffic
     """
     data = http_call(self.SERVER+self.TRAFFIC_URL)
     for d in data:
         assert 'alienvaultid' in d, 'Missing AlienVaultId'
         assert 'visits' in d, 'Missing visits'
         for v in d['visits']:
             assert isinstance(v.get('address',None), basestring), 'address missing or wrong type'
             assert isinstance(v.get('timestamp',None), int), 'timestamp missing or wrong type'
             assert isinstance(v.get('endpoint',None), basestring), 'endpoint missing or wrong type'
Ejemplo n.º 3
0
    def test_adding_cookie(self):
        """
            This will add a random cookie and make sure the visit was registered
        """
        data1 = http_call(self.SERVER+self.TRAFFIC_URL)
        http_call(self.SERVER+self.THREAT_URL%self.THREAT_IP)
        data2 = http_call(self.SERVER+self.TRAFFIC_URL)
        new_visit = [d for d in data2 if not d in data1][0]
        assert new_visit['visits'][0]['endpoint'] == self.THREAT_URL[1:]%self.THREAT_IP

        http_call(self.SERVER+self.THREAT_URL%self.SAFE_IP)
        data3 = http_call(self.SERVER+self.TRAFFIC_URL)
        new_visit = [d for d in data3 if not d in data2][0]
        assert new_visit['visits'][0]['endpoint'] == self.THREAT_URL[1:]%self.SAFE_IP
Ejemplo n.º 4
0
 def test_burn(self):
     """
         This will test "count" ip addresses starting at "index"
     """
     failures = {}
     index= self.BURN_TEST_START_IP
     for i in range(self.BURN_TEST_COUNT):
         index += 1
         ip = '%s.%s.%s.%s'%(int(index/(256*256*256)),
                             int(index/256*256)%256,
                             int(index/256)%256,
                             index%256)
         try:
             print 'Burn testing %s'%ip
             data = http_call(self.SERVER+self.THREAT_URL%ip)
             self.validate_threat(data)
         except Exception as e:
             failures[ip] = e
             print '     failure'
     if failures:
         raise
Ejemplo n.º 5
0
 def test_known_safe(self):
     """
         This will test an ip address that is known to be safe
     """
     data = http_call(self.SERVER + self.THREAT_URL%self.SAFE_IP)
     self.validate_threat(threat=data)