MCPcopy
hub / github.com/mitmproxy/mitmproxy / test_simple

Function test_simple

test/mitmproxy/addons/test_intercept.py:9–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7
8
9async def test_simple():
10 r = intercept.Intercept()
11 with taddons.context(r) as tctx:
12 assert not r.filt
13 tctx.configure(r, intercept="~q")
14 assert r.filt
15 assert tctx.options.intercept_active
16 with pytest.raises(exceptions.OptionsError):
17 tctx.configure(r, intercept="~~")
18 tctx.configure(r, intercept=None)
19 assert not r.filt
20 assert not tctx.options.intercept_active
21
22 tctx.configure(r, intercept="~s")
23
24 f = tflow.tflow(resp=True)
25 await tctx.cycle(r, f)
26 assert f.intercepted
27
28 f = tflow.tflow(resp=False)
29 await tctx.cycle(r, f)
30 assert not f.intercepted
31
32 f = tflow.tflow(resp=True)
33 r.response(f)
34 assert f.intercepted
35
36 tctx.configure(r, intercept_active=False)
37 f = tflow.tflow(resp=True)
38 await tctx.cycle(r, f)
39 assert not f.intercepted
40
41 tctx.configure(r, intercept_active=True)
42 f = tflow.tflow(resp=True)
43 await tctx.cycle(r, f)
44 assert f.intercepted
45
46
47async def test_dns():

Callers

nothing calls this directly

Calls 4

responseMethod · 0.95
contextMethod · 0.80
configureMethod · 0.45
cycleMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…