From: Joseph Sutton Date: Thu, 29 Apr 2021 08:23:21 +0000 (+1200) Subject: samba-tool:testparm: Test error handling for unknown sections and parameters X-Git-Tag: tevent-0.11.0~871 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=11f26877ce1849439948c8d1f12dc9dd43cd534d;p=thirdparty%2Fsamba.git samba-tool:testparm: Test error handling for unknown sections and parameters BUG: https://bugzilla.samba.org/show_bug.cgi?id=14143 Signed-off-by: Joseph Sutton Reviewed-by: Rowland Penny Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/tests/netcmd.py b/python/samba/tests/netcmd.py index 68838759fa4..4bcddd332e7 100644 --- a/python/samba/tests/netcmd.py +++ b/python/samba/tests/netcmd.py @@ -94,6 +94,34 @@ class TestParmTests(NetCmdTestCase): "--section-name=tmp"], retcode=None) + def test_no_such_section(self): + out, err = self.run_netcmd(cmd_testparm, + ["--configfile=%s" % self.smbconf.name, + "--section-name=foo"], + retcode=-1) + # Ensure all exceptions are caught. + self.assertEqual("", out) + self.assertNotIn("uncaught exception", err) + + out, err = self.run_netcmd(cmd_testparm, + ["--configfile=%s" % self.smbconf.name, + "--section-name=foo", + "--parameter-name=foo"], + retcode=-1) + # Ensure all exceptions are caught. + self.assertEqual("", out) + self.assertNotIn("uncaught exception", err) + + def test_no_such_parameter(self): + out, err = self.run_netcmd(cmd_testparm, + ["--configfile=%s" % self.smbconf.name, + "--section-name=tmp", + "--parameter-name=foo"], + retcode=-1) + # Ensure all exceptions are caught. + self.assertEqual("", out) + self.assertNotIn("uncaught exception", err) + class CommandTests(NetCmdTestCase): diff --git a/selftest/knownfail.d/bug-14143 b/selftest/knownfail.d/bug-14143 new file mode 100644 index 00000000000..2902127ed9b --- /dev/null +++ b/selftest/knownfail.d/bug-14143 @@ -0,0 +1,2 @@ +^samba.tests.netcmd.samba.tests.netcmd.TestParmTests.test_no_such_section +^samba.tests.netcmd.samba.tests.netcmd.TestParmTests.test_no_such_parameter