]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
pytests: test pysmbd with non-existent file
authorBjörn Baumbach <bb@sernet.de>
Wed, 12 Feb 2025 16:15:37 +0000 (17:15 +0100)
committerJule Anger <janger@samba.org>
Thu, 20 Feb 2025 10:19:35 +0000 (10:19 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15807

Signed-off-by: Björn Baumbach <bb@sernet.de>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
(cherry picked from commit 334f621e4b74e9cda735982e223aefc7eefb4631)

python/samba/tests/samba_tool/ntacl.py

index 11731011e95b3b6091a688d483289e8a6a8087bc..414ff982bf70b45c9633dec828eab2c215f22333 100644 (file)
@@ -22,6 +22,7 @@ import os
 from samba.tests.samba_tool.base import SambaToolCmdTest
 from samba.tests import env_loadparm
 import random
+import secrets
 
 
 class NtACLCmdSysvolTestCase(SambaToolCmdTest):
@@ -123,6 +124,24 @@ class NtACLCmdGetSetTestCase(SambaToolCmdTest):
         self.assertEqual(err, "", "Shouldn't be any error messages")
         self.assertEqual(out, "", "Shouldn't be any output messages")
 
+    def test_set_expect_file_not_found(self):
+        path = os.environ['SELFTEST_PREFIX']
+        tempf_basename = f"{self.unique_name()}-{secrets.token_hex(10)}"
+        tempf = os.path.join(path, tempf_basename)
+
+        for fs_arg in ["--use-s3fs", "--use-ntvfs"]:
+            (result, out, err) = self.runsubcmd("ntacl",
+                                                "set",
+                                                self.acl,
+                                                tempf_basename,
+                                                fs_arg)
+
+            self.assertCmdFail(result, "succeeded with non-existent file")
+            self.assertIn("No such file or directory",
+                          err,
+                          "No such file or directory expected")
+            self.assertEqual(out, "", "Shouldn't be any output messages")
+
     def test_ntvfs_check(self):
         path = os.environ['SELFTEST_PREFIX']
         tempf = os.path.join(path, "pytests" + str(int(100000 * random.random())))