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')
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)
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)
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)
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)
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)
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)