Ejemplo n.º 1
0
 def test_no_functions_throw_exceptions(self):
     try:
         dshield.backscatter()
         dshield.handler()
         dshield.infocon()
         dshield.ip('8.8.8.8')
         dshield.port(80)
         dshield.portdate(80)
         dshield.topports()
         dshield.topips()
         dshield.sources()
         dshield.porthistory(80)
         dshield.asnum(1)
         dshield.dailysummary()
         dshield.daily404summary(datetime.date(2011, 12, 1))
         dshield.daily404detail(datetime.date(2011, 12, 1))
         dshield.glossary()
         dshield.webhoneypotsummary(datetime.date(2011, 12, 1))
         dshield.webhoneypotbytype(datetime.date(2011, 12, 1))
     except requests.RequestException:
         # don't care about network errors
         pass
     except Exception:
         # anything else is a fail
         self.assertTrue(False)
Ejemplo n.º 2
0
 def test_no_functions_throw_exceptions(self):
     try:
         dshield.backscatter()
         dshield.handler()
         dshield.infocon()
         dshield.ip('8.8.8.8')
         dshield.port(80)
         dshield.portdate(80)
         dshield.topports()
         dshield.topips()
         dshield.sources()
         dshield.porthistory(80)
         dshield.asnum(1)
         dshield.dailysummary()
         dshield.daily404summary(datetime.date(2011, 12, 1))
         dshield.daily404detail(datetime.date(2011, 12, 1))
         dshield.glossary()
         dshield.webhoneypotsummary(datetime.date(2011, 12, 1))
         dshield.webhoneypotbytype(datetime.date(2011, 12, 1))
     except requests.RequestException:
         # don't care about network errors
         pass
     except Exception:
         # anything else is a fail
         self.assertTrue(False)
Ejemplo n.º 3
0
 def test_topips(self):
     responses.add(
         responses.GET,
         'https://dshield.org/api/topips/records/10/2011-07-23?json',
         body='{"topips":"test"}',
         match_querystring=True,
         content_type='text/json')
     responses.add(responses.GET,
                   'https://dshield.org/api/topips/records/10?json',
                   body='{"topips":"test"}',
                   match_querystring=True,
                   content_type='text/json')
     responses.add(responses.GET,
                   'https://dshield.org/api/topips/records?json',
                   body='{"topips":"test"}',
                   match_querystring=True,
                   content_type='text/json')
     responses.add(responses.GET,
                   'https://dshield.org/api/topips?json',
                   body='{"topips":"test"}',
                   match_querystring=True,
                   content_type='text/json')
     data = {'topips': 'test'}
     self.assertEquals(dshield.topips(), data)
     self.assertEquals(dshield.topips('records'), data)
     self.assertEquals(dshield.topips('records', 10), data)
     self.assertEquals(
         dshield.topips('records', '10', datetime.date(2011, 7, 23)), data)
     self.assertEquals(dshield.topips('records', 10, '2011-07-23'), data)
     self.assertEquals(
         dshield.topips('records', return_format=dshield.JSON),
         '{"topips":"test"}')
Ejemplo n.º 4
0
 def test_topips(self):
     responses.add(responses.GET, 'https://dshield.org/api/topips/records/10/2011-07-23?json',
                   body='{"topips":"test"}',
                   match_querystring=True, content_type='text/json')
     responses.add(responses.GET, 'https://dshield.org/api/topips/records/10?json',
                   body='{"topips":"test"}',
                   match_querystring=True, content_type='text/json')
     responses.add(responses.GET, 'https://dshield.org/api/topips/records?json',
                   body='{"topips":"test"}',
                   match_querystring=True, content_type='text/json')
     responses.add(responses.GET, 'https://dshield.org/api/topips?json',
                   body='{"topips":"test"}',
                   match_querystring=True, content_type='text/json')
     data = {'topips': 'test'}
     self.assertEquals(dshield.topips(), data)
     self.assertEquals(dshield.topips('records'), data)
     self.assertEquals(dshield.topips('records', 10), data)
     self.assertEquals(dshield.topips('records', '10', datetime.date(2011, 7, 23)), data)
     self.assertEquals(dshield.topips('records', 10, '2011-07-23'), data)
     self.assertEquals(dshield.topips('records', return_format=dshield.JSON), '{"topips":"test"}')
Ejemplo n.º 5
0
 def test_limits_respected(self):
     self.assertEquals(len(dshield.topips(limit=100)), 100)
Ejemplo n.º 6
0
 def test_limits_respected(self):
     self.assertEquals(len(dshield.topips(limit=100)), 100)