selftest: Make create_test_ou() return a ldb.Dn
authorAndrew Bartlett <abartlet@samba.org>
Thu, 24 May 2018 08:28:13 +0000 (20:28 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 30 May 2018 02:23:28 +0000 (04:23 +0200)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
python/samba/tests/__init__.py
source4/dsdb/tests/python/password_settings.py
source4/torture/drs/python/getncchanges.py

index 61036b5247dc594b0df7c4283747bceda5e4db58..7061f8b3d149e00b05b7590e235bcb28a18e5552 100644 (file)
@@ -485,6 +485,6 @@ def create_test_ou(samdb, name):
     # objects can be slow to replicate out. So the OU created by a previous
     # testenv may still exist at the point that tests start on another testenv.
     rand = randint(1, 10000000)
-    dn = "OU=%s%d,%s" %(name, rand, samdb.get_default_basedn())
+    dn = ldb.Dn(samdb, "OU=%s%d,%s" %(name, rand, samdb.get_default_basedn()))
     samdb.add({ "dn": dn, "objectclass": "organizationalUnit"})
     return dn
index 71ab74e63230b8d161e7d3f3bfde2c63a935bccd..d072a8fa165eb140e27f43ebae06ef7b07d86cb5 100644 (file)
@@ -92,7 +92,7 @@ class PasswordSettingsTestCase(PasswordTestCase):
 
     def add_user(self, username):
         # add a new user to the DB under our top-level OU
-        userou = self.ou.split(',')[0]
+        userou = "ou=%s" % self.ou.get_component_value(0)
         return TestUser(username, self.ldb, userou=userou)
 
     def assert_password_invalid(self, user, password):
@@ -577,7 +577,7 @@ class PasswordSettingsTestCase(PasswordTestCase):
 
         # you can apply a PSO to other objects (like OUs), but the resultantPSO
         # attribute should only be returned for users
-        dummy_pso.apply_to(self.ou)
+        dummy_pso.apply_to(str(self.ou))
         res = self.ldb.search(self.ou, attrs=['msDS-ResultantPSO'])
         self.assertFalse('msDS-ResultantPSO' in res[0])
 
index d545fe07e584b0f20d6e8446fa7ed32e6b72d4db..9136d076e7bbd2e625e5c9f4a1736a656de70def 100644 (file)
@@ -46,7 +46,8 @@ class DrsReplicaSyncIntegrityTestCase(drs_base.DrsBaseTestCase):
         # the vampire_dc), so we point this test directly at that DC
         self.set_test_ldb_dc(self.ldb_dc2)
 
-        self.ou = samba.tests.create_test_ou(self.test_ldb_dc, "getncchanges")
+        self.ou = str(samba.tests.create_test_ou(self.test_ldb_dc,
+                                                 "getncchanges"))
         self.base_dn = self.test_ldb_dc.get_default_basedn()
 
         self.default_conn = DcConnection(self, self.ldb_dc2, self.dnsname_dc2)