Example #1
0
    def test_create_message(self):
        sid1 = SIDPacket()
        sid1.from_string("S-1-1-0")
        sid2 = SIDPacket()
        sid2.from_string("S-1-5-21-3242954042-3778974373-1659123385-1104")

        ace1 = AccessAllowedAce()
        ace1['mask'] = 2032127
        ace1['sid'] = sid1
        ace2 = AccessAllowedAce()
        ace2['mask'] = 2032127
        ace2['sid'] = sid2
        # define an illegal ACE for tests to see if it is flexible for custom
        # aces'
        ace3 = AccessAllowedAce()
        ace3['ace_type'] = AceType.ACCESS_ALLOWED_OBJECT_ACE_TYPE
        ace3['sid'] = sid1

        message = AclPacket()
        message['aces'] = [ace1, ace2, ace3.pack()]
        expected = b"\x02" \
                   b"\x00" \
                   b"\x54\x00" \
                   b"\x03\x00" \
                   b"\x00\x00" \
                   b"\x00" \
                   b"\x00" \
                   b"\x14\x00" \
                   b"\xff\x01\x1f\x00" \
                   b"\x01" \
                   b"\x01" \
                   b"\x00\x00" \
                   b"\x00\x00\x00\x01" \
                   b"\x00\x00\x00\x00" \
                   b"\x00" \
                   b"\x00" \
                   b"\x24\x00" \
                   b"\xff\x01\x1f\x00" \
                   b"\x01" \
                   b"\x05" \
                   b"\x00\x00" \
                   b"\x00\x00\x00\x05" \
                   b"\x15\x00\x00\x00" \
                   b"\x3a\x8d\x4b\xc1" \
                   b"\xa5\x92\x3e\xe1" \
                   b"\xb9\x36\xe4\x62" \
                   b"\x50\x04\x00\x00" \
                   b"\x05" \
                   b"\x00" \
                   b"\x14\x00" \
                   b"\x00\x00\x00\x00" \
                   b"\x01" \
                   b"\x01" \
                   b"\x00\x00" \
                   b"\x00\x00\x00\x01" \
                   b"\x00\x00\x00\x00"
        actual = message.pack()
        assert len(message) == 84
        assert actual == expected
Example #2
0
    def test_create_message(self):
        sid = SIDPacket()
        sid.from_string("S-1-1-0")

        message = AccessAllowedAce()
        message['mask'] = 2032127
        message['sid'] = sid
        expected = b"\x00" \
                   b"\x00" \
                   b"\x14\x00" \
                   b"\xff\x01\x1f\x00" \
                   b"\x01" \
                   b"\x01" \
                   b"\x00\x00" \
                   b"\x00\x00\x00\x01" \
                   b"\x00\x00\x00\x00"
        actual = message.pack()
        assert len(message) == 20
        assert actual == expected