MCPcopy Index your code
hub / github.com/mitmproxy/mitmproxy / test_extract

Function test_extract

test/mitmproxy/addons/test_cut.py:14–58  ·  view source on GitHub ↗
(tdata)

Source from the content-addressed store, hash-verified

12
13
14def test_extract(tdata):
15 tf = tflow.tflow(resp=True)
16 tests = [
17 ["request.method", "GET"],
18 ["request.scheme", "http"],
19 ["request.host", "address"],
20 ["request.http_version", "HTTP/1.1"],
21 ["request.port", "22"],
22 ["request.path", "/path"],
23 ["request.url", "http://address:22/path"],
24 ["request.text", "content"],
25 ["request.content", b"content"],
26 ["request.raw_content", b"content"],
27 ["request.timestamp_start", "946681200"],
28 ["request.timestamp_end", "946681201"],
29 ["request.header[header]", "qvalue"],
30 ["response.status_code", "200"],
31 ["response.reason", "OK"],
32 ["response.text", "message"],
33 ["response.content", b"message"],
34 ["response.raw_content", b"message"],
35 ["response.header[header-response]", "svalue"],
36 ["response.timestamp_start", "946681202"],
37 ["response.timestamp_end", "946681203"],
38 ["client_conn.peername.port", "22"],
39 ["client_conn.peername.host", "127.0.0.1"],
40 ["client_conn.tls_version", "TLSv1.2"],
41 ["client_conn.sni", "address"],
42 ["client_conn.tls_established", "true"],
43 ["server_conn.address.port", "22"],
44 ["server_conn.address.host", "address"],
45 ["server_conn.peername.host", "192.168.0.1"],
46 ["server_conn.tls_version", "TLSv1.2"],
47 ["server_conn.sni", "address"],
48 ["server_conn.tls_established", "true"],
49 ]
50 for spec, expected in tests:
51 ret = cut.extract(spec, tf)
52 assert spec and ret == expected
53
54 with open(tdata.path("mitmproxy/net/data/text_cert"), "rb") as f:
55 d = f.read()
56 c1 = certs.Cert.from_pem(d)
57 tf.server_conn.certificate_list = [c1]
58 assert "CERTIFICATE" in cut.extract("server_conn.certificate_list", tf)
59
60
61def test_extract_websocket():

Callers

nothing calls this directly

Calls 3

from_pemMethod · 0.80
pathMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…