]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
pytests: import test_prefix_longer_than_message (test3)
authorTomas Krizek <tomas.krizek@nic.cz>
Mon, 12 Nov 2018 18:28:50 +0000 (19:28 +0100)
committerTomas Krizek <tomas.krizek@nic.cz>
Tue, 4 Dec 2018 16:13:42 +0000 (17:13 +0100)
tests/pytests/test_conn_mgmt.py

index 814513617d16038fd68557ddbc2f4b74ad45b503..d8827ef9500b2166a1e8208b54e61cce50d951eb 100644 (file)
@@ -67,3 +67,26 @@ def test_prefix_shorter_than_header(kresd_sock):
             time.sleep(1)
     else:
         assert False, "kresd didn't close connection"
+
+
+def test_prefix_longer_than_message(kresd_sock):
+    """
+    Test prefixes message by the value, which is greater then the length of the
+    whole message and sequentially sends it over TCP connection.
+
+    Expected: TCP connection must be closed after net.tcp_in_idle milliseconds
+    """
+    msg = dns.message.make_query('localhost.', dns.rdatatype.A, dns.rdataclass.IN)
+    data = msg.to_wire()
+    datalen = len(data) + 16
+    buf = struct.pack("!H", datalen) + data
+
+    for _ in range(15):
+        try:
+            kresd_sock.sendall(buf)
+        except BrokenPipeError:
+            break
+        else:
+            time.sleep(1)
+    else:
+        assert False, "kresd didn't close the connection"