aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2016-10-22 19:10:44 -0700
committerGitHub <noreply@github.com>2016-10-22 19:10:44 -0700
commitc09cedd0f850a863665c67ecc0a6166488a0f8cb (patch)
tree3f0ab76804d6d59fb6c79ce65a2cc6c95c806d0f /test
parent37a05e27526d22a23f7579dd1dbb0a04ea4eedcc (diff)
parenta1a792aeac20eab1fd2f2e1a91d34ba990fc111b (diff)
downloadmitmproxy-c09cedd0f850a863665c67ecc0a6166488a0f8cb.tar.gz
mitmproxy-c09cedd0f850a863665c67ecc0a6166488a0f8cb.tar.bz2
mitmproxy-c09cedd0f850a863665c67ecc0a6166488a0f8cb.zip
Merge pull request #1655 from mhils/fix-encoding
Encoding Fixes
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")