s4-test-delete_object.py: Use common implementation for connect_samdb()
authorKamen Mazdrashki <kamenim@samba.org>
Wed, 29 Sep 2010 00:00:18 +0000 (03:00 +0300)
committerKamen Mazdrashki <kamenim@samba.org>
Sat, 2 Oct 2010 22:24:56 +0000 (01:24 +0300)
Connections are restricted to LDAP only (remote),
as this test can't be run against local LDBs

source4/torture/drs/python/delete_object.py

index 09126dcd01177f8de5a215d02f506144d5fe8312..fb944456bc0e7864f7a7d38048933a35f5e3fcc9 100644 (file)
@@ -54,10 +54,10 @@ class DrsDeleteObjectTestCase(samba.tests.TestCase):
         # connect to DCs singleton
         if self.ldb_dc1 is None:
             DrsDeleteObjectTestCase.dc1 = get_env_var("DC1")
-            DrsDeleteObjectTestCase.ldb_dc1 = connect_samdb(self.dc1)
+            DrsDeleteObjectTestCase.ldb_dc1 = samba.tests.connect_samdb(self.dc1, ldap_only=True)
         if self.ldb_dc2 is None:
             DrsDeleteObjectTestCase.dc2 = get_env_var("DC2")
-            DrsDeleteObjectTestCase.ldb_dc2 = connect_samdb(self.dc2)
+            DrsDeleteObjectTestCase.ldb_dc2 = samba.tests.connect_samdb(self.dc2, ldap_only=True)
 
         # fetch rootDSEs
         if self.info_dc1 is None:
@@ -215,21 +215,3 @@ def get_env_var(var_name):
     if not var_name in os.environ.keys():
         raise AssertionError("Please supply %s in environment" % var_name)
     return os.environ[var_name]
-
-def connect_samdb(samdb_url):
-    ldb_options = []
-    if not "://" in samdb_url:
-        if os.path.isfile(samdb_url):
-            samdb_url = "tdb://%s" % samdb_url
-        else:
-            samdb_url = "ldap://%s" % samdb_url
-    # use 'paged_search' module when connecting remotely
-    if samdb_url.lower().startswith("ldap://"):
-        ldb_options = ["modules:paged_searches"]
-
-    return SamDB(url=samdb_url,
-                 lp=samba.tests.env_loadparm(),
-                 session_info=system_session(),
-                 credentials=samba.tests.cmdline_credentials,
-                 options=ldb_options)
-