[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [sbws/master] tests: Add test to check get/head timeout
commit 6578a95f556400215754016f90bfb00a738d3a94
Author: juga0 <juga@xxxxxxxxxx>
Date: Thu Feb 21 13:57:13 2019 +0000
tests: Add test to check get/head timeout
Closes: #29551. Bugfix 1.0.3-dev0.
---
tests/integration/util/test_requests.py | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/tests/integration/util/test_requests.py b/tests/integration/util/test_requests.py
new file mode 100644
index 0000000..ecb22ad
--- /dev/null
+++ b/tests/integration/util/test_requests.py
@@ -0,0 +1,29 @@
+"""Integration tests for requests."""
+import requests
+import uuid
+
+from sbws import settings
+from sbws.util import requests as requests_utils
+
+
+def test_make_session(conf, persistent_launch_tor, dests):
+ uuid_str = str(uuid.uuid4())
+ settings.init_http_headers(conf.get('scanner', 'nickname'), uuid_str,
+ str(persistent_launch_tor.get_version()))
+ session = requests_utils.make_session(
+ persistent_launch_tor, conf.getfloat('general', 'http_timeout'))
+ assert session._timeout == conf.getfloat('general', 'http_timeout')
+
+ # Because there is not an stream attached to a circuit, this will timeout.
+ response = None
+ try:
+ response = session.get(dests.next().url, verify=False)
+ except requests.exceptions.ConnectTimeout:
+ pass
+ assert response is None
+
+ # Disable socks proxies to test a session request not over Tor
+ # without timeout.
+ session.proxies = {}
+ response = session.get(dests.next().url, verify=False)
+ print(response.request.__dict__)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits