]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
samba-tool:testparm: Test error handling for unknown sections and parameters
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Thu, 29 Apr 2021 08:23:21 +0000 (20:23 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 17 May 2021 21:39:38 +0000 (21:39 +0000)
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>
python/samba/tests/netcmd.py
selftest/knownfail.d/bug-14143 [new file with mode: 0644]

index 68838759fa4b27a4398205494c90ad8b49883f89..4bcddd332e71e72e5be8fc542fcc65c1ec7d4d12 100644 (file)
@@ -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 (file)
index 0000000..2902127
--- /dev/null
@@ -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