MCPcopy
hub / github.com/mitmproxy/mitmproxy / test_str

Method test_str

test/mitmproxy/test_dns.py:14–69  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

12
13class TestResourceRecord:
14 def test_str(self):
15 assert (
16 str(dns.ResourceRecord.A("test", ipaddress.IPv4Address("1.2.3.4")))
17 == "1.2.3.4"
18 )
19 assert (
20 str(dns.ResourceRecord.AAAA("test", ipaddress.IPv6Address("::1"))) == "::1"
21 )
22 assert (
23 str(dns.ResourceRecord.CNAME("test", "some.other.host"))
24 == "some.other.host"
25 )
26 assert (
27 str(dns.ResourceRecord.PTR("test", "some.other.host")) == "some.other.host"
28 )
29 assert (
30 str(dns.ResourceRecord.TXT("test", "unicode text 😀")) == "unicode text 😀"
31 )
32 params = {
33 0: b"\x00",
34 1: b"\x01",
35 2: b"",
36 3: b"\x02",
37 4: b"\x03",
38 5: b"\x04",
39 6: b"\x05",
40 }
41 record = dns.https_records.HTTPSRecord(1, "example.com", params)
42 assert (
43 str(dns.ResourceRecord.HTTPS("example.com", record))
44 == r"{'target_name': 'example.com', 'priority': 1, 'mandatory': '\\x00', 'alpn': '\\x01', 'no_default_alpn': '', 'port': '\\x02', 'ipv4hint': '\\x03', 'ech': '\\x04', 'ipv6hint': '\\x05'}"
45 )
46 assert (
47 str(
48 dns.ResourceRecord(
49 "test",
50 dns.types.A,
51 dns.classes.IN,
52 dns.ResourceRecord.DEFAULT_TTL,
53 b"",
54 )
55 )
56 == "0x (invalid A data)"
57 )
58 assert (
59 str(
60 dns.ResourceRecord(
61 "test",
62 dns.types.SOA,
63 dns.classes.IN,
64 dns.ResourceRecord.DEFAULT_TTL,
65 b"\x00\x01\x02\x03",
66 )
67 )
68 == "0x00010203"
69 )
70
71 def test_setter(self):

Callers

nothing calls this directly

Calls 6

AMethod · 0.80
AAAAMethod · 0.80
CNAMEMethod · 0.80
PTRMethod · 0.80
TXTMethod · 0.80
HTTPSMethod · 0.80

Tested by

no test coverage detected