def setUp(self): self.exception_handler = ExceptionHandler() self.exception_handler.clear() self.status = fake_status(None) self.status.set_running_plugin('phase', 'plugin') self.status.set_current_fuzzable_request('phase', 'http://www.w3af.org/')
def setUp(self): self.exception_handler = ExceptionHandler() self.exception_handler.clear() self.status = fake_status(None) self.status.set_running_plugin("phase", "plugin") self.status.set_current_fuzzable_request("phase", "http://www.w3af.org/")
class TestExceptionHandler(unittest.TestCase): def setUp(self): self.exception_handler = ExceptionHandler() self.exception_handler.clear() self.status = fake_status(None) self.status.set_running_plugin('phase', 'plugin') self.status.set_current_fuzzable_request('phase', 'http://www.w3af.org/') @attr('smoke') def test_handle_one(self): try: raise Exception('unittest') except Exception, e: exec_info = sys.exc_info() enabled_plugins = '' self.exception_handler.handle(self.status, e, exec_info, enabled_plugins) scan_id = self.exception_handler.get_scan_id() self.assertTrue(scan_id) all_edata = self.exception_handler.get_all_exceptions() self.assertEqual(1, len(all_edata)) edata = all_edata[0] self.assertTrue( edata.get_summary().startswith('An exception was found')) self.assertTrue('traceback' in edata.get_details()) self.assertEquals(edata.plugin, 'plugin') self.assertEquals(edata.phase, 'phase') self.assertEquals(edata.fuzzable_request, 'http://www.w3af.org/') self.assertEquals(edata.filename, 'test_exception_handler.py') self.assertEquals(edata.exception, e) # This is very very very dependant on changes to this file, but it was # the only way to do it without much effort self.assertEquals(edata.lineno, 48)