aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-04-08 19:23:05 +1200
committerAldo Cortesi <aldo@nullcube.com>2012-04-08 19:44:01 +1200
commit4e2d19714c8c0f801ba58fccece8e658bc321c4e (patch)
tree07b62518bb8d54e41d9234b9d62f496e05d6bb19 /test
parent618a9c0e2b447f200afec8b2dcdba3c3426a17fa (diff)
downloadmitmproxy-4e2d19714c8c0f801ba58fccece8e658bc321c4e.tar.gz
mitmproxy-4e2d19714c8c0f801ba58fccece8e658bc321c4e.tar.bz2
mitmproxy-4e2d19714c8c0f801ba58fccece8e658bc321c4e.zip
Add an "f" shortcut key to load full body contents.
Diffstat (limited to 'test')
-rw-r--r--test/test_console_contentview.py71
1 files changed, 39 insertions, 32 deletions
diff --git a/test/test_console_contentview.py b/test/test_console_contentview.py
index e0dbd577..bd91d2eb 100644
--- a/test/test_console_contentview.py
+++ b/test/test_console_contentview.py
@@ -1,3 +1,4 @@
+import sys
import libpry
import libmproxy.console.contentview as cv
from libmproxy import utils, flow, encoding
@@ -5,9 +6,9 @@ from libmproxy import utils, flow, encoding
class uContentView(libpry.AutoTree):
def test_trailer(self):
txt = []
- cv.trailer(5, txt)
+ cv.trailer(5, txt, 1000)
assert not txt
- cv.trailer(cv.VIEW_CUTOFF + 10, txt)
+ cv.trailer(cv.VIEW_CUTOFF + 10, txt, cv.VIEW_CUTOFF)
assert txt
def test_get_view_func(self):
@@ -54,25 +55,26 @@ class uContentView(libpry.AutoTree):
def test_view_urlencoded(self):
d = utils.urlencode([("one", "two"), ("three", "four")])
- assert cv.view_urlencoded([], d)
- assert not cv.view_urlencoded([], "foo")
+ assert cv.view_urlencoded([], d, 100)
+ assert not cv.view_urlencoded([], "foo", 100)
def test_view_html(self):
s = "<html><br><br></br><p>one</p></html>"
- assert cv.view_html([], s)
+ assert cv.view_html([], s, 1000)
s = "gobbledygook"
- assert not cv.view_html([], s)
+ assert not cv.view_html([], s, 1000)
def test_view_json(self):
cv.VIEW_CUTOFF = 100
- assert cv.view_json([], "{}")
- assert not cv.view_urlencoded([], "{")
- assert cv.view_json([], "[" + ",".join(["0"]*cv.VIEW_CUTOFF) + "]")
+ assert cv.view_json([], "{}", 1000)
+ assert not cv.view_json([], "{", 1000)
+ assert cv.view_json([], "[" + ",".join(["0"]*cv.VIEW_CUTOFF) + "]", 1000)
+ assert cv.view_json([], "[1, 2, 3, 4, 5]", 5)
def test_view_xml(self):
- assert cv.view_xml([], "<foo></foo>")
- assert not cv.view_xml([], "<foo>")
+ assert cv.view_xml([], "<foo></foo>", 1000)
+ assert not cv.view_xml([], "<foo>", 1000)
s = """<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet title="XSL_formatting"?>
<rss
@@ -81,25 +83,25 @@ class uContentView(libpry.AutoTree):
version="2.0">
</rss>
"""
- assert cv.view_xml([], s)
+ assert cv.view_xml([], s, 1000)
def test_view_raw(self):
- assert cv.view_raw([], "foo")
+ assert cv.view_raw([], "foo", 1000)
def test_view_javascript(self):
- assert cv.view_javascript([], "[1, 2, 3]")
- assert cv.view_javascript([], "[1, 2, 3")
- assert cv.view_javascript([], "function(a){[1, 2, 3]}")
+ assert cv.view_javascript([], "[1, 2, 3]", 100)
+ assert cv.view_javascript([], "[1, 2, 3", 100)
+ assert cv.view_javascript([], "function(a){[1, 2, 3]}", 100)
- def test_view_raw(self):
- assert cv.view_hex([], "foo")
+ def test_view_hex(self):
+ assert cv.view_hex([], "foo", 1000)
def test_view_image(self):
- assert cv.view_image([], file("data/image.png").read())
- assert cv.view_image([], file("data/image.gif").read())
- assert cv.view_image([], file("data/image-err1.jpg").read())
- assert cv.view_image([], file("data/image.ico").read())
- assert not cv.view_image([], "flibble")
+ assert cv.view_image([], file("data/image.png").read(), sys.maxint)
+ assert cv.view_image([], file("data/image.gif").read(), sys.maxint)
+ assert cv.view_image([], file("data/image-err1.jpg").read(), sys.maxint)
+ assert cv.view_image([], file("data/image.ico").read(), sys.maxint)
+ assert not cv.view_image([], "flibble", sys.maxint)
def test_view_multipart(self):
v = """
@@ -112,40 +114,43 @@ Larry
h = flow.ODictCaseless(
[("Content-Type", "multipart/form-data; boundary=AaB03x")]
)
- assert cv.view_multipart(h, v)
+ assert cv.view_multipart(h, v, 1000)
h = flow.ODictCaseless()
- assert not cv.view_multipart(h, v)
+ assert not cv.view_multipart(h, v, 1000)
h = flow.ODictCaseless(
[("Content-Type", "multipart/form-data")]
)
- assert not cv.view_multipart(h, v)
+ assert not cv.view_multipart(h, v, 1000)
h = flow.ODictCaseless(
[("Content-Type", "unparseable")]
)
- assert not cv.view_multipart(h, v)
+ assert not cv.view_multipart(h, v, 1000)
def test_get_content_view(self):
r = cv.get_content_view(
cv.VIEW_RAW,
[["content-type", "application/json"]],
- "[1, 2, 3]"
+ "[1, 2, 3]",
+ 1000
)
assert "Raw" in r[0]
r = cv.get_content_view(
cv.VIEW_AUTO,
[["content-type", "application/json"]],
- "[1, 2, 3]"
+ "[1, 2, 3]",
+ 1000
)
assert r[0] == "JSON"
r = cv.get_content_view(
cv.VIEW_AUTO,
[["content-type", "application/json"]],
- "[1, 2"
+ "[1, 2",
+ 1000
)
assert "Raw" in r[0]
@@ -155,7 +160,8 @@ Larry
["content-type", "application/json"],
["content-encoding", "gzip"]
],
- encoding.encode('gzip', "[1, 2, 3]")
+ encoding.encode('gzip', "[1, 2, 3]"),
+ 1000
)
assert "decoded gzip" in r[0]
assert "JSON" in r[0]
@@ -166,7 +172,8 @@ Larry
["content-type", "application/json"],
["content-encoding", "gzip"]
],
- encoding.encode('gzip', "[1, 2, 3]")
+ encoding.encode('gzip', "[1, 2, 3]"),
+ 1000
)
assert "decoded gzip" in r[0]
assert "Raw" in r[0]