Ejemplo n.º 1
0
 def test_200_14(self):
     conf = HttpdConf()
     conf.add_line("""
         LimitRequestFields 20
         """)
     conf.add_vhost_cgi()
     conf.install()
     assert TestEnv.apache_restart() == 0
     url = TestEnv.mkurl("https", "cgi", "/")
     opt = []
     for i in range(21):
         opt += ["-H", "x{0}: 1".format(i)]
     r = TestEnv.curl_get(url, options=opt)
     assert 431 == r["response"]["status"]
     conf = HttpdConf()
     conf.add_line("""
         LimitRequestFields 0
         """)
     conf.add_vhost_cgi()
     conf.install()
     assert TestEnv.apache_restart() == 0
     url = TestEnv.mkurl("https", "cgi", "/")
     opt = []
     for i in range(100):
         opt += ["-H", "x{0}: 1".format(i)]
     r = TestEnv.curl_get(url, options=opt)
     assert 200 == r["response"]["status"]
Ejemplo n.º 2
0
 def test_100_01(self):
     # this host defaults to h2, but we can request h1
     url = TestEnv.mkurl("https", "cgi", "/hello.py")
     assert "2" == TestEnv.curl_protocol_version( url )
     assert "1.1" == TestEnv.curl_protocol_version( url, options=[ "--http1.1" ] )
     
     # this host does not enable h2, it always falls back to h1
     url = TestEnv.mkurl("https", "noh2", "/hello.py")
     assert "1.1" == TestEnv.curl_protocol_version( url )
     assert "1.1" == TestEnv.curl_protocol_version( url, options=[ "--http2" ] )
Ejemplo n.º 3
0
    def test_100_01(self):
        # this host defaults to h2, but we can request h1
        url = TestEnv.mkurl("https", "cgi", "/hello.py")
        assert "2" == TestEnv.curl_protocol_version(url)
        assert "1.1" == TestEnv.curl_protocol_version(url,
                                                      options=["--http1.1"])

        # this host does not enable h2, it always falls back to h1
        url = TestEnv.mkurl("https", "noh2", "/hello.py")
        assert "1.1" == TestEnv.curl_protocol_version(url)
        assert "1.1" == TestEnv.curl_protocol_version(url, options=["--http2"])
Ejemplo n.º 4
0
    def test_003_02(self):
        with open(TestEnv.e2e_src( "htdocs/test1/index.html"), mode='rb') as file:
            src = file.read()

        url = TestEnv.mkurl("https", "test1", "/index.html")
        r = TestEnv.curl_get(url, 5)
        assert 200 == r["response"]["status"]
        assert "HTTP/2" == r["response"]["protocol"]
        assert src == r["response"]["body"]

        url = TestEnv.mkurl("https", "test1", "/index.html")
        r = TestEnv.curl_get(url, 5, [ "--http1.1" ])
        assert 200 == r["response"]["status"]
        assert "HTTP/1.1" == r["response"]["protocol"]
        assert src == r["response"]["body"]
Ejemplo n.º 5
0
    def test_003_02(self):
        with open(TestEnv.e2e_src( "htdocs/test1/index.html"), mode='rb') as file:
            src = file.read()

        url = TestEnv.mkurl("https", "test1", "/index.html")
        r = TestEnv.curl_get(url, 5)
        assert 200 == r["response"]["status"]
        assert "HTTP/2" == r["response"]["protocol"]
        assert src == r["response"]["body"]

        url = TestEnv.mkurl("https", "test1", "/index.html")
        r = TestEnv.curl_get(url, 5, [ "--http1.1" ])
        assert 200 == r["response"]["status"]
        assert "HTTP/1.1" == r["response"]["protocol"]
        assert src == r["response"]["body"]
