From bd8a8691184cad4325f6b8609863bd9311f39a81 Mon Sep 17 00:00:00 2001 From: Ujjwal Verma Date: Wed, 24 May 2017 21:37:49 +0530 Subject: [PATCH] Tests for wbxml --- setup.cfg | 2 -- test/mitmproxy/contentviews/test_wbxml.py | 22 +++++++++++++++++- .../test_wbxml_data/data-formatted.wbxml | 10 ++++++++ .../contentviews/test_wbxml_data/data.wbxml | Bin 0 -> 34 bytes 4 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 test/mitmproxy/contentviews/test_wbxml_data/data-formatted.wbxml create mode 100644 test/mitmproxy/contentviews/test_wbxml_data/data.wbxml diff --git a/setup.cfg b/setup.cfg index 1721975ed..fc35021c4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -21,7 +21,6 @@ exclude_lines = [tool:full_coverage] exclude = - mitmproxy/contentviews/wbxml.py mitmproxy/proxy/protocol/ mitmproxy/proxy/config.py mitmproxy/proxy/root_context.py @@ -39,7 +38,6 @@ exclude = mitmproxy/addons/onboardingapp/app.py mitmproxy/addons/termlog.py mitmproxy/contentviews/base.py - mitmproxy/contentviews/wbxml.py mitmproxy/controller.py mitmproxy/ctx.py mitmproxy/exceptions.py diff --git a/test/mitmproxy/contentviews/test_wbxml.py b/test/mitmproxy/contentviews/test_wbxml.py index 777ab4dd1..09c770e71 100644 --- a/test/mitmproxy/contentviews/test_wbxml.py +++ b/test/mitmproxy/contentviews/test_wbxml.py @@ -1 +1,21 @@ -# TODO: write tests +from mitmproxy.contentviews import wbxml +from mitmproxy.test import tutils +from . import full_eval + +data = tutils.test_data.push("mitmproxy/contentviews/test_wbxml_data/") + + +def test_wbxml(): + v = full_eval(wbxml.ViewWBXML()) + + assert v(b'\x03\x01\x6A\x00') == ('WBXML', [[('text', '')]]) + assert v(b'foo') is None + + path = data.path("data.wbxml") # File taken from https://github.com/davidpshaw/PyWBXMLDecoder/tree/master/wbxml_samples + with open(path, 'rb') as f: + input = f.read() + with open("-formatted.".join(path.rsplit(".", 1))) as f: + expected = f.read() + + p = wbxml.ASCommandResponse.ASCommandResponse(input) + assert p.xmlString == expected diff --git a/test/mitmproxy/contentviews/test_wbxml_data/data-formatted.wbxml b/test/mitmproxy/contentviews/test_wbxml_data/data-formatted.wbxml new file mode 100644 index 000000000..fed293bd1 --- /dev/null +++ b/test/mitmproxy/contentviews/test_wbxml_data/data-formatted.wbxml @@ -0,0 +1,10 @@ + + + + + 1509029063 + 7 + 1 + + + diff --git a/test/mitmproxy/contentviews/test_wbxml_data/data.wbxml b/test/mitmproxy/contentviews/test_wbxml_data/data.wbxml new file mode 100644 index 0000000000000000000000000000000000000000..7c7a2004f80aa1f5112bb5618365f8444d17b3fd GIT binary patch literal 34 ncmZQ(%wlkj@%LsnG&Qg^FtRi-GiG26Vm4=B^kX(;U<3jHWbFjR literal 0 HcmV?d00001