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
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
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"]
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"]
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"]
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"]
def test_003_30(self, path): url = TestEnv.mkurl("https", "test1", path) r = TestEnv.curl_get(url, 5) assert 200 == r["response"]["status"] assert "HTTP/2" == r["response"]["protocol"] h = r["response"]["header"] assert "last-modified" in h lastmod = h["last-modified"] r = TestEnv.curl_get(url, 5, [ '-H', ("if-modified-since: %s" % lastmod) ]) assert 304 == r["response"]["status"]
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"]
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"]
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"]
def test_200_13(self): url = TestEnv.mkurl("https", "cgi", "/") opt = [] for i in range( 98): # curl sends 2 headers itself (user-agent and accept) opt += ["-H", "x{0}: 1".format(i)] r = TestEnv.curl_get(url, options=opt) assert 200 == r["response"]["status"] r = TestEnv.curl_get(url, options=(opt + ["-H", "y: 2"])) assert 431 == r["response"]["status"]
def test_003_31(self, path): url = TestEnv.mkurl("https", "test1", path) r = TestEnv.curl_get(url, 5) assert 200 == r["response"]["status"] assert "HTTP/2" == r["response"]["protocol"] h = r["response"]["header"] assert "etag" in h etag = h["etag"] r = TestEnv.curl_get(url, 5, [ '-H', ("if-none-match: %s" % etag) ]) assert 304 == r["response"]["status"]
def test_200_10(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) # LimitRequestLine 8190 ok, one more char -> 431 r = TestEnv.curl_get(url, options=["-H", "x: %s" % (val[:8187])]) assert 200 == r["response"]["status"] r = TestEnv.curl_get(url, options=["-H", "x: %sx" % (val[:8188])]) assert 431 == r["response"]["status"]
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"]
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"]
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"]
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"]
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"]
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"]
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"])
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"]
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"]
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"]
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"]
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"])
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"]
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"]
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"]
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"]
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"]
def test_201_03(self): url = TestEnv.mkurl("https", "test1", "/006.html") r = TestEnv.curl_get(url, options=[ "-H", "Accept-Encoding: gzip"]) assert 200 == r["response"]["status"] for h in r["response"]["header"]: print("%s: %s" % (h, r["response"]["header"][h])) lm = r["response"]["header"]["last-modified"] assert lm assert "gzip" == r["response"]["header"]["content-encoding"] assert "Accept-Encoding" in r["response"]["header"]["vary"] r = TestEnv.curl_get(url, options=[ "-H", "if-modified-since: %s" % lm, "-H", "Accept-Encoding: gzip"]) assert 304 == r["response"]["status"] for h in r["response"]["header"]: print("%s: %s" % (h, r["response"]["header"][h])) assert "vary" in r["response"]["header"]
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"]
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"]
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"]
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"]
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 } } }
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 } } }
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"]
def test_500_01(self): url = TestEnv.mkurl("https", "cgi", "/proxy/hello.py") r = TestEnv.curl_get(url, 5) assert 200 == r["response"]["status"] assert "HTTP/1.1" == r["response"]["json"]["protocol"] assert "" == r["response"]["json"]["https"] assert "" == r["response"]["json"]["ssl_protocol"] assert "" == r["response"]["json"]["h2"] assert "" == r["response"]["json"]["h2push"]
def test_003_40(self): n = 1001 while n <= 1025024: url = TestEnv.mkurl("https", "cgi", "/mnot164.py?count=%d&text=X" % (n)) r = TestEnv.curl_get(url, 5) assert 200 == r["response"]["status"] assert "HTTP/2" == r["response"]["protocol"] assert n == len(r["response"]["body"]) n *= 2
def test_003_50(self, path): # check that the resource supports ranges and we see its raw content-length url = TestEnv.mkurl("https", "test1", path) r = TestEnv.curl_get(url, 5) assert 200 == r["response"]["status"] assert "HTTP/2" == r["response"]["protocol"] h = r["response"]["header"] assert "accept-ranges" in h assert "bytes" == h["accept-ranges"] assert "content-length" in h clen = h["content-length"] # get the first 1024 bytes of the resource, 206 status, but content-length as original r = TestEnv.curl_get(url, 5, options=[ "-H", "range: bytes=0-1023"]) assert 206 == r["response"]["status"] assert "HTTP/2" == r["response"]["protocol"] assert 1024 == len(r["response"]["body"]) assert "content-length" in h assert clen == h["content-length"]
def test_004_30(self): # issue: #203 resource = "data-1k" full_length = 1000 chunk = 200 self.curl_upload_and_verify(resource, ["-v", "--http2"]) logfile = os.path.join(TestEnv.HTTPD_LOGS_DIR, "test_004_30") if os.path.isfile(logfile): os.remove(logfile) HttpdConf().add_line(""" LogFormat "{ \\"request\\": \\"%r\\", \\"status\\": %>s, \\"bytes_resp_B\\": %B, \\"bytes_tx_O\\": %O, \\"bytes_rx_I\\": %I, \\"bytes_rx_tx_S\\": %S }" issue_203 CustomLog logs/test_004_30 issue_203 """).add_vhost_cgi().install() assert TestEnv.apache_restart() == 0 url = TestEnv.mkurl("https", "cgi", "/files/{0}".format(resource)) r = TestEnv.curl_get(url, 5, ["--http2"]) assert 200 == r["response"]["status"] r = TestEnv.curl_get( url, 5, ["--http1.1", "-H", "Range: bytes=0-{0}".format(chunk - 1)]) assert 206 == r["response"]["status"] assert chunk == len(r["response"]["body"].decode('utf-8')) r = TestEnv.curl_get( url, 5, ["--http2", "-H", "Range: bytes=0-{0}".format(chunk - 1)]) assert 206 == r["response"]["status"] assert chunk == len(r["response"]["body"].decode('utf-8')) # now check what response lengths have actually been reported lines = open(logfile).readlines() log_h2_full = json.loads(lines[-3]) log_h1 = json.loads(lines[-2]) log_h2 = json.loads(lines[-1]) assert log_h2_full['bytes_rx_I'] > 0 assert log_h2_full['bytes_resp_B'] == full_length assert log_h2_full['bytes_tx_O'] > full_length assert log_h1['bytes_rx_I'] > 0 # input bytes recieved assert log_h1['bytes_resp_B'] == chunk # response bytes sent (payload) assert log_h1['bytes_tx_O'] > chunk # output bytes sent assert log_h2['bytes_rx_I'] > 0 assert log_h2['bytes_resp_B'] == chunk assert log_h2['bytes_tx_O'] > chunk
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"]
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"]
def curl_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.curl_upload(url, fpath, options=options) assert r["rv"] == 0 assert 200 <= r["response"]["status"] < 300 # why is the scheme wrong? r2 = TestEnv.curl_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"]
def test_003_20(self): url = TestEnv.mkurl("https", "test1", "/006/") r = TestEnv.curl_get(url, 5) assert 200 == r["response"]["status"] assert '''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <html> <head> <title>Index of /006</title> </head> <body> <title>My Header Title</title> <ul><li><a href="/"> Parent Directory</a></li> <li><a href="006.css"> 006.css</a></li> <li><a href="006.js"> 006.js</a></li> <li><a href="header.html"> header.html</a></li> </ul> </body></html> ''' == r["response"]["body"]
def test_002_04(self): url = TestEnv.mkurl("https", "test1", "/alive.json") r = TestEnv.curl_get(url, 5, [ "--http2" ]) assert 200 == r["response"]["status"] assert "HTTP/2" == r["response"]["protocol"]
def test_103_04(self): url = TestEnv.mkurl("https", "noh2", "/index.html") r = TestEnv.curl_get(url) assert 0 == r["rv"] assert "response" in r assert not "upgrade" in r["response"]["header"]
def test_100_05(self): url = TestEnv.mkurl("https", "cgi", "/hello.py") hostname = ("unknown.%s" % TestEnv.HTTP_TLD) r = TestEnv.curl_get(url, 5, [ "-H", "Host:%s" % hostname ]) assert 421 == r["response"]["status"]
def test_002_05(self): url = TestEnv.mkurl("https", "test1", "/alive.json") r = TestEnv.curl_get(url, 5, [ "--no-alpn" ]) assert 200 == r["response"]["status"] assert "HTTP/1.1" == r["response"]["protocol"] assert "test1" == r["response"]["json"]["host"]
def test_001_02(self): r = TestEnv.curl_get(TestEnv.HTTPS_URL + "/alive.json", 5) assert r["rv"] == 0 assert r["response"]["json"] assert True == r["response"]["json"]["alive"] assert "generic" == r["response"]["json"]["host"]
def test_101_10b(self): url = TestEnv.mkurl("https", "ssl", "/requiressl/index.html") r = TestEnv.curl_get( url ) assert 0 == r["rv"] assert "response" in r assert 404 == r["response"]["status"]
def test_101_01(self): url = TestEnv.mkurl("https", "ssl", "/renegotiate/cipher/") r = TestEnv.curl_get( url, options=[ "-v", "--http1.1" ] ) assert 0 == r["rv"] assert "response" in r assert 403 == r["response"]["status"]
def test_101_03(self): url = TestEnv.mkurl("https", "ssl", "/renegotiate/verify/") r = TestEnv.curl_get( url, options=[ "-vvv" ] ) assert 0 != r["rv"] assert not "response" in r assert re.search(r'HTTP_1_1_REQUIRED \(err 13\)', r["out"]["err"])
def test_101_04(self): url = TestEnv.mkurl("https", "ssl", "/ssl-client-verify/index.html") r = TestEnv.curl_get( url, options=[ "-vvv" ] ) assert 0 != r["rv"] assert not "response" in r assert re.search(r'HTTP_1_1_REQUIRED \(err 13\)', r["out"]["err"])
def test_102_02(self): url = TestEnv.mkurl("https", "ssl", "/noh2.html") r = TestEnv.curl_get( url ) assert 0 == r["rv"] assert "response" in r assert 403 == r["response"]["status"]