Ejemplo n.º 6
0
    def test_003_21(self):
        url = TestEnv.mkurl("https", "test1", "/index.html")
        r = TestEnv.curl_get(url, 5, [ "-I" ])
        assert 200 == r["response"]["status"]
        assert "HTTP/2" == r["response"]["protocol"]
        s = self.clean_header(r["response"]["body"])
        assert '''HTTP/2 200 
content-length: 2007
content-type: text/html

''' == s

        r = TestEnv.curl_get(url, 5, [ "-I", url ])
        assert 200 == r["response"]["status"]
        assert "HTTP/2" == r["response"]["protocol"]
        s = self.clean_header(r["response"]["body"])
        assert '''HTTP/2 200 
content-length: 2007
content-type: text/html

HTTP/2 200 
content-length: 2007
content-type: text/html

''' == s
Ejemplo n.º 7
0
 def test_002_02(self):
     url = TestEnv.mkurl("https", "test1", "/alive.json")
     r = TestEnv.curl_get(url, 5)
     assert 200 == r["response"]["status"]
     assert True == r["response"]["json"]["alive"]
     assert "test1" == r["response"]["json"]["host"]
     assert "application/json" == r["response"]["header"]["content-type"]
Ejemplo n.º 8
0
 def test_200_03(self):
     url = TestEnv.mkurl("https", "cgi", "/hecho.py")
     for hex in [ "10", "7f" ]:
         r = TestEnv.curl_post_data(url, "name=x%%%s&value=yz" % hex)
         assert 0 != r["rv"]
         r = TestEnv.curl_post_data(url, "name=x&value=y%%%sz" % hex)
         assert 0 != r["rv"]
Ejemplo n.º 9
0
 def test_103_06(self):
     url = TestEnv.mkurl("https", "test1", "/index.html")
     r = TestEnv.curl_get(url, options=[ "--http1.1" ])
     assert 0 == r["rv"]
     assert "response" in r
     assert "upgrade" in r["response"]["header"]
     assert "h2" == r["response"]["header"]["upgrade"]
Ejemplo n.º 10
0
 def test_104_04(self):
     url = TestEnv.mkurl("https", "pad2", "/echo.py")
     for data in [ "x", "xx", "xxx", "xxxx", "xxxxx", "xxxxxx", "xxxxxxx", "xxxxxxxx" ]:
         r = r = TestEnv.nghttp().post_data(url, data, 5)
         assert 200 == r["response"]["status"]
         for i in r["paddings"]:
             assert i in range(0, 4)
Ejemplo n.º 11
0
 def test_400_07(self):
     url = TestEnv.mkurl("https", "push", "/006-push7.html")
     r = TestEnv.nghttp().get(url)
     assert 200 == r["response"]["status"]
     promises = r["streams"][r["response"]["id"]]["promises"]
     assert 1 == len(promises)
     assert '/006/006.css' == promises[0]["request"]["header"][":path"]
Ejemplo n.º 12
0
 def test_002_02(self):
     url = TestEnv.mkurl("https", "test1", "/alive.json")
     r = TestEnv.curl_get(url, 5)
     assert 200 == r["response"]["status"]
     assert True == r["response"]["json"]["alive"]
     assert "test1" == r["response"]["json"]["host"]
     assert "application/json" == r["response"]["header"]["content-type"]
Ejemplo n.º 13
0
    def test_003_21(self):
        url = TestEnv.mkurl("https", "test1", "/index.html")
        r = TestEnv.curl_get(url, 5, [ "-I" ])
        assert 200 == r["response"]["status"]
        assert "HTTP/2" == r["response"]["protocol"]
        s = self.clean_header(r["response"]["body"])
        assert '''HTTP/2 200 
content-length: 2007
content-type: text/html

''' == s

        r = TestEnv.curl_get(url, 5, [ "-I", url ])
        assert 200 == r["response"]["status"]
        assert "HTTP/2" == r["response"]["protocol"]
        s = self.clean_header(r["response"]["body"])
        assert '''HTTP/2 200 
content-length: 2007
content-type: text/html

HTTP/2 200 
content-length: 2007
content-type: text/html

''' == s
Ejemplo n.º 14
0
 def test_101_04(self):
     url = TestEnv.mkurl("https", "ssl", "/ssl-client-verify/index.html")
     r = TestEnv.curl_get(url,
                          options=["-vvv", "--tlsv1.2", "--tls-max", "1.2"])
     assert 0 != r["rv"]
     assert not "response" in r
     assert re.search(r'HTTP_1_1_REQUIRED \(err 13\)', r["out"]["err"])
Ejemplo n.º 15
0
 def test_002_01(self):
     url = TestEnv.mkurl("http", "test1", "/alive.json")
     r = TestEnv.curl_get(url, 5)
     assert 200 == r["response"]["status"]
     assert "HTTP/1.1" == r["response"]["protocol"]
     assert True == r["response"]["json"]["alive"]
     assert "test1" == r["response"]["json"]["host"]
