From: Tomas Krizek Date: Mon, 12 Nov 2018 16:56:19 +0000 (+0100) Subject: pytests: import test_ignore_garbage (test10) X-Git-Tag: v3.2.0~18^2~56 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=eb461c40c68a54d62d30ffa21d8ea31c8d114a7a;p=thirdparty%2Fknot-resolver.git pytests: import test_ignore_garbage (test10) --- diff --git a/tests/pytests/test_conn_mgmt.py b/tests/pytests/test_conn_mgmt.py new file mode 100644 index 000000000..c88aabdd4 --- /dev/null +++ b/tests/pytests/test_conn_mgmt.py @@ -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