aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/data/protobuf012
-rw-r--r--test/test_console_contentview.py12
-rw-r--r--test/test_flow.py2
-rw-r--r--test/test_server.py12
-rw-r--r--test/tservers.py15
5 files changed, 40 insertions, 3 deletions
diff --git a/test/data/protobuf01 b/test/data/protobuf01
new file mode 100644
index 00000000..fbfdbff3
--- /dev/null
+++ b/test/data/protobuf01
@@ -0,0 +1,2 @@
+
+$3bbc333c-e61c-433b-819a-0b9a8cc103b8 \ No newline at end of file
diff --git a/test/test_console_contentview.py b/test/test_console_contentview.py
index 8a5dabb8..1798ce85 100644
--- a/test/test_console_contentview.py
+++ b/test/test_console_contentview.py
@@ -58,7 +58,9 @@ class TestContentView:
d = utils.urlencode([("one", "two"), ("three", "four")])
v = cv.ViewURLEncoded()
assert v([], d, 100)
- assert not v([], "foo", 100)
+ d = utils.urlencode([("adsfa", "")])
+ v = cv.ViewURLEncoded()
+ assert v([], d, 100)
def test_view_html(self):
v = cv.ViewHTML()
@@ -232,6 +234,14 @@ if pyamf:
p = tutils.test_data.path("data/amf03")
assert v([], file(p).read(), sys.maxint)
+if cv.ViewProtobuf.is_available():
+ def test_view_protobuf_request():
+ v = cv.ViewProtobuf()
+
+ p = tutils.test_data.path("data/protobuf01")
+ content_type, output = v([], file(p).read(), sys.maxint)
+ assert content_type == "Protobuf"
+ assert output[0].text == '1: "3bbc333c-e61c-433b-819a-0b9a8cc103b8"'
def test_get_by_shortcut():
assert cv.get_by_shortcut("h")
diff --git a/test/test_flow.py b/test/test_flow.py
index fce4e98a..4ad692bc 100644
--- a/test/test_flow.py
+++ b/test/test_flow.py
@@ -841,7 +841,7 @@ class TestRequest:
r = flow.Request(None, (1, 1), "host", 22, "https", "GET", "/?adsfa", h, "content")
q = r.get_query()
- assert not q
+ assert q.lst == [("adsfa", "")]
r = flow.Request(None, (1, 1), "host", 22, "https", "GET", "/foo?x=y&a=b", h, "content")
assert r.get_query()
diff --git a/test/test_server.py b/test/test_server.py
index fbd5af39..6a88578c 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)
+
+
+