Ejemplo n.º 16
0
 def test_101_01(self):
     url = TestEnv.mkurl("https", "ssl", "/renegotiate/cipher/")
     r = TestEnv.curl_get(
         url, options=["-v", "--http1.1", "--tlsv1.2", "--tls-max", "1.2"])
     assert 0 == r["rv"]
     assert "response" in r
     assert 403 == r["response"]["status"]
Ejemplo n.º 17
0
 def test_101_02(self):
     url = TestEnv.mkurl("https", "ssl", "/renegotiate/cipher/")
     r = TestEnv.curl_get(url,
                          options=["-vvv", "--tlsv1.2", "--tls-max", "1.2"])
     assert 0 != r["rv"]
     assert not "response" in r
     assert re.search(r'HTTP_1_1_REQUIRED \(err 13\)', r["out"]["err"])
Ejemplo n.º 18
0
 def test_103_01(self):
     url = TestEnv.mkurl("http", "test1", "/index.html")
     r = TestEnv.curl_get(url)
     assert 0 == r["rv"]
     assert "response" in r
     assert "upgrade" in r["response"]["header"]
     assert "h2c" == r["response"]["header"]["upgrade"]
Ejemplo n.º 19
0
 def test_103_06(self):
     url = TestEnv.mkurl("https", "test1", "/index.html")
     r = TestEnv.curl_get(url, options=[ "--http1.1" ])
     assert 0 == r["rv"]
     assert "response" in r
     assert "upgrade" in r["response"]["header"]
     assert "h2" == r["response"]["header"]["upgrade"]
Ejemplo n.º 20
0
 def test_200_03(self):
     url = TestEnv.mkurl("https", "cgi", "/hecho.py")
     for hex in ["10", "7f"]:
         r = TestEnv.curl_post_data(url, "name=x%%%s&value=yz" % hex)
         assert 0 != r["rv"]
         r = TestEnv.curl_post_data(url, "name=x&value=y%%%sz" % hex)
         assert 0 != r["rv"]
Ejemplo n.º 21
0
 def test_200_11(self):
     url = TestEnv.mkurl("https", "cgi", "/")
     val = "1234567890"  # 10 chars
     for i in range(3):  # make a 10000 char string
         val = "%s%s%s%s%s%s%s%s%s%s" % (val, val, val, val, val, val, val,
                                         val, val, val)
     # LimitRequestFieldSize 8190 ok, one more char -> 400 in HTTP/1.1
     # (we send 4000+4185 since they are concatenated by ", " and start with "x: "
     r = TestEnv.curl_get(url,
                          options=[
                              "-H",
                              "x: %s" % (val[:4000]), "-H",
                              "x: %s" % (val[:4185])
                          ])
     assert 200 == r["response"]["status"]
     r = TestEnv.curl_get(url,
                          options=[
                              "--http1.1", "-H",
                              "x: %s" % (val[:4000]), "-H",
                              "x: %s" % (val[:4189])
                          ])
     assert 400 == r["response"]["status"]
     r = TestEnv.curl_get(url,
                          options=[
                              "-H",
                              "x: %s" % (val[:4000]), "-H",
                              "x: %s" % (val[:4191])
                          ])
     assert 431 == r["response"]["status"]
Ejemplo n.º 22
0
 def test_400_07(self):
     url = TestEnv.mkurl("https", "push", "/006-push7.html")
     r = TestEnv.nghttp().get(url)
     assert 200 == r["response"]["status"]
     promises = r["streams"][r["response"]["id"]]["promises"]
     assert 1 == len(promises)
     assert '/006/006.css' == promises[0]["request"]["header"][":path"]
Ejemplo n.º 23
0
 def test_400_32(self):
     url = TestEnv.mkurl("https", "hints", "/006-nohints.html")
     r = TestEnv.nghttp().get(url)
     assert 200 == r["response"]["status"]
     promises = r["streams"][r["response"]["id"]]["promises"]
     assert 1 == len(promises)
     assert not "previous" in r["response"]
Ejemplo n.º 24
0
 def test_400_32(self):
     url = TestEnv.mkurl("https", "hints", "/006-nohints.html")
     r = TestEnv.nghttp().get(url)
     assert 200 == r["response"]["status"]
     promises = r["streams"][r["response"]["id"]]["promises"]
     assert 1 == len(promises)
     assert not "previous" in r["response"]
