]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[1462] Changed 'int' serial to 'Serial' object.
authorXie Jiagui <xiejiagui@cnnic.cn>
Fri, 23 Dec 2011 07:40:36 +0000 (15:40 +0800)
committerXie Jiagui <xiejiagui@cnnic.cn>
Fri, 23 Dec 2011 07:40:36 +0000 (15:40 +0800)
src/bin/xfrout/tests/xfrout_test.py.in
src/bin/xfrout/xfrout.py.in

index b509ab341edade3adea527ba0ffca172891dcac0..a4a39dded8700901e3edb8f0157f8c5e10622ab8 100644 (file)
@@ -727,7 +727,7 @@ class TestXfroutSession(TestXfroutSessionBase):
                 self.getmsg(), TEST_ZONE_NAME, TEST_RRCLASS), Rcode.NOERROR())
         self.assertEqual(None, self.xfrsess._iterator)
         self.assertEqual(None, self.xfrsess._jnl_reader)
-
+        
         # The data source doesn't support journaling.  Should fallback to AXFR.
         zone_name = Name('nojournal.example.com')
         self.mdata = self.create_request_data(ixfr=IXFR_OK_VERSION,
@@ -1070,6 +1070,20 @@ class TestXfroutSessionWithSQLite3(TestXfroutSessionBase):
         self.assertEqual(Rcode.NOERROR(), response.get_rcode())
         self.check_axfr_stream(response)
 
+    def test_ixfr_to_axfr(self):
+        self.xfrsess._request_data = \
+             self.create_request_data(ixfr=IXFR_NG_VERSION)
+        XfroutSession._handle(self.xfrsess)
+        response = self.sock.read_msg(Message.PRESERVE_ORDER);
+        self.assertEqual(Rcode.NOERROR(), response.get_rcode())
+        # The SOA serial is greater than that of requested one.
+        # So only the SOA was send.
+        answers = response.get_section(Message.SECTION_ANSWER)
+        self.assertEqual(1, len(answers))
+        self.assertTrue(rrsets_equal(create_soa(SOA_CURRENT_VERSION),
+                                     answers[0]))
+        self.assertEqual(RRType.IXFR(), response.get_question()[0].get_type())
+
     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
@@ -1077,7 +1091,7 @@ class TestXfroutSessionWithSQLite3(TestXfroutSessionBase):
         self.xfrsess._request_data = \
             self.create_request_data(ixfr=IXFR_OK_VERSION)
         XfroutSession._handle(self.xfrsess)
-        response = self.sock.read_msg(Message.PRESERVE_ORDER);
+        response = self.sock.read_msg(Message.PRESERVE_ORDER)
         actual_records = response.get_section(Message.SECTION_ANSWER)
         expected_records = [create_soa(2011112001), create_soa(2011111802),
                             create_soa(2011111900),
index 9aa1887c29878f3699639b7c21d9efc27aeedd18..127c61344dac65fa3c8b20d74129482195f9f237 100755 (executable)
@@ -140,10 +140,9 @@ def get_rrset_len(rrset):
     return len(bytes)
 
 def get_soa_serial(soa_rdata):
-    '''Extract the serial field of an SOA RDATA and returns it as an intger.
-    (borrowed from xfrin)
+    '''Extract the serial field of an SOA RDATA and returns it as an Serial object.
     '''
-    return int(soa_rdata.to_text().split()[2])
+    return Serial(int(soa_rdata.to_text().split()[2]))
 
 class XfroutSession():
     def __init__(self, sock_fd, request_data, server, tsig_key_ring, remote,
@@ -423,11 +422,11 @@ class XfroutSession():
                         format_zone_str(zone_name, zone_class),
                         begin_serial, end_serial)
             return Rcode.NOERROR()
-
+        
         # Set up the journal reader or fall back to AXFR-style IXFR
         try:
             code, self._jnl_reader = self._datasrc_client.get_journal_reader(
-                zone_name, begin_serial, end_serial)
+                zone_name, begin_serial.get_value(), end_serial.get_value())
         except isc.datasrc.NotImplemented as ex:
             # The underlying data source doesn't support journaling.
             # Fall back to AXFR-style IXFR.
@@ -451,7 +450,7 @@ class XfroutSession():
 
         # Use the reader as the iterator to generate the response.
         self._iterator = self._jnl_reader
-
+        
         return Rcode.NOERROR()
 
     def _xfrout_setup(self, request_msg, zone_name, zone_class):