def testTruncated(self): with self.assertRaises(ValueError): wmi_parser.BinarySIDtoStringSID( b"\x01\x05\x00\x00\x00\x00\x00\x05\x15\x00\x00") with self.assertRaises(ValueError): wmi_parser.BinarySIDtoStringSID( b"\x01\x05\x00\x00\x00\x00\x00\x05\x15\x00")
def testConversion(self): for expected_value, binary in self.tests: binary_sid = "".join([chr(x).encode("latin-1") for x in binary]) if expected_value is None: # Test is meant to raise self.assertRaises(ValueError, wmi_parser.BinarySIDtoStringSID, binary_sid) else: self.assertEqual(wmi_parser.BinarySIDtoStringSID(binary_sid), expected_value)
def testLastAuthorityTruncated(self): with self.assertRaises(ValueError): wmi_parser.BinarySIDtoStringSID( b"\x01\x05\x00\x00\x00\x00\x00\x05\x15\x00\x00\x00\x85\x74\x77\xb9" b"\x7c\x0d\x7a\x96\x6f\xbd\x29\x9a\xf4")
def assertConvertsTo(self, sid, expected_output): self.assertEqual(wmi_parser.BinarySIDtoStringSID(sid), expected_output)