mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
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>
This commit is contained in:
parent
d8177912be
commit
1800bc567d
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user