BIND 10 trac1455, updated. f621147e9399d1b8199dbe4be92e83f356c066b3 [1455] make shallow copy of to-be-modified list

BIND 10 source code commits bind10-changes at lists.isc.org
Thu May 24 07:43:16 UTC 2012


The branch, trac1455 has been updated
       via  f621147e9399d1b8199dbe4be92e83f356c066b3 (commit)
       via  b9a9623ae1ef39893ff245d7a89e4083626ee714 (commit)
       via  35ad857d5fa798fd632958e0ee8a2150f002a0a1 (commit)
      from  d8f2ae1c3e671294f01e737edc71bc78eb0e7d1f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit f621147e9399d1b8199dbe4be92e83f356c066b3
Author: Jelte Jansen <jelte at isc.org>
Date:   Thu May 24 09:42:54 2012 +0200

    [1455] make shallow copy of to-be-modified list

commit b9a9623ae1ef39893ff245d7a89e4083626ee714
Author: Jelte Jansen <jelte at isc.org>
Date:   Wed May 23 17:45:26 2012 +0200

    [1455] arg, whitespace

commit 35ad857d5fa798fd632958e0ee8a2150f002a0a1
Author: Jelte Jansen <jelte at isc.org>
Date:   Wed May 23 17:42:29 2012 +0200

    [1455] use the correct RRClass in the tests

-----------------------------------------------------------------------

Summary of changes:
 src/lib/python/isc/ddns/session.py             |    6 ++-
 src/lib/python/isc/ddns/tests/session_tests.py |   64 ++++++++++++++----------
 2 files changed, 42 insertions(+), 28 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/python/isc/ddns/session.py b/src/lib/python/isc/ddns/session.py
index 50549da..5374790 100644
--- a/src/lib/python/isc/ddns/session.py
+++ b/src/lib/python/isc/ddns/session.py
@@ -19,6 +19,7 @@ from isc.log import *
 from isc.ddns.logger import logger, ClientFormatter, ZoneFormatter,\
                             RRsetFormatter
 from isc.log_messages.libddns_messages import *
+import copy
 
 # Result codes for UpdateSession.handle()
 UPDATE_SUCCESS = 0
@@ -220,7 +221,10 @@ class UpdateSession:
             # We need to match all actual RRs, unfortunately there is no
             # direct order-independent comparison for rrsets, so this
             # a slightly inefficient way to handle that.
-            found_rdata = found_rrset.get_rdata()
+
+            # shallow copy of the rdata list, so we are sure that this
+            # loop does not mess with actual data.
+            found_rdata = copy.copy(found_rrset.get_rdata())
             for rdata in rrset.get_rdata():
                 if rdata in found_rdata:
                     found_rdata.remove(rdata)
diff --git a/src/lib/python/isc/ddns/tests/session_tests.py b/src/lib/python/isc/ddns/tests/session_tests.py
index 9dcbf37..e5b85d7 100644
--- a/src/lib/python/isc/ddns/tests/session_tests.py
+++ b/src/lib/python/isc/ddns/tests/session_tests.py
@@ -156,91 +156,96 @@ class SessionTest(unittest.TestCase):
            Function does not do much but makes the code look nicer'''
         self.assertEqual(expected, method(self.__datasrc_client, rrset))
 
-    def __check_prerequisite_exists_combined(self, method, expected):
+    def __check_prerequisite_exists_combined(self, method, rrclass, expected):
         '''shared code for the checks for the very similar (but reversed
            in behaviour) methods __prereq_rrset_exists and
            __prereq_rrset_does_not_exist.
