aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorUjjwal Verma <ujjwalverma1111@gmail.com>2017-05-24 21:37:49 +0530
committerUjjwal Verma <ujjwalverma1111@gmail.com>2017-05-24 21:37:49 +0530
commitbd8a8691184cad4325f6b8609863bd9311f39a81 (patch)
tree2f43ee20782751d93fb08da21936abac22a7d9f9 /test
parent8b31f5c324fac1296d0a89fc42f4e86046d28970 (diff)
downloadmitmproxy-bd8a8691184cad4325f6b8609863bd9311f39a81.tar.gz
mitmproxy-bd8a8691184cad4325f6b8609863bd9311f39a81.tar.bz2
mitmproxy-bd8a8691184cad4325f6b8609863bd9311f39a81.zip
Tests for wbxml
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/contentviews/test_wbxml.py22
-rw-r--r--test/mitmproxy/contentviews/test_wbxml_data/data-formatted.wbxml10
-rw-r--r--test/mitmproxy/contentviews/test_wbxml_data/data.wbxmlbin0 -> 34 bytes
3 files changed, 31 insertions, 1 deletions
diff --git a/test/mitmproxy/contentviews/test_wbxml.py b/test/mitmproxy/contentviews/test_wbxml.py
index 777ab4dd..09c770e7 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', '<?xml version="1.0" ?>')]])
+ 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 00000000..fed293bd
--- /dev/null
+++ b/test/mitmproxy/contentviews/test_wbxml_data/data-formatted.wbxml
@@ -0,0 +1,10 @@
+<?xml version="1.0" ?>
+<Sync>
+ <Collections>
+ <Collection>
+ <SyncKey>1509029063</SyncKey>
+ <CollectionId>7</CollectionId>
+ <Status>1</Status>
+ </Collection>
+ </Collections>
+</Sync>
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 00000000..7c7a2004
--- /dev/null
+++ b/test/mitmproxy/contentviews/test_wbxml_data/data.wbxml
Binary files differ