コード例 #1
0
ファイル: test.py プロジェクト: rshipp/python-dshield
 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)
コード例 #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)
コード例 #3
0
 def test_sources(self):
     responses.add(responses.GET,
                   'https://dshield.org/api/sources/ip/10/2012-03-08?json',
                   body='{"sources":"test"}',
                   match_querystring=True,
                   content_type='text/json')
     responses.add(responses.GET,
                   'https://dshield.org/api/sources/ip/10?json',
                   body='{"sources":"test"}',
                   match_querystring=True,
                   content_type='text/json')
     responses.add(responses.GET,
                   'https://dshield.org/api/sources/attacks/10?json',
                   body='{"sources":"test"}',
                   match_querystring=True,
                   content_type='text/json')
     responses.add(responses.GET,
                   'https://dshield.org/api/sources/ip?json',
                   body='{"sources":"test"}',
                   match_querystring=True,
                   content_type='text/json')
     responses.add(responses.GET,
                   'https://dshield.org/api/sources?json',
                   body='{"sources":"test"}',
                   match_querystring=True,
                   content_type='text/json')
     data = {'sources': 'test'}
     self.assertEquals(dshield.sources(), data)
     self.assertEquals(dshield.sources('ip'), data)
     self.assertEquals(dshield.sources('ip', 10), data)
     self.assertEquals(
         dshield.sources('ip', '10', datetime.date(2012, 3, 8)), data)
     self.assertEquals(dshield.sources('ip', 10, '2012-03-08'), data)
     self.assertEquals(dshield.sources('ip', return_format=dshield.JSON),
                       '{"sources":"test"}')
コード例 #4
0
ファイル: test.py プロジェクト: carriercomm/python-dshield
 def test_sources(self):
     responses.add(responses.GET, 'https://dshield.org/api/sources/ip/10/2012-03-08?json',
                   body='{"sources":"test"}',
                   match_querystring=True, content_type='text/json')
     responses.add(responses.GET, 'https://dshield.org/api/sources/ip/10?json',
                   body='{"sources":"test"}',
                   match_querystring=True, content_type='text/json')
     responses.add(responses.GET, 'https://dshield.org/api/sources/ip?json',
                   body='{"sources":"test"}',
                   match_querystring=True, content_type='text/json')
     responses.add(responses.GET, 'https://dshield.org/api/sources?json',
                   body='{"sources":"test"}',
                   match_querystring=True, content_type='text/json')
     data = {'sources': 'test'}
     self.assertEquals(dshield.sources(), data)
     self.assertEquals(dshield.sources('ip'), data)
     self.assertEquals(dshield.sources('ip', 10), data)
     self.assertEquals(dshield.sources('ip', '10', datetime.date(2012, 3, 8)), data)
     self.assertEquals(dshield.sources('ip', 10, '2012-03-08'), data)
     self.assertEquals(dshield.sources('ip', return_format=dshield.JSON), '{"sources":"test"}')