summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorBjörn Baumbach <bb@sernet.de>2025-02-13 18:05:44 +0100
committerBjörn Baumbach <bb@sernet.de>2025-02-14 16:18:19 +0000
commit3e1c19c2c3f8b0bdf21301431bc886757fd4b3ce (patch)
treedf3dc7f719d526ab430d827756116cbb03f72029 /python
parent26705d047cb885957a49939370e03047429351b6 (diff)
downloadsamba-3e1c19c2c3f8b0bdf21301431bc886757fd4b3ce.tar.gz
samba-3e1c19c2c3f8b0bdf21301431bc886757fd4b3ce.tar.bz2
samba-3e1c19c2c3f8b0bdf21301431bc886757fd4b3ce.zip
pytests: test pysmbd with relative path names via samba-tool ntacl
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
Diffstat (limited to 'python')
-rw-r--r--python/samba/tests/samba_tool/ntacl.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/python/samba/tests/samba_tool/ntacl.py b/python/samba/tests/samba_tool/ntacl.py
index 414ff982bf7..8dd3d236989 100644
--- a/python/samba/tests/samba_tool/ntacl.py
+++ b/python/samba/tests/samba_tool/ntacl.py
@@ -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())))