From aa01a62df7ce015ba4bf3c5ba9f3074616530496 Mon Sep 17 00:00:00 2001 From: Matthew Shao Date: Wed, 5 Jul 2017 08:40:21 +0800 Subject: [web] Add keys argument for dump_dict in optmanager. --- test/mitmproxy/test_optmanager.py | 1 + test/mitmproxy/tools/web/test_app.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/mitmproxy/test_optmanager.py b/test/mitmproxy/test_optmanager.py index 0c400683..7b4ffb8b 100644 --- a/test/mitmproxy/test_optmanager.py +++ b/test/mitmproxy/test_optmanager.py @@ -341,6 +341,7 @@ def test_dump_defaults(): def test_dump_dicts(): o = options.Options() assert optmanager.dump_dicts(o) + assert optmanager.dump_dicts(o, ['http2', 'anticomp']) class TTypes(optmanager.OptManager): diff --git a/test/mitmproxy/tools/web/test_app.py b/test/mitmproxy/tools/web/test_app.py index e6d563e7..044b4595 100644 --- a/test/mitmproxy/tools/web/test_app.py +++ b/test/mitmproxy/tools/web/test_app.py @@ -255,8 +255,8 @@ class TestApp(tornado.testing.AsyncHTTPTestCase): def test_options(self): j = json(self.fetch("/options")) - assert type(j) == list - assert type(j[0]) == dict + assert type(j) == dict + assert type(j['anticache']) == dict def test_option_update(self): assert self.put_json("/options", {"anticache": True}).code == 200 -- cgit v1.2.3 From 37fea267c1d171fb661736b96db62943e7b49791 Mon Sep 17 00:00:00 2001 From: Matthew Shao Date: Wed, 5 Jul 2017 18:57:19 +0800 Subject: Fix the test for websocket connection. --- test/mitmproxy/tools/web/test_app.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/mitmproxy/tools/web/test_app.py b/test/mitmproxy/tools/web/test_app.py index 044b4595..bb439b34 100644 --- a/test/mitmproxy/tools/web/test_app.py +++ b/test/mitmproxy/tools/web/test_app.py @@ -275,12 +275,32 @@ class TestApp(tornado.testing.AsyncHTTPTestCase): ws_client = yield websocket.websocket_connect(ws_url) self.master.options.anticomp = True - response = yield ws_client.read_message() - assert _json.loads(response) == { + r1 = yield ws_client.read_message() + 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 + assert response['settings'] == { "resource": "settings", "cmd": "update", "data": {"anticomp": True}, } + assert response['options'] == { + "resource": "options", + "cmd": "update", + "data": { + "anticomp": { + "value": True, + "choices": None, + "default": False, + "help": "Try to convince servers to send us un-compressed data.", + "type": "bool", + } + } + } ws_client.close() # trigger on_close by opening a second connection. -- cgit v1.2.3