mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-30 03:14:22 +00:00
websocket: test killable
This commit is contained in:
parent
f123fb600d
commit
a35716a3a7
@ -3,6 +3,7 @@ import pytest
|
|||||||
|
|
||||||
from mitmproxy.io import tnetstring
|
from mitmproxy.io import tnetstring
|
||||||
from mitmproxy import flowfilter
|
from mitmproxy import flowfilter
|
||||||
|
from mitmproxy.exceptions import Kill, ControlException
|
||||||
from mitmproxy.test import tflow
|
from mitmproxy.test import tflow
|
||||||
|
|
||||||
|
|
||||||
@ -42,6 +43,20 @@ class TestWebSocketFlow:
|
|||||||
assert f.error.get_state() == f2.error.get_state()
|
assert f.error.get_state() == f2.error.get_state()
|
||||||
assert f.error is not f2.error
|
assert f.error is not f2.error
|
||||||
|
|
||||||
|
def test_kill(self):
|
||||||
|
f = tflow.twebsocketflow()
|
||||||
|
with pytest.raises(ControlException):
|
||||||
|
f.intercept()
|
||||||
|
f.resume()
|
||||||
|
f.kill()
|
||||||
|
|
||||||
|
f = tflow.twebsocketflow()
|
||||||
|
f.intercept()
|
||||||
|
assert f.killable
|
||||||
|
f.kill()
|
||||||
|
assert not f.killable
|
||||||
|
assert f.reply.value == Kill
|
||||||
|
|
||||||
def test_match(self):
|
def test_match(self):
|
||||||
f = tflow.twebsocketflow()
|
f = tflow.twebsocketflow()
|
||||||
assert not flowfilter.match("~b nonexistent", f)
|
assert not flowfilter.match("~b nonexistent", f)
|
||||||
|
Loading…
Reference in New Issue
Block a user