+           For rrset_exists, rrclass should be ANY, for rrset_does_not_exist,
+           it should be NONE.
         '''
-
         # Basic existence checks
         # www.example.org should have an A, but not an MX
         rrset = isc.dns.RRset(isc.dns.Name("www.example.org"),
-                              isc.dns.RRClass.IN(), isc.dns.RRType.A(),
+                              rrclass, isc.dns.RRType.A(),
                               isc.dns.RRTTL(0))
         self.__prereq_helper(method, expected, rrset)
         rrset = isc.dns.RRset(isc.dns.Name("www.example.org"),
-                              isc.dns.RRClass.IN(), isc.dns.RRType.MX(),
+                              rrclass, isc.dns.RRType.MX(),
                               isc.dns.RRTTL(0))
         self.__prereq_helper(method, not expected, rrset)
 
         # example.org should have an MX, but not an A
         rrset = isc.dns.RRset(isc.dns.Name("example.org"),
-                              isc.dns.RRClass.IN(), isc.dns.RRType.MX(),
+                              rrclass, isc.dns.RRType.MX(),
                               isc.dns.RRTTL(0))
         self.__prereq_helper(method, expected, rrset)
         rrset = isc.dns.RRset(isc.dns.Name("example.org"),
-                              isc.dns.RRClass.IN(), isc.dns.RRType.A(),
+                              rrclass, isc.dns.RRType.A(),
                               isc.dns.RRTTL(0))
         self.__prereq_helper(method, not expected, rrset)
 
         # Also check the case where the name does not even exist
         rrset = isc.dns.RRset(isc.dns.Name("doesnotexist.example.org"),
-                              isc.dns.RRClass.IN(), isc.dns.RRType.A(),
+                              rrclass, isc.dns.RRType.A(),
                               isc.dns.RRTTL(0))
         self.__prereq_helper(method, not expected, rrset)
 
         # Wildcard expansion should not be applied, but literal matches
         # should work
         rrset = isc.dns.RRset(isc.dns.Name("foo.wildcard.example.org"),
-                              isc.dns.RRClass.IN(), isc.dns.RRType.A(),
+                              rrclass, isc.dns.RRType.A(),
                               isc.dns.RRTTL(0))
         self.__prereq_helper(method, not expected, rrset)
 
         rrset = isc.dns.RRset(isc.dns.Name("*.wildcard.example.org"),
-                              isc.dns.RRClass.IN(), isc.dns.RRType.A(),
+                              rrclass, isc.dns.RRType.A(),
                               isc.dns.RRTTL(0))
         self.__prereq_helper(method, expected, rrset)
 
         # Likewise, CNAME directly should match, but what it points to should
         # not
         rrset = isc.dns.RRset(isc.dns.Name("cname.example.org"),
-                              isc.dns.RRClass.IN(), isc.dns.RRType.A(),
+                              rrclass, isc.dns.RRType.A(),
                               isc.dns.RRTTL(0))
         self.__prereq_helper(method, not expected, rrset)
 
         rrset = isc.dns.RRset(isc.dns.Name("cname.example.org"),
-                              isc.dns.RRClass.IN(), isc.dns.RRType.CNAME(),
+                              rrclass, isc.dns.RRType.CNAME(),
                               isc.dns.RRTTL(0))
         self.__prereq_helper(method, expected, rrset)
 
         # And also make sure a delegation (itself) is not treated as existing
         # data
         rrset = isc.dns.RRset(isc.dns.Name("foo.sub.example.org"),
-                              isc.dns.RRClass.IN(), isc.dns.RRType.A(),
+                              rrclass, isc.dns.RRType.A(),
                               isc.dns.RRTTL(0))
         self.__prereq_helper(method, not expected, rrset)
         # But the delegation data itself should match
         rrset = isc.dns.RRset(isc.dns.Name("sub.example.org"),
-                              isc.dns.RRClass.IN(), isc.dns.RRType.NS(),
+                              rrclass, isc.dns.RRType.NS(),
                               isc.dns.RRTTL(0))
         self.__prereq_helper(method, expected, rrset)
         # As should glue
         rrset = isc.dns.RRset(isc.dns.Name("ns.sub.example.org"),
-                              isc.dns.RRClass.IN(), isc.dns.RRType.A(),
+                              rrclass, isc.dns.RRType.A(),
                               isc.dns.RRTTL(0))
         self.__prereq_helper(method, expected, rrset)
 
     def test_check_prerequisite_exists(self):
         method = self.__session._UpdateSession__prereq_rrset_exists
-        self.__check_prerequisite_exists_combined(method, True)
+        self.__check_prerequisite_exists_combined(method,
+                                                  isc.dns.RRClass.ANY(),
+                                                  True)
 
     def test_check_prerequisite_does_not_exist(self):
         method = self.__session._UpdateSession__prereq_rrset_does_not_exist
-        self.__check_prerequisite_exists_combined(method, False)
+        self.__check_prerequisite_exists_combined(method,
+                                                  isc.dns.RRClass.NONE(),
+                                                  False)
 
     def test_check_prerequisite_exists_value(self):
         method = self.__session._UpdateSession__prereq_rrset_exists_value
-        
+
         rrset = isc.dns.RRset(isc.dns.Name("www.example.org"),
                               isc.dns.RRClass.IN(), isc.dns.RRType.A(),
                               isc.dns.RRTTL(0))
@@ -312,53 +317,58 @@ class SessionTest(unittest.TestCase):
                                       "192.0.2.1"))
         self.__prereq_helper(method, False, rrset)
 
-    def __check_prerequisite_name_in_use_combined(self, method, expected):
+    def __check_prerequisite_name_in_use_combined(self, method, rrclass,
+                                                  expected):
         '''shared code for the checks for the very similar (but reversed
            in behaviour) methods __prereq_name_in_use and
            __prereq_name_not_in_use
         '''
         rrset = isc.dns.RRset(isc.dns.Name("example.org"),
-                              isc.dns.RRClass.NONE(), isc.dns.RRType.ANY(),
+                              rrclass, isc.dns.RRType.ANY(),
                               isc.dns.RRTTL(0))
         self.__prereq_helper(method, expected, rrset)
 
         rrset = isc.dns.RRset(isc.dns.Name("www.example.org"),
-                              isc.dns.RRClass.NONE(), isc.dns.RRType.ANY(),
+                              rrclass, isc.dns.RRType.ANY(),
                               isc.dns.RRTTL(0))
         self.__prereq_helper(method, expected, rrset)
 
         rrset = isc.dns.RRset(isc.dns.Name("doesnotexist.example.org"),
-                              isc.dns.RRClass.NONE(), isc.dns.RRType.ANY(),
+                              rrclass, isc.dns.RRType.ANY(),
                               isc.dns.RRTTL(0))
         self.__prereq_helper(method, not expected, rrset)
 
         rrset = isc.dns.RRset(isc.dns.Name("belowdelegation.sub.example.org"),
-                              isc.dns.RRClass.NONE(), isc.dns.RRType.ANY(),
+                              rrclass, isc.dns.RRType.ANY(),
                               isc.dns.RRTTL(0))
         self.__prereq_helper(method, not expected, rrset)
 
         rrset = isc.dns.RRset(isc.dns.Name("foo.wildcard.example.org"),
-                              isc.dns.RRClass.NONE(), isc.dns.RRType.ANY(),
+                              rrclass, isc.dns.RRType.ANY(),
                               isc.dns.RRTTL(0))
         self.__prereq_helper(method, not expected, rrset)
 
         # empty nonterminal should not match
         rrset = isc.dns.RRset(isc.dns.Name("nonterminal.example.org"),
-                              isc.dns.RRClass.NONE(), isc.dns.RRType.ANY(),
+                              rrclass, isc.dns.RRType.ANY(),
                               isc.dns.RRTTL(0))
         self.__prereq_helper(method, not expected, rrset)
         rrset = isc.dns.RRset(isc.dns.Name("empty.nonterminal.example.org"),
-                              isc.dns.RRClass.NONE(), isc.dns.RRType.ANY(),
+                              rrclass, isc.dns.RRType.ANY(),
                               isc.dns.RRTTL(0))
         self.__prereq_helper(method, expected, rrset)
 
     def test_check_prerequisite_name_in_use(self):
         method = self.__session._UpdateSession__prereq_name_in_use
-        self.__check_prerequisite_name_in_use_combined(method, True)
+        self.__check_prerequisite_name_in_use_combined(method,
+                                                       isc.dns.RRClass.ANY(),
+                                                       True)
 
     def test_check_prerequisite_name_not_in_use(self):
         method = self.__session._UpdateSession__prereq_name_not_in_use
-        self.__check_prerequisite_name_in_use_combined(method, False)
+        self.__check_prerequisite_name_in_use_combined(method,
+                                                       isc.dns.RRClass.NONE(),
+                                                       False)
 
     def check_prerequisite_result(self, expected, prerequisites):
         '''Helper method for checking the result of a prerequisite check;



More information about the bind10-changes mailing list