aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_server.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2013-02-16 16:46:16 +1300
committerAldo Cortesi <aldo@nullcube.com>2013-02-16 16:46:16 +1300
commit1ccb2c5dea9530682aae83d489f1738d9286fa4e (patch)
tree8c15602c3bf5dab0428a0a2bc4ce88dfe7d2eae5 /test/test_server.py
parent782bbee8c0a7d14be25e87d61c9c6db03b532eb7 (diff)
downloadmitmproxy-1ccb2c5dea9530682aae83d489f1738d9286fa4e.tar.gz
mitmproxy-1ccb2c5dea9530682aae83d489f1738d9286fa4e.tar.bz2
mitmproxy-1ccb2c5dea9530682aae83d489f1738d9286fa4e.zip
Test WSGI app calling.
- Factor out test servers into a separate file - Adjust docs to note new Flask dependency
Diffstat (limited to 'test/test_server.py')
-rw-r--r--test/test_server.py24
1 files changed, 18 insertions, 6 deletions
diff --git a/test/test_server.py b/test/test_server.py
index 0a2f142e..58dfee58 100644
--- a/test/test_server.py
+++ b/test/test_server.py
@@ -1,7 +1,7 @@
import socket, time
from netlib import tcp
from libpathod import pathoc
-import tutils
+import tutils, tservers
"""
Note that the choice of response code in these tests matters more than you
@@ -39,7 +39,19 @@ class SanityMixin:
assert l.error
-class TestHTTP(tutils.HTTPProxTest, SanityMixin):
+class TestHTTP(tservers.HTTPProxTest, SanityMixin):
+ def test_app(self):
+ p = self.pathoc()
+ ret = p.request("get:'http://testapp/'")
+ assert ret[1] == 200
+ assert ret[4] == "testapp"
+
+ def test_app_err(self):
+ p = self.pathoc()
+ ret = p.request("get:'http://errapp/'")
+ assert ret[1] == 500
+ assert "ValueError" in ret[4]
+
def test_invalid_http(self):
t = tcp.TCPClient("127.0.0.1", self.proxy.port)
t.connect()
@@ -69,7 +81,7 @@ class TestHTTP(tutils.HTTPProxTest, SanityMixin):
assert l.response.code == 304
-class TestHTTPS(tutils.HTTPProxTest, SanityMixin):
+class TestHTTPS(tservers.HTTPProxTest, SanityMixin):
ssl = True
clientcerts = True
def test_clientcert(self):
@@ -77,15 +89,15 @@ class TestHTTPS(tutils.HTTPProxTest, SanityMixin):
assert self.last_log()["request"]["clientcert"]["keyinfo"]
-class TestReverse(tutils.ReverseProxTest, SanityMixin):
+class TestReverse(tservers.ReverseProxTest, SanityMixin):
reverse = True
-class TestTransparent(tutils.TransparentProxTest, SanityMixin):
+class TestTransparent(tservers.TransparentProxTest, SanityMixin):
transparent = True
-class TestProxy(tutils.HTTPProxTest):
+class TestProxy(tservers.HTTPProxTest):
def test_http(self):
f = self.pathod("304")
assert f.status_code == 304