Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into v4-0-test
[obnox/samba/samba-obnox.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
25 setup_dir = "setup"
26 def setup_path(file):
27     return os.path.join(setup_dir, file)
28
29
30 class ProvisionTestCase(samba.tests.TestCaseInTempDir):
31     def test_setup_secretsdb(self):
32         path = os.path.join(self.tempdir, "secrets.ldb")
33         ldb = setup_secretsdb(path, setup_path, None, None, None)
34         try:
35             self.assertEquals("LSA Secrets",
36                  ldb.searchone(basedn="CN=LSA Secrets", attribute="CN"))
37         finally:
38             del ldb
39             os.unlink(path)
40             
41     def test_become_dc(self):
42         path = os.path.join(self.tempdir, "secrets.ldb")
43         secrets_ldb = setup_secretsdb(path, setup_path, None, None, None)
44         try:
45             secretsdb_become_dc(secrets_ldb, setup_path, domain="EXAMPLE", 
46                    realm="example", netbiosname="myhost", 
47                    domainsid="S-5-22", keytab_path="keytab.path", 
48                    samdb_url="ldap://url/", 
49                    dns_keytab_path="dns.keytab", dnspass="bla", 
50                            machinepass="machinepass", dnsdomain="example.com")
51             self.assertEquals(1, 
52                     len(secrets_ldb.search("samAccountName=krbtgt,flatname=EXAMPLE,CN=Principals")))
53             self.assertEquals("keytab.path",
54                     secrets_ldb.searchone(basedn="flatname=EXAMPLE,CN=primary domains", 
55                                           expression="(privateKeytab=*)", 
56                                           attribute="privateKeytab"))
57             self.assertEquals("S-5-22",
58                     secrets_ldb.searchone(basedn="flatname=EXAMPLE,CN=primary domains",
59                                           expression="objectSid=*", attribute="objectSid"))
60
61         finally:
62             del secrets_ldb
63             os.unlink(path)
64
65 class Disabled:
66     def test_setup_templatesdb(self):
67         raise NotImplementedError(self.test_setup_templatesdb)
68
69     def test_setup_registry(self):
70         raise NotImplementedError(self.test_setup_registry)
71
72     def test_setup_samdb_rootdse(self):
73         raise NotImplementedError(self.test_setup_samdb_rootdse)
74
75     def test_setup_samdb_partitions(self):
76         raise NotImplementedError(self.test_setup_samdb_partitions)
77
78     def test_create_phpldapadmin_config(self):
79         raise NotImplementedError(self.test_create_phpldapadmin_config)
80
81     def test_provision_dns(self):
82         raise NotImplementedError(self.test_provision_dns)
83
84     def test_provision_ldapbase(self):
85         raise NotImplementedError(self.test_provision_ldapbase)
86
87     def test_provision_guess(self):
88         raise NotImplementedError(self.test_provision_guess)
89
90     def test_join_domain(self):
91         raise NotImplementedError(self.test_join_domain)
92
93     def test_vampire(self):
94         raise NotImplementedError(self.test_vampire)
95
96     def test_erase_partitions(self):
97         raise NotImplementedError(self.test_erase_partitions)
98