예제 #1
0
    def test_get_offset(self):
        """Tests the get_offset function."""
        test_source = unittest.source
        if not test_source:
            raise unittest.SkipTest("missing source")

        if not os.path.isfile(test_source):
            raise unittest.SkipTest("source not a regular file")

        fvde_volume = pyfvde.volume()
        if unittest.password:
            fvde_volume.set_password(unittest.password)
        if unittest.recovery_password:
            fvde_volume.set_recovery_password(unittest.recovery_password)

        with DataRangeFileObject(test_source, unittest.offset or 0,
                                 None) as file_object:

            fvde_volume = pyfvde.volume()
            fvde_volume.open_file_object(file_object)

            offset = fvde_volume.get_offset()
            self.assertIsNotNone(offset)

            fvde_volume.close()
예제 #2
0
    def test_is_locked(self):
        """Tests the is_locked function."""
        if not unittest.source:
            raise unittest.SkipTest("missing source")

        if unittest.offset:
            raise unittest.SkipTest("source defines offset")

        fvde_volume = pyfvde.volume()

        fvde_volume.open(unittest.source)

        result = fvde_volume.is_locked()
        self.assertTrue(result)

        fvde_volume.close()

        if unittest.password or unittest.recovery_password:
            fvde_volume = pyfvde.volume()
            if unittest.password:
                fvde_volume.set_password(unittest.password)
            if unittest.recovery_password:
                fvde_volume.set_recovery_password(unittest.recovery_password)

            fvde_volume.open(unittest.source)

            result = fvde_volume.is_locked()
            self.assertFalse(result)

            fvde_volume.close()
예제 #3
0
    def test_get_size(self):
        """Tests the get_size function and size property."""
        if not unittest.source:
            raise unittest.SkipTest("missing source")

        if not os.path.isfile(unittest.source):
            raise unittest.SkipTest("source not a regular file")

        fvde_volume = pyfvde.volume()
        if unittest.password:
            fvde_volume.set_password(unittest.password)
        if unittest.recovery_password:
            fvde_volume.set_recovery_password(unittest.recovery_password)

        with DataRangeFileObject(unittest.source, unittest.offset or 0,
                                 None) as file_object:

            fvde_volume = pyfvde.volume()
            fvde_volume.open_file_object(file_object)

            size = fvde_volume.get_size()
            self.assertIsNotNone(size)

            self.assertIsNotNone(fvde_volume.size)

            fvde_volume.close()
예제 #4
0
  def _Open(self, path_spec, mode='rb'):
    """Opens the file system defined by path specification.

    Args:
      path_spec (PathSpec): path specification.
      mode (Optional[str]): file access mode. The default is 'rb'
          read-only binary.

    Raises:
      AccessError: if the access to open the file was denied.
      IOError: if the file system could not be opened.
      PathSpecError: if the path specification is incorrect.
      ValueError: if the path specification is invalid.
    """
    if not path_spec.HasParent():
      raise errors.PathSpecError(
          u'Unsupported path specification without parent.')

    resolver.Resolver.key_chain.ExtractCredentialsFromPathSpec(path_spec)

    fvde_volume = pyfvde.volume()
    file_object = resolver.Resolver.OpenFileObject(
        path_spec.parent, resolver_context=self._resolver_context)

    try:
      fvde.FVDEVolumeOpen(
          fvde_volume, path_spec, file_object, resolver.Resolver.key_chain)
    except:
      file_object.close()
      raise

    self._fvde_volume = fvde_volume
    self._file_object = file_object
예제 #5
0
    def test_open_file_object(self):
        """Tests the open_file_object function."""
        if not unittest.source:
            return

        file_object = open(unittest.source, "rb")
        if unittest.offset:
            file_object = DataRangeFileObject(file_object, unittest.offset,
                                              None)

        fvde_volume = pyfvde.volume()

        if unittest.password:
            fvde_volume.set_password(unittest.password)
        if unittest.recovery_password:
            fvde_volume.set_recovery_password(unittest.recovery_password)

        fvde_volume.open_file_object(file_object)

        with self.assertRaises(IOError):
            fvde_volume.open_file_object(file_object)

        fvde_volume.close()

        # TODO: change IOError into TypeError
        with self.assertRaises(IOError):
            fvde_volume.open_file_object(None)

        with self.assertRaises(ValueError):
            fvde_volume.open_file_object(file_object, mode="w")
