aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2016-10-22 18:47:12 -0700
committerMaximilian Hils <git@maximilianhils.com>2016-10-22 18:47:12 -0700
commita1a792aeac20eab1fd2f2e1a91d34ba990fc111b (patch)
tree7f06cd5b8d3c927f7420fee15d52130aed0049a1 /test
parent0526d94f4a073cc4d15a02bdbbf447776d75f81d (diff)
downloadmitmproxy-a1a792aeac20eab1fd2f2e1a91d34ba990fc111b.tar.gz
mitmproxy-a1a792aeac20eab1fd2f2e1a91d34ba990fc111b.tar.bz2
mitmproxy-a1a792aeac20eab1fd2f2e1a91d34ba990fc111b.zip
various encoding fixes, fix #1650
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/test_examples.py21
-rw-r--r--test/mitmproxy/test_flow.py2
-rw-r--r--test/mitmproxy/test_utils_strutils.py2
3 files changed, 23 insertions, 2 deletions
diff --git a/test/mitmproxy/test_examples.py b/test/mitmproxy/test_examples.py
index 6972da0c..3cd29a50 100644
--- a/test/mitmproxy/test_examples.py
+++ b/test/mitmproxy/test_examples.py
@@ -160,3 +160,24 @@ class TestHARDump:
f = format_cookies([("n", "v", CA([("expires", "Mon, 24-Aug-2037 00:00:00 GMT")]))])[0]
assert f['expires']
+
+ def test_binary(self):
+
+ f = self.flow()
+ f.request.method = "POST"
+ f.request.headers["content-type"] = "application/x-www-form-urlencoded"
+ f.request.content = b"foo=bar&baz=s%c3%bc%c3%9f"
+ f.response.headers["random-junk"] = bytes(range(256))
+ f.response.content = bytes(range(256))
+
+ with tutils.tmpdir() as tdir:
+ path = os.path.join(tdir, "somefile")
+
+ m, sc = tscript("har_dump.py", shlex.quote(path))
+ m.addons.invoke(m, "response", f)
+ m.addons.remove(sc)
+
+ with open(path, "r") as inp:
+ har = json.load(inp)
+
+ assert len(har["log"]["entries"]) == 1
diff --git a/test/mitmproxy/test_flow.py b/test/mitmproxy/test_flow.py
index 5b9f3835..d16bb6dd 100644
--- a/test/mitmproxy/test_flow.py
+++ b/test/mitmproxy/test_flow.py
@@ -346,7 +346,7 @@ class TestSerialize:
sio = io.BytesIO()
f = tutils.tflow()
f.marked = True
- f.request.content = bytes(bytearray(range(256)))
+ f.request.content = bytes(range(256))
w = mitmproxy.io.FlowWriter(sio)
w.add(f)
diff --git a/test/mitmproxy/test_utils_strutils.py b/test/mitmproxy/test_utils_strutils.py
index d4c2883c..84281c6b 100644
--- a/test/mitmproxy/test_utils_strutils.py
+++ b/test/mitmproxy/test_utils_strutils.py
@@ -3,7 +3,7 @@ from mitmproxy.test import tutils
def test_always_bytes():
- assert strutils.always_bytes(bytes(bytearray(range(256)))) == bytes(bytearray(range(256)))
+ assert strutils.always_bytes(bytes(range(256))) == bytes(range(256))
assert strutils.always_bytes("foo") == b"foo"
with tutils.raises(ValueError):
strutils.always_bytes(u"\u2605", "ascii")