Ejemplo n.º 1
0
    def testInitialize(self):
        """Tests the path specification initialization."""
        path_spec = bde_path_spec.BDEPathSpec(parent=self._path_spec)

        self.assertIsNotNone(path_spec)

        with self.assertRaises(ValueError):
            bde_path_spec.BDEPathSpec(parent=None)

        with self.assertRaises(ValueError):
            bde_path_spec.BDEPathSpec(parent=self._path_spec, bogus='BOGUS')
Ejemplo n.º 2
0
 def setUp(self):
     """Sets up the needed objects used throughout the test."""
     super(BDEFileWithPathSpecCredentialsTest, self).setUp()
     test_file = self._GetTestFilePath([u'bdetogo.raw'])
     self._os_path_spec = os_path_spec.OSPathSpec(location=test_file)
     self._bde_path_spec = bde_path_spec.BDEPathSpec(
         password=self._BDE_PASSWORD, parent=self._os_path_spec)
Ejemplo n.º 3
0
    def GetRootFileEntry(self):
        """Retrieves the root file entry.

    Returns:
      BDEFileEntry: file entry or None.
    """
        path_spec = bde_path_spec.BDEPathSpec(parent=self._path_spec.parent)
        return self.GetFileEntryByPathSpec(path_spec)
Ejemplo n.º 4
0
 def setUp(self):
     """Sets up the needed objects used throughout the test."""
     self._resolver_context = context.Context()
     test_file = self._GetTestFilePath(['bdetogo.raw'])
     path_spec = os_path_spec.OSPathSpec(location=test_file)
     self._bde_path_spec = bde_path_spec.BDEPathSpec(parent=path_spec)
     resolver.Resolver.key_chain.SetCredential(self._bde_path_spec,
                                               'password',
                                               self._BDE_PASSWORD)
Ejemplo n.º 5
0
    def testComparable(self):
        """Tests the path specification comparable property."""
        path_spec = bde_path_spec.BDEPathSpec(parent=self._path_spec)

        self.assertIsNotNone(path_spec)

        expected_comparable = u'\n'.join([u'type: TEST', u'type: BDE', u''])

        self.assertEqual(path_spec.comparable, expected_comparable)
Ejemplo n.º 6
0
    def testOpenCloseLocation(self):
        """Test the open and close functionality using a location."""
        self._TestOpenCloseLocation(self._bde_path_spec)

        # Try open with a path specification that has no parent.
        path_spec = bde_path_spec.BDEPathSpec(parent=self._os_path_spec)
        path_spec.parent = None

        with self.assertRaises(errors.PathSpecError):
            self._TestOpenCloseLocation(path_spec)
Ejemplo n.º 7
0
 def setUp(self):
     """Sets up the needed objects used throughout the test."""
     super(BDEFileWithKeyChainTest, self).setUp()
     test_file = self._GetTestFilePath([u'bdetogo.raw'])
     self._os_path_spec = os_path_spec.OSPathSpec(location=test_file)
     self._bde_path_spec = bde_path_spec.BDEPathSpec(
         parent=self._os_path_spec)
     resolver.Resolver.key_chain.SetCredential(self._bde_path_spec,
                                               u'password',
                                               self._BDE_PASSWORD)