Example #1
0
  def testFileEntryExistsByPathSpec(self):
    """Test the file entry exists by path specification functionality."""
    file_system = vshadow_file_system.VShadowFileSystem(self._resolver_context)
    self.assertIsNotNone(file_system)

    file_system.Open(self._vshadow_path_spec)

    path_spec = vshadow_path_spec.VShadowPathSpec(
        location='/', parent=self._qcow_path_spec)
    self.assertTrue(file_system.FileEntryExistsByPathSpec(path_spec))

    path_spec = vshadow_path_spec.VShadowPathSpec(
        parent=self._qcow_path_spec, store_index=1)
    self.assertTrue(file_system.FileEntryExistsByPathSpec(path_spec))

    path_spec = vshadow_path_spec.VShadowPathSpec(
        location='/vss2', parent=self._qcow_path_spec)
    self.assertTrue(file_system.FileEntryExistsByPathSpec(path_spec))

    path_spec = vshadow_path_spec.VShadowPathSpec(
        parent=self._qcow_path_spec, store_index=9)
    self.assertFalse(file_system.FileEntryExistsByPathSpec(path_spec))

    path_spec = vshadow_path_spec.VShadowPathSpec(
        location='/vss0', parent=self._qcow_path_spec)
    self.assertFalse(file_system.FileEntryExistsByPathSpec(path_spec))

    path_spec = vshadow_path_spec.VShadowPathSpec(
        location='/vss9', parent=self._qcow_path_spec)
    self.assertFalse(file_system.FileEntryExistsByPathSpec(path_spec))

    file_system.Close()
Example #2
0
  def testOpenAndClose(self):
    """Test the open and close functionality."""
    file_system = vshadow_file_system.VShadowFileSystem(
        self._resolver_context, self._vshadow_path_spec)
    self.assertIsNotNone(file_system)

    file_system.Open()
Example #3
0
  def testOpenAndClose(self):
    """Test the open and close functionality."""
    file_system = vshadow_file_system.VShadowFileSystem(self._resolver_context)
    self.assertNotEqual(file_system, None)

    file_system.Open(path_spec=self._vshadow_path_spec)

    file_system.Close()
Example #4
0
  def NewFileSystem(self, resolver_context):
    """Creates a new file system object.

    Args:
      resolver_context (Context): resolver context.

    Returns:
      FileSystem: file system.
    """
    return vshadow_file_system.VShadowFileSystem(resolver_context)
Example #5
0
  def NewFileSystem(self, resolver_context, path_spec):
    """Creates a new file system object.

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

    Returns:
      FileSystem: file system.
    """
    return vshadow_file_system.VShadowFileSystem(resolver_context, path_spec)
    def setUp(self):
        """Sets up the needed objects used throughout the test."""
        self._resolver_context = context.Context()
        test_file = self._GetTestFilePath(['vsstest.qcow2'])
        path_spec = os_path_spec.OSPathSpec(location=test_file)
        self._qcow_path_spec = qcow_path_spec.QCOWPathSpec(parent=path_spec)
        self._vshadow_path_spec = vshadow_path_spec.VShadowPathSpec(
            location='/', parent=self._qcow_path_spec)

        self._file_system = vshadow_file_system.VShadowFileSystem(
            self._resolver_context)
        self._file_system.Open(self._vshadow_path_spec)
Example #7
0
  def testGetRootFileEntry(self):
    """Test the get root file entry functionality."""
    file_system = vshadow_file_system.VShadowFileSystem(
        self._resolver_context, self._vshadow_path_spec)
    self.assertIsNotNone(file_system)

    file_system.Open()

    file_entry = file_system.GetRootFileEntry()

    self.assertIsNotNone(file_entry)
    self.assertEqual(file_entry.name, '')
Example #8
0
    def setUp(self):
        """Sets up the needed objects used throughout the test."""
        self._resolver_context = context.Context()
        test_file = os.path.join(u'test_data', u'vsstest.qcow2')
        path_spec = os_path_spec.OSPathSpec(location=test_file)
        self._qcow_path_spec = qcow_path_spec.QcowPathSpec(parent=path_spec)
        self._vshadow_path_spec = vshadow_path_spec.VShadowPathSpec(
            location=u'/', parent=self._qcow_path_spec)

        self._file_system = vshadow_file_system.VShadowFileSystem(
            self._resolver_context)
        self._file_system.Open(path_spec=self._vshadow_path_spec)
Example #9
0
  def testGetFileEntryByPathSpec(self):
    """Tests the GetFileEntryByPathSpec function."""
    file_system = vshadow_file_system.VShadowFileSystem(
        self._resolver_context, self._vshadow_path_spec)
    self.assertIsNotNone(file_system)

    file_system.Open()

    path_spec = path_spec_factory.Factory.NewPathSpec(
        definitions.TYPE_INDICATOR_VSHADOW, location='/',
        parent=self._qcow_path_spec)
    file_entry = file_system.GetFileEntryByPathSpec(path_spec)

    self.assertIsNotNone(file_entry)
    self.assertEqual(file_entry.name, '')

    path_spec = path_spec_factory.Factory.NewPathSpec(
        definitions.TYPE_INDICATOR_VSHADOW, parent=self._qcow_path_spec,
        store_index=1)
    file_entry = file_system.GetFileEntryByPathSpec(path_spec)

    self.assertIsNotNone(file_entry)
    self.assertEqual(file_entry.name, 'vss2')

    path_spec = path_spec_factory.Factory.NewPathSpec(
        definitions.TYPE_INDICATOR_VSHADOW, location='/vss2',
        parent=self._qcow_path_spec)
    file_entry = file_system.GetFileEntryByPathSpec(path_spec)

    self.assertIsNotNone(file_entry)
    self.assertEqual(file_entry.name, 'vss2')

    path_spec = path_spec_factory.Factory.NewPathSpec(
        definitions.TYPE_INDICATOR_VSHADOW, parent=self._qcow_path_spec,
        store_index=9)
    file_entry = file_system.GetFileEntryByPathSpec(path_spec)

    self.assertIsNone(file_entry)

    path_spec = path_spec_factory.Factory.NewPathSpec(
        definitions.TYPE_INDICATOR_VSHADOW, location='/vss0',
        parent=self._qcow_path_spec)
    file_entry = file_system.GetFileEntryByPathSpec(path_spec)

    self.assertIsNone(file_entry)

    path_spec = path_spec_factory.Factory.NewPathSpec(
        definitions.TYPE_INDICATOR_VSHADOW, location='/vss9',
        parent=self._qcow_path_spec)
    file_entry = file_system.GetFileEntryByPathSpec(path_spec)

    self.assertIsNone(file_entry)
Example #10
0
  def testGetRootFileEntry(self):
    """Test the get root file entry functionality."""
    file_system = vshadow_file_system.VShadowFileSystem(self._resolver_context)
    self.assertNotEqual(file_system, None)

    file_system.Open(path_spec=self._vshadow_path_spec)

    file_entry = file_system.GetRootFileEntry()

    self.assertNotEqual(file_entry, None)
    self.assertEqual(file_entry.name, u'')

    file_system.Close()
Example #11
0
    def testGetFileEntryByPathSpec(self):
        """Tests the GetFileEntryByPathSpec function."""
        file_system = vshadow_file_system.VShadowFileSystem(
            self._resolver_context)
        self.assertIsNotNone(file_system)

        file_system.Open(self._vshadow_path_spec)

        path_spec = vshadow_path_spec.VShadowPathSpec(
            location='/', parent=self._qcow_path_spec)
        file_entry = file_system.GetFileEntryByPathSpec(path_spec)

        self.assertIsNotNone(file_entry)
        self.assertEqual(file_entry.name, '')

        path_spec = vshadow_path_spec.VShadowPathSpec(
            parent=self._qcow_path_spec, store_index=1)
        file_entry = file_system.GetFileEntryByPathSpec(path_spec)

        self.assertIsNotNone(file_entry)
        self.assertEqual(file_entry.name, 'vss2')

        path_spec = vshadow_path_spec.VShadowPathSpec(
            location='/vss2', parent=self._qcow_path_spec)
        file_entry = file_system.GetFileEntryByPathSpec(path_spec)

        self.assertIsNotNone(file_entry)
        self.assertEqual(file_entry.name, 'vss2')

        path_spec = vshadow_path_spec.VShadowPathSpec(
            parent=self._qcow_path_spec, store_index=9)
        file_entry = file_system.GetFileEntryByPathSpec(path_spec)

        self.assertIsNone(file_entry)

        path_spec = vshadow_path_spec.VShadowPathSpec(
            location='/vss0', parent=self._qcow_path_spec)
        file_entry = file_system.GetFileEntryByPathSpec(path_spec)

        self.assertIsNone(file_entry)

        path_spec = vshadow_path_spec.VShadowPathSpec(
            location='/vss9', parent=self._qcow_path_spec)
        file_entry = file_system.GetFileEntryByPathSpec(path_spec)

        self.assertIsNone(file_entry)

        file_system.Close()
Example #12
0
  def testGetFileEntryByPathSpec(self):
    """Test the get entry by path specification functionality."""
    file_system = vshadow_file_system.VShadowFileSystem(self._resolver_context)
    self.assertNotEqual(file_system, None)

    file_system.Open(path_spec=self._vshadow_path_spec)

    path_spec = vshadow_path_spec.VShadowPathSpec(
        location=u'/', parent=self._qcow_path_spec)
    file_entry = file_system.GetFileEntryByPathSpec(path_spec)

    self.assertNotEqual(file_entry, None)
    self.assertEqual(file_entry.name, u'')

    path_spec = vshadow_path_spec.VShadowPathSpec(
        store_index=1, parent=self._qcow_path_spec)
    file_entry = file_system.GetFileEntryByPathSpec(path_spec)

    self.assertNotEqual(file_entry, None)
    self.assertEqual(file_entry.name, u'vss2')

    path_spec = vshadow_path_spec.VShadowPathSpec(
        location=u'/vss2', parent=self._qcow_path_spec)
    file_entry = file_system.GetFileEntryByPathSpec(path_spec)

    self.assertNotEqual(file_entry, None)
    self.assertEqual(file_entry.name, u'vss2')

    path_spec = vshadow_path_spec.VShadowPathSpec(
        store_index=9, parent=self._qcow_path_spec)
    file_entry = file_system.GetFileEntryByPathSpec(path_spec)

    self.assertEqual(file_entry, None)

    path_spec = vshadow_path_spec.VShadowPathSpec(
        location=u'/vss0', parent=self._qcow_path_spec)
    file_entry = file_system.GetFileEntryByPathSpec(path_spec)

    self.assertEqual(file_entry, None)

    path_spec = vshadow_path_spec.VShadowPathSpec(
        location=u'/vss9', parent=self._qcow_path_spec)
    file_entry = file_system.GetFileEntryByPathSpec(path_spec)

    self.assertEqual(file_entry, None)

    file_system.Close()
Example #13
0
    def setUp(self):
        """Sets up the needed objects used throughout the test."""
        self._resolver_context = context.Context()
        test_path = self._GetTestFilePath(['vsstest.qcow2'])
        self._SkipIfPathNotExists(test_path)

        test_os_path_spec = path_spec_factory.Factory.NewPathSpec(
            definitions.TYPE_INDICATOR_OS, location=test_path)
        self._qcow_path_spec = path_spec_factory.Factory.NewPathSpec(
            definitions.TYPE_INDICATOR_QCOW, parent=test_os_path_spec)
        self._vshadow_path_spec = path_spec_factory.Factory.NewPathSpec(
            definitions.TYPE_INDICATOR_VSHADOW,
            location='/',
            parent=self._qcow_path_spec)

        self._file_system = vshadow_file_system.VShadowFileSystem(
            self._resolver_context, self._vshadow_path_spec)
        self._file_system.Open()
Example #14
0
  def testFileEntryExistsByPathSpec(self):
    """Test the file entry exists by path specification functionality."""
    file_system = vshadow_file_system.VShadowFileSystem(
        self._resolver_context, self._vshadow_path_spec)
    self.assertIsNotNone(file_system)

    file_system.Open()

    path_spec = path_spec_factory.Factory.NewPathSpec(
        definitions.TYPE_INDICATOR_VSHADOW, location='/',
        parent=self._qcow_path_spec)
    self.assertTrue(file_system.FileEntryExistsByPathSpec(path_spec))

    path_spec = path_spec_factory.Factory.NewPathSpec(
        definitions.TYPE_INDICATOR_VSHADOW, parent=self._qcow_path_spec,
        store_index=1)
    self.assertTrue(file_system.FileEntryExistsByPathSpec(path_spec))

    path_spec = path_spec_factory.Factory.NewPathSpec(
        definitions.TYPE_INDICATOR_VSHADOW, location='/vss2',
        parent=self._qcow_path_spec)
    self.assertTrue(file_system.FileEntryExistsByPathSpec(path_spec))

    path_spec = path_spec_factory.Factory.NewPathSpec(
        definitions.TYPE_INDICATOR_VSHADOW, parent=self._qcow_path_spec,
        store_index=9)
    self.assertFalse(file_system.FileEntryExistsByPathSpec(path_spec))

    path_spec = path_spec_factory.Factory.NewPathSpec(
        definitions.TYPE_INDICATOR_VSHADOW, location='/vss0',
        parent=self._qcow_path_spec)
    self.assertFalse(file_system.FileEntryExistsByPathSpec(path_spec))

    path_spec = path_spec_factory.Factory.NewPathSpec(
        definitions.TYPE_INDICATOR_VSHADOW, location='/vss9',
        parent=self._qcow_path_spec)
    self.assertFalse(file_system.FileEntryExistsByPathSpec(path_spec))