aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_fuzzing.py
blob: 646ce5c16a3a02c246de80091c9324b265f8a16a (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
import tservers

"""
    A collection of errors turned up by fuzzing. Errors are integrated here
    after being fixed to check for regressions.
"""

class TestFuzzy(tservers.HTTPProxTest):
    def test_idna_err(self):
        req = r'get:"http://localhost:%s":i10,"\xc6"'
        p = self.pathoc()
        assert p.request(req%self.server.port).status_code == 400

    def test_nullbytes(self):
        req = r'get:"http://localhost:%s":i19,"\x00"'
        p = self.pathoc()
        assert p.request(req%self.server.port).status_code == 400

    def test_invalid_ports(self):
        req = 'get:"http://localhost:999999"'
        p = self.pathoc()
        assert p.request(req).status_code == 400

    def test_invalid_ipv6_url(self):
        req = 'get:"http://localhost:%s":i13,"["'
        p = self.pathoc()
        assert p.request(req%self.server.port).status_code == 400

    def test_invalid_upstream(self):
        req = r"get:'http://localhost:%s/p/200:i10,\'+\''"
        p = self.pathoc()
        assert p.request(req%self.server.port).status_code == 502

    def test_upstream_disconnect(self):
        req = r'200:d0'
        p = self.pathod(req)
        assert p.status_code == 502