aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMatthew Shao <me@matshao.com>2017-07-24 20:35:43 +0800
committerMatthew Shao <me@matshao.com>2017-07-24 20:36:21 +0800
commit5c45a90ce961d740e59644f4de0f8ffe97a5706c (patch)
tree0a80cbf76983042ee33c6b8d66439c0ac1e02198 /test
parent8c3e988a8c95bae7235d5de4ba8e85e77988c395 (diff)
downloadmitmproxy-5c45a90ce961d740e59644f4de0f8ffe97a5706c.tar.gz
mitmproxy-5c45a90ce961d740e59644f4de0f8ffe97a5706c.tar.bz2
mitmproxy-5c45a90ce961d740e59644f4de0f8ffe97a5706c.zip
[web] Update tests.
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/test_optmanager.py4
-rw-r--r--test/mitmproxy/tools/web/test_app.py13
2 files changed, 16 insertions, 1 deletions
diff --git a/test/mitmproxy/test_optmanager.py b/test/mitmproxy/test_optmanager.py
index 7b4ffb8b..3b38162f 100644
--- a/test/mitmproxy/test_optmanager.py
+++ b/test/mitmproxy/test_optmanager.py
@@ -285,6 +285,10 @@ def test_saving(tmpdir):
optmanager.load_paths(o, dst)
assert o.three == "foo"
+ o2 = TD2()
+ o2.three = "foo"
+ assert(optmanager.save(o2, None, defaults=False)) == "three: foo\n"
+
with open(dst, 'a') as f:
f.write("foobar: '123'")
assert optmanager.load_paths(o, dst) == {"foobar": "123"}
diff --git a/test/mitmproxy/tools/web/test_app.py b/test/mitmproxy/tools/web/test_app.py
index bb439b34..bb0b1907 100644
--- a/test/mitmproxy/tools/web/test_app.py
+++ b/test/mitmproxy/tools/web/test_app.py
@@ -263,6 +263,18 @@ class TestApp(tornado.testing.AsyncHTTPTestCase):
assert self.put_json("/options", {"wtf": True}).code == 400
assert self.put_json("/options", {"anticache": "foo"}).code == 400
+ def test_option_dump(self):
+ resp = self.fetch("/options/dump")
+ assert b"http2: false" in resp.body
+
+ assert self.fetch("/options/dump", method="POST", body=b"http2: true").code == 200
+ j = json(self.fetch("/options"))
+ assert j["http2"]["value"]
+
+ resp = self.fetch("/options/dump", method="POST", body=b"wtf: true")
+ assert resp.code == 400
+ assert resp.body == b"'Unknown options: wtf'"
+
def test_err(self):
with mock.patch("mitmproxy.tools.web.app.IndexHandler.get") as f:
f.side_effect = RuntimeError
@@ -279,7 +291,6 @@ class TestApp(tornado.testing.AsyncHTTPTestCase):
r2 = yield ws_client.read_message()
j1 = _json.loads(r1)
j2 = _json.loads(r2)
- print(j1)
response = dict()
response[j1['resource']] = j1
response[j2['resource']] = j2