(tctx, transport_protocol)
| 103 | |
| 104 | @pytest.mark.parametrize("transport_protocol", ["tcp", "udp"]) |
| 105 | def test_regular_mode_no_hook(tctx, transport_protocol): |
| 106 | tctx.client.transport_protocol = transport_protocol |
| 107 | tctx.server.transport_protocol = transport_protocol |
| 108 | |
| 109 | f = Placeholder(DNSFlow) |
| 110 | layer = dns.DNSLayer(tctx) |
| 111 | layer.context.server.address = None |
| 112 | |
| 113 | req = tdnsreq() |
| 114 | |
| 115 | def no_resolve(flow: DNSFlow): |
| 116 | nonlocal req |
| 117 | assert flow.request |
| 118 | req.timestamp = flow.request.timestamp |
| 119 | assert flow.request == req |
| 120 | |
| 121 | assert ( |
| 122 | Playbook(layer) |
| 123 | >> DataReceived( |
| 124 | tctx.client, dns.pack_message(req, tctx.client.transport_protocol) |
| 125 | ) |
| 126 | << dns.DnsRequestHook(f) |
| 127 | >> reply(side_effect=no_resolve) |
| 128 | << dns.DnsErrorHook(f) |
| 129 | >> reply() |
| 130 | << SendData( |
| 131 | tctx.client, |
| 132 | dns.pack_message( |
| 133 | req.fail(response_codes.SERVFAIL), tctx.client.transport_protocol |
| 134 | ), |
| 135 | ) |
| 136 | >> ConnectionClosed(tctx.client) |
| 137 | << None |
| 138 | ) |
| 139 | assert f().request == req |
| 140 | assert not f().response |
| 141 | assert not f().live |
| 142 | assert ( |
| 143 | f().error.msg == "No hook has set a response and there is no upstream server." |
| 144 | ) |
| 145 | |
| 146 | |
| 147 | @pytest.mark.parametrize("transport_protocol", ["tcp", "udp"]) |
nothing calls this directly
no test coverage detected
searching dependent graphs…