mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 18:18:25 +00:00
websocket: add flow kill test
This commit is contained in:
parent
43c74ff1ef
commit
59c277effd
@ -221,6 +221,25 @@ class TestSimple(_WebSocketTest):
|
|||||||
assert frame.payload == b'foo'
|
assert frame.payload == b'foo'
|
||||||
|
|
||||||
|
|
||||||
|
class TestKillFlow(_WebSocketTest):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def handle_websockets(cls, rfile, wfile):
|
||||||
|
wfile.write(bytes(websockets.Frame(fin=1, opcode=websockets.OPCODE.TEXT, payload=b'server-foobar')))
|
||||||
|
wfile.flush()
|
||||||
|
|
||||||
|
def test_kill(self):
|
||||||
|
class KillFlow:
|
||||||
|
def websocket_message(self, f):
|
||||||
|
f.kill()
|
||||||
|
|
||||||
|
self.master.addons.add(KillFlow())
|
||||||
|
self.setup_connection()
|
||||||
|
|
||||||
|
frame = websockets.Frame.from_file(self.client.rfile)
|
||||||
|
assert frame.payload == b'foo'
|
||||||
|
|
||||||
|
|
||||||
class TestSimpleTLS(_WebSocketTest):
|
class TestSimpleTLS(_WebSocketTest):
|
||||||
ssl = True
|
ssl = True
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user