diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/http/http1/test_read.py | 12 | ||||
-rw-r--r-- | test/http/http2/test_protocol.py | 20 | ||||
-rw-r--r-- | test/http/test_models.py | 8 |
3 files changed, 22 insertions, 18 deletions
diff --git a/test/http/http1/test_read.py b/test/http/http1/test_read.py index 5e6680af..55def2a5 100644 --- a/test/http/http1/test_read.py +++ b/test/http/http1/test_read.py @@ -108,14 +108,14 @@ class TestReadBody(object): def test_connection_close(): headers = Headers() - assert connection_close((1, 0), headers) - assert not connection_close((1, 1), headers) + assert connection_close(b"HTTP/1.0", headers) + assert not connection_close(b"HTTP/1.1", headers) headers["connection"] = "keep-alive" - assert not connection_close((1, 1), headers) + assert not connection_close(b"HTTP/1.1", headers) headers["connection"] = "close" - assert connection_close((1, 1), headers) + assert connection_close(b"HTTP/1.1", headers) def test_expected_http_body_size(): @@ -281,6 +281,10 @@ class TestReadHeaders(object): with raises(HttpSyntaxException): self._read(data) + def test_read_empty_name(self): + data = b":foo" + with raises(HttpSyntaxException): + self._read(data) def test_read_chunked(): req = treq(body=None) diff --git a/test/http/http2/test_protocol.py b/test/http/http2/test_protocol.py index 789b6e63..a369eb49 100644 --- a/test/http/http2/test_protocol.py +++ b/test/http/http2/test_protocol.py @@ -64,7 +64,7 @@ class TestProtocol: class TestCheckALPNMatch(tservers.ServerTestBase): handler = EchoHandler ssl = dict( - alpn_select=HTTP2Protocol.ALPN_PROTO_H2, + alpn_select=ALPN_PROTO_H2, ) if OpenSSL._util.lib.Cryptography_HAS_ALPN: @@ -72,7 +72,7 @@ class TestCheckALPNMatch(tservers.ServerTestBase): def test_check_alpn(self): c = tcp.TCPClient(("127.0.0.1", self.port)) c.connect() - c.convert_to_ssl(alpn_protos=[HTTP2Protocol.ALPN_PROTO_H2]) + c.convert_to_ssl(alpn_protos=[ALPN_PROTO_H2]) protocol = HTTP2Protocol(c) assert protocol.check_alpn() @@ -88,7 +88,7 @@ class TestCheckALPNMismatch(tservers.ServerTestBase): def test_check_alpn(self): c = tcp.TCPClient(("127.0.0.1", self.port)) c.connect() - c.convert_to_ssl(alpn_protos=[HTTP2Protocol.ALPN_PROTO_H2]) + c.convert_to_ssl(alpn_protos=[ALPN_PROTO_H2]) protocol = HTTP2Protocol(c) tutils.raises(NotImplementedError, protocol.check_alpn) @@ -306,7 +306,7 @@ class TestReadRequest(tservers.ServerTestBase): protocol = HTTP2Protocol(c, is_server=True) protocol.connection_preface_performed = True - req = protocol.read_request() + req = protocol.read_request(NotImplemented) assert req.stream_id assert req.headers.fields == [[':method', 'GET'], [':path', '/'], [':scheme', 'https']] @@ -329,7 +329,7 @@ class TestReadRequestRelative(tservers.ServerTestBase): protocol = HTTP2Protocol(c, is_server=True) protocol.connection_preface_performed = True - req = protocol.read_request() + req = protocol.read_request(NotImplemented) assert req.form_in == "relative" assert req.method == "OPTIONS" @@ -352,7 +352,7 @@ class TestReadRequestAbsolute(tservers.ServerTestBase): protocol = HTTP2Protocol(c, is_server=True) protocol.connection_preface_performed = True - req = protocol.read_request() + req = protocol.read_request(NotImplemented) assert req.form_in == "absolute" assert req.scheme == "http" @@ -378,13 +378,13 @@ class TestReadRequestConnect(tservers.ServerTestBase): protocol = HTTP2Protocol(c, is_server=True) protocol.connection_preface_performed = True - req = protocol.read_request() + req = protocol.read_request(NotImplemented) assert req.form_in == "authority" assert req.method == "CONNECT" assert req.host == "address" assert req.port == 22 - req = protocol.read_request() + req = protocol.read_request(NotImplemented) assert req.form_in == "authority" assert req.method == "CONNECT" assert req.host == "example.com" @@ -410,7 +410,7 @@ class TestReadResponse(tservers.ServerTestBase): protocol = HTTP2Protocol(c) protocol.connection_preface_performed = True - resp = protocol.read_response(stream_id=42) + resp = protocol.read_response(NotImplemented, stream_id=42) assert resp.httpversion == (2, 0) assert resp.status_code == 200 @@ -436,7 +436,7 @@ class TestReadEmptyResponse(tservers.ServerTestBase): protocol = HTTP2Protocol(c) protocol.connection_preface_performed = True - resp = protocol.read_response(stream_id=42) + resp = protocol.read_response(NotImplemented, stream_id=42) assert resp.stream_id == 42 assert resp.httpversion == (2, 0) diff --git a/test/http/test_models.py b/test/http/test_models.py index 0f4dcc3b..8fce2e9d 100644 --- a/test/http/test_models.py +++ b/test/http/test_models.py @@ -20,7 +20,7 @@ class TestRequest(object): 'host', 'port', 'path', - (1, 1), + b"HTTP/1.1", 'foobar', ) @@ -31,7 +31,7 @@ class TestRequest(object): 'host', 'port', 'path', - (1, 1), + b"HTTP/1.1", ) assert isinstance(req.headers, Headers) @@ -307,13 +307,13 @@ class TestRequest(object): class TestResponse(object): def test_headers(self): tutils.raises(AssertionError, Response, - (1, 1), + b"HTTP/1.1", 200, headers='foobar', ) resp = Response( - (1, 1), + b"HTTP/1.1", 200, ) assert isinstance(resp.headers, Headers) |