]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
pytests: import test_ignore_garbage (test10)
authorTomas Krizek <tomas.krizek@nic.cz>
Mon, 12 Nov 2018 16:56:19 +0000 (17:56 +0100)
committerTomas Krizek <tomas.krizek@nic.cz>
Tue, 4 Dec 2018 16:13:42 +0000 (17:13 +0100)
tests/pytests/test_conn_mgmt.py [new file with mode: 0644]

diff --git a/tests/pytests/test_conn_mgmt.py b/tests/pytests/test_conn_mgmt.py
new file mode 100644 (file)
index 0000000..c88aabd
--- /dev/null
@@ -0,0 +1,25 @@
+"""TCP Connection Management tests"""
+
+import dns
+import dns.message
+
+import utils
+
+
+def test_ignore_garbage(kresd_sock):
+    """
+    Send chunk of garbage, correctly prefixed by garbage length. Then, send
+    correct DNS query.
+
+    Expected: garbage must be ignored and the second query must be answered
+    """
+    MSG_ID = 1
+
+    msg = utils.get_msgbuf('localhost.', dns.rdatatype.A, MSG_ID)
+    garbage = utils.get_prefixed_garbage(1024)
+    buf = garbage + msg
+
+    kresd_sock.sendall(buf)
+    msg_answer = utils.receive_parse_answer(kresd_sock)
+
+    assert msg_answer.id == MSG_ID