From 02f3695897dddb013fc1268a4f1a852cd4a3465e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Apr 2008 18:30:07 +0200 Subject: Add convenience TestCase class for testing RPC interfaces. (This used to be commit 2f19f981449bf6f4d29f231259817c8b66104a9b) --- source4/scripting/python/samba/tests/__init__.py | 7 +++++++ source4/scripting/python/samba/tests/dcerpc/registry.py | 9 ++++----- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/samba/tests/__init__.py b/source4/scripting/python/samba/tests/__init__.py index c8673d3fae..ceb7dd23f3 100644 --- a/source4/scripting/python/samba/tests/__init__.py +++ b/source4/scripting/python/samba/tests/__init__.py @@ -90,3 +90,10 @@ def get_loadparm(): lp = param.LoadParm() lp.load(os.getenv("SMB_CONF_PATH")) return lp + +class RpcInterfaceTestCase(unittest.TestCase): + def get_loadparm(self): + return get_loadparm() + + def get_credentials(self): + return None diff --git a/source4/scripting/python/samba/tests/dcerpc/registry.py b/source4/scripting/python/samba/tests/dcerpc/registry.py index 147acc5098..1afdc582a7 100644 --- a/source4/scripting/python/samba/tests/dcerpc/registry.py +++ b/source4/scripting/python/samba/tests/dcerpc/registry.py @@ -18,14 +18,13 @@ # import winreg -from param import LoadParm import unittest -from samba.tests import get_loadparm +from samba.tests import RpcInterfaceTestCase -class WinregTests(unittest.TestCase): +class WinregTests(RpcInterfaceTestCase): def setUp(self): - lp_ctx = get_loadparm() - self.conn = winreg.winreg("ncalrpc:", lp_ctx) + self.conn = winreg.winreg("ncalrpc:", self.get_loadparm(), + self.get_credentials()) def get_hklm(self): return self.conn.OpenHKLM(None, -- cgit From c1d9167fbcc5df9da4f603084ad732915c68c0c0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Apr 2008 19:01:32 +0200 Subject: Also look in the environment for smb.conf path. (This used to be commit 8be7d93735a357a3b73a1c4413d6fd9ec09b7555) --- source4/scripting/python/samba/getopt.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/samba/getopt.py b/source4/scripting/python/samba/getopt.py index 82cb004b62..7ec684a9d6 100644 --- a/source4/scripting/python/samba/getopt.py +++ b/source4/scripting/python/samba/getopt.py @@ -35,12 +35,14 @@ class SambaOptions(optparse.OptionGroup): self._configfile = arg def get_loadparm(self): - import param + import os, param lp = param.LoadParm() - if self._configfile is None: - lp.load_default() - else: + if self._configfile is not None: lp.load(self._configfile) + elif os.getenv("SMB_CONF_PATH") is not None: + lp.load(os.getenv("SMB_CONF_PATH")) + else: + lp.load_default() return lp class VersionOptions(optparse.OptionGroup): -- cgit From 1bcbc4afcf2f9984081652c1fbe50d329c86b3b5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Apr 2008 19:13:41 +0200 Subject: Allow command line options in the subunitrun script. (This used to be commit 524ec0796efebd48e7b5b2eb5fcc92ecc13c0071) --- source4/scripting/python/samba/tests/__init__.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/samba/tests/__init__.py b/source4/scripting/python/samba/tests/__init__.py index ceb7dd23f3..e29b4a87d5 100644 --- a/source4/scripting/python/samba/tests/__init__.py +++ b/source4/scripting/python/samba/tests/__init__.py @@ -85,15 +85,13 @@ class LdbExtensionTests(TestCaseInTempDir): os.unlink(path) -def get_loadparm(): - import param - lp = param.LoadParm() - lp.load(os.getenv("SMB_CONF_PATH")) - return lp +cmdline_loadparm = None +cmdline_credentials = None class RpcInterfaceTestCase(unittest.TestCase): def get_loadparm(self): - return get_loadparm() + assert cmdline_loadparm is not None + return cmdline_loadparm def get_credentials(self): - return None + return cmdline_credentials -- cgit From 2cdfaedee203a726bddfb46fb10d9604de32a05f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Apr 2008 19:20:43 +0200 Subject: Make sure credentials are specified when running the Python winreg RPC tests. (This used to be commit 280339e3d126f5c72dc271051b72839fde0c5c9f) --- source4/scripting/python/samba/tests/dcerpc/registry.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/samba/tests/dcerpc/registry.py b/source4/scripting/python/samba/tests/dcerpc/registry.py index 1afdc582a7..05ac7c66ee 100644 --- a/source4/scripting/python/samba/tests/dcerpc/registry.py +++ b/source4/scripting/python/samba/tests/dcerpc/registry.py @@ -23,8 +23,8 @@ from samba.tests import RpcInterfaceTestCase class WinregTests(RpcInterfaceTestCase): def setUp(self): - self.conn = winreg.winreg("ncalrpc:", self.get_loadparm(), - self.get_credentials()) + lp = self.get_loadparm() + self.conn = winreg.winreg("ncalrpc:", lp, self.get_credentials()) def get_hklm(self): return self.conn.OpenHKLM(None, -- cgit