mitmproxy/test/test_app.py

65 lines
2.2 KiB
Python
Raw Normal View History

import tutils
class TestApp(tutils.DaemonTests):
SSL = False
def test_index(self):
r = self.getpath("/")
assert r.status_code == 200
assert r.content
2012-07-23 04:28:34 +00:00
def test_docs(self):
assert self.getpath("/docs/pathod").status_code == 200
assert self.getpath("/docs/pathoc").status_code == 200
assert self.getpath("/docs/language").status_code == 200
assert self.getpath("/docs/test").status_code == 200
def test_log(self):
assert self.getpath("/log").status_code == 200
assert self.get("200").status_code == 200
id = self.d.log()[0]["id"]
assert self.getpath("/log").status_code == 200
assert self.getpath("/log/%s"%id).status_code == 200
assert self.getpath("/log/9999999").status_code == 404
def test_response_preview(self):
r = self.getpath("/response_preview", params=dict(spec="200"))
2012-07-23 04:28:34 +00:00
assert r.status_code == 200
assert 'Response' in r.content
r = self.getpath("/response_preview", params=dict(spec="foo"))
2012-07-23 04:28:34 +00:00
assert r.status_code == 200
assert 'Error' in r.content
r = self.getpath("/response_preview", params=dict(spec="200:b@100m"))
2012-07-23 04:28:34 +00:00
assert r.status_code == 200
assert "too large" in r.content
r = self.getpath("/response_preview", params=dict(spec="200:b@5k"))
2012-07-23 04:39:25 +00:00
assert r.status_code == 200
assert 'Response' in r.content
r = self.getpath("/response_preview", params=dict(spec="200:b<foo"))
assert r.status_code == 200
assert 'File access is disabled' in r.content
def test_request_preview(self):
r = self.getpath("/request_preview", params=dict(spec="get:/"))
assert r.status_code == 200
assert 'Request' in r.content
r = self.getpath("/request_preview", params=dict(spec="foo"))
assert r.status_code == 200
assert 'Error' in r.content
r = self.getpath("/request_preview", params=dict(spec="get:/:b@100m"))
assert r.status_code == 200
assert "too large" in r.content
r = self.getpath("/request_preview", params=dict(spec="get:/:b@5k"))
assert r.status_code == 200
assert 'Request' in r.content
2012-07-23 04:28:34 +00:00