Ejemplo n.º 25
0
 def test_400_53(self):
     url = TestEnv.mkurl("https", "push", "/006-push.html")
     r = TestEnv.nghttp().get(
         url, options=['-H', 'accept-push-policy: fast-load'])
     assert 200 == r["response"]["status"]
     promises = r["streams"][r["response"]["id"]]["promises"]
     assert 1 == len(promises)
Ejemplo n.º 26
0
 def test_100_02(self):
     url = TestEnv.mkurl("https", "cgi", "/hello.py")
     hostname = ("cgi-alias.%s" % TestEnv.HTTP_TLD)
     r = TestEnv.curl_get(url, 5, ["-H", "Host:%s" % hostname])
     assert 200 == r["response"]["status"]
     assert "HTTP/2" == r["response"]["protocol"]
     assert hostname == r["response"]["json"]["host"]
Ejemplo n.º 27
0
 def test_300_03(self):
     url = TestEnv.mkurl("https", "test1", "/index.html")
     r = TestEnv.curl_post_data(url,
                                'XYZ',
                                options=["-H", "expect: the-unexpected"])
     assert 417 == r["response"]["status"]
     assert not "previous" in r["response"]
Ejemplo n.º 28
0
 def test_100_03(self):
     url = TestEnv.mkurl("https", "cgi", "/")
     hostname = ("test1.%s" % TestEnv.HTTP_TLD)
     r = TestEnv.curl_get(url, 5, ["-H", "Host:%s" % hostname])
     assert 200 == r["response"]["status"]
     assert "HTTP/2" == r["response"]["protocol"]
     assert "text/html" == r["response"]["header"]["content-type"]
Ejemplo n.º 29
0
 def test_103_01(self):
     url = TestEnv.mkurl("http", "test1", "/index.html")
     r = TestEnv.curl_get(url)
     assert 0 == r["rv"]
     assert "response" in r
     assert "upgrade" in r["response"]["header"]
     assert "h2c" == r["response"]["header"]["upgrade"]
Ejemplo n.º 30
0
 def test_002_01(self):
     url = TestEnv.mkurl("http", "test1", "/alive.json")
     r = TestEnv.curl_get(url, 5)
     assert 200 == r["response"]["status"]
     assert "HTTP/1.1" == r["response"]["protocol"]
     assert True == r["response"]["json"]["alive"]
     assert "test1" == r["response"]["json"]["host"]
Ejemplo n.º 31
0
 def test_100_03(self):
     url = TestEnv.mkurl("https", "cgi", "/")
     hostname = ("test1.%s" % TestEnv.HTTP_TLD)
     r = TestEnv.curl_get(url, 5, [ "-H", "Host:%s" % hostname ])
     assert 200 == r["response"]["status"]
     assert "HTTP/2" == r["response"]["protocol"]
     assert "text/html" == r["response"]["header"]["content-type"]
Ejemplo n.º 32
0
 def test_100_02(self):
     url = TestEnv.mkurl("https", "cgi", "/hello.py")
     hostname = ("cgi-alias.%s" % TestEnv.HTTP_TLD)
     r = TestEnv.curl_get(url, 5, [ "-H", "Host:%s" % hostname ])
     assert 200 == r["response"]["status"]
     assert "HTTP/2" == r["response"]["protocol"]
     assert hostname == r["response"]["json"]["host"]
Ejemplo n.º 33
0
 def check_necho(self, n, text):
     url = TestEnv.mkurl("https", "cgi", "/necho.py")
     r = TestEnv.curl_get(url, 5, [ "-F", ("count=%d" % (n)), "-F", ("text=%s" % (text)) ])
     assert 200 == r["response"]["status"]
     exp = ""
     for i in range(n):
         exp += text + "\n"
     assert exp == r["response"]["body"]
Ejemplo n.º 34
0
 def test_400_01(self):
     url = TestEnv.mkurl("https", "push", "/006-push.html")
     r = TestEnv.nghttp().get(url, options=["-Haccept-encoding: none"])
     assert 200 == r["response"]["status"]
     promises = r["streams"][r["response"]["id"]]["promises"]
     assert 1 == len(promises)
     assert '/006/006.css' == promises[0]["request"]["header"][":path"]
     assert 216 == len(promises[0]["response"]["body"])
