|
@@ -38,7 +38,7 @@ TEST_ZONE_NAME = Name(TEST_ZONE_NAME_STR)
|
|
|
TEST_RRCLASS = RRClass.IN()
|
|
|
IXFR_OK_VERSION = 2011111802
|
|
|
IXFR_NG_VERSION = 2011112800
|
|
|
-SOA_CURRENT_VERSION = 2011111802
|
|
|
+SOA_CURRENT_VERSION = 2011112001
|
|
|
|
|
|
# Shortcut functions to create RRsets commonly used in tests below.
|
|
|
def create_a(address, ttl=3600):
|
|
@@ -851,11 +851,20 @@ class TestXfroutSession(TestXfroutSessionBase):
|
|
|
self.assertEqual(0, len(self.sock.sendqueue))
|
|
|
|
|
|
def test_reply_xfrout_query_ixfr(self):
|
|
|
- self.xfrsess._soa = self.soa_rrset
|
|
|
- self.xfrsess._iterator = [self.soa_rrset]
|
|
|
+ # Creating an pure (incremental) IXFR response. Intermediate SOA
|
|
|
+ # RRs won't be skipped.
|
|
|
+ self.xfrsess._soa = create_soa(SOA_CURRENT_VERSION)
|
|
|
+ self.xfrsess._iterator = [create_soa(IXFR_OK_VERSION),
|
|
|
+ create_a('192.0.2.2'),
|
|
|
+ create_soa(SOA_CURRENT_VERSION),
|
|
|
+ create_aaaa('2001:db8::1')]
|
|
|
+ self.xfrsess._jnl_reader = self.xfrsess._iterator
|
|
|
self.xfrsess._reply_xfrout_query(self.getmsg(), self.sock)
|
|
|
- reply_msg = self.sock.read_msg()
|
|
|
- self.assertEqual(reply_msg.get_rr_count(Message.SECTION_ANSWER), 2)
|
|
|
+ reply_msg = self.sock.read_msg(Message.PRESERVE_ORDER)
|
|
|
+ # The answer section should contain everything in the "fake"
|
|
|
+ # iterator and two SOAs.
|
|
|
+ self.assertEqual(reply_msg.get_rr_count(Message.SECTION_ANSWER),
|
|
|
+ len(self.xfrsess._iterator) + 2)
|
|
|
|
|
|
class TestXfroutSessionWithSQLite3(TestXfroutSessionBase):
|
|
|
'''Tests for XFR-out sessions using an SQLite3 DB.
|
|
@@ -913,6 +922,26 @@ class TestXfroutSessionWithSQLite3(TestXfroutSessionBase):
|
|
|
self.assertEqual(RRType.IXFR(), response.get_question()[0].get_type())
|
|
|
self.check_axfr_stream(response)
|
|
|
|
|
|
+ def test_ixfr_normal_session(self):
|
|
|
+ # See testdata/creatediff.py. There are 8 changes between two
|
|
|
+ # versions. So the answer section should contain all of these and
|
|
|
+ # two beginning and trailing SOAs.
|
|
|
+ self.xfrsess._request_data = \
|
|
|
+ self.create_request_data(ixfr=IXFR_OK_VERSION)
|
|
|
+ XfroutSession._handle(self.xfrsess)
|
|
|
+ response = self.sock.read_msg(Message.PRESERVE_ORDER);
|
|
|
+ actual_records = response.get_section(Message.SECTION_ANSWER)
|
|
|
+ self.assertEqual(10, len(actual_records))
|
|
|
+ # The first and last RRs must be SOA whose serial is the latest one.
|
|
|
+ soa = actual_records[0]
|
|
|
+ self.assertEqual(RRType.SOA(), soa.get_type())
|
|
|
+ self.assertEqual(SOA_CURRENT_VERSION,
|
|
|
+ xfrout.get_soa_serial(soa.get_rdata()[0]))
|
|
|
+ soa = actual_records[-1]
|
|
|
+ self.assertEqual(RRType.SOA(), soa.get_type())
|
|
|
+ self.assertEqual(SOA_CURRENT_VERSION,
|
|
|
+ xfrout.get_soa_serial(soa.get_rdata()[0]))
|
|
|
+
|
|
|
class MyUnixSockServer(UnixSockServer):
|
|
|
def __init__(self):
|
|
|
self._shutdown_event = threading.Event()
|