Example #1
0
    def test_from_stream(self):
        ae = self.assertEqual

        stream = ByteIStream(bytes([x for x in range(17)]))
        uuid1 = GUIDToUUID.from_stream(stream, byte_order=LITTLE_ENDIAN)
        uuid2 = GUIDToUUID.from_stream(stream, 1, byte_order=LITTLE_ENDIAN)

        stream.seek(0, SEEK_SET)
        uuid3 = GUIDToUUID.from_stream(stream, byte_order=BIG_ENDIAN)
        uuid4 = GUIDToUUID.from_stream(stream, 1, byte_order=BIG_ENDIAN)

        ae(uuid1, UUID(bytes_le=bytes([x for x in range(16)])))
        ae(uuid2, UUID(bytes_le=bytes([x for x in range(1, 17)])))
        ae(uuid3, UUID(bytes=bytes([x for x in range(16)])))
        ae(uuid4, UUID(bytes=bytes([x for x in range(1, 17)])))
Example #2
0
    def test_from_stream(self):
        ae = self.assertEqual

        stream = ByteIStream(bytes([x for x in range(17)]))
        uuid1 = GUIDToUUID.from_stream(stream, byte_order=LITTLE_ENDIAN)
        uuid2 = GUIDToUUID.from_stream(stream, 1, byte_order=LITTLE_ENDIAN)

        stream.seek(0, SEEK_SET)
        uuid3 = GUIDToUUID.from_stream(stream, byte_order=BIG_ENDIAN)
        uuid4 = GUIDToUUID.from_stream(stream, 1, byte_order=BIG_ENDIAN)

        ae(uuid1, UUID(bytes_le=bytes([x for x in range(16)])))
        ae(uuid2, UUID(bytes_le=bytes([x for x in range(1, 17)])))
        ae(uuid3, UUID(bytes=bytes([x for x in range(16)])))
        ae(uuid4, UUID(bytes=bytes([x for x in range(1, 17)])))
Example #3
0
    def test_from_guid(self):
        ae = self.assertEqual

        uuid = GUIDToUUID.from_guid(0x00010203, 0x0405, 0x0607,
                                    b"\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F")

        ae(uuid, UUID(bytes=bytes([x for x in range(16)])))
Example #4
0
    def test_from_ctype(self):
        ae = self.assertEqual

        stream = ByteIStream(bytes([x for x in range(16)]))
        uuid1 = guid_be.from_buffer_copy(stream.read(16))
        uuid1 = GUIDToUUID.from_ctype(uuid1)

        ae(uuid1, UUID(bytes=bytes([x for x in range(16)])))
Example #5
0
    def test_from_ctype(self):
        ae = self.assertEqual

        stream = ByteIStream(bytes([x for x in range(16)]))
        uuid1 = guid_be.from_buffer_copy(stream.read(16))
        uuid1 = GUIDToUUID.from_ctype(uuid1)

        ae(uuid1, UUID(bytes=bytes([x for x in range(16)])))
Example #6
0
    def test_from_stream(self):
        ae = self.assertEqual

        data = bytes([x for x in range(28)])
        stream = ByteIStream(data)
        kfp1 = KnownFolderProps.from_stream(stream)
        kfp2 = KnownFolderProps.from_stream(stream, 0)

        ae(kfp1.size, 0x03020100)
        ae(kfp2.size, 0x03020100)

        ae(kfp1.sig, 0x07060504)
        ae(kfp2.sig, 0x07060504)

        kf_id = GUIDToUUID.from_stream(ByteIStream(data[8:24]))
        ae(kfp1.kf_id, kf_id)
        ae(kfp2.kf_id, kf_id)

        ae(kfp1.offset, 0x1B1A1918)
        ae(kfp2.offset, 0x1B1A1918)
Example #7
0
    def test_from_stream(self):
        ae = self.assertEqual

        data = bytes([x for x in range(28)])
        stream = ByteIStream(data)
        kfp1 = KnownFolderProps.from_stream(stream)
        kfp2 = KnownFolderProps.from_stream(stream, 0)

        ae(kfp1.size, 0x03020100)
        ae(kfp2.size, 0x03020100)

        ae(kfp1.sig, 0x07060504)
        ae(kfp2.sig, 0x07060504)

        kf_id = GUIDToUUID.from_stream(ByteIStream(data[8:24]))
        ae(kfp1.kf_id, kf_id)
        ae(kfp2.kf_id, kf_id)

        ae(kfp1.offset, 0x1B1A1918)
        ae(kfp2.offset, 0x1B1A1918)
Example #8
0
    def test_from_guid(self):
        ae = self.assertEqual

        uuid = GUIDToUUID.from_guid(0x00010203, 0x0405, 0x0607, b"\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F")

        ae(uuid, UUID(bytes=bytes([x for x in range(16)])))