Ejemplo n.º 35
0
 def test_201_04(self):
     url = TestEnv.mkurl("https", "test1", "/006.html")
     r = TestEnv.curl_get(url, options=[ "--http1.1", "-H", "Connection: keep-alive" ])
     assert 200 == r["response"]["status"]
     assert "timeout=30, max=30" == r["response"]["header"]["keep-alive"]
     r = TestEnv.curl_get(url, options=[ "-H", "Connection: keep-alive" ])
     assert 200 == r["response"]["status"]
     assert not "keep-alive" in r["response"]["header"]
Ejemplo n.º 36
0
 def test_400_02(self):
     url = TestEnv.mkurl("https", "push", "/006-push.html")
     r = TestEnv.nghttp().get(url)
     assert 200 == r["response"]["status"]
     assert 13 == r["response"]["id"]
     assert 2 == len(r["streams"])
     assert r["streams"][2]
     assert 216 == len(r["streams"][2]["response"]["body"])
Ejemplo n.º 37
0
 def test_300_02(self):
     url = TestEnv.mkurl("https", "test1", "/index.html")
     r = TestEnv.curl_post_data(url,
                                'XYZ',
                                options=["-H", "expect: 100-continue"])
     assert 200 == r["response"]["status"]
     assert "previous" in r["response"]
     assert 100 == r["response"]["previous"]["status"]
Ejemplo n.º 38
0
 def test_004_07(self, name, value):
     url = TestEnv.mkurl("https", "cgi", "/env.py")
     r = TestEnv.curl_post_value( url, "name", name )
     assert r["rv"] == 0
     assert r["response"]["status"] == 200
     m = re.match("{0}=(.*)".format(name), r["response"]["body"].decode('utf-8'))
     assert m
     assert re.match(value, m.group(1)) 
Ejemplo n.º 39
0
    def nghttp_upload_stat(self, fname, options=None):
        url = TestEnv.mkurl("https", "cgi", "/proxy/upload.py")
        fpath = os.path.join(TestEnv.GEN_DIR, fname)

        r = TestEnv.nghttp().upload_file(url, fpath, options=options)
        assert r["rv"] == 0
        assert r["response"]["status"] >= 200 and r["response"]["status"] < 300
        assert r["response"]["header"]["location"]
Ejemplo n.º 40
0
    def nghttp_upload_stat(self, fname, options=None):
        url = TestEnv.mkurl("https", "cgi", "/proxy/upload.py")
        fpath = os.path.join(TestEnv.GEN_DIR, fname)

        r = TestEnv.nghttp().upload_file(url, fpath, options=options)
        assert r["rv"] == 0
        assert 200 <= r["response"]["status"] < 300
        assert r["response"]["header"]["location"]
Ejemplo n.º 41
0
 def test_006_02(self):
     url = TestEnv.mkurl("https", "test1", "/002.jpg")
     r = TestEnv.nghttp().assets(url)
     assert 0 == r["rv"]
     assert 1 == len(r["assets"])
     assert r["assets"] == [
         { "status": 200, "size": "88K", "path" : "/002.jpg" }
     ]
Ejemplo n.º 42
0
 def test_202_05(self):
     url = TestEnv.mkurl("https", "cgi", "/.well-known/h2/state")
     fpath = os.path.join(TestEnv.GEN_DIR, "data-1k")
     r = TestEnv.nghttp().upload(url,
                                 fpath,
                                 options=["--trailer", "test: 2"])
     assert 200 == r["response"]["status"]
     assert "1" == r["response"]["trailer"]["h2-trailers-in"]
Ejemplo n.º 43
0
 def check_necho(self, n, text):
     url = TestEnv.mkurl("https", "cgi", "/necho.py")
     r = TestEnv.curl_get(url, 5, [ "-F", ("count=%d" % (n)), "-F", ("text=%s" % (text)) ])
     assert 200 == r["response"]["status"]
     exp = ""
     for i in range(n):
         exp += text + "\n"
     assert exp == r["response"]["body"]
