summaryrefslogtreecommitdiff
path: root/source4/dsdb/tests/python/acl.py
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2014-11-01 20:06:52 -0700
committerJelmer Vernooij <jelmer@samba.org>2014-11-19 18:30:07 +0100
commit1800bc567d56d0c193410a83692185ebbbce7f43 (patch)
treebaf6b51218f19a84ce00c355d6c359286b5d5951 /source4/dsdb/tests/python/acl.py
parentd8177912be179dc4342118827ce439048df43ef9 (diff)
downloadsamba-1800bc567d56d0c193410a83692185ebbbce7f43.tar.gz
dsdb.tests.acl: Create and run a single testsuite, should easy migration to regulary Python unit tests.
Change-Id: I89072d3af1d90e87a47c197d28943f47cedc5deb Signed-off-by: Jelmer Vernooij <jelmer@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4/dsdb/tests/python/acl.py')
-rwxr-xr-xsource4/dsdb/tests/python/acl.py77
1 files changed, 43 insertions, 34 deletions
diff --git a/source4/dsdb/tests/python/acl.py b/source4/dsdb/tests/python/acl.py
index a8c3b127da3..7ef9ad9e4e6 100755
--- a/source4/dsdb/tests/python/acl.py
+++ b/source4/dsdb/tests/python/acl.py
@@ -67,12 +67,12 @@ class AclTests(samba.tests.TestCase):
def setUp(self):
super(AclTests, self).setUp()
- self.ldb_admin = ldb
- self.base_dn = ldb.domain_dn()
- self.domain_sid = security.dom_sid(ldb.get_domain_sid())
+ self.ldb_admin = SamDB(ldaphost, credentials=creds, session_info=system_session(lp), lp=lp)
+ self.base_dn = self.ldb_admin.domain_dn()
+ self.domain_sid = security.dom_sid(self.ldb_admin.get_domain_sid())
self.user_pass = "samba123@"
self.configuration_dn = self.ldb_admin.get_config_basedn().get_linearized()
- self.sd_utils = sd_utils.SDUtils(ldb)
+ self.sd_utils = sd_utils.SDUtils(self.ldb_admin)
#used for anonymous login
self.creds_tmp = Credentials()
self.creds_tmp.set_username("")
@@ -620,6 +620,19 @@ class AclSearchTests(AclTests):
def setUp(self):
super(AclSearchTests, self).setUp()
+ # Get the old "dSHeuristics" if it was set
+ dsheuristics = self.ldb_admin.get_dsheuristics()
+ # Reset the "dSHeuristics" as they were before
+ self.addCleanup(self.ldb_admin.set_dsheuristics, dsheuristics)
+ # Set the "dSHeuristics" to activate the correct "userPassword" behaviour
+ self.ldb_admin.set_dsheuristics("000000001")
+ # Get the old "minPwdAge"
+ minPwdAge = self.ldb_admin.get_minPwdAge()
+ # Reset the "minPwdAge" as it was before
+ self.addCleanup(self.ldb_admin.set_minPwdAge, minPwdAge)
+ # Set it temporarely to "0"
+ self.ldb_admin.set_minPwdAge("0")
+
self.u1 = "search_u1"
self.u2 = "search_u2"
self.u3 = "search_u3"
@@ -1281,6 +1294,20 @@ class AclCARTests(AclTests):
def setUp(self):
super(AclCARTests, self).setUp()
+
+ # Get the old "dSHeuristics" if it was set
+ dsheuristics = self.ldb_admin.get_dsheuristics()
+ # Reset the "dSHeuristics" as they were before
+ self.addCleanup(self.ldb_admin.set_dsheuristics, dsheuristics)
+ # Set the "dSHeuristics" to activate the correct "userPassword" behaviour
+ self.ldb_admin.set_dsheuristics("000000001")
+ # Get the old "minPwdAge"
+ minPwdAge = self.ldb_admin.get_minPwdAge()
+ # Reset the "minPwdAge" as it was before
+ self.addCleanup(self.ldb_admin.set_minPwdAge, minPwdAge)
+ # Set it temporarely to "0"
+ self.ldb_admin.set_minPwdAge("0")
+
self.user_with_wp = "acl_car_user1"
self.user_with_pc = "acl_car_user2"
self.ldb_admin.newuser(self.user_with_wp, self.user_pass)
@@ -1876,35 +1903,17 @@ class AclSPNTests(AclTests):
ldb = SamDB(ldaphost, credentials=creds, session_info=system_session(lp), lp=lp)
runner = SubunitTestRunner()
-rc = 0
-if not runner.run(unittest.makeSuite(AclAddTests)).wasSuccessful():
- rc = 1
-if not runner.run(unittest.makeSuite(AclModifyTests)).wasSuccessful():
- rc = 1
-if not runner.run(unittest.makeSuite(AclDeleteTests)).wasSuccessful():
- rc = 1
-if not runner.run(unittest.makeSuite(AclRenameTests)).wasSuccessful():
- rc = 1
-
-# Get the old "dSHeuristics" if it was set
-dsheuristics = ldb.get_dsheuristics()
-# Set the "dSHeuristics" to activate the correct "userPassword" behaviour
-ldb.set_dsheuristics("000000001")
-# Get the old "minPwdAge"
-minPwdAge = ldb.get_minPwdAge()
-# Set it temporarely to "0"
-ldb.set_minPwdAge("0")
-if not runner.run(unittest.makeSuite(AclCARTests)).wasSuccessful():
- rc = 1
-if not runner.run(unittest.makeSuite(AclSearchTests)).wasSuccessful():
- rc = 1
-# Reset the "dSHeuristics" as they were before
-ldb.set_dsheuristics(dsheuristics)
-# Reset the "minPwdAge" as it was before
-ldb.set_minPwdAge(minPwdAge)
-
-if not runner.run(unittest.makeSuite(AclExtendedTests)).wasSuccessful():
- rc = 1
-if not runner.run(unittest.makeSuite(AclSPNTests)).wasSuccessful():
+suite = unittest.TestSuite()
+suite.addTests(unittest.makeSuite(AclAddTests))
+suite.addTests(unittest.makeSuite(AclModifyTests))
+suite.addTests(unittest.makeSuite(AclDeleteTests))
+suite.addTests(unittest.makeSuite(AclRenameTests))
+suite.addTests(unittest.makeSuite(AclCARTests))
+suite.addTests(unittest.makeSuite(AclSearchTests))
+suite.addTests(unittest.makeSuite(AclExtendedTests))
+suite.addTests(unittest.makeSuite(AclSPNTests))
+if not runner.run(suite).wasSuccessful():
rc = 1
+else:
+ rc = 0
sys.exit(rc)