From 78ed8d3a985654a7982e63accded24ddcb5fd378 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bj=C3=B6rn=20Baumbach?= Date: Wed, 12 Feb 2025 17:15:37 +0100 Subject: [PATCH] pytests: test pysmbd with non-existent file MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit BUG: https://bugzilla.samba.org/show_bug.cgi?id=15807 Signed-off-by: Björn Baumbach Reviewed-by: Douglas Bagnall (cherry picked from commit 334f621e4b74e9cda735982e223aefc7eefb4631) --- python/samba/tests/samba_tool/ntacl.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/python/samba/tests/samba_tool/ntacl.py b/python/samba/tests/samba_tool/ntacl.py index 11731011e95..414ff982bf7 100644 --- a/python/samba/tests/samba_tool/ntacl.py +++ b/python/samba/tests/samba_tool/ntacl.py @@ -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()))) -- 2.47.2