本文整理汇总了Python中w3af.core.data.url.tests.helpers.upper_daemon.UpperDaemon.start方法的典型用法代码示例。如果您正苦于以下问题:Python UpperDaemon.start方法的具体用法?Python UpperDaemon.start怎么用?Python UpperDaemon.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类w3af.core.data.url.tests.helpers.upper_daemon.UpperDaemon
的用法示例。
在下文中一共展示了UpperDaemon.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_exception_is_raised_always_after_stop
# 需要导入模块: from w3af.core.data.url.tests.helpers.upper_daemon import UpperDaemon [as 别名]
# 或者: from w3af.core.data.url.tests.helpers.upper_daemon.UpperDaemon import start [as 别名]
def test_exception_is_raised_always_after_stop(self):
return_empty_daemon = UpperDaemon(EmptyTCPHandler)
return_empty_daemon.start()
return_empty_daemon.wait_for_start()
port = return_empty_daemon.get_port()
# No retries means that the test is easier to read/understand
self.uri_opener.settings.set_max_http_retries(0)
# Don't rate limit
self.uri_opener._rate_limit = lambda: True
url = URL('http://127.0.0.1:%s/' % port)
http_exception_count = 0
loops = 100
# Loop until we reach a must stop exception
for i in xrange(loops):
try:
self.uri_opener.GET(url, cache=False)
except HTTPRequestException:
http_exception_count += 1
except ScanMustStopByKnownReasonExc, smse:
break
except Exception, e:
msg = 'Not expecting: "%s"'
self.assertTrue(False, msg % e.__class__.__name__)
示例2: test_timeout_many
# 需要导入模块: from w3af.core.data.url.tests.helpers.upper_daemon import UpperDaemon [as 别名]
# 或者: from w3af.core.data.url.tests.helpers.upper_daemon.UpperDaemon import start [as 别名]
def test_timeout_many(self):
upper_daemon = UpperDaemon(TimeoutTCPHandler)
upper_daemon.start()
upper_daemon.wait_for_start()
port = upper_daemon.get_port()
self.uri_opener.settings.set_configured_timeout(0.5)
self.uri_opener.clear_timeout()
# We can mock this because it's being tested at TestXUrllibDelayOnError
self.uri_opener._pause_on_http_error = Mock()
url = URL('http://127.0.0.1:%s/' % port)
http_request_e = 0
scan_stop_e = 0
for _ in xrange(MAX_ERROR_COUNT):
try:
self.uri_opener.GET(url)
except HTTPRequestException, hre:
http_request_e += 1
self.assertEqual(hre.message, 'HTTP timeout error')
except ScanMustStopException:
scan_stop_e += 1
self.assertTrue(True)
break
示例3: test_timeout_many
# 需要导入模块: from w3af.core.data.url.tests.helpers.upper_daemon import UpperDaemon [as 别名]
# 或者: from w3af.core.data.url.tests.helpers.upper_daemon.UpperDaemon import start [as 别名]
def test_timeout_many(self):
upper_daemon = UpperDaemon(TimeoutTCPHandler)
upper_daemon.start()
upper_daemon.wait_for_start()
port = upper_daemon.get_port()
self.uri_opener.settings.set_timeout(1)
url = URL('http://127.0.0.1:%s/' % port)
for _ in xrange(MAX_ERROR_COUNT):
try:
self.uri_opener.GET(url)
except ScanMustStopByUnknownReasonExc:
self.assertTrue(False, 'Not expecting this exception type.')
except ScanMustStopOnUrlError:
self.assertTrue(True)
except ScanMustStopException:
self.assertTrue(True)
break
else:
self.assertTrue(False)
self.uri_opener.settings.set_default_values()
示例4: test_http_timeout_with_plugin
# 需要导入模块: from w3af.core.data.url.tests.helpers.upper_daemon import UpperDaemon [as 别名]
# 或者: from w3af.core.data.url.tests.helpers.upper_daemon.UpperDaemon import start [as 别名]
def test_http_timeout_with_plugin(self):
"""
This is very related with the tests at:
w3af/core/data/url/tests/test_xurllib.py
Very similar test is TestXUrllib.test_timeout
:see: https://github.com/andresriancho/w3af/issues/7112
"""
upper_daemon = UpperDaemon(TimeoutTCPHandler)
upper_daemon.start()
upper_daemon.wait_for_start()
port = upper_daemon.get_port()
url = URL('http://127.0.0.1:%s/' % port)
freq = FuzzableRequest(url)
plugin_inst = self.w3af.plugins.get_plugin_inst('audit', 'sqli')
plugin_inst._uri_opener.settings.set_configured_timeout(1)
plugin_inst._uri_opener.clear_timeout()
# We expect the server to timeout and the response to be a 204
resp = plugin_inst.get_original_response(freq)
self.assertEqual(resp.get_url(), url)
self.assertEqual(resp.get_code(), 204)
plugin_inst._uri_opener.settings.set_default_values()
示例5: test_timeout_many
# 需要导入模块: from w3af.core.data.url.tests.helpers.upper_daemon import UpperDaemon [as 别名]
# 或者: from w3af.core.data.url.tests.helpers.upper_daemon.UpperDaemon import start [as 别名]
def test_timeout_many(self):
upper_daemon = UpperDaemon(TimeoutTCPHandler)
upper_daemon.start()
upper_daemon.wait_for_start()
port = upper_daemon.get_port()
self.uri_opener.settings.set_timeout(1)
url = URL('http://127.0.0.1:%s/' % port)
http_request_e = 0
scan_stop_e = 0
for _ in xrange(MAX_ERROR_COUNT):
try:
self.uri_opener.GET(url)
except HTTPRequestException:
http_request_e += 1
self.assertTrue(True)
except ScanMustStopException:
scan_stop_e += 1
self.assertTrue(True)
break
except Exception, e:
msg = 'Not expecting: "%s"'
self.assertTrue(False, msg % e.__class__.__name__)
示例6: test_url_port_not_http
# 需要导入模块: from w3af.core.data.url.tests.helpers.upper_daemon import UpperDaemon [as 别名]
# 或者: from w3af.core.data.url.tests.helpers.upper_daemon.UpperDaemon import start [as 别名]
def test_url_port_not_http(self):
upper_daemon = UpperDaemon(EmptyTCPHandler)
upper_daemon.start()
upper_daemon.wait_for_start()
port = upper_daemon.get_port()
url = URL('http://127.0.0.1:%s/' % port)
self.assertRaises(ScanMustStopOnUrlError, self.uri_opener.GET, url)
示例7: test_ssl_fail_when_requesting_http
# 需要导入模块: from w3af.core.data.url.tests.helpers.upper_daemon import UpperDaemon [as 别名]
# 或者: from w3af.core.data.url.tests.helpers.upper_daemon.UpperDaemon import start [as 别名]
def test_ssl_fail_when_requesting_http(self):
http_daemon = UpperDaemon(Ok200Handler)
http_daemon.start()
http_daemon.wait_for_start()
port = http_daemon.get_port()
# Note that here I'm using httpS <<---- "S" and that I've started an
# HTTP server. We should get an exception
url = URL('https://127.0.0.1:%s/' % port)
self.assertRaises(HTTPRequestException, self.uri_opener.GET, url)
示例8: test_url_port_not_http
# 需要导入模块: from w3af.core.data.url.tests.helpers.upper_daemon import UpperDaemon [as 别名]
# 或者: from w3af.core.data.url.tests.helpers.upper_daemon.UpperDaemon import start [as 别名]
def test_url_port_not_http(self):
upper_daemon = UpperDaemon(EmptyTCPHandler)
upper_daemon.start()
upper_daemon.wait_for_start()
port = upper_daemon.get_port()
url = URL('http://127.0.0.1:%s/' % port)
try:
self.uri_opener.GET(url)
except HTTPRequestException, hre:
self.assertEqual(hre.value, "Bad HTTP response status line: ''")
示例9: test_timeout
# 需要导入模块: from w3af.core.data.url.tests.helpers.upper_daemon import UpperDaemon [as 别名]
# 或者: from w3af.core.data.url.tests.helpers.upper_daemon.UpperDaemon import start [as 别名]
def test_timeout(self):
upper_daemon = UpperDaemon(TimeoutTCPHandler)
upper_daemon.start()
upper_daemon.wait_for_start()
port = upper_daemon.get_port()
url = URL('http://127.0.0.1:%s/' % port)
self.uri_opener.settings.set_timeout(1)
self.assertRaises(ScanMustStopOnUrlError, self.uri_opener.GET, url)
self.uri_opener.settings.set_default_values()
示例10: test_timeout_auto_adjust
# 需要导入模块: from w3af.core.data.url.tests.helpers.upper_daemon import UpperDaemon [as 别名]
# 或者: from w3af.core.data.url.tests.helpers.upper_daemon.UpperDaemon import start [as 别名]
def test_timeout_auto_adjust(self):
upper_daemon = UpperDaemon(Ok200SmallDelayHandler)
upper_daemon.start()
upper_daemon.wait_for_start()
port = upper_daemon.get_port()
# Enable timeout auto-adjust
self.uri_opener.settings.set_configured_timeout(0)
self.uri_opener.clear_timeout()
# We can mock this because it's being tested at TestXUrllibDelayOnError
self.uri_opener._pause_on_http_error = Mock()
# Mock to verify the calls
self.uri_opener.set_timeout = Mock()
# Make sure we start from the desired timeout value
self.assertEqual(self.uri_opener.get_timeout('127.0.0.1'),
DEFAULT_TIMEOUT)
url = URL('http://127.0.0.1:%s/' % port)
sent_requests = 0
for _ in xrange(TIMEOUT_ADJUST_LIMIT * 2):
try:
self.uri_opener.GET(url)
except Exception:
raise
else:
sent_requests += 1
if self.uri_opener.set_timeout.call_count:
break
self.assertEqual(self.uri_opener.set_timeout.call_count, 1)
rtt = self.uri_opener.get_average_rtt()[0]
adjusted_tout = self.uri_opener.set_timeout.call_args[0][0]
expected_tout = TIMEOUT_MULT_CONST * rtt
delta = rtt * 0.2
self.assertGreaterEqual(adjusted_tout, expected_tout - delta)
self.assertLessEqual(adjusted_tout, expected_tout + delta)
self.assertLess(adjusted_tout, DEFAULT_TIMEOUT)
self.assertEqual(sent_requests, TIMEOUT_ADJUST_LIMIT + 1)
示例11: test_timeout
# 需要导入模块: from w3af.core.data.url.tests.helpers.upper_daemon import UpperDaemon [as 别名]
# 或者: from w3af.core.data.url.tests.helpers.upper_daemon.UpperDaemon import start [as 别名]
def test_timeout(self):
upper_daemon = UpperDaemon(TimeoutTCPHandler)
upper_daemon.start()
upper_daemon.wait_for_start()
port = upper_daemon.get_port()
url = URL('http://127.0.0.1:%s/' % port)
self.uri_opener.settings.set_configured_timeout(0.5)
self.uri_opener.clear_timeout()
# We can mock this because it's being tested at TestXUrllibDelayOnError
self.uri_opener._pause_on_http_error = Mock()
start = time.time()
try:
self.uri_opener.GET(url)
except HTTPRequestException, hre:
self.assertEqual(hre.message, 'HTTP timeout error')
示例12: test_ignore_errors
# 需要导入模块: from w3af.core.data.url.tests.helpers.upper_daemon import UpperDaemon [as 别名]
# 或者: from w3af.core.data.url.tests.helpers.upper_daemon.UpperDaemon import start [as 别名]
def test_ignore_errors(self):
upper_daemon = UpperDaemon(TimeoutTCPHandler)
upper_daemon.start()
upper_daemon.wait_for_start()
port = upper_daemon.get_port()
self.uri_opener.settings.set_timeout(1)
self.uri_opener._retry = Mock()
url = URL('http://127.0.0.1:%s/' % port)
try:
self.uri_opener.GET(url, ignore_errors=True)
except ScanMustStopOnUrlError:
self.assertEqual(self.uri_opener._retry.call_count, 0)
else:
self.assertTrue(False, 'Exception not raised')
self.uri_opener.settings.set_default_values()
示例13: test_error_handling_disable_per_request
# 需要导入模块: from w3af.core.data.url.tests.helpers.upper_daemon import UpperDaemon [as 别名]
# 或者: from w3af.core.data.url.tests.helpers.upper_daemon.UpperDaemon import start [as 别名]
def test_error_handling_disable_per_request(self):
upper_daemon = UpperDaemon(TimeoutTCPHandler)
upper_daemon.start()
upper_daemon.wait_for_start()
port = upper_daemon.get_port()
self.uri_opener.settings.set_configured_timeout(1)
self.uri_opener.clear_timeout()
self.uri_opener._retry = Mock()
url = URL('http://127.0.0.1:%s/' % port)
try:
self.uri_opener.GET(url, error_handling=False)
except HTTPRequestException:
self.assertEqual(self.uri_opener._retry.call_count, 0)
else:
self.assertTrue(False, 'Exception not raised')
self.uri_opener.settings.set_default_values()
示例14: TestUpperDaemon
# 需要导入模块: from w3af.core.data.url.tests.helpers.upper_daemon import UpperDaemon [as 别名]
# 或者: from w3af.core.data.url.tests.helpers.upper_daemon.UpperDaemon import start [as 别名]
class TestUpperDaemon(unittest.TestCase):
"""
This is a unittest for the UpperDaemon which lives in upper_daemon.py
@author: Andres Riancho <andres . riancho | gmail . com>
"""
def setUp(self):
self.upper_daemon = UpperDaemon()
self.upper_daemon.start()
self.upper_daemon.wait_for_start()
def test_basic(self):
sent = 'abc'
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('127.0.0.1', self.upper_daemon.get_port()))
sock.sendall(sent)
received = sock.recv(3)
self.assertEqual(received, sent.upper())
示例15: test_url_port_not_http_many
# 需要导入模块: from w3af.core.data.url.tests.helpers.upper_daemon import UpperDaemon [as 别名]
# 或者: from w3af.core.data.url.tests.helpers.upper_daemon.UpperDaemon import start [as 别名]
def test_url_port_not_http_many(self):
upper_daemon = UpperDaemon(EmptyTCPHandler)
upper_daemon.start()
upper_daemon.wait_for_start()
port = upper_daemon.get_port()
self.uri_opener.settings.set_max_http_retries(0)
url = URL('http://127.0.0.1:%s/' % port)
http_request_e = 0
scan_must_stop_e = 0
for _ in xrange(MAX_ERROR_COUNT):
try:
self.uri_opener.GET(url)
except HTTPRequestException:
http_request_e += 1
except ScanMustStopException, smse:
scan_must_stop_e += 1
break
except Exception, e:
msg = 'Not expecting "%s".'
self.assertTrue(False, msg % e.__class__.__name__)