s4: Add unit test for increment_calculated_keyversion_number
authorMatthieu Patou <mat@matws.net>
Tue, 15 Jun 2010 08:54:05 +0000 (12:54 +0400)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 15 Jul 2010 12:08:21 +0000 (22:08 +1000)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
source4/scripting/python/samba/tests/upgradeprovisionneeddc.py

index b32ffc6155da3e8f7004d19d8ad5d67d8a73932c..e30906fc6b0ad4d9f00990004f71fcf7bf937709 100644 (file)
@@ -29,7 +29,8 @@ from samba.upgradehelpers import (get_paths, get_ldbs,
                                  find_provision_key_parameters, identic_rename,
                                  updateOEMInfo, getOEMInfo, update_gpo,
                                  delta_update_basesamdb,
-                                 search_constructed_attrs_stored)
+                                 search_constructed_attrs_stored,
+                                 increment_calculated_keyversion_number)
 from samba.tests import env_loadparm, TestCaseInTempDir
 from samba.tests.provision import create_dummy_secretsdb
 import ldb
@@ -91,6 +92,29 @@ class UpgradeProvisionWithLdbTestCase(TestCaseInTempDir):
                                                   ["msds-KeyVersionNumber"])
         self.assertFalse(hashAtt.has_key("msds-KeyVersionNumber"))
 
+    def test_increment_calculated_keyversion_number(self):
+        dn = "CN=Administrator,CN=Users,%s" % self.names.rootdn
+        # We conctruct a simple hash for the user administrator
+        hash = {}
+        # And we want the version to be 140
+        hash[dn.lower()] = 140
+
+        increment_calculated_keyversion_number(self.ldbs.sam,
+                                               self.names.rootdn,
+                                               hash)
+        self.assertEqual(self.ldbs.sam.get_attribute_replmetadata_version(dn,
+                            "unicodePwd"),
+                            140)
+        # This function should not decrement the version
+        hash[dn.lower()] = 130
+
+        increment_calculated_keyversion_number(self.ldbs.sam,
+                                               self.names.rootdn,
+                                               hash)
+        self.assertEqual(self.ldbs.sam.get_attribute_replmetadata_version(dn,
+                            "unicodePwd"),
+                            140)
+
     def test_identic_rename(self):
         rootdn = "DC=samba,DC=example,DC=com"