From: Douglas Bagnall Date: Wed, 7 Sep 2022 00:46:42 +0000 (+1200) Subject: pytest: posixacl getntacl should raise OSError X-Git-Tag: talloc-2.4.0~1150 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a64839bc297bdb8b71db446ac6b55fb4503bdc0e;p=thirdparty%2Fsamba.git pytest: posixacl getntacl should raise OSError 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 Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/tests/posixacl.py b/python/samba/tests/posixacl.py index 4fcf7bb21ed..ed3c29a14be 100644 --- a/python/samba/tests/posixacl.py +++ b/python/samba/tests/posixacl.py @@ -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")) diff --git a/selftest/knownfail.d/samba-tool-ntacl b/selftest/knownfail.d/samba-tool-ntacl index cffdcd1788a..aa37955471c 100644 --- a/selftest/knownfail.d/samba-tool-ntacl +++ b/selftest/knownfail.d/samba-tool-ntacl @@ -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