예제 #6
0
    def test_read_buffer_file_object(self):
        """Tests the read_buffer function on a file-like object."""
        if not unittest.source:
            raise unittest.SkipTest("missing source")

        if not os.path.isfile(unittest.source):
            raise unittest.SkipTest("source not a regular file")

        fvde_volume = pyfvde.volume()
        if unittest.password:
            fvde_volume.set_password(unittest.password)
        if unittest.recovery_password:
            fvde_volume.set_recovery_password(unittest.recovery_password)

        with DataRangeFileObject(unittest.source, unittest.offset or 0,
                                 None) as file_object:

            fvde_volume.open_file_object(file_object)

            size = fvde_volume.get_size()

            # Test normal read.
            data = fvde_volume.read_buffer(size=4096)

            self.assertIsNotNone(data)
            self.assertEqual(len(data), min(size, 4096))

            fvde_volume.close()
예제 #7
0
    def test_open_close(self):
        """Tests the open and close functions."""
        if not unittest.source or unittest.offset:
            return

        fvde_volume = pyfvde.volume()

        if unittest.password:
            fvde_volume.set_password(unittest.password)
        if unittest.recovery_password:
            fvde_volume.set_recovery_password(unittest.recovery_password)

        # Test open and close.
        fvde_volume.open(unittest.source)
        fvde_volume.close()

        # Test open and close a second time to validate clean up on close.
        fvde_volume.open(unittest.source)
        fvde_volume.close()

        file_object = open(unittest.source, "rb")

        # Test open_file_object and close.
        fvde_volume.open_file_object(file_object)
        fvde_volume.close()

        # Test open_file_object and close a second time to validate clean up on close.
        fvde_volume.open_file_object(file_object)
        fvde_volume.close()

        # Test open_file_object and close and dereferencing file_object.
        fvde_volume.open_file_object(file_object)
        del file_object
        fvde_volume.close()
예제 #8
0
    def test_read_buffer_file_object(self):
        """Tests the read_buffer function on a file-like object."""
        if not unittest.source:
            return

        file_object = open(unittest.source, "rb")
        if unittest.offset:
            file_object = DataRangeFileObject(file_object, unittest.offset,
                                              None)

        fvde_volume = pyfvde.volume()

        if unittest.password:
            fvde_volume.set_password(unittest.password)
        if unittest.recovery_password:
            fvde_volume.set_recovery_password(unittest.recovery_password)

        fvde_volume.open_file_object(file_object)

        file_size = fvde_volume.get_size()

        # Test normal read.
        data = fvde_volume.read_buffer(size=4096)

        self.assertIsNotNone(data)
        self.assertEqual(len(data), min(file_size, 4096))

        fvde_volume.close()
예제 #9
0
    def test_open_file_object(self):
        """Tests the open_file_object function."""
        if not unittest.source:
            raise unittest.SkipTest("missing source")

        if not os.path.isfile(unittest.source):
            raise unittest.SkipTest("source not a regular file")

        fvde_volume = pyfvde.volume()
        if unittest.password:
            fvde_volume.set_password(unittest.password)
        if unittest.recovery_password:
            fvde_volume.set_recovery_password(unittest.recovery_password)

        with DataRangeFileObject(unittest.source, unittest.offset or 0,
                                 None) as file_object:

            fvde_volume.open_file_object(file_object)

            with self.assertRaises(IOError):
                fvde_volume.open_file_object(file_object)

            fvde_volume.close()

            with self.assertRaises(TypeError):
                fvde_volume.open_file_object(None)

            with self.assertRaises(ValueError):
                fvde_volume.open_file_object(file_object, mode="w")
예제 #10
0
    def test_open(self):
        """Tests the open function."""
        if not unittest.source:
            raise unittest.SkipTest("missing source")

        if unittest.offset:
            raise unittest.SkipTest("source defines offset")

        fvde_volume = pyfvde.volume()
        if unittest.password:
            fvde_volume.set_password(unittest.password)
        if unittest.recovery_password:
            fvde_volume.set_recovery_password(unittest.recovery_password)

        fvde_volume.open(unittest.source)

        with self.assertRaises(IOError):
            fvde_volume.open(unittest.source)

        fvde_volume.close()

        with self.assertRaises(TypeError):
            fvde_volume.open(None)

        with self.assertRaises(ValueError):
            fvde_volume.open(unittest.source, mode="w")
