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

Function test_cut

test/mitmproxy/addons/test_cut.py:161–193  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

159
160
161def test_cut():
162 c = cut.Cut()
163 with taddons.context():
164 tflows = [tflow.tflow(resp=True)]
165 assert c.cut(tflows, ["request.method"]) == [["GET"]]
166 assert c.cut(tflows, ["request.scheme"]) == [["http"]]
167 assert c.cut(tflows, ["request.host"]) == [["address"]]
168 assert c.cut(tflows, ["request.port"]) == [["22"]]
169 assert c.cut(tflows, ["request.path"]) == [["/path"]]
170 assert c.cut(tflows, ["request.url"]) == [["http://address:22/path"]]
171 assert c.cut(tflows, ["request.content"]) == [[b"content"]]
172 assert c.cut(tflows, ["request.header[header]"]) == [["qvalue"]]
173 assert c.cut(tflows, ["request.header[unknown]"]) == [[""]]
174
175 assert c.cut(tflows, ["response.status_code"]) == [["200"]]
176 assert c.cut(tflows, ["response.reason"]) == [["OK"]]
177 assert c.cut(tflows, ["response.content"]) == [[b"message"]]
178 assert c.cut(tflows, ["response.header[header-response]"]) == [["svalue"]]
179 assert c.cut(tflows, ["moo"]) == [[""]]
180 with pytest.raises(exceptions.CommandError):
181 assert c.cut(tflows, ["__dict__"]) == [[""]]
182
183 with taddons.context():
184 tflows = [tflow.tflow(resp=False)]
185 assert c.cut(tflows, ["response.reason"]) == [[""]]
186 assert c.cut(tflows, ["response.header[key]"]) == [[""]]
187
188 for f in (tflow.ttcpflow(), tflow.tudpflow()):
189 c = cut.Cut()
190 with taddons.context():
191 tflows = [f]
192 assert c.cut(tflows, ["request.method"]) == [[""]]
193 assert c.cut(tflows, ["response.status"]) == [[""]]

Callers

nothing calls this directly

Calls 2

cutMethod · 0.95
contextMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…