1# -*- coding: utf-8 -*-
2"""
3Automatic tests for module ldap0.msad
4"""
5
6# from Python's standard lib
7import unittest
8
9from ldap0.msad import sid2sddl, sddl2sid
10
11
12class Test001Functions(unittest.TestCase):
13
14    test_vectors = (
15        (
16            b'\x01\x05\x00\x00\x00\x00\x00\x05\x15\x00\x00\x00\xbaZ\x17^U\xdf\x83a)XU\x0eP\x04\x00\x00',
17            'S-1-5-21-1578588858-1636032341-240474153-1104'
18        ),
19        (
20            b'\x01\x04\x00\x00\x00\x00\x00\x05\x15\x00\x00\x00\xbaZ\x17^U\xdf\x83a)XU\x0e',
21            'S-1-5-21-1578588858-1636032341-240474153'
22        ),
23    )
24
25    def test001_sid2sddl(self):
26        for sid_b, sddl_s in self.test_vectors:
27            self.assertEqual(sid2sddl(sid_b), sddl_s)
28
29    def test002_sddl2sid(self):
30        for sid_b, sddl_s in self.test_vectors:
31            self.assertEqual(sddl2sid(sddl_s), sid_b)
32
33    def test003_inverse(self):
34        for sid_b, sddl_s in self.test_vectors:
35            self.assertEqual(sid2sddl(sddl2sid(sddl_s)), sddl_s)
36            self.assertEqual(sddl2sid(sid2sddl(sid_b)), sid_b)
37
38
39if __name__ == '__main__':
40    unittest.main()
41