Example #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)
Example #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)
Example #3
0
 def test_backscatter(self):
     responses.add(responses.GET,
                   'https://dshield.org/api/backscatter?json',
                   body='["test"]',
                   status=200,
                   match_querystring=True,
                   content_type='text/json')
     responses.add(responses.GET,
                   'https://dshield.org/api/backscatter/2011-12-01?json',
                   body='["2011-12-01"]',
                   status=200,
                   match_querystring=True,
                   content_type='text/json')
     responses.add(responses.GET,
                   'https://dshield.org/api/backscatter/2011-12-01/10?json',
                   body='["10"]',
                   status=200,
                   match_querystring=True,
                   content_type='text/json')
     self.assertEquals(dshield.backscatter(), ["test"])
     self.assertEquals(dshield.backscatter("2011-12-01"), ["2011-12-01"])
     self.assertEquals(dshield.backscatter(datetime.date(2011, 12, 1)),
                       ["2011-12-01"])
     self.assertEquals(dshield.backscatter("2011-12-01", 10), ["10"])
     self.assertEquals(dshield.backscatter("2011-12-01", "10"), ["10"])
     self.assertEquals(
         dshield.backscatter("2011-12-01", "10", dshield.JSON), '["10"]')
Example #4
0
 def test_backscatter(self):
     responses.add(responses.GET, 'https://dshield.org/api/backscatter?json',
                   body='["test"]', status=200,
                   match_querystring=True, content_type='text/json')
     responses.add(responses.GET,
                   'https://dshield.org/api/backscatter/2011-12-01?json',
                   body='["2011-12-01"]', status=200, match_querystring=True,
                   content_type='text/json')
     responses.add(responses.GET,
                   'https://dshield.org/api/backscatter/2011-12-01/10?json',
                   body='["10"]', status=200, match_querystring=True,
                   content_type='text/json')
     self.assertEquals(dshield.backscatter(), ["test"])
     self.assertEquals(dshield.backscatter("2011-12-01"), ["2011-12-01"])
     self.assertEquals(dshield.backscatter(datetime.date(2011, 12, 1)), ["2011-12-01"])
     self.assertEquals(dshield.backscatter("2011-12-01", 10), ["10"])
     self.assertEquals(dshield.backscatter("2011-12-01", "10"), ["10"])
     self.assertEquals(dshield.backscatter("2011-12-01", "10", dshield.JSON),
                       '["10"]')