def test_stop_by_user_request(self): ''' Verify that the w3afMustStopByUserRequest stops the scan. ''' self.exception_plugin.exception_to_raise = w3afMustStopByUserRequest with patch('core.controllers.w3afCore.om.out') as om_mock: self.w3afcore.start() message = 'Test exception.' self.assertIn(call.information(message), om_mock.mock_calls)
def test_stop_by_user_request(self): """ Verify that the ScanMustStopByUserRequest stops the scan. """ self.exception_plugin.exception_to_raise = ScanMustStopByUserRequest with patch('w3af.core.controllers.w3afCore.om.out') as om_mock: self.w3afcore.start() message = 'Test exception.' self.assertIn(call.information(message), om_mock.mock_calls)
def test_ghdb_private(self): cfg = self._run_configs['cfg'] with patch('w3af.plugins.crawl.web_diff.om.out') as om_mock: self._scan(self.private_url, cfg['plugins']) msg = 'There is no point in searching google for "site:moth".' \ ' Google doesn\'t index private pages.' self.assertIn(call.information(msg), om_mock.mock_calls) vulns = self.kb.get('ghdb', 'vuln') self.assertEqual(len(vulns), 0, vulns)
def test_compare(self): cfg = self._run_configs["basic"] with patch("w3af.plugins.crawl.web_diff.om.out") as om_mock: self._scan(cfg["target"], cfg["plugins"]) EXPECTED_CALLS = [ call.information("The following files exist in the local" " directory and in the remote server:"), call.information(u"- http://moth/w3af/crawl/web_diff/456.html"), call.information(u"- http://moth/w3af/crawl/web_diff/exclude.php"), call.information(u"- http://moth/w3af/crawl/web_diff/123.html"), call.information(u"- http://moth/w3af/crawl/web_diff/index.html"), call.information( "The following files exist in the local" " directory and in the remote server and" " their contents match:" ), call.information(u"- http://moth/w3af/crawl/web_diff/123.html"), call.information(u"- http://moth/w3af/crawl/web_diff/index.html"), call.information( "The following files exist in the local" " directory and in the remote server but" " their contents don't match:" ), call.information(u"- http://moth/w3af/crawl/web_diff/456.html"), call.information("Match files: 4 of 4"), call.information("Match contents: 2 of 3"), ] for ecall in EXPECTED_CALLS: self.assertIn(ecall, om_mock.mock_calls)
def test_compare(self): cfg = self._run_configs['basic'] with patch('plugins.crawl.web_diff.om.out') as om_mock: self._scan(cfg['target'], cfg['plugins']) EXPECTED_CALLS = [ call.information( 'The following files exist in the local directory and in the remote server:' ), call.information( u'- http://moth/w3af/crawl/web_diff/456.html'), call.information( u'- http://moth/w3af/crawl/web_diff/exclude.php'), call.information( u'- http://moth/w3af/crawl/web_diff/123.html'), call.information( u'- http://moth/w3af/crawl/web_diff/index.html'), call.information( 'The following files exist in the local directory and in the remote server and their contents match:' ), call.information( u'- http://moth/w3af/crawl/web_diff/123.html'), call.information( u'- http://moth/w3af/crawl/web_diff/index.html'), call.information( "The following files exist in the local directory and in the remote server but their contents don't match:" ), call.information( u'- http://moth/w3af/crawl/web_diff/456.html'), call.information('Match files: 4 of 4'), call.information('Match contents: 2 of 3') ] for ecall in EXPECTED_CALLS: self.assertIn(ecall, om_mock.mock_calls)
def test_compare(self): cfg = self._run_configs['basic'] with patch('w3af.plugins.crawl.web_diff.om.out') as om_mock: self._scan(cfg['target'], cfg['plugins']) EXPECTED_CALLS = [ call.information('The following files exist in the local' ' directory and in the remote server:'), call.information( u'- http://moth/w3af/crawl/web_diff/456.html'), call.information( u'- http://moth/w3af/crawl/web_diff/exclude.php'), call.information( u'- http://moth/w3af/crawl/web_diff/123.html'), call.information( u'- http://moth/w3af/crawl/web_diff/index.html'), call.information('The following files exist in the local' ' directory and in the remote server and' ' their contents match:'), call.information( u'- http://moth/w3af/crawl/web_diff/123.html'), call.information( u'- http://moth/w3af/crawl/web_diff/index.html'), call.information("The following files exist in the local" " directory and in the remote server but" " their contents don't match:"), call.information( u'- http://moth/w3af/crawl/web_diff/456.html'), call.information('Match files: 4 of 4'), call.information('Match contents: 2 of 3') ] for ecall in EXPECTED_CALLS: self.assertIn(ecall, om_mock.mock_calls)