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

Method test_from_json

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

Source from the content-addressed store, hash-verified

130 assert DNSMessage.from_json(resp.to_json()) == resp
131
132 def test_from_json(self):
133 assert DNSMessage.from_json(
134 {
135 **tutils.tdnsresp().to_json(),
136 "answers": [
137 {
138 "name": "dns.google",
139 "type": "A",
140 "class": "IN",
141 "ttl": 32,
142 "data": "8.8.8.8",
143 },
144 {
145 "name": "dns.google",
146 "type": "AAAA",
147 "class": "IN",
148 "ttl": 32,
149 "data": "::1",
150 },
151 {
152 "name": "dns.google",
153 "type": "CNAME",
154 "class": "IN",
155 "ttl": 32,
156 "data": "alias.google",
157 },
158 {
159 "name": "dns.google",
160 "type": "TXT",
161 "class": "IN",
162 "ttl": 32,
163 "data": "random text",
164 },
165 {
166 "name": "dns.google",
167 "type": "HTTPS",
168 "class": "IN",
169 "ttl": 32,
170 "data": {
171 "target_name": "dns.google",
172 "priority": 42,
173 },
174 },
175 {
176 "name": "dns.google",
177 "type": "TYPE(42)",
178 "class": "IN",
179 "ttl": 32,
180 "data": "0xffff",
181 },
182 ],
183 }
184 )
185
186 def test_responses(self):
187 req = tutils.tdnsreq()

Callers

nothing calls this directly

Calls 2

from_jsonMethod · 0.45
to_jsonMethod · 0.45

Tested by

no test coverage detected