Exemplo n.º 1
0
    def testInitialize(self):
        """Tests the path specification initialization."""
        path_spec = ewf_path_spec.EWFPathSpec(parent=self._path_spec)

        self.assertIsNotNone(path_spec)

        with self.assertRaises(ValueError):
            ewf_path_spec.EWFPathSpec(parent=None)

        with self.assertRaises(ValueError):
            ewf_path_spec.EWFPathSpec(parent=self._path_spec, bogus='BOGUS')
Exemplo n.º 2
0
 def setUp(self):
     """Sets up the needed objects used throughout the test."""
     super(EWFFileTest, self).setUp()
     test_file = self._GetTestFilePath([u'image.E01'])
     self._os_path_spec = os_path_spec.OSPathSpec(location=test_file)
     self._ewf_path_spec = ewf_path_spec.EWFPathSpec(
         parent=self._os_path_spec)
Exemplo n.º 3
0
    def testComparable(self):
        """Tests the path specification comparable property."""
        path_spec = ewf_path_spec.EWFPathSpec(parent=self._path_spec)

        self.assertIsNotNone(path_spec)

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

        self.assertEqual(path_spec.comparable, expected_comparable)
Exemplo n.º 4
0
    def setUp(self):
        """Sets up the needed objects used throughout the test."""
        super(SplitEWFFileTest, self).setUp()
        test_file = self._GetTestFilePath(['ext2.split.E01'])
        self._SkipIfPathNotExists(test_file)

        self._os_path_spec = os_path_spec.OSPathSpec(location=test_file)
        self._ewf_path_spec = ewf_path_spec.EWFPathSpec(
            parent=self._os_path_spec)
Exemplo n.º 5
0
  def testOpenCloseLocation(self):
    """Test the open and close functionality using a location."""
    self._TestOpenCloseLocation(self._ewf_path_spec)

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

    with self.assertRaises(errors.PathSpecError):
      self._TestOpenCloseLocation(path_spec)
Exemplo n.º 6
0
 def setUp(self):
   """Sets up the needed objects used throughout the test."""
   super(SplitEWFFileTest, self).setUp()
   test_file = os.path.join(u'test_data', u'image-split.E01')
   path_spec = os_path_spec.OSPathSpec(location=test_file)
   self._ewf_path_spec = ewf_path_spec.EWFPathSpec(parent=path_spec)
Exemplo n.º 7
0
    def testGlobE01(self):
        """Test the glob function."""
        expected_segment_file_path_specs = []
        file_system = self._BuildFileFakeFileSystem(
            u'image.E01', 1, expected_segment_file_path_specs)

        # Test single segment file: E01.
        path_spec = fake_path_spec.FakePathSpec(location=u'/image.E01')
        path_spec = ewf_path_spec.EWFPathSpec(parent=path_spec)

        segment_file_path_specs = ewf.EWFGlobPathSpec(file_system, path_spec)
        self.assertEqual(len(segment_file_path_specs),
                         len(expected_segment_file_path_specs))
        self.assertEqual(segment_file_path_specs,
                         expected_segment_file_path_specs)

        # Test non exiting segment file: E01.
        expected_segment_file_path_specs = []

        path_spec = fake_path_spec.FakePathSpec(location=u'/bogus.E01')
        path_spec = ewf_path_spec.EWFPathSpec(parent=path_spec)

        segment_file_path_specs = ewf.EWFGlobPathSpec(file_system, path_spec)
        self.assertEqual(len(segment_file_path_specs),
                         len(expected_segment_file_path_specs))
        self.assertEqual(segment_file_path_specs,
                         expected_segment_file_path_specs)

        # Test multiple segment files: E01-E10.
        expected_segment_file_path_specs = []
        file_system = self._BuildFileFakeFileSystem(
            u'image.E01', 10, expected_segment_file_path_specs)

        path_spec = fake_path_spec.FakePathSpec(location=u'/image.E01')
        path_spec = ewf_path_spec.EWFPathSpec(parent=path_spec)

        segment_file_path_specs = ewf.EWFGlobPathSpec(file_system, path_spec)
        self.assertEqual(len(segment_file_path_specs),
                         len(expected_segment_file_path_specs))
        self.assertEqual(segment_file_path_specs,
                         expected_segment_file_path_specs)

        # Test multiple segment files: E01-E99,EAA.
        expected_segment_file_path_specs = []
        file_system = self._BuildFileFakeFileSystem(
            u'image.E01', 100, expected_segment_file_path_specs)

        path_spec = fake_path_spec.FakePathSpec(location=u'/image.E01')
        path_spec = ewf_path_spec.EWFPathSpec(parent=path_spec)

        segment_file_path_specs = ewf.EWFGlobPathSpec(file_system, path_spec)
        self.assertEqual(len(segment_file_path_specs),
                         len(expected_segment_file_path_specs))
        self.assertEqual(segment_file_path_specs,
                         expected_segment_file_path_specs)

        # Test multiple segment files: E01-E99,EAA-EBA.
        expected_segment_file_path_specs = []
        file_system = self._BuildFileFakeFileSystem(
            u'image.E01', 126, expected_segment_file_path_specs)

        path_spec = fake_path_spec.FakePathSpec(location=u'/image.E01')
        path_spec = ewf_path_spec.EWFPathSpec(parent=path_spec)

        segment_file_path_specs = ewf.EWFGlobPathSpec(file_system, path_spec)
        self.assertEqual(len(segment_file_path_specs),
                         len(expected_segment_file_path_specs))
        self.assertEqual(segment_file_path_specs,
                         expected_segment_file_path_specs)

        # Test multiple segment files: E01-E99,EAA-EZZ.
        expected_segment_file_path_specs = []
        file_system = self._BuildFileFakeFileSystem(
            u'image.E01', 775, expected_segment_file_path_specs)

        path_spec = fake_path_spec.FakePathSpec(location=u'/image.E01')
        path_spec = ewf_path_spec.EWFPathSpec(parent=path_spec)

        segment_file_path_specs = ewf.EWFGlobPathSpec(file_system, path_spec)
        self.assertEqual(len(segment_file_path_specs),
                         len(expected_segment_file_path_specs))
        self.assertEqual(segment_file_path_specs,
                         expected_segment_file_path_specs)

        # Test multiple segment files: E01-E99,EAA-ZZZ.
        expected_segment_file_path_specs = []
        file_system = self._BuildFileFakeFileSystem(
            u'image.E01', 14970, expected_segment_file_path_specs)

        path_spec = fake_path_spec.FakePathSpec(location=u'/image.E01')
        path_spec = ewf_path_spec.EWFPathSpec(parent=path_spec)

        segment_file_path_specs = ewf.EWFGlobPathSpec(file_system, path_spec)
        self.assertEqual(len(segment_file_path_specs),
                         len(expected_segment_file_path_specs))
        self.assertEqual(segment_file_path_specs,
                         expected_segment_file_path_specs)

        # Test multiple segment files: E01-E99,EAA-[ZZ.
        expected_segment_file_path_specs = []
        file_system = self._BuildFileFakeFileSystem(
            u'image.E01', 14971, expected_segment_file_path_specs)

        path_spec = fake_path_spec.FakePathSpec(location=u'/image.E01')
        path_spec = ewf_path_spec.EWFPathSpec(parent=path_spec)

        with self.assertRaises(RuntimeError):
            segment_file_path_specs = ewf.EWFGlobPathSpec(
                file_system, path_spec)