]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
pytests: test pysmbd with relative path names via samba-tool ntacl
authorBjörn Baumbach <bb@sernet.de>
Thu, 13 Feb 2025 17:05:44 +0000 (18:05 +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=15806

Signed-off-by: Björn Baumbach <bb@sernet.de>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Autobuild-User(master): Björn Baumbach <bb@sernet.de>
Autobuild-Date(master): Fri Feb 14 16:18:19 UTC 2025 on atb-devel-224

(cherry picked from commit 3e1c19c2c3f8b0bdf21301431bc886757fd4b3ce)

python/samba/tests/samba_tool/ntacl.py

index 414ff982bf70b45c9633dec828eab2c215f22333..8dd3d236989480525bd13a3ffd3458456b43a1c3 100644 (file)
@@ -142,6 +142,67 @@ class NtACLCmdGetSetTestCase(SambaToolCmdTest):
                           "No such file or directory expected")
             self.assertEqual(out, "", "Shouldn't be any output messages")
 
+    def test_set_with_relative_path(self):
+        path = os.environ['SELFTEST_PREFIX']
+        tempf_basename = f"{self.unique_name()}-{secrets.token_hex(10)}"
+        tempf = os.path.join(path, tempf_basename)
+        workdir = os.getcwd()
+
+        open(tempf, 'w').write("empty")
+
+        os.chdir(path)
+
+        for fs_arg in ["--use-s3fs", "--use-ntvfs"]:
+            (result, out, err) = self.runsubcmd("ntacl",
+                                                "set",
+                                                self.acl,
+                                                tempf_basename,
+                                                fs_arg)
+
+            self.assertCmdSuccess(result, out, err)
+            if fs_arg == "--use-s3fs":
+                self.assertEqual(err, "", "Shouldn't be any error messages")
+            elif fs_arg == "--use-ntvfs":
+                self.assertIn("only the stored NT ACL",
+                              err,
+                              "only the stored NT ACL warning expected")
+            self.assertEqual(out, "", "Shouldn't be any output messages")
+
+        os.chdir(workdir)
+
+    def test_set_with_relative_parent_path(self):
+        path = os.environ['SELFTEST_PREFIX']
+        tempf_basename = f"{self.unique_name()}-{secrets.token_hex(10)}"
+        tempf = os.path.join(path, tempf_basename)
+        subdir_basename = f"{self.unique_name()}-subdir-{secrets.token_hex(10)}"
+        subdir_path = os.path.join(path, subdir_basename)
+        workdir = os.getcwd()
+
+        os.mkdir(subdir_path)
+        open(tempf, 'w').write("empty")
+
+        tempf_relative_path = os.path.join("../", tempf_basename)
+
+        os.chdir(subdir_path)
+
+        for fs_arg in ["--use-s3fs", "--use-ntvfs"]:
+            (result, out, err) = self.runsubcmd("ntacl",
+                                                "set",
+                                                self.acl,
+                                                tempf_relative_path,
+                                                fs_arg)
+
+            self.assertCmdSuccess(result, out, err)
+            if fs_arg == "--use-s3fs":
+                self.assertEqual(err, "", "Shouldn't be any error messages")
+            elif fs_arg == "--use-ntvfs":
+                self.assertIn("only the stored NT ACL",
+                              err,
+                              "only the stored NT ACL warning expected")
+            self.assertEqual(out, "", "Shouldn't be any output messages")
+
+        os.chdir(workdir)
+
     def test_ntvfs_check(self):
         path = os.environ['SELFTEST_PREFIX']
         tempf = os.path.join(path, "pytests" + str(int(100000 * random.random())))