Ejemplo n.º 44
0
    def test_005_01(self):
        url = TestEnv.mkurl("https", "cgi", "/.well-known/h2/state")
        r = TestEnv.curl_get(url, 5)
        assert 200 == r["response"]["status"]
        st = r["response"]["json"]

        # remove some parts that are very dependant on client/lib versions
        # or connection time etc.
        del st["settings"]["SETTINGS_INITIAL_WINDOW_SIZE"]
        del st["peerSettings"]["SETTINGS_INITIAL_WINDOW_SIZE"]
        del st["streams"]["1"]["created"]
        del st["streams"]["1"]["flowOut"]
        del st["stats"]["in"]["frames"]
        del st["stats"]["in"]["octets"]
        del st["stats"]["out"]["frames"]
        del st["stats"]["out"]["octets"]
        del st["connFlowOut"]

        assert st == {
            "version": "draft-01",
            "settings": {
                "SETTINGS_MAX_CONCURRENT_STREAMS": 100,
                "SETTINGS_MAX_FRAME_SIZE": 16384,
                "SETTINGS_ENABLE_PUSH": 0
            },
            "peerSettings": {
                "SETTINGS_MAX_CONCURRENT_STREAMS": 100,
                "SETTINGS_MAX_FRAME_SIZE": 16384,
                "SETTINGS_ENABLE_PUSH": 0,
                "SETTINGS_HEADER_TABLE_SIZE": 4096,
                "SETTINGS_MAX_HEADER_LIST_SIZE": -1
            },
            "connFlowIn": 2147483647,
            "sentGoAway": 0,
            "streams": {
                "1": {
                    "state": "HALF_CLOSED_REMOTE",
                    "flowIn": 65535,
                    "dataIn": 0,
                    "dataOut": 0
                }
            },
            "stats": {
                "in": {
                    "requests": 1,
                    "resets": 0,
                },
                "out": {
                    "responses": 0,
                },
                "push": {
                    "cacheDigest": "AQg",
                    "promises": 0,
                    "submits": 0,
                    "resets": 0
                }
            }
        }
Ejemplo n.º 45
0
 def test_005_01(self):
     url = TestEnv.mkurl("https", "cgi", "/.well-known/h2/state")
     r = TestEnv.curl_get(url, 5)
     assert 200 == r["response"]["status"]
     st = r["response"]["json"]
     
     # remove some parts that are very dependant on client/lib versions
     # or connection time etc.
     del st["settings"]["SETTINGS_INITIAL_WINDOW_SIZE"]
     del st["peerSettings"]["SETTINGS_INITIAL_WINDOW_SIZE"]
     del st["streams"]["1"]["created"]
     del st["streams"]["1"]["flowOut"]
     del st["stats"]["in"]["frames"]
     del st["stats"]["in"]["octets"]
     del st["stats"]["out"]["frames"]
     del st["stats"]["out"]["octets"]
     del st["connFlowOut"]
     
     assert st == {
         "version" : "draft-01",
         "settings" : {
             "SETTINGS_MAX_CONCURRENT_STREAMS": 100,
             "SETTINGS_MAX_FRAME_SIZE": 16384,
             "SETTINGS_ENABLE_PUSH": 0
         },
         "peerSettings" : {
             "SETTINGS_MAX_CONCURRENT_STREAMS": 100,
             "SETTINGS_MAX_FRAME_SIZE": 16384,
             "SETTINGS_ENABLE_PUSH": 0,
             "SETTINGS_HEADER_TABLE_SIZE": 4096,
             "SETTINGS_MAX_HEADER_LIST_SIZE": -1
         },
         "connFlowIn": 2147483647,
         "sentGoAway": 0,
         "streams": {
             "1": {
                 "state": "HALF_CLOSED_REMOTE",
                 "flowIn": 65535,
                 "dataIn": 0,
                 "dataOut": 0
             }
         },
         "stats": {
             "in": {
                 "requests": 1,
                 "resets": 0, 
             },
             "out": {
                 "responses": 0,
             },
             "push": {
                 "cacheDigest": "AQg",
                 "promises": 0,
                 "submits": 0,
                 "resets": 0
             }
         }
     }
Ejemplo n.º 46
0
 def test_600_01(self):
     url = TestEnv.mkurl("https", "cgi", "/h2proxy/hello.py")
     r = TestEnv.curl_get(url, 5)
     assert 200 == r["response"]["status"]
     assert "HTTP/2.0" == r["response"]["json"]["protocol"]
     assert "on" == r["response"]["json"]["https"]
     assert "" != r["response"]["json"]["ssl_protocol"]
     assert "on" == r["response"]["json"]["h2"]
     assert "off" == r["response"]["json"]["h2push"]