예제 #11
0
    def test_read_buffer_at_offset(self):
        """Tests the read_buffer_at_offset function."""
        if not unittest.source:
            return

        fvde_volume = pyfvde.volume()

        fvde_volume.open(unittest.source)

        file_size = fvde_volume.get_size()

        # Test normal read.
        data = fvde_volume.read_buffer_at_offset(4096, 0)

        self.assertIsNotNone(data)
        self.assertEqual(len(data), min(file_size, 4096))

        # Test read beyond file size.
        if file_size > 16:
            data = fvde_volume.read_buffer_at_offset(4096, file_size - 16)

            self.assertIsNotNone(data)
            self.assertEqual(len(data), 16)

        with self.assertRaises(ValueError):
            fvde_volume.read_buffer_at_offset(-1, 0)

        with self.assertRaises(ValueError):
            fvde_volume.read_buffer_at_offset(4096, -1)

        fvde_volume.close()

        # Test the read without open.
        with self.assertRaises(IOError):
            fvde_volume.read_buffer_at_offset(4096, 0)
예제 #12
0
    def _Open(self, mode='rb'):
        """Opens the file system defined by path specification.

    Args:
      mode (Optional[str]): file access mode. The default is 'rb'
          read-only binary.

    Raises:
      AccessError: if the access to open the file was denied.
      IOError: if the file system could not be opened.
      PathSpecError: if the path specification is incorrect.
      ValueError: if the path specification is invalid.
    """
        if not self._path_spec.HasParent():
            raise errors.PathSpecError(
                'Unsupported path specification without parent.')

        resolver.Resolver.key_chain.ExtractCredentialsFromPathSpec(
            self._path_spec)

        fvde_volume = pyfvde.volume()
        file_object = resolver.Resolver.OpenFileObject(
            self._path_spec.parent, resolver_context=self._resolver_context)

        fvde.FVDEVolumeOpen(fvde_volume, self._path_spec, file_object,
                            resolver.Resolver.key_chain)

        self._fvde_volume = fvde_volume
        self._file_object = file_object
예제 #13
0
    def test_seek_offset(self):
        """Tests the seek_offset function."""
        if not unittest.source:
            return

        fvde_volume = pyfvde.volume()

        fvde_volume.open(unittest.source)

        file_size = fvde_volume.get_size()

        fvde_volume.seek_offset(16, os.SEEK_SET)

        offset = fvde_volume.get_offset()
        self.assertEqual(offset, 16)

        fvde_volume.seek_offset(16, os.SEEK_CUR)

        offset = fvde_volume.get_offset()
        self.assertEqual(offset, 32)

        fvde_volume.seek_offset(-16, os.SEEK_CUR)

        offset = fvde_volume.get_offset()
        self.assertEqual(offset, 16)

        fvde_volume.seek_offset(-16, os.SEEK_END)

        offset = fvde_volume.get_offset()
        self.assertEqual(offset, file_size - 16)

        fvde_volume.seek_offset(16, os.SEEK_END)

        offset = fvde_volume.get_offset()
        self.assertEqual(offset, file_size + 16)

        # TODO: change IOError into ValueError
        with self.assertRaises(IOError):
            fvde_volume.seek_offset(-1, os.SEEK_SET)

        # TODO: change IOError into ValueError
        with self.assertRaises(IOError):
            fvde_volume.seek_offset(-32 - file_size, os.SEEK_CUR)

        # TODO: change IOError into ValueError
        with self.assertRaises(IOError):
            fvde_volume.seek_offset(-32 - file_size, os.SEEK_END)

        # TODO: change IOError into ValueError
        with self.assertRaises(IOError):
            fvde_volume.seek_offset(0, -1)

        fvde_volume.close()

        # Test the seek without open.
        with self.assertRaises(IOError):
            fvde_volume.seek_offset(16, os.SEEK_SET)
예제 #14
0
    def test_close(self):
        """Tests the close function."""
        if not unittest.source:
            return

        fvde_volume = pyfvde.volume()

        with self.assertRaises(IOError):
            fvde_volume.close()
예제 #15
0
    def test_close(self):
        """Tests the close function."""
        if not unittest.source:
            raise unittest.SkipTest("missing source")

        fvde_volume = pyfvde.volume()
        if unittest.password:
            fvde_volume.set_password(unittest.password)
        if unittest.recovery_password:
            fvde_volume.set_recovery_password(unittest.recovery_password)

        with self.assertRaises(IOError):
            fvde_volume.close()
