2012-07-23 04:18:47 +00:00
|
|
|
import tutils
|
|
|
|
|
2014-10-25 02:37:57 +00:00
|
|
|
|
2012-07-23 04:18:47 +00:00
|
|
|
class TestApp(tutils.DaemonTests):
|
|
|
|
SSL = False
|
2014-10-25 02:37:57 +00:00
|
|
|
|
2012-07-23 04:18:47 +00:00
|
|
|
def test_index(self):
|
|
|
|
r = self.getpath("/")
|
|
|
|
assert r.status_code == 200
|
2015-09-26 15:40:22 +00:00
|
|
|
assert r.content
|
2012-07-23 04:28:34 +00:00
|
|
|
|
2012-07-25 00:39:51 +00:00
|
|
|
def test_about(self):
|
|
|
|
r = self.getpath("/about")
|
|
|
|
assert r.ok
|
|
|
|
|
2012-10-24 21:59:18 +00:00
|
|
|
def test_download(self):
|
|
|
|
r = self.getpath("/download")
|
|
|
|
assert r.ok
|
|
|
|
|
2012-07-23 04:18:47 +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
|
2012-10-24 21:59:18 +00:00
|
|
|
assert self.getpath("/docs/libpathod").status_code == 200
|
2012-07-23 04:18:47 +00:00
|
|
|
assert self.getpath("/docs/test").status_code == 200
|
|
|
|
|
|
|
|
def test_log(self):
|
|
|
|
assert self.getpath("/log").status_code == 200
|
2012-11-17 20:04:49 +00:00
|
|
|
assert self.get("200:da").status_code == 200
|
2012-07-23 04:18:47 +00:00
|
|
|
id = self.d.log()[0]["id"]
|
|
|
|
assert self.getpath("/log").status_code == 200
|
2015-05-30 00:03:13 +00:00
|
|
|
assert self.getpath("/log/%s" % id).status_code == 200
|
2012-07-23 04:18:47 +00:00
|
|
|
assert self.getpath("/log/9999999").status_code == 404
|
|
|
|
|
2013-04-29 21:32:11 +00:00
|
|
|
def test_log_binary(self):
|
|
|
|
assert self.get("200:h@10b=@10b:da")
|
|
|
|
|
2012-07-24 11:13:04 +00:00
|
|
|
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
|
2015-09-26 15:40:22 +00:00
|
|
|
assert 'Response' in r.content
|
2012-07-23 04:28:34 +00:00
|
|
|
|
2012-07-24 11:13:04 +00:00
|
|
|
r = self.getpath("/response_preview", params=dict(spec="foo"))
|
2012-07-23 04:28:34 +00:00
|
|
|
assert r.status_code == 200
|
2015-09-26 15:40:22 +00:00
|
|
|
assert 'Error' in r.content
|
2012-07-23 04:28:34 +00:00
|
|
|
|
2012-07-24 11:13:04 +00:00
|
|
|
r = self.getpath("/response_preview", params=dict(spec="200:b@100m"))
|
2012-07-23 04:28:34 +00:00
|
|
|
assert r.status_code == 200
|
2015-09-26 15:40:22 +00:00
|
|
|
assert "too large" in r.content
|
2012-07-23 04:28:34 +00:00
|
|
|
|
2012-07-24 11:13:04 +00:00
|
|
|
r = self.getpath("/response_preview", params=dict(spec="200:b@5k"))
|
2012-07-23 04:39:25 +00:00
|
|
|
assert r.status_code == 200
|
2015-09-26 15:40:22 +00:00
|
|
|
assert 'Response' in r.content
|
2012-07-23 04:39:25 +00:00
|
|
|
|
2015-05-30 00:03:13 +00:00
|
|
|
r = self.getpath(
|
|
|
|
"/response_preview",
|
|
|
|
params=dict(
|
|
|
|
spec="200:b<nonexistent"))
|
2012-07-24 12:16:24 +00:00
|
|
|
assert r.status_code == 200
|
2015-09-26 15:40:22 +00:00
|
|
|
assert 'File access denied' in r.content
|
2012-10-27 23:56:08 +00:00
|
|
|
|
|
|
|
r = self.getpath("/response_preview", params=dict(spec="200:b<file"))
|
|
|
|
assert r.status_code == 200
|
2015-09-26 15:40:22 +00:00
|
|
|
assert 'testfile' in r.content
|
2012-07-24 12:16:24 +00:00
|
|
|
|
2012-07-24 11:13:04 +00:00
|
|
|
def test_request_preview(self):
|
|
|
|
r = self.getpath("/request_preview", params=dict(spec="get:/"))
|
|
|
|
assert r.status_code == 200
|
2015-09-26 15:40:22 +00:00
|
|
|
assert 'Request' in r.content
|
2012-07-24 11:13:04 +00:00
|
|
|
|
|
|
|
r = self.getpath("/request_preview", params=dict(spec="foo"))
|
|
|
|
assert r.status_code == 200
|
2015-09-26 15:40:22 +00:00
|
|
|
assert 'Error' in r.content
|
2012-07-24 11:13:04 +00:00
|
|
|
|
|
|
|
r = self.getpath("/request_preview", params=dict(spec="get:/:b@100m"))
|
|
|
|
assert r.status_code == 200
|
2015-09-26 15:40:22 +00:00
|
|
|
assert "too large" in r.content
|
2012-07-24 11:13:04 +00:00
|
|
|
|
|
|
|
r = self.getpath("/request_preview", params=dict(spec="get:/:b@5k"))
|
|
|
|
assert r.status_code == 200
|
2015-09-26 15:40:22 +00:00
|
|
|
assert 'Request' in r.content
|
2012-07-24 11:13:04 +00:00
|
|
|
|
2012-07-24 22:53:29 +00:00
|
|
|
r = self.getpath("/request_preview", params=dict(spec=""))
|
|
|
|
assert r.status_code == 200
|
2015-09-26 15:40:22 +00:00
|
|
|
assert 'empty spec' in r.content
|