mirror of
https://github.com/samba-team/samba.git
synced 2025-08-03 04:22:09 +03:00
s4-test: Use smb.conf path set in environment rather than using
command-line options. This is the first step towards supporting custom test runners.
This commit is contained in:
@ -32,7 +32,7 @@ def checkset_backend(lp, backend, eadbfile):
|
||||
if backend == "native":
|
||||
lp.set("posix:eadb", "")
|
||||
elif backend == "tdb":
|
||||
if eadbfile != None:
|
||||
if eadbfile is not None:
|
||||
lp.set("posix:eadb", eadbfile)
|
||||
else:
|
||||
os.path.abspath(os.path.join(lp.get("private dir"), "eadb.tdb"))
|
||||
|
@ -22,6 +22,7 @@
|
||||
import os
|
||||
import ldb
|
||||
import samba
|
||||
from samba import param
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
@ -90,14 +91,20 @@ class LdbExtensionTests(TestCaseInTempDir):
|
||||
os.unlink(path)
|
||||
|
||||
|
||||
cmdline_loadparm = None
|
||||
def env_loadparm():
|
||||
lp = param.LoadParm()
|
||||
try:
|
||||
lp.load(os.environ["SMB_CONF_PATH"])
|
||||
except KeyError:
|
||||
raise Exception("SMB_CONF_PATH not set")
|
||||
return lp
|
||||
|
||||
cmdline_credentials = None
|
||||
|
||||
class RpcInterfaceTestCase(unittest.TestCase):
|
||||
|
||||
def get_loadparm(self):
|
||||
assert cmdline_loadparm is not None
|
||||
return cmdline_loadparm
|
||||
return env_loadparm()
|
||||
|
||||
def get_credentials(self):
|
||||
return cmdline_credentials
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
from samba.dcerpc import ClientConnection
|
||||
from unittest import TestCase
|
||||
from samba.tests import cmdline_loadparm
|
||||
from samba.tests import env_loadparm
|
||||
|
||||
|
||||
class BareTestCase(TestCase):
|
||||
@ -28,22 +28,22 @@ class BareTestCase(TestCase):
|
||||
def test_bare(self):
|
||||
# Connect to the echo pipe
|
||||
x = ClientConnection("ncalrpc:localhost[DEFAULT]",
|
||||
("60a15ec5-4de8-11d7-a637-005056a20182", 1), lp_ctx=cmdline_loadparm)
|
||||
("60a15ec5-4de8-11d7-a637-005056a20182", 1), lp_ctx=env_loadparm())
|
||||
self.assertEquals("\x01\x00\x00\x00", x.request(0, chr(0) * 4))
|
||||
|
||||
def test_alter_context(self):
|
||||
x = ClientConnection("ncalrpc:localhost[DEFAULT]",
|
||||
("12345778-1234-abcd-ef00-0123456789ac", 1), lp_ctx=cmdline_loadparm)
|
||||
("12345778-1234-abcd-ef00-0123456789ac", 1), lp_ctx=env_loadparm())
|
||||
y = ClientConnection("ncalrpc:localhost",
|
||||
("60a15ec5-4de8-11d7-a637-005056a20182", 1),
|
||||
basis_connection=x, lp_ctx=cmdline_loadparm)
|
||||
basis_connection=x, lp_ctx=env_loadparm())
|
||||
x.alter_context(("60a15ec5-4de8-11d7-a637-005056a20182", 1))
|
||||
# FIXME: self.assertEquals("\x01\x00\x00\x00", x.request(0, chr(0) * 4))
|
||||
|
||||
def test_two_connections(self):
|
||||
x = ClientConnection("ncalrpc:localhost[DEFAULT]",
|
||||
("60a15ec5-4de8-11d7-a637-005056a20182", 1), lp_ctx=cmdline_loadparm)
|
||||
("60a15ec5-4de8-11d7-a637-005056a20182", 1), lp_ctx=env_loadparm())
|
||||
y = ClientConnection("ncalrpc:localhost",
|
||||
("60a15ec5-4de8-11d7-a637-005056a20182", 1),
|
||||
basis_connection=x, lp_ctx=cmdline_loadparm)
|
||||
basis_connection=x, lp_ctx=env_loadparm())
|
||||
self.assertEquals("\x01\x00\x00\x00", y.request(0, chr(0) * 4))
|
||||
|
@ -20,10 +20,9 @@
|
||||
import os
|
||||
from samba.provision import setup_secretsdb, findnss
|
||||
import samba.tests
|
||||
from samba.tests import env_loadparm
|
||||
import unittest
|
||||
|
||||
lp = samba.tests.cmdline_loadparm
|
||||
|
||||
setup_dir = "setup"
|
||||
def setup_path(file):
|
||||
return os.path.join(setup_dir, file)
|
||||
@ -34,7 +33,7 @@ class ProvisionTestCase(samba.tests.TestCaseInTempDir):
|
||||
"""
|
||||
def test_setup_secretsdb(self):
|
||||
path = os.path.join(self.tempdir, "secrets.ldb")
|
||||
ldb = setup_secretsdb(path, setup_path, None, None, lp=lp)
|
||||
ldb = setup_secretsdb(path, setup_path, None, None, lp=env_loadparm())
|
||||
try:
|
||||
self.assertEquals("LSA Secrets",
|
||||
ldb.searchone(basedn="CN=LSA Secrets", attribute="CN"))
|
||||
|
Reference in New Issue
Block a user