예제 #16
0
    def test_read_buffer(self):
        """Tests the read_buffer function."""
        if not unittest.source or unittest.offset:
            return

        fvde_volume = pyfvde.volume()

        if unittest.password:
            fvde_volume.set_password(unittest.password)
        if unittest.recovery_password:
            fvde_volume.set_recovery_password(unittest.recovery_password)

        fvde_volume.open(unittest.source)

        file_size = fvde_volume.get_size()

        # Test normal read.
        data = fvde_volume.read_buffer(size=4096)

        self.assertIsNotNone(data)
        self.assertEqual(len(data), min(file_size, 4096))

        if file_size < 4096:
            data = fvde_volume.read_buffer()

            self.assertIsNotNone(data)
            self.assertEqual(len(data), file_size)

        # Test read beyond file size.
        if file_size > 16:
            fvde_volume.seek_offset(-16, os.SEEK_END)

            data = fvde_volume.read_buffer(size=4096)

            self.assertIsNotNone(data)
            self.assertEqual(len(data), 16)

        with self.assertRaises(ValueError):
            fvde_volume.read_buffer(size=-1)

        fvde_volume.close()

        # Test the read without open.
        with self.assertRaises(IOError):
            fvde_volume.read_buffer(size=4096)
예제 #17
0
    def test_open(self):
        """Tests the open function."""
        if not unittest.source:
            return

        fvde_volume = pyfvde.volume()

        fvde_volume.open(unittest.source)

        with self.assertRaises(IOError):
            fvde_volume.open(unittest.source)

        fvde_volume.close()

        with self.assertRaises(TypeError):
            fvde_volume.open(None)

        with self.assertRaises(ValueError):
            fvde_volume.open(unittest.source, mode="w")
예제 #18
0
    def test_read_buffer_file_object(self):
        """Tests the read_buffer function on a file-like object."""
        if not unittest.source:
            return

        file_object = open(unittest.source, "rb")

        fvde_volume = pyfvde.volume()

        fvde_volume.open_file_object(file_object)

        file_size = fvde_volume.get_size()

        # Test normal read.
        data = fvde_volume.read_buffer(size=4096)

        self.assertIsNotNone(data)
        self.assertEqual(len(data), min(file_size, 4096))

        fvde_volume.close()
예제 #19
0
    def test_open_file_object(self):
        """Tests the open_file_object function."""
        if not unittest.source:
            return

        file_object = open(unittest.source, "rb")

        fvde_volume = pyfvde.volume()

        fvde_volume.open_file_object(file_object)

        with self.assertRaises(IOError):
            fvde_volume.open_file_object(file_object)

        fvde_volume.close()

        # TODO: change IOError into TypeError
        with self.assertRaises(IOError):
            fvde_volume.open_file_object(None)

        with self.assertRaises(ValueError):
            fvde_volume.open_file_object(file_object, mode="w")
예제 #20
0
파일: fvde_file_io.py 프로젝트: devgc/dfvfs
    def _OpenFileObject(self, path_spec):
        """Opens the file-like object defined by path specification.

    Args:
      path_spec (PathSpec): path specification.

    Returns:
      A file-like object.

    Raises:
      PathSpecError: if the path specification is incorrect.
    """
        if not path_spec.HasParent():
            raise errors.PathSpecError(
                u'Unsupported path specification without parent.')

        file_object = resolver.Resolver.OpenFileObject(
            path_spec.parent, resolver_context=self._resolver_context)
        fvde_volume = pyfvde.volume()
        fvde.FVDEVolumeOpen(fvde_volume, path_spec, file_object,
                            resolver.Resolver.key_chain)
        return fvde_volume
예제 #21
0
    def test_open_close(self):
        """Tests the open and close functions."""
        test_source = unittest.source
        if not test_source:
            return

        if unittest.offset:
            raise unittest.SkipTest("source defines offset")

        fvde_volume = pyfvde.volume()
        if unittest.password:
            fvde_volume.set_password(unittest.password)
        if unittest.recovery_password:
            fvde_volume.set_recovery_password(unittest.recovery_password)

        # Test open and close.
        fvde_volume.open(test_source)
        fvde_volume.close()

        # Test open and close a second time to validate clean up on close.
        fvde_volume.open(test_source)
        fvde_volume.close()

        if os.path.isfile(test_source):
            with open(test_source, "rb") as file_object:

                # Test open_file_object and close.
                fvde_volume.open_file_object(file_object)
                fvde_volume.close()

                # Test open_file_object and close a second time to validate clean up on close.
                fvde_volume.open_file_object(file_object)
                fvde_volume.close()

                # Test open_file_object and close and dereferencing file_object.
                fvde_volume.open_file_object(file_object)
                del file_object
                fvde_volume.close()
