3 # Unix SMB/CIFS implementation.
4 # Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007-2008
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 from samba.provision import setup_secretsdb, findnss
23 from samba.tests import env_loadparm, TestCase
27 return os.path.join(setup_dir, file)
30 def create_dummy_secretsdb(path, lp=None):
31 """Create a dummy secrets database for use in tests.
33 :param path: Path to store the secrets db
34 :param lp: Optional loadparm context. A simple one will
35 be generated if not specified.
39 secrets_ldb = setup_secretsdb(path, setup_path, None, None, lp=lp)
40 secrets_ldb.transaction_commit()
44 class ProvisionTestCase(samba.tests.TestCaseInTempDir):
45 """Some simple tests for individual functions in the provisioning code.
48 def test_setup_secretsdb(self):
49 path = os.path.join(self.tempdir, "secrets.ldb")
50 ldb = setup_secretsdb(path, setup_path, None, None, lp=env_loadparm())
52 self.assertEquals("LSA Secrets",
53 ldb.searchone(basedn="CN=LSA Secrets", attribute="CN"))
59 class FindNssTests(TestCase):
60 """Test findnss() function."""
62 def test_nothing(self):
65 self.assertRaises(KeyError, findnss, x, [])
68 self.assertEquals("bla", findnss(lambda x: "bla", ["bla"]))
70 def test_skip_first(self):
75 self.assertEquals("ha", findnss(x, ["bloe", "bla"]))
78 class Disabled(object):
80 def test_setup_templatesdb(self):
81 raise NotImplementedError(self.test_setup_templatesdb)
83 def test_setup_registry(self):
84 raise NotImplementedError(self.test_setup_registry)
86 def test_setup_samdb_rootdse(self):
87 raise NotImplementedError(self.test_setup_samdb_rootdse)
89 def test_setup_samdb_partitions(self):
90 raise NotImplementedError(self.test_setup_samdb_partitions)
92 def test_create_phpldapadmin_config(self):
93 raise NotImplementedError(self.test_create_phpldapadmin_config)
95 def test_provision_dns(self):
96 raise NotImplementedError(self.test_provision_dns)
98 def test_provision_ldapbase(self):
99 raise NotImplementedError(self.test_provision_ldapbase)
101 def test_provision_guess(self):
102 raise NotImplementedError(self.test_provision_guess)
104 def test_join_domain(self):
105 raise NotImplementedError(self.test_join_domain)
107 def test_vampire(self):
108 raise NotImplementedError(self.test_vampire)