]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
pytest: posixacl getntacl should raise OSError
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 7 Sep 2022 00:46:42 +0000 (12:46 +1200)
committerDouglas Bagnall <dbagnall@samba.org>
Wed, 7 Sep 2022 05:01:37 +0000 (05:01 +0000)
Not TypeError, which is supposed to be about Python data types. This
way we get to check/see an errno and strerror, and will allow us to
set the filename which will be useful for some errors.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/tests/posixacl.py
selftest/knownfail.d/samba-tool-ntacl

index 4fcf7bb21ed5bbc712df44a13486dc6a47560df8..ed3c29a14be0670c40c51cb0ecfff7653f2953ee 100644 (file)
@@ -28,6 +28,7 @@ from samba.samba3 import param as s3param
 from samba import auth
 from samba.samdb import SamDB
 from samba.auth_util import system_session_unix
+from errno import ENODATA
 
 DOM_SID = "S-1-5-21-2212615479-2695158682-2101375467"
 ACL = "O:S-1-5-21-2212615479-2695158682-2101375467-512G:S-1-5-21-2212615479-2695158682-2101375467-513D:(A;OICI;0x001f01ff;;;S-1-5-21-2212615479-2695158682-2101375467-512)"
@@ -89,8 +90,11 @@ class PosixAclMappingTests(SmbdBaseTests):
         smbd.set_simple_acl(self.tempf, 0o640, self.get_session_info())
 
         # However, this only asks the xattr
-        self.assertRaises(
-            TypeError, getntacl, self.lp, self.tempf, self.get_session_info(), direct_db_access=True)
+        with self.assertRaises(OSError) as cm:
+            getntacl(self.lp, self.tempf, self.get_session_info(),
+                     direct_db_access=True)
+
+        self.assertEqual(cm.exception.errno, ENODATA)
 
     def test_setntacl_invalidate_getntacl(self):
         acl = ACL
@@ -202,7 +206,10 @@ class PosixAclMappingTests(SmbdBaseTests):
     def test_setposixacl_getntacl(self):
         smbd.set_simple_acl(self.tempf, 0o750, self.get_session_info())
         # We don't expect the xattr to be filled in in this case
-        self.assertRaises(TypeError, getntacl, self.lp, self.tempf, self.get_session_info())
+        with self.assertRaises(OSError) as cm:
+            getntacl(self.lp, self.tempf, self.get_session_info())
+
+        self.assertEqual(cm.exception.errno, ENODATA)
 
     def test_setposixacl_getntacl_smbd(self):
         s4_passdb = passdb.PDB(self.lp.get("passdb backend"))
index cffdcd1788a076adda6df3a3835e00e8fb52ae81..aa37955471cd31c68d68ae0d00245b62d1451574 100644 (file)
@@ -1 +1,3 @@
 ^samba.tests.samba_tool.ntacl.+test_with_missing_files
+^samba.tests.posixacl.+test_setntacl_smbd_setposixacl_getntacl
+^samba.tests.posixacl.+test_setposixacl_getntacl