예제 #22
0
    def test_open(self):
        """Tests the open function."""
        if not unittest.source or unittest.offset:
            return

        fvde_volume = pyfvde.volume()

        if unittest.password:
            fvde_volume.set_password(unittest.password)
        if unittest.recovery_password:
            fvde_volume.set_recovery_password(unittest.recovery_password)

        fvde_volume.open(unittest.source)

        with self.assertRaises(IOError):
            fvde_volume.open(unittest.source)

        fvde_volume.close()

        with self.assertRaises(TypeError):
            fvde_volume.open(None)

        with self.assertRaises(ValueError):
            fvde_volume.open(unittest.source, mode="w")
예제 #23
0
  def _OpenFileObject(self, path_spec):
    """Opens the file-like object defined by path specification.

    Args:
      path_spec (PathSpec): path specification.

    Returns:
      FileIO: a file-like object.

    Raises:
      PathSpecError: if the path specification is incorrect.
    """
    if not path_spec.HasParent():
      raise errors.PathSpecError(
          'Unsupported path specification without parent.')

    resolver.Resolver.key_chain.ExtractCredentialsFromPathSpec(path_spec)

    file_object = resolver.Resolver.OpenFileObject(
        path_spec.parent, resolver_context=self._resolver_context)
    fvde_volume = pyfvde.volume()
    fvde.FVDEVolumeOpen(
        fvde_volume, path_spec, file_object, resolver.Resolver.key_chain)
    return fvde_volume
예제 #24
0
    def test_read_buffer(self):
        """Tests the read_buffer function."""
        if not unittest.source:
            raise unittest.SkipTest("missing source")

        if unittest.offset:
            raise unittest.SkipTest("source defines offset")

        fvde_volume = pyfvde.volume()
        if unittest.password:
            fvde_volume.set_password(unittest.password)
        if unittest.recovery_password:
            fvde_volume.set_recovery_password(unittest.recovery_password)

        fvde_volume.open(unittest.source)

        size = fvde_volume.get_size()

        if size < 4096:
            # Test read without maximum size.
            fvde_volume.seek_offset(0, os.SEEK_SET)

            data = fvde_volume.read_buffer()

            self.assertIsNotNone(data)
            self.assertEqual(len(data), size)

        # Test read with maximum size.
        fvde_volume.seek_offset(0, os.SEEK_SET)

        data = fvde_volume.read_buffer(size=4096)

        self.assertIsNotNone(data)
        self.assertEqual(len(data), min(size, 4096))

        if size > 8:
            fvde_volume.seek_offset(-8, os.SEEK_END)

            # Read buffer on size boundary.
            data = fvde_volume.read_buffer(size=4096)

            self.assertIsNotNone(data)
            self.assertEqual(len(data), 8)

            # Read buffer beyond size boundary.
            data = fvde_volume.read_buffer(size=4096)

            self.assertIsNotNone(data)
            self.assertEqual(len(data), 0)

        # Stress test read buffer.
        fvde_volume.seek_offset(0, os.SEEK_SET)

        remaining_size = size

        for _ in range(1024):
            read_size = int(random.random() * 4096)

            data = fvde_volume.read_buffer(size=read_size)

            self.assertIsNotNone(data)

            data_size = len(data)

            if read_size > remaining_size:
                read_size = remaining_size

            self.assertEqual(data_size, read_size)

            remaining_size -= data_size

            if not remaining_size:
                fvde_volume.seek_offset(0, os.SEEK_SET)

                remaining_size = size

        with self.assertRaises(ValueError):
            fvde_volume.read_buffer(size=-1)

        fvde_volume.close()

        # Test the read without open.
        with self.assertRaises(IOError):
            fvde_volume.read_buffer(size=4096)
예제 #25
0
    def test_close(self):
        """Tests the close function."""
        fvde_volume = pyfvde.volume()

        with self.assertRaises(IOError):
            fvde_volume.close()
