Commit 2753e17d authored by Štěpán Balážik's avatar Štěpán Balážik

pydnstest: make "ADJUST raw_id" work again

Fixes #40.
parent e0520387
Pipeline #46360 failed with stage
in 65 minutes and 22 seconds
......@@ -44,6 +44,13 @@ test:unittests:
script:
- make check
# There are no tests in the repo which use this feature but others do
# and do not want to cause them breakage
test:sanity:raw_id:
<<: *test
script:
- ci/raw_id_check.sh
# changes in Deckard itself must not change result of tests
test:comparative:kresd:
<<: *test
......
#!/usr/bin/python3
import sys
import dns.message
from pydnstest import mock_client
q = dns.message.make_query("anything", "A")
qid = q.id.to_bytes(2, "big", signed=False)
sock = mock_client.setup_socket("1.2.3.4", 53)
mock_client.send_query(sock, q)
a = mock_client.get_answer(sock)
print(qid)
print(a)
if a == qid:
sys.exit(0)
else:
sys.exit(1)
#!/bin/bash
make depend
cat env.sh
source env.sh
export SOCKET_WRAPPER_DIR=/tmp
python3 -m pydnstest.testserver --scenario $(pwd)/tests/deckard_raw_id.rpl &
sleep 1
python3 -m ci.raw_id
\ No newline at end of file
......@@ -111,9 +111,9 @@ class DNSReplyRaw(DNSBlob):
def adjust_reply(
self,
query: dns.message.Message,
copy_id: bool = True
raw_id: bool = True
) -> None:
if copy_id:
if raw_id:
if len(self.wire) < 2:
raise ValueError(
'wire data must contain at least 2 bytes to adjust query id')
......@@ -366,9 +366,9 @@ class Entry:
if 'do_not_answer' in self.adjust_fields:
return None
if self.raw_data is not None:
copy_id = 'raw_data' in self.adjust_fields
raw_id = 'raw_id' in self.adjust_fields
assert self.raw_data is not None
return DNSReplyRaw(self.raw_data, query, copy_id)
return DNSReplyRaw(self.raw_data, query, raw_id)
copy_id = 'copy_id' in self.adjust_fields
copy_query = 'copy_query' in self.adjust_fields
return DNSReply(self.message, query, copy_id, copy_query)
......
stub-addr: 1.2.3.4
CONFIG_END
SCENARIO_BEGIN Sanity check for Deckard's "ADJUST raw_id" option
RANGE_BEGIN 0 100
ADDRESS 1.2.3.4
ENTRY_BEGIN
MATCH opcode
ADJUST raw_id
RAW
0000
ENTRY_END
RANGE_END
STEP 1 TIME_PASSES ELAPSE 1
SCENARIO_END
programs:
- name: raw_id
binary: test_raw_id.py
additional: []
templates: []
configs: []
......@@ -134,4 +134,3 @@ def test_udp_fragmentation_truncated(server):
server,
ALL - {"authority"},
unset_flags=[dns.flags.AD])
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