python: Load smb.conf file for the provision tests.
[amitay/samba.git] / source4 / scripting / python / samba / tests / provision.py
1 #!/usr/bin/python
2
3 # Unix SMB/CIFS implementation.
4 # Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007-2008
5 #   
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.
10 #   
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.
15 #   
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/>.
18 #
19
20 import os
21 from samba.provision import setup_secretsdb, secretsdb_become_dc
22 import samba.tests
23 from ldb import Dn
24 import param
25
26 lp = param.LoadParm()
27 lp.load("st/dc/etc/smb.conf")
28
29 setup_dir = "setup"
30 def setup_path(file):
31     return os.path.join(setup_dir, file)
32
33
34 class ProvisionTestCase(samba.tests.TestCaseInTempDir):
35     def test_setup_secretsdb(self):
36         path = os.path.join(self.tempdir, "secrets.ldb")
37         ldb = setup_secretsdb(path, setup_path, None, None, lp=lp)
38         try:
39             self.assertEquals("LSA Secrets",
40                  ldb.searchone(basedn="CN=LSA Secrets", attribute="CN"))
41         finally:
42             del ldb
43             os.unlink(path)
44             
45     def test_become_dc(self):
46         path = os.path.join(self.tempdir, "secrets.ldb")
47         secrets_ldb = setup_secretsdb(path, setup_path, None, None, lp=lp)
48         try:
49             secretsdb_become_dc(secrets_ldb, setup_path, domain="EXAMPLE", 
50                    realm="example", netbiosname="myhost", 
51                    domainsid="S-5-22", keytab_path="keytab.path", 
52                    samdb_url="ldap://url/", 
53                    dns_keytab_path="dns.keytab", dnspass="bla", 
54                            machinepass="machinepass", dnsdomain="example.com")
55             self.assertEquals(1, 
56                     len(secrets_ldb.search("samAccountName=krbtgt,flatname=EXAMPLE,CN=Principals")))
57             self.assertEquals("keytab.path",
58                     secrets_ldb.searchone(basedn="flatname=EXAMPLE,CN=primary domains", 
59                                           expression="(privateKeytab=*)", 
60                                           attribute="privateKeytab"))
61             self.assertEquals("S-5-22",
62                     secrets_ldb.searchone(basedn="flatname=EXAMPLE,CN=primary domains",
63                                           expression="objectSid=*", attribute="objectSid"))
64
65         finally:
66             del secrets_ldb
67             os.unlink(path)
68
69 class Disabled:
70     def test_setup_templatesdb(self):
71         raise NotImplementedError(self.test_setup_templatesdb)
72
73     def test_setup_registry(self):
74         raise NotImplementedError(self.test_setup_registry)
75
76     def test_setup_samdb_rootdse(self):
77         raise NotImplementedError(self.test_setup_samdb_rootdse)
78
79     def test_setup_samdb_partitions(self):
80         raise NotImplementedError(self.test_setup_samdb_partitions)
81
82     def test_create_phpldapadmin_config(self):
83         raise NotImplementedError(self.test_create_phpldapadmin_config)
84
85     def test_provision_dns(self):
86         raise NotImplementedError(self.test_provision_dns)
87
88     def test_provision_ldapbase(self):
89         raise NotImplementedError(self.test_provision_ldapbase)
90
91     def test_provision_guess(self):
92         raise NotImplementedError(self.test_provision_guess)
93
94     def test_join_domain(self):
95         raise NotImplementedError(self.test_join_domain)
96
97     def test_vampire(self):
98         raise NotImplementedError(self.test_vampire)
99
100     def test_erase_partitions(self):
101         raise NotImplementedError(self.test_erase_partitions)
102