From 83794d08bc39c74caebebd8dee4cc3f207ed90c5 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 23 Sep 2024 19:37:15 +0200 Subject: [PATCH] tests: Check that we return the posix type in query_directory Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- python/samba/tests/smb3unix.py | 17 ++++++++++++++--- selftest/knownfail.d/smb3unix | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 selftest/knownfail.d/smb3unix diff --git a/python/samba/tests/smb3unix.py b/python/samba/tests/smb3unix.py index 5a005889298..612a54e0f79 100644 --- a/python/samba/tests/smb3unix.py +++ b/python/samba/tests/smb3unix.py @@ -297,18 +297,28 @@ class Smb3UnixTests(samba.tests.libsmb.LibsmbTests): for fname,perm in test_files.items(): self.assertIn(get_string(fname), found_files.keys(), 'Test file not found') - self.assertEqual(test_files[fname], found_files[fname]['perms'], + + found_unixmode = found_files[fname]['perms'] + found_perms = found_unixmode & (stat.S_IRWXU| + stat.S_IRWXG| + stat.S_IRWXO| + stat.S_ISUID| + stat.S_ISGID| + stat.S_ISVTX) + + self.assertEqual(test_files[fname], found_perms, 'Requested %04o, Received %04o' % \ - (test_files[fname], found_files[fname]['perms'])) + (test_files[fname], found_perms)) self.assertEqual(found_files[fname]['reparse_tag'], libsmb.IO_REPARSE_TAG_RESERVED_ZERO) - self.assertEqual(found_files[fname]['perms'], perm) + self.assertEqual(found_perms, perm) self.assertEqual(found_files[fname]['owner_sid'], self.samsid + "-1000") self.assertTrue(found_files[fname]['group_sid'].startswith("S-1-22-2-")) if fname.startswith("testfile"): + self.assertTrue(stat.S_ISREG(found_unixmode)) self.assertEqual(found_files[fname]['nlink'], 1) self.assertEqual(found_files[fname]['size'], 4) self.assertEqual(found_files[fname]['allocaction_size'], @@ -316,6 +326,7 @@ class Smb3UnixTests(samba.tests.libsmb.LibsmbTests): self.assertEqual(found_files[fname]['attrib'], libsmb.FILE_ATTRIBUTE_ARCHIVE) else: + self.assertTrue(stat.S_ISDIR(found_unixmode)) # Note: btrfs always reports the link count of directories as one. if self.fstype == "btrfs": self.assertEqual(found_files[fname]['nlink'], 1) diff --git a/selftest/knownfail.d/smb3unix b/selftest/knownfail.d/smb3unix new file mode 100644 index 00000000000..59920f281b7 --- /dev/null +++ b/selftest/knownfail.d/smb3unix @@ -0,0 +1 @@ +samba.tests.smb3unix.samba.tests.smb3unix.Smb3UnixTests.test_posix_perm_files -- 2.47.3