aboutsummaryrefslogtreecommitdiffstats
path: root/test/pathod/test_app.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2016-02-15 23:00:11 +0100
committerMaximilian Hils <git@maximilianhils.com>2016-02-15 23:00:11 +0100
commit87d9afcf2e257eee7c5aa08c3f0dc64da79b0647 (patch)
tree71b10729d160f0269d02548d1ef9e183be1397d9 /test/pathod/test_app.py
parent36f34f701991b5d474c005ec45e3b66e20f326a8 (diff)
parent3d9a5157e77b5a3237dc62994f4e3d4c75c2066e (diff)
downloadmitmproxy-87d9afcf2e257eee7c5aa08c3f0dc64da79b0647.tar.gz
mitmproxy-87d9afcf2e257eee7c5aa08c3f0dc64da79b0647.tar.bz2
mitmproxy-87d9afcf2e257eee7c5aa08c3f0dc64da79b0647.zip
Merge pull request #937 from mhils/single-repo
Combine mitmproxy, pathod and netlib in a single repo.
Diffstat (limited to 'test/pathod/test_app.py')
-rw-r--r--test/pathod/test_app.py85
1 files changed, 85 insertions, 0 deletions
diff --git a/test/pathod/test_app.py b/test/pathod/test_app.py
new file mode 100644
index 00000000..4536db8e
--- /dev/null
+++ b/test/pathod/test_app.py
@@ -0,0 +1,85 @@
+import tutils
+
+
+class TestApp(tutils.DaemonTests):
+ SSL = False
+
+ def test_index(self):
+ r = self.getpath("/")
+ assert r.status_code == 200
+ assert r.content
+
+ def test_about(self):
+ r = self.getpath("/about")
+ assert r.ok
+
+ def test_download(self):
+ r = self.getpath("/download")
+ assert r.ok
+
+ 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/libpathod").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:da").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_log_binary(self):
+ assert self.get("200:h@10b=@10b:da")
+
+ def test_response_preview(self):
+ r = self.getpath("/response_preview", params=dict(spec="200"))
+ assert r.status_code == 200
+ assert 'Response' in r.content
+
+ r = self.getpath("/response_preview", params=dict(spec="foo"))
+ assert r.status_code == 200
+ assert 'Error' in r.content
+
+ r = self.getpath("/response_preview", params=dict(spec="200:b@100m"))
+ assert r.status_code == 200
+ assert "too large" in r.content
+
+ r = self.getpath("/response_preview", params=dict(spec="200:b@5k"))
+ assert r.status_code == 200
+ assert 'Response' in r.content
+
+ r = self.getpath(
+ "/response_preview",
+ params=dict(
+ spec="200:b<nonexistent"))
+ assert r.status_code == 200
+ assert 'File access denied' in r.content
+
+ r = self.getpath("/response_preview", params=dict(spec="200:b<file"))
+ assert r.status_code == 200
+ assert 'testfile' 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
+
+ r = self.getpath("/request_preview", params=dict(spec=""))
+ assert r.status_code == 200
+ assert 'empty spec' in r.content