Ejemplo n.º 47
0
 def test_400_52(self):
     url = TestEnv.mkurl("https", "push", "/006-push.html")
     r = TestEnv.nghttp().get(url, options=[ '-H', 'accept-push-policy: head'])
     assert 200 == r["response"]["status"]
     promises = r["streams"][r["response"]["id"]]["promises"]
     assert 1 == len(promises)
     assert '/006/006.css' == promises[0]["request"]["header"][":path"]
     assert "" == promises[0]["response"]["body"]
     assert 0 == len(promises[0]["response"]["body"])
Ejemplo n.º 48
0
 def test_006_05(self):
     url = TestEnv.mkurl("https", "test1", "/003.html")
     r = TestEnv.nghttp().assets(url, options=[ "--window-bits=24" ])
     assert 0 == r["rv"]
     assert 2 == len(r["assets"])
     assert r["assets"] == [
         { "status": 200, "size": "316", "path": "/003.html" },
         { "status": 200, "size": "88K", "path": "/003/003_img.jpg" }
     ]
Ejemplo n.º 49
0
 def test_006_04(self):
     url = TestEnv.mkurl("https", "test1", "/006.html")
     r = TestEnv.nghttp().assets(url)
     assert 0 == r["rv"]
     assert 3 == len(r["assets"])
     assert r["assets"] == [
         { "status": 200, "size": "543", "path": "/006.html" },
         { "status": 200, "size": "216", "path": "/006/006.css" },
         { "status": 200, "size": "839", "path": "/006/006.js" }
     ]
Ejemplo n.º 50
0
 def test_201_02(self):
     url = TestEnv.mkurl("https", "test1", "/006/006.css")
     r = TestEnv.curl_get(url)
     assert 200 == r["response"]["status"]
     etag = r["response"]["header"]["etag"]
     assert etag
     r = TestEnv.curl_get(url, options=[ "-H", "if-none-match: %s" % etag])
     assert 304 == r["response"]["status"]
     r = TestEnv.curl_get(url, options=[ "-H", "if-none-match: dummy"])
     assert 200 == r["response"]["status"]
Ejemplo n.º 51
0
 def test_201_01(self):
     url = TestEnv.mkurl("https", "test1", "/006/006.css")
     r = TestEnv.curl_get(url)
     assert 200 == r["response"]["status"]
     lm = r["response"]["header"]["last-modified"]
     assert lm
     r = TestEnv.curl_get(url, options=[ "-H", "if-modified-since: %s" % lm])
     assert 304 == r["response"]["status"]
     r = TestEnv.curl_get(url, options=[ "-H", "if-modified-since: Tue, 04 Sep 2010 11:51:59 GMT"])
     assert 200 == r["response"]["status"]
Ejemplo n.º 52
0
 def test_400_31(self):
     url = TestEnv.mkurl("https", "hints", "/006-hints.html")
     r = TestEnv.nghttp().get(url)
     assert 200 == r["response"]["status"]
     promises = r["streams"][r["response"]["id"]]["promises"]
     assert 1 == len(promises)
     early = r["response"]["previous"]
     assert early
     assert 103 == int(early["header"][":status"])
     assert early["header"]["link"]
Ejemplo n.º 53
0
 def test_200_02(self):
     url = TestEnv.mkurl("https", "cgi", "/hecho.py")
     for x in range(1, 32):
         if 9 != x:
             r = TestEnv.curl_post_data(url, "name=x&value=y%%%02x" % x)
             if x in [ 10, 13 ]:
                 assert 0 == r["rv"], "unexpected exit code for char 0x%02x" % x
                 assert 200 == r["response"]["status"], "unexpected status for char 0x%02x" % x
             else:
                 assert 0 != r["rv"], "unexpected exit code for char 0x%02x" % x
Ejemplo n.º 54
0
    def nghttp_post_and_verify(self, fname, options=None):
        url = TestEnv.mkurl("https", "cgi", "/echo.py")
        fpath = os.path.join(TestEnv.GEN_DIR, fname)

        r = TestEnv.nghttp().upload(url, fpath, options=options)
        assert r["rv"] == 0
        assert r["response"]["status"] >= 200 and r["response"]["status"] < 300

        with open(TestEnv.e2e_src( fpath ), mode='rb') as file:
            src = file.read()
        assert src == r["response"]["body"]
