summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJoseph Sutton <josephsutton@catalyst.net.nz>2021-04-29 20:17:09 +1200
committerAndrew Bartlett <abartlet@samba.org>2021-05-17 21:39:38 +0000
commit33bb6ad35635590be112e94941dbfc02b4db1d30 (patch)
tree9ea4d1a958d71d31974a0d97a26de771666e5b59 /python
parent52744d35a37680c382800539a4c88d553496dbec (diff)
downloadsamba-33bb6ad35635590be112e94941dbfc02b4db1d30.tar.gz
samba-33bb6ad35635590be112e94941dbfc02b4db1d30.tar.bz2
samba-33bb6ad35635590be112e94941dbfc02b4db1d30.zip
samba-tool:testparm: Test that --section-name works without --parameter-name
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14143 Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Rowland Penny <rpenny@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'python')
-rw-r--r--python/samba/tests/netcmd.py40
1 files changed, 39 insertions, 1 deletions
diff --git a/python/samba/tests/netcmd.py b/python/samba/tests/netcmd.py
index 08d5bda8dda..68838759fa4 100644
--- a/python/samba/tests/netcmd.py
+++ b/python/samba/tests/netcmd.py
@@ -17,6 +17,9 @@
"""Tests for samba.netcmd."""
+import os
+import tempfile
+
from io import StringIO
from samba.netcmd import Command
from samba.netcmd.testparm import cmd_testparm
@@ -24,7 +27,7 @@ from samba.netcmd.main import cmd_sambatool
import samba.tests
-class NetCmdTestCase(samba.tests.TestCase):
+class NetCmdTestCase(samba.tests.TestCaseInTempDir):
def run_netcmd(self, cmd_klass, args, retcode=0):
cmd = cmd_klass(outf=StringIO(), errf=StringIO())
@@ -48,6 +51,33 @@ class NetCmdTestCase(samba.tests.TestCase):
class TestParmTests(NetCmdTestCase):
+ def setUp(self):
+ super().setUp()
+
+ # Override these global parameters in case their default values are
+ # invalid.
+ contents = """[global]
+ netbios name = test
+ lock dir = /
+ pid directory = /
+[tmp]
+ path = /
+"""
+ self.smbconf = self.create_smbconf(contents)
+
+ def create_smbconf(self, contents):
+ smbconf = tempfile.NamedTemporaryFile(mode='w',
+ dir=self.tempdir,
+ delete=False)
+ self.addCleanup(os.remove, smbconf.name)
+
+ try:
+ smbconf.write(contents)
+ finally:
+ smbconf.close()
+
+ return smbconf
+
def test_no_client_ip(self):
out, err = self.run_netcmd(cmd_testparm, ["--client-name=foo"],
retcode=-1)
@@ -56,6 +86,14 @@ class TestParmTests(NetCmdTestCase):
"ERROR: Both a DNS name and an IP address are "
"required for the host access check\n", err)
+ def test_section(self):
+ # We don't get an opportunity to verify the output, as the parameters
+ # are dumped directly to stdout, so just check the return code.
+ self.run_netcmd(cmd_testparm,
+ ["--configfile=%s" % self.smbconf.name,
+ "--section-name=tmp"],
+ retcode=None)
+
class CommandTests(NetCmdTestCase):