mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-30 03:14:22 +00:00
http2: simplify test class
This commit is contained in:
parent
e89defe9ad
commit
b611997619
@ -151,8 +151,7 @@ class _Http2TestBase(object):
|
|||||||
wfile.flush()
|
wfile.flush()
|
||||||
|
|
||||||
|
|
||||||
@requires_alpn
|
class _Http2Test(_Http2TestBase, _Http2ServerBase):
|
||||||
class TestSimple(_Http2TestBase, _Http2ServerBase):
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setup_class(self):
|
def setup_class(self):
|
||||||
@ -164,6 +163,10 @@ class TestSimple(_Http2TestBase, _Http2ServerBase):
|
|||||||
_Http2TestBase.teardown_class()
|
_Http2TestBase.teardown_class()
|
||||||
_Http2ServerBase.teardown_class()
|
_Http2ServerBase.teardown_class()
|
||||||
|
|
||||||
|
|
||||||
|
@requires_alpn
|
||||||
|
class TestSimple(_Http2Test):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def handle_server_event(self, event, h2_conn, rfile, wfile):
|
def handle_server_event(self, event, h2_conn, rfile, wfile):
|
||||||
if isinstance(event, h2.events.ConnectionTerminated):
|
if isinstance(event, h2.events.ConnectionTerminated):
|
||||||
@ -196,14 +199,18 @@ class TestSimple(_Http2TestBase, _Http2ServerBase):
|
|||||||
def test_simple(self):
|
def test_simple(self):
|
||||||
client, h2_conn = self._setup_connection()
|
client, h2_conn = self._setup_connection()
|
||||||
|
|
||||||
self._send_request(client.wfile, h2_conn, headers=[
|
self._send_request(
|
||||||
(':authority', "127.0.0.1:%s" % self.server.server.address.port),
|
client.wfile,
|
||||||
(':method', 'GET'),
|
h2_conn,
|
||||||
(':scheme', 'https'),
|
headers=[
|
||||||
(':path', '/'),
|
(':authority', "127.0.0.1:%s" % self.server.server.address.port),
|
||||||
('ClIeNt-FoO', 'client-bar-1'),
|
(':method', 'GET'),
|
||||||
('ClIeNt-FoO', 'client-bar-2'),
|
(':scheme', 'https'),
|
||||||
], body=b'my request body echoed back to me')
|
(':path', '/'),
|
||||||
|
('ClIeNt-FoO', 'client-bar-1'),
|
||||||
|
('ClIeNt-FoO', 'client-bar-2'),
|
||||||
|
],
|
||||||
|
body=b'my request body echoed back to me')
|
||||||
|
|
||||||
done = False
|
done = False
|
||||||
while not done:
|
while not done:
|
||||||
@ -233,19 +240,9 @@ class TestSimple(_Http2TestBase, _Http2ServerBase):
|
|||||||
|
|
||||||
|
|
||||||
@requires_alpn
|
@requires_alpn
|
||||||
class TestWithBodies(_Http2TestBase, _Http2ServerBase):
|
class TestWithBodies(_Http2Test):
|
||||||
tmp_data_buffer_foobar = b''
|
tmp_data_buffer_foobar = b''
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def setup_class(self):
|
|
||||||
_Http2TestBase.setup_class()
|
|
||||||
_Http2ServerBase.setup_class()
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def teardown_class(self):
|
|
||||||
_Http2TestBase.teardown_class()
|
|
||||||
_Http2ServerBase.teardown_class()
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def handle_server_event(self, event, h2_conn, rfile, wfile):
|
def handle_server_event(self, event, h2_conn, rfile, wfile):
|
||||||
if isinstance(event, h2.events.ConnectionTerminated):
|
if isinstance(event, h2.events.ConnectionTerminated):
|
||||||
@ -302,17 +299,7 @@ class TestWithBodies(_Http2TestBase, _Http2ServerBase):
|
|||||||
|
|
||||||
|
|
||||||
@requires_alpn
|
@requires_alpn
|
||||||
class TestPushPromise(_Http2TestBase, _Http2ServerBase):
|
class TestPushPromise(_Http2Test):
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def setup_class(self):
|
|
||||||
_Http2TestBase.setup_class()
|
|
||||||
_Http2ServerBase.setup_class()
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def teardown_class(self):
|
|
||||||
_Http2TestBase.teardown_class()
|
|
||||||
_Http2ServerBase.teardown_class()
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def handle_server_event(self, event, h2_conn, rfile, wfile):
|
def handle_server_event(self, event, h2_conn, rfile, wfile):
|
||||||
@ -465,17 +452,7 @@ class TestPushPromise(_Http2TestBase, _Http2ServerBase):
|
|||||||
|
|
||||||
|
|
||||||
@requires_alpn
|
@requires_alpn
|
||||||
class TestConnectionLost(_Http2TestBase, _Http2ServerBase):
|
class TestConnectionLost(_Http2Test):
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def setup_class(self):
|
|
||||||
_Http2TestBase.setup_class()
|
|
||||||
_Http2ServerBase.setup_class()
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def teardown_class(self):
|
|
||||||
_Http2TestBase.teardown_class()
|
|
||||||
_Http2ServerBase.teardown_class()
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def handle_server_event(self, event, h2_conn, rfile, wfile):
|
def handle_server_event(self, event, h2_conn, rfile, wfile):
|
||||||
@ -517,17 +494,7 @@ class TestConnectionLost(_Http2TestBase, _Http2ServerBase):
|
|||||||
|
|
||||||
|
|
||||||
@requires_alpn
|
@requires_alpn
|
||||||
class TestMaxConcurrentStreams(_Http2TestBase, _Http2ServerBase):
|
class TestMaxConcurrentStreams(_Http2Test):
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def setup_class(self):
|
|
||||||
_Http2TestBase.setup_class()
|
|
||||||
_Http2ServerBase.setup_class(h2_server_settings={h2.settings.MAX_CONCURRENT_STREAMS: 2})
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def teardown_class(self):
|
|
||||||
_Http2TestBase.teardown_class()
|
|
||||||
_Http2ServerBase.teardown_class()
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def handle_server_event(self, event, h2_conn, rfile, wfile):
|
def handle_server_event(self, event, h2_conn, rfile, wfile):
|
||||||
@ -583,17 +550,7 @@ class TestMaxConcurrentStreams(_Http2TestBase, _Http2ServerBase):
|
|||||||
|
|
||||||
|
|
||||||
@requires_alpn
|
@requires_alpn
|
||||||
class TestConnectionTerminated(_Http2TestBase, _Http2ServerBase):
|
class TestConnectionTerminated(_Http2Test):
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def setup_class(self):
|
|
||||||
_Http2TestBase.setup_class()
|
|
||||||
_Http2ServerBase.setup_class()
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def teardown_class(self):
|
|
||||||
_Http2TestBase.teardown_class()
|
|
||||||
_Http2ServerBase.teardown_class()
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def handle_server_event(self, event, h2_conn, rfile, wfile):
|
def handle_server_event(self, event, h2_conn, rfile, wfile):
|
||||||
|
Loading…
Reference in New Issue
Block a user