summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/scripting/python/samba/provision.py6
-rw-r--r--source4/scripting/python/samba/tests/samdb.py14
2 files changed, 15 insertions, 5 deletions
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
index d77b487512..10daf1b2b9 100644
--- a/source4/scripting/python/samba/provision.py
+++ b/source4/scripting/python/samba/provision.py
@@ -454,7 +454,7 @@ def setup_samdb_partitions(samdb_path, setup_path, message, lp, session_info,
credentials=credentials, lp=lp)
# Wipes the database
samdb.erase()
- except:
+ except LdbError:
os.unlink(samdb_path)
samdb = SamDB(samdb_path, session_info=session_info,
credentials=credentials, lp=lp)
@@ -647,7 +647,7 @@ def setup_templatesdb(path, setup_path, session_info, credentials, lp):
# Wipes the database
try:
templates_ldb.erase()
- except:
+ except LdbError:
os.unlink(path)
templates_ldb.load_ldif_file_add(setup_path("provision_templates_init.ldif"))
@@ -1222,7 +1222,7 @@ def provision_backend(setup_dir=None, message=None,
schemadb_path = os.path.join(paths.ldapdir, "schema-tmp.ldb")
try:
os.unlink(schemadb_path)
- except:
+ except OSError:
pass
schemadb = Ldb(schemadb_path, lp=lp)
diff --git a/source4/scripting/python/samba/tests/samdb.py b/source4/scripting/python/samba/tests/samdb.py
index 434d7a71f2..d0b95cf542 100644
--- a/source4/scripting/python/samba/tests/samdb.py
+++ b/source4/scripting/python/samba/tests/samdb.py
@@ -21,13 +21,19 @@ from samba.credentials import Credentials
import os
from samba.provision import setup_samdb, guess_names, setup_templatesdb, make_smbconf, find_setup_dir
from samba.samdb import SamDB
-from samba.tests import cmdline_loadparm, TestCaseInTempDir
+from samba.tests import TestCaseInTempDir
from samba.dcerpc import security
from unittest import TestCase
import uuid
from samba import param
+
class SamDBTestCase(TestCaseInTempDir):
+ """Base-class for tests with a Sam Database.
+
+ This is used by the Samba SamDB-tests, but e.g. also by the OpenChange
+ provisioning tests (which need a Sam).
+ """
def setup_path(self, relpath):
return os.path.join(find_setup_dir(), relpath)
@@ -69,7 +75,7 @@ class SamDBTestCase(TestCaseInTempDir):
self.setup_path, session_info=session_info,
credentials=creds, lp=self.lp)
self.samdb = setup_samdb(path, self.setup_path, session_info, creds,
- cmdline_loadparm, names,
+ self.lp, names,
lambda x: None, domainsid,
"# no aci", domainguid,
policyguid, False, "secret",
@@ -82,6 +88,10 @@ class SamDBTestCase(TestCaseInTempDir):
os.remove(os.path.join(self.tempdir, f))
super(SamDBTestCase, self).tearDown()
+
+class SamDBTests(SamDBTestCase):
+ """Tests for the SamDB implementation."""
+
def test_add_foreign(self):
self.samdb.add_foreign(self.domaindn, "S-1-5-7", "Somedescription")