pytests: import test_prefix_shorter_than_header (test1)

parent 9638d51c
"""TCP Connection Management tests""" """TCP Connection Management tests"""
import struct
import time
import dns import dns
import dns.message import dns.message
...@@ -41,3 +43,27 @@ def test_pipelining(kresd_sock): ...@@ -41,3 +43,27 @@ def test_pipelining(kresd_sock):
msg_answer = utils.receive_parse_answer(kresd_sock) msg_answer = utils.receive_parse_answer(kresd_sock)
assert == MSG_ID_SECOND assert == MSG_ID_SECOND
def test_prefix_shorter_than_header(kresd_sock):
Test prefixes message by the value, which is less then the length of the DNS
message header and sequentially sends it over TCP connection. (RFC1035 4.2.2)
Expected: TCP connection must be closed after `net.tcp_in_idle` milliseconds.
(by default, after about 10s after connection is established)
msg = dns.message.make_query('localhost.', dns.rdatatype.A, dns.rdataclass.IN)
data = msg.to_wire()
datalen = 11 # DNS Header size minus 1
buf = struct.pack("!H", datalen) + data
for _ in range(15):
except BrokenPipeError:
assert False, "kresd didn't close connection"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment