def testRead(self):
        """Test the read functionality."""
        file_object = encrypted_stream_io.EncryptedStream(
            self._resolver_context, self._encrypted_stream_path_spec)
        file_object.Open()

        self._TestReadFileObject(file_object)
    def testOpenClosePathSpec(self):
        """Test the open and close functionality using a path specification."""
        file_object = encrypted_stream_io.EncryptedStream(
            self._resolver_context, self._encrypted_stream_path_spec)
        file_object.Open()

        self._TestGetSizeFileObject(file_object)
    def testSeek(self):
        """Test the seek functionality."""
        file_object = encrypted_stream_io.EncryptedStream(
            self._resolver_context, self._encrypted_stream_path_spec)
        file_object.Open()

        self._TestSeekFileObject(file_object)

        # TODO: Test SEEK_CUR after open.

        # Test SEEK_END after open.
        file_object = encrypted_stream_io.EncryptedStream(
            self._resolver_context, self._encrypted_stream_path_spec)
        file_object.Open()

        file_object.seek(-10 - self.padding_size, os.SEEK_END)
        self.assertEqual(file_object.read(5), b'times')
Exemple #4
0
    def testSeek(self):
        """Test the seek functionality."""
        file_object = encrypted_stream_io.EncryptedStream(
            self._resolver_context)
        file_object.open(path_spec=self._encrypted_stream_path_spec)

        self._TestSeekFileObject(file_object)

        file_object.close()
Exemple #5
0
  def NewFileObject(self, resolver_context):
    """Creates a new file-like object.

    Args:
      resolver_context (Context): resolver context.

    Returns:
      FileIO: file-like object.
    """
    return encrypted_stream_io.EncryptedStream(resolver_context)
Exemple #6
0
  def NewFileObject(self, resolver_context, path_spec):
    """Creates a new file input/output (IO) object.

    Args:
      resolver_context (Context): resolver context.
      path_spec (PathSpec): a path specification.

    Returns:
      FileIO: file input/output (IO) object.
    """
    return encrypted_stream_io.EncryptedStream(resolver_context, path_spec)
Exemple #7
0
    def testOpenCloseFileObject(self):
        """Test the open and close functionality using a file-like object."""
        os_file_object = os_file_io.OSFile(self._resolver_context)
        os_file_object.open(path_spec=self._os_path_spec)
        file_object = encrypted_stream_io.EncryptedStream(
            self._resolver_context,
            encryption_method=definitions.ENCRYPTION_METHOD_AES,
            file_object=os_file_object)
        file_object.open(path_spec=self._encrypted_stream_path_spec)

        self._TestGetSizeFileObject(file_object)

        file_object.close()
        os_file_object.close()