Ejemplo n.º 55
0
    def curl_upload_and_verify(self, fname, options=None):
        url = TestEnv.mkurl("https", "cgi", "/upload.py")
        fpath = os.path.join(TestEnv.GEN_DIR, fname)
        r = TestEnv.curl_upload(url, fpath, options=options)
        assert r["rv"] == 0
        assert r["response"]["status"] >= 200 and r["response"]["status"] < 300

        r2 = TestEnv.curl_get( r["response"]["header"]["location"])
        assert r2["rv"] == 0
        assert r2["response"]["status"] == 200 
        with open(TestEnv.e2e_src( fpath ), mode='rb') as file:
            src = file.read()
        assert src == r2["response"]["body"]
Ejemplo n.º 56
0
    def test_400_20(self):
        url = TestEnv.mkurl("https", "push", "/006-push20.html")
        r = TestEnv.nghttp().get(url)
        assert 200 == r["response"]["status"]
        promises = r["streams"][r["response"]["id"]]["promises"]
        assert 2 == len(promises)

        fpath = os.path.join(TestEnv.GEN_DIR, "data-400-20")
        with open(fpath, 'w') as f:
            f.write("test upload data")
        r = TestEnv.nghttp().upload(url, fpath)
        assert 200 == r["response"]["status"]
        promises = r["streams"][r["response"]["id"]]["promises"]
        assert 0 == len(promises)
Ejemplo n.º 57
0
 def test_101_05(self):
     url = TestEnv.mkurl("https", "ssl", "/ssl-client-verify/index.html")
     r = TestEnv.run( [ TestEnv.H2LOAD, "-n", "10", "-c", "1", "-m", "1", "-vvvv", 
         "https://%s:%s/ssl-client-verify/index.html" % (TestEnv.HTTPD_ADDR, TestEnv.HTTPS_PORT)] )
     assert 0 == r["rv"]
     r = TestEnv.h2load_status(r)
     assert 10 == r["h2load"]["requests"]["total"]
     assert 10 == r["h2load"]["requests"]["started"]
     assert 10 == r["h2load"]["requests"]["done"]
     assert 0 == r["h2load"]["requests"]["succeeded"]
     assert 0 == r["h2load"]["status"]["2xx"]
     assert 0 == r["h2load"]["status"]["3xx"]
     assert 0 == r["h2load"]["status"]["4xx"]
     assert 0 == r["h2load"]["status"]["5xx"]
Ejemplo n.º 58
0
    def nghttp_upload_and_verify(self, fname, options=None):
        url = TestEnv.mkurl("https", "cgi", "/proxy/upload.py")
        fpath = os.path.join(TestEnv.GEN_DIR, fname)

        r = TestEnv.nghttp().upload_file(url, fpath, options=options)
        assert r["rv"] == 0
        assert r["response"]["status"] >= 200 and r["response"]["status"] < 300
        assert r["response"]["header"]["location"]

        # why is the scheme wrong?
        r2 = TestEnv.nghttp().get(re.sub(r'http:', 'https:', r["response"]["header"]["location"]))
        assert r2["rv"] == 0
        assert r2["response"]["status"] == 200 
        with open(TestEnv.e2e_src( fpath ), mode='rb') as file:
            src = file.read()
        assert src == r2["response"]["body"]
Ejemplo n.º 59
0
    def test_003_01(self):
        url = TestEnv.mkurl("https", "cgi", "/hello.py")
        r = TestEnv.curl_get(url, 5)
        assert 200 == r["response"]["status"]
        assert "HTTP/2.0" == r["response"]["json"]["protocol"]
        assert "on" == r["response"]["json"]["https"]
        assert "TLSv1.2" == r["response"]["json"]["ssl_protocol"]
        assert "on" == r["response"]["json"]["h2"]
        assert "off" == r["response"]["json"]["h2push"]

        r = TestEnv.curl_get(url, 5, [ "--http1.1" ])
        assert 200 == r["response"]["status"]
        assert "HTTP/1.1" == r["response"]["json"]["protocol"]
        assert "on" == r["response"]["json"]["https"]
        assert "TLSv1.2" == r["response"]["json"]["ssl_protocol"]
        assert "" == r["response"]["json"]["h2"]
        assert "" == r["response"]["json"]["h2push"]