aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_proxy.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_proxy.py')
-rw-r--r--test/test_proxy.py32
1 files changed, 31 insertions, 1 deletions
diff --git a/test/test_proxy.py b/test/test_proxy.py
index e137c687..89e5a825 100644
--- a/test/test_proxy.py
+++ b/test/test_proxy.py
@@ -1,5 +1,7 @@
-from libmproxy import proxy
+from libmproxy import proxy, flow
import tutils
+from libpathod import test
+from netlib import http
def test_proxy_error():
@@ -26,3 +28,31 @@ def test_app_registry():
assert not ar.get(r)
r.headers["host"] = ["domain"]
assert ar.get(r)
+
+
+
+class TestServerConnection:
+ def setUp(self):
+ self.d = test.Daemon()
+
+ def tearDown(self):
+ self.d.shutdown()
+
+ def test_simple(self):
+ sc = proxy.ServerConnection(proxy.ProxyConfig(), self.d.IFACE, self.d.port)
+ sc.connect("http")
+ r = tutils.treq()
+ r.path = "/p/200:da"
+ sc.send(r)
+ assert http.read_response(sc.rfile, r.method, 1000)
+ assert self.d.last_log()
+
+ r.content = flow.CONTENT_MISSING
+ tutils.raises("incomplete request", sc.send, r)
+
+ def test_send_error(self):
+ sc = proxy.ServerConnection(proxy.ProxyConfig(), self.d.IFACE, self.d.port)
+ sc.connect("http")
+ r = tutils.treq()
+ sc.send(r)
+