aboutsummaryrefslogtreecommitdiffstats
path: root/test/pathod/test_app.py
blob: ac89c44c1c21cf266cc16a0aa16e46273eef8f29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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/pathod").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