aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_server.py12
-rw-r--r--test/tservers.py15
2 files changed, 26 insertions, 1 deletions
diff --git a/test/test_server.py b/test/test_server.py
index f12fbcee..c20b0cea 100644
--- a/test/test_server.py
+++ b/test/test_server.py
@@ -53,7 +53,16 @@ class CommonMixin:
assert "Bad Request" in t.rfile.readline()
-class TestHTTP(tservers.HTTPProxTest, CommonMixin):
+
+class AppMixin:
+ def test_app(self):
+ ret = self.app("/")
+ assert ret.status_code == 200
+ assert "mitmproxy" in ret.content
+
+
+
+class TestHTTP(tservers.HTTPProxTest, CommonMixin, AppMixin):
def test_app_err(self):
p = self.pathoc()
ret = p.request("get:'http://errapp/'")
@@ -135,6 +144,7 @@ class TestHTTP(tservers.HTTPProxTest, CommonMixin):
assert req.status_code == 400
+
class TestHTTPAuth(tservers.HTTPProxTest):
authenticator = http_auth.BasicProxyAuth(http_auth.PassManSingleUser("test", "test"), "realm")
def test_auth(self):
diff --git a/test/tservers.py b/test/tservers.py
index 0c2f8c2f..91ce4dc0 100644
--- a/test/tservers.py
+++ b/test/tservers.py
@@ -84,6 +84,7 @@ class ProxTestBase:
no_upstream_cert = cls.no_upstream_cert,
cacert = tutils.test_data.path("data/serverkey.pem"),
authenticator = cls.authenticator,
+ app = True,
**pconf
)
tmaster = cls.masterclass(cls.tqueue, config)
@@ -156,6 +157,17 @@ class HTTPProxTest(ProxTestBase):
q = "get:'%s/p/%s'"%(self.server.urlbase, spec)
return p.request(q)
+ def app(self, page):
+ if self.ssl:
+ p = libpathod.pathoc.Pathoc("127.0.0.1", self.proxy.port, True)
+ print "PRE"
+ p.connect((proxy.APP_IP, 80))
+ print "POST"
+ return p.request("get:'/%s'"%page)
+ else:
+ p = self.pathoc()
+ return p.request("get:'http://%s/%s'"%(proxy.APP_DOMAIN, page))
+
class TResolver:
def __init__(self, port):
@@ -234,3 +246,6 @@ class ReverseProxTest(ProxTestBase):
q = "get:'/p/%s'"%spec
return p.request(q)
+
+
+