예제 #26
0
    def test_read_buffer_at_offset(self):
        """Tests the read_buffer_at_offset function."""
        if not unittest.source:
            raise unittest.SkipTest("missing source")

        if unittest.offset:
            raise unittest.SkipTest("source defines offset")

        fvde_volume = pyfvde.volume()
        if unittest.password:
            fvde_volume.set_password(unittest.password)
        if unittest.recovery_password:
            fvde_volume.set_recovery_password(unittest.recovery_password)

        fvde_volume.open(unittest.source)

        size = fvde_volume.get_size()

        # Test normal read.
        data = fvde_volume.read_buffer_at_offset(4096, 0)

        self.assertIsNotNone(data)
        self.assertEqual(len(data), min(size, 4096))

        if size > 8:
            # Read buffer on size boundary.
            data = fvde_volume.read_buffer_at_offset(4096, size - 8)

            self.assertIsNotNone(data)
            self.assertEqual(len(data), 8)

            # Read buffer beyond size boundary.
            data = fvde_volume.read_buffer_at_offset(4096, size + 8)

            self.assertIsNotNone(data)
            self.assertEqual(len(data), 0)

        # Stress test read buffer.
        for _ in range(1024):
            random_number = random.random()

            media_offset = int(random_number * size)
            read_size = int(random_number * 4096)

            data = fvde_volume.read_buffer_at_offset(read_size, media_offset)

            self.assertIsNotNone(data)

            remaining_size = size - media_offset

            data_size = len(data)

            if read_size > remaining_size:
                read_size = remaining_size

            self.assertEqual(data_size, read_size)

            remaining_size -= data_size

            if not remaining_size:
                fvde_volume.seek_offset(0, os.SEEK_SET)

        with self.assertRaises(ValueError):
            fvde_volume.read_buffer_at_offset(-1, 0)

        with self.assertRaises(ValueError):
            fvde_volume.read_buffer_at_offset(4096, -1)

        fvde_volume.close()

        # Test the read without open.
        with self.assertRaises(IOError):
            fvde_volume.read_buffer_at_offset(4096, 0)
예제 #27
0
    def test_signal_abort(self):
        """Tests the signal_abort function."""
        fvde_volume = pyfvde.volume()

        fvde_volume.signal_abort()
예제 #28
0
    def test_seek_offset(self):
        """Tests the seek_offset function."""
        if not unittest.source:
            raise unittest.SkipTest("missing source")

        if unittest.offset:
            raise unittest.SkipTest("source defines offset")

        fvde_volume = pyfvde.volume()
        if unittest.password:
            fvde_volume.set_password(unittest.password)
        if unittest.recovery_password:
            fvde_volume.set_recovery_password(unittest.recovery_password)

        fvde_volume.open(unittest.source)

        size = fvde_volume.get_size()

        fvde_volume.seek_offset(16, os.SEEK_SET)

        offset = fvde_volume.get_offset()
        self.assertEqual(offset, 16)

        fvde_volume.seek_offset(16, os.SEEK_CUR)

        offset = fvde_volume.get_offset()
        self.assertEqual(offset, 32)

        fvde_volume.seek_offset(-16, os.SEEK_CUR)

        offset = fvde_volume.get_offset()
        self.assertEqual(offset, 16)

        if size > 16:
            fvde_volume.seek_offset(-16, os.SEEK_END)

            offset = fvde_volume.get_offset()
            self.assertEqual(offset, size - 16)

        fvde_volume.seek_offset(16, os.SEEK_END)

        offset = fvde_volume.get_offset()
        self.assertEqual(offset, size + 16)

        # TODO: change IOError into ValueError
        with self.assertRaises(IOError):
            fvde_volume.seek_offset(-1, os.SEEK_SET)

        # TODO: change IOError into ValueError
        with self.assertRaises(IOError):
            fvde_volume.seek_offset(-32 - size, os.SEEK_CUR)

        # TODO: change IOError into ValueError
        with self.assertRaises(IOError):
            fvde_volume.seek_offset(-32 - size, os.SEEK_END)

        # TODO: change IOError into ValueError
        with self.assertRaises(IOError):
            fvde_volume.seek_offset(0, -1)

        fvde_volume.close()

        # Test the seek without open.
        with self.assertRaises(IOError):
            fvde_volume.seek_offset(16, os.SEEK_SET)