1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

Fix up provision and samdb tests.

This fixes up the provision to operate with a target directory - it
must override the smb.conf in this case.

Andrew Bartlett
(This used to be commit 89fc39f7ed)
This commit is contained in:
Andrew Bartlett 2008-05-30 14:26:47 +10:00
parent 437ca06107
commit b9babfe4cc
2 changed files with 23 additions and 7 deletions

View File

@ -930,7 +930,8 @@ def provision(setup_dir, message, session_info,
if aci is None: if aci is None:
aci = "# no aci for local ldb" aci = "# no aci for local ldb"
if smbconf is None: if targetdir is not None:
if (not os.path.exists(os.path.join(targetdir, "etc"))):
os.makedirs(os.path.join(targetdir, "etc")) os.makedirs(os.path.join(targetdir, "etc"))
smbconf = os.path.join(targetdir, "etc", "smb.conf") smbconf = os.path.join(targetdir, "etc", "smb.conf")

View File

@ -19,12 +19,13 @@
from samba.auth import system_session from samba.auth import system_session
from samba.credentials import Credentials from samba.credentials import Credentials
import os import os
from samba.provision import setup_samdb, guess_names, setup_templatesdb from samba.provision import setup_samdb, guess_names, setup_templatesdb, make_smbconf
from samba.samdb import SamDB from samba.samdb import SamDB
from samba.tests import cmdline_loadparm, TestCaseInTempDir from samba.tests import cmdline_loadparm, TestCaseInTempDir
from samba import security from samba import security
from unittest import TestCase from unittest import TestCase
import uuid import uuid
import param
class SamDBTestCase(TestCaseInTempDir): class SamDBTestCase(TestCaseInTempDir):
def setUp(self): def setUp(self):
@ -43,9 +44,22 @@ class SamDBTestCase(TestCaseInTempDir):
hostguid = str(uuid.uuid4()) hostguid = str(uuid.uuid4())
path = os.path.join(self.tempdir, "samdb.ldb") path = os.path.join(self.tempdir, "samdb.ldb")
session_info = system_session() session_info = system_session()
names = guess_names(lp=cmdline_loadparm, hostname="foo",
domain="EXAMPLE.COM", dnsdomain="example.com", hostname="foo"
serverrole="domain controller", domain="EXAMPLE"
dnsdomain="example.com"
serverrole="domain controller"
smbconf = os.path.join(self.tempdir, "smb.conf")
make_smbconf(smbconf, setup_path, hostname, domain, dnsdomain, serverrole,
self.tempdir)
lp = param.LoadParm()
lp.load(smbconf)
names = guess_names(lp=lp, hostname=hostname,
domain=domain, dnsdomain=dnsdomain,
serverrole=severrole,
domaindn=self.domaindn, configdn=configdn, domaindn=self.domaindn, configdn=configdn,
schemadn=schemadn) schemadn=schemadn)
setup_templatesdb(os.path.join(self.tempdir, "templates.ldb"), setup_templatesdb(os.path.join(self.tempdir, "templates.ldb"),
@ -58,9 +72,10 @@ class SamDBTestCase(TestCaseInTempDir):
policyguid, False, "secret", policyguid, False, "secret",
"secret", "secret", invocationid, "secret", "secret", invocationid,
"secret", "domain controller") "secret", "domain controller")
def tearDown(self): def tearDown(self):
for f in ['templates.ldb', 'schema.ldb', 'configuration.ldb', for f in ['templates.ldb', 'schema.ldb', 'configuration.ldb',
'users.ldb', 'samdb.ldb']: 'users.ldb', 'samdb.ldb', 'smb.conf']:
os.remove(os.path.join(self.tempdir, f)) os.remove(os.path.join(self.tempdir, f))
super(SamDBTestCase, self).tearDown() super(SamDBTestCase, self).tearDown()