MCPcopy Create free account
hub / github.com/mitmproxy/mitmproxy / test_inject_fail

Function test_inject_fail

test/mitmproxy/addons/test_proxyserver.py:166–186  ·  view source on GitHub ↗
(caplog)

Source from the content-addressed store, hash-verified

164
165
166async def test_inject_fail(caplog) -> None:
167 ps = Proxyserver()
168 ps.inject_websocket(tflow.tflow(), True, b"test")
169 assert "Cannot inject WebSocket messages into non-WebSocket flows." in caplog.text
170 ps.inject_tcp(tflow.tflow(), True, b"test")
171 assert "Cannot inject TCP messages into non-TCP flows." in caplog.text
172 ps.inject_tcp(tflow.ttcpflow(), True, b"test")
173 assert "Flow is not from a live connection." in caplog.text
174
175 ps.inject_udp(tflow.tflow(), True, b"test")
176 assert "Cannot inject UDP messages into non-UDP flows." in caplog.text
177 ps.inject_udp(tflow.tudpflow(), True, b"test")
178 assert "Flow is not from a live connection." in caplog.text
179
180 ps.inject_websocket(tflow.twebsocketflow(), True, b"test")
181 assert "Flow is not from a live connection." in caplog.text
182 ps.inject_websocket(tflow.ttcpflow(), True, b"test")
183 assert "Cannot inject WebSocket messages into non-WebSocket flows" in caplog.text
184
185 # str must not reach inject_event (issue #5808).
186 ps.inject_websocket("@focus", True, b"test") # type: ignore[arg-type]
187
188
189async def test_warn_no_nextlayer(caplog):

Callers

nothing calls this directly

Calls 4

inject_websocketMethod · 0.95
inject_tcpMethod · 0.95
inject_udpMethod · 0.95
ProxyserverClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…