1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-05 20:58:40 +03:00

pytest:sddl: assert SDDLValueError values make sense

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Douglas Bagnall 2023-10-26 16:31:40 +13:00 committed by Andrew Bartlett
parent d7fe04205f
commit 42b5a09a03

View File

@ -82,9 +82,20 @@ class SddlDecodeEncodeBase(TestCase):
self.assertEqual(sddl, canonical)
def _test_sddl_should_fail_with_args(self, s, canonical):
with self.assertRaises(security.SDDLValueError):
try:
sd = security.descriptor.from_sddl(s, self.domain_sid)
print(sd.as_sddl(self.domain_sid))
except security.SDDLValueError as e:
generic_msg, specific_msg, position, sddl = e.args
self.assertEqual(generic_msg, "Unable to parse SDDL")
self.assertIsInstance(specific_msg, str)
self.assertIsInstance(position, int)
self.assertLessEqual(position, len(s))
self.assertGreaterEqual(position, 0)
self.assertEqual(s, sddl)
print(f"{s}\n{' ' * position}^\n {specific_msg}")
else:
self.fail(f"{sd.as_sddl(self.domain_sid)} should fail to parse")
@classmethod
def write_sddl_strings_for_fuzz_seeds(cls, dir):