diff --git a/dfvfs/vfs/ext_attribute.py b/dfvfs/vfs/ext_attribute.py index 8f781ee7..34710bc4 100644 --- a/dfvfs/vfs/ext_attribute.py +++ b/dfvfs/vfs/ext_attribute.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -"""The EXT attribute implementations.""" +"""The EXT attribute implementation.""" import os diff --git a/test_data/ext2.E01 b/test_data/ext2.E01 index adb42fe0..d59a90a1 100644 Binary files a/test_data/ext2.E01 and b/test_data/ext2.E01 differ diff --git a/test_data/ext2.qcow2 b/test_data/ext2.qcow2 index 76a07f73..4d230b44 100644 Binary files a/test_data/ext2.qcow2 and b/test_data/ext2.qcow2 differ diff --git a/test_data/ext2.raw b/test_data/ext2.raw index 8fc1f6c0..2b4b9aaf 100644 Binary files a/test_data/ext2.raw and b/test_data/ext2.raw differ diff --git a/test_data/ext2.split.E01 b/test_data/ext2.split.E01 index 95745565..f2c7a247 100644 Binary files a/test_data/ext2.split.E01 and b/test_data/ext2.split.E01 differ diff --git a/test_data/ext2.split.E02 b/test_data/ext2.split.E02 index 3a2780f6..b46f3539 100644 Binary files a/test_data/ext2.split.E02 and b/test_data/ext2.split.E02 differ diff --git a/test_data/ext2.splitraw.000 b/test_data/ext2.splitraw.000 index d0d71abf..c8dcde41 100644 Binary files a/test_data/ext2.splitraw.000 and b/test_data/ext2.splitraw.000 differ diff --git a/test_data/ext2.vhd b/test_data/ext2.vhd index 67b59236..fc6dc802 100644 Binary files a/test_data/ext2.vhd and b/test_data/ext2.vhd differ diff --git a/test_data/ext2.vhdx b/test_data/ext2.vhdx index 5bfa6bca..7e475feb 100644 Binary files a/test_data/ext2.vhdx and b/test_data/ext2.vhdx differ diff --git a/test_data/ext2.vmdk b/test_data/ext2.vmdk index c1275db2..b549aa40 100644 Binary files a/test_data/ext2.vmdk and b/test_data/ext2.vmdk differ diff --git a/test_data/ext4.raw b/test_data/ext4.raw index af750ac9..f1fe4d4b 100644 Binary files a/test_data/ext4.raw and b/test_data/ext4.raw differ diff --git a/test_data/gpt.raw b/test_data/gpt.raw index 91a270eb..1b59eace 100644 Binary files a/test_data/gpt.raw and b/test_data/gpt.raw differ diff --git a/test_data/luks1.raw b/test_data/luks1.raw index 36ee629f..c2f0d1ac 100644 Binary files a/test_data/luks1.raw and b/test_data/luks1.raw differ diff --git a/test_data/luks2.raw b/test_data/luks2.raw new file mode 100644 index 00000000..59732866 Binary files /dev/null and b/test_data/luks2.raw differ diff --git a/test_data/lvm.raw b/test_data/lvm.raw index 6c867389..fd2e8070 100644 Binary files a/test_data/lvm.raw and b/test_data/lvm.raw differ diff --git a/test_data/mbr.raw b/test_data/mbr.raw index c17a6a30..e9613f80 100644 Binary files a/test_data/mbr.raw and b/test_data/mbr.raw differ diff --git a/test_data/xfs.raw b/test_data/xfs.raw index 2749d9a8..3c44527e 100644 Binary files a/test_data/xfs.raw and b/test_data/xfs.raw differ diff --git a/tests/file_io/test_lib.py b/tests/file_io/test_lib.py index fde3a829..5cc1f344 100644 --- a/tests/file_io/test_lib.py +++ b/tests/file_io/test_lib.py @@ -580,8 +580,9 @@ def _TestSeek(self, parent_path_spec): file_object.seek(4128) self.assertEqual(file_object.get_offset(), 0x11620 - self._OFFSET_P2) - self.assertEqual( - file_object.read(16), b'lost+found\x00\x00\x0c\x00\x00\x00') + + data = file_object.read(16) + self.assertEqual(data, b'lost+found\x00\x00\x0c\x00\x00\x00') self.assertEqual(file_object.get_offset(), 0x11630 - self._OFFSET_P2) file_object.seek(-28156, os.SEEK_END) @@ -633,7 +634,7 @@ def _TestRead(self, parent_path_spec): self.assertEqual(file_object.get_size(), self._SIZE_P2) - file_object.seek(0x19e00 - self._OFFSET_P2) + file_object.seek(0x15a00 - self._OFFSET_P2) data = file_object.read(32) diff --git a/tests/vfs/ext_attribute.py b/tests/vfs/ext_attribute.py new file mode 100644 index 00000000..a708971a --- /dev/null +++ b/tests/vfs/ext_attribute.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +"""Tests for the EXT attribute.""" + +import unittest + +from dfvfs.lib import definitions +from dfvfs.lib import errors +from dfvfs.path import factory as path_spec_factory +from dfvfs.resolver import context +from dfvfs.vfs import ext_attribute +from dfvfs.vfs import ext_file_system + +from tests import test_lib as shared_test_lib + + +class EXTAttributeTest(shared_test_lib.BaseTestCase): + """Tests the EXT attribute.""" + + # pylint: disable=protected-access + + _INODE_A_FILE = 13 + + def setUp(self): + """Sets up the needed objects used throughout the test.""" + self._resolver_context = context.Context() + test_path = self._GetTestFilePath(['ext2.raw']) + self._SkipIfPathNotExists(test_path) + + test_os_path_spec = path_spec_factory.Factory.NewPathSpec( + definitions.TYPE_INDICATOR_OS, location=test_path) + self._raw_path_spec = path_spec_factory.Factory.NewPathSpec( + definitions.TYPE_INDICATOR_RAW, parent=test_os_path_spec) + self._ext_path_spec = path_spec_factory.Factory.NewPathSpec( + definitions.TYPE_INDICATOR_EXT, location='/', + parent=self._raw_path_spec) + + self._file_system = ext_file_system.EXTFileSystem( + self._resolver_context, self._ext_path_spec) + self._file_system.Open() + + def tearDown(self): + """Cleans up the needed objects used throughout the test.""" + self._resolver_context.Empty() + + def testIntialize(self): + """Tests the __init__ function.""" + test_location = '/a_directory/a_file' + path_spec = path_spec_factory.Factory.NewPathSpec( + definitions.TYPE_INDICATOR_EXT, inode=self._INODE_A_FILE, + location=test_location, parent=self._raw_path_spec) + file_entry = self._file_system.GetFileEntryByPathSpec(path_spec) + + fsext_attribute = file_entry._fsext_file_entry.get_extended_attribute(0) + self.assertIsNotNone(fsext_attribute) + self.assertEqual(fsext_attribute.name, 'user.myxattr') + + test_attribute = ext_attribute.EXTExtendedAttribute(fsext_attribute) + self.assertIsNotNone(test_attribute) + + with self.assertRaises(errors.BackEndError): + ext_attribute.EXTExtendedAttribute(None) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/vfs/ext_file_entry.py b/tests/vfs/ext_file_entry.py index daff5031..8c7c9ee0 100644 --- a/tests/vfs/ext_file_entry.py +++ b/tests/vfs/ext_file_entry.py @@ -146,15 +146,15 @@ def testGetStat(self): self.assertEqual(stat_object.uid, 1000) self.assertEqual(stat_object.gid, 1000) - self.assertEqual(stat_object.atime, 1567246979) + self.assertEqual(stat_object.atime, 1626962852) self.assertFalse(hasattr(stat_object, 'atime_nano')) - self.assertEqual(stat_object.ctime, 1567246979) + self.assertEqual(stat_object.ctime, 1626962852) self.assertFalse(hasattr(stat_object, 'ctime_nano')) self.assertFalse(hasattr(stat_object, 'crtime')) - self.assertEqual(stat_object.mtime, 1567246979) + self.assertEqual(stat_object.mtime, 1626962852) self.assertFalse(hasattr(stat_object, 'mtime_nano')) def testGetStatAttribute(self): @@ -490,17 +490,17 @@ def testGetStat(self): self.assertEqual(stat_object.uid, 1000) self.assertEqual(stat_object.gid, 1000) - self.assertEqual(stat_object.atime, 1620201706) - self.assertEqual(stat_object.atime_nano, 4539288) + self.assertEqual(stat_object.atime, 1626962852) + self.assertEqual(stat_object.atime_nano, 8436108) - self.assertEqual(stat_object.ctime, 1620201706) - self.assertEqual(stat_object.ctime_nano, 4549288) + self.assertEqual(stat_object.ctime, 1626962852) + self.assertEqual(stat_object.ctime_nano, 8436108) - self.assertEqual(stat_object.crtime, 1620201706) - self.assertEqual(stat_object.crtime_nano, 4539288) + self.assertEqual(stat_object.crtime, 1626962852) + self.assertEqual(stat_object.crtime_nano, 8436108) - self.assertEqual(stat_object.mtime, 1620201706) - self.assertEqual(stat_object.mtime_nano, 4549288) + self.assertEqual(stat_object.mtime, 1626962852) + self.assertEqual(stat_object.mtime_nano, 8436108) def testIsFunctions(self): """Tests the Is? functions.""" diff --git a/tests/vfs/luksde_file_entry.py b/tests/vfs/luksde_file_entry.py index 16b1b85a..6b02496a 100644 --- a/tests/vfs/luksde_file_entry.py +++ b/tests/vfs/luksde_file_entry.py @@ -56,7 +56,7 @@ def testSize(self): self._luksde_path_spec) self.assertIsNotNone(file_entry) - self.assertEqual(file_entry.size, 6291456) + self.assertEqual(file_entry.size, 8388608) def testGetFileEntryByPathSpec(self): """Test the get a file entry by path specification functionality.""" @@ -82,7 +82,7 @@ def testGetStat(self): stat_object = file_entry.GetStat() self.assertIsNotNone(stat_object) self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 6291456) + self.assertEqual(stat_object.size, 8388608) def testIsAllocated(self): """Test the IsAllocated function.""" diff --git a/tests/vfs/tsk_file_entry.py b/tests/vfs/tsk_file_entry.py index a4b26e60..52be8aba 100644 --- a/tests/vfs/tsk_file_entry.py +++ b/tests/vfs/tsk_file_entry.py @@ -340,17 +340,17 @@ def testGetStat(self): self.assertEqual(stat_object.uid, 1000) self.assertEqual(stat_object.gid, 1000) - self.assertEqual(stat_object.atime, 1567246979) + self.assertEqual(stat_object.atime, 1626962852) self.assertFalse(hasattr(stat_object, 'atime_nano')) - self.assertEqual(stat_object.ctime, 1567246979) + self.assertEqual(stat_object.ctime, 1626962852) self.assertFalse(hasattr(stat_object, 'ctime_nano')) # EXT2 has no crtime timestamp. self.assertFalse(hasattr(stat_object, 'crtime')) self.assertFalse(hasattr(stat_object, 'crtime_nano')) - self.assertEqual(stat_object.mtime, 1567246979) + self.assertEqual(stat_object.mtime, 1626962852) self.assertFalse(hasattr(stat_object, 'mtime_nano')) # TODO: add tests for GetTSKFile diff --git a/tests/vfs/xfs_file_entry.py b/tests/vfs/xfs_file_entry.py index 2b831649..0299a82a 100644 --- a/tests/vfs/xfs_file_entry.py +++ b/tests/vfs/xfs_file_entry.py @@ -155,17 +155,17 @@ def testGetStat(self): self.assertEqual(stat_object.uid, 1000) self.assertEqual(stat_object.gid, 1000) - self.assertEqual(stat_object.atime, 1605204173) - self.assertEqual(stat_object.atime_nano, 7637974) + self.assertEqual(stat_object.atime, 1626962854) + self.assertEqual(stat_object.atime_nano, 8136161) - self.assertEqual(stat_object.ctime, 1605204173) - self.assertEqual(stat_object.ctime_nano, 7637974) + self.assertEqual(stat_object.ctime, 1626962854) + self.assertEqual(stat_object.ctime_nano, 8146161) - self.assertEqual(stat_object.crtime, 1605204173) - self.assertEqual(stat_object.crtime_nano, 7637974) + self.assertEqual(stat_object.crtime, 1626962854) + self.assertEqual(stat_object.crtime_nano, 8136161) - self.assertEqual(stat_object.mtime, 1605204173) - self.assertEqual(stat_object.mtime_nano, 7637974) + self.assertEqual(stat_object.mtime, 1626962854) + self.assertEqual(stat_object.mtime_nano, 8146161) def testIsFunctions(self): """Tests the Is? functions.""" diff --git a/tests/volume/gpt_volume_system.py b/tests/volume/gpt_volume_system.py index 078c9b1f..e1e152ed 100644 --- a/tests/volume/gpt_volume_system.py +++ b/tests/volume/gpt_volume_system.py @@ -30,23 +30,23 @@ def setUp(self): # vsgptinfo gpt.raw # # GUID Partition Table (GPT) information: - # Disk identifier : 25271092-82a1-4e85-9be8-2eb59926af3f - # Bytes per sector : 512 - # Number of partitions : 2 + # Disk identifier : e86e657a-d840-4c09-afe3-a1a5f665cf44 + # Bytes per sector : 512 + # Number of partitions : 2 # # Partition: 1 - # Identifier : b6d37ab4-051f-4556-97d2-ad1f8a609644 - # Type identifier : 0fc63daf-8483-4772-8e79-3d69d8477de4 - # Type : 0x00 (Empty) - # Offset : 1048576 (0x00100000) - # Size : 65024 + # Identifier : 1e25588c-27a9-4094-868c-2f257021f87b + # Type identifier : 0fc63daf-8483-4772-8e79-3d69d8477de4 + # Type : 0x00 (Empty) + # Offset : 1048576 (0x00100000) + # Size : 65024 # # Partition: 2 - # Identifier : a03faa35-d9a1-4315-a644-681506850073 - # Type identifier : 0fc63daf-8483-4772-8e79-3d69d8477de4 - # Type : 0x00 (Empty) - # Offset : 2097152 (0x00200000) - # Size : 65024 + # Identifier : 53d86ccf-3188-4b54-90d8-81866426b70a + # Type identifier : 0fc63daf-8483-4772-8e79-3d69d8477de4 + # Type : 0x00 (Empty) + # Offset : 2097152 (0x00200000) + # Size : 65024 def testIterateVolumes(self): """Test the iterate volumes functionality.""" @@ -69,7 +69,7 @@ def testIterateVolumes(self): volume_attribute = volume.GetAttribute('identifier') self.assertIsNotNone(volume_attribute) self.assertEqual( - volume_attribute.value, 'b6d37ab4-051f-4556-97d2-ad1f8a609644') + volume_attribute.value, '1e25588c-27a9-4094-868c-2f257021f87b') volume_extent = volume.extents[0] self.assertIsNotNone(volume_extent) diff --git a/tests/volume/lvm_volume_system.py b/tests/volume/lvm_volume_system.py index d34286dc..ef75fda8 100644 --- a/tests/volume/lvm_volume_system.py +++ b/tests/volume/lvm_volume_system.py @@ -28,45 +28,46 @@ def setUp(self): parent=test_raw_path_spec) # vslvminfo lvm.raw + # vslvminfo 20210524 # # Linux Logical Volume Manager (LVM) information: # Volume Group (VG): - # Name: test_volume_group - # Identifier: OdFqZi-WJfC-35Ok-2Jxv-mcC3-e2OS-QROmeJ - # Sequence number: 3 - # Extent size: 4.0 MiB (4194304 bytes) - # Number of physical volumes: 1 - # Number of logical volumes: 2 + # Name: test_volume_group + # Identifier: Lu8jtE-dBED-jxdl-bAXG-vmAA-Oh9y-KCiNMy + # Sequence number: 3 + # Extent size: 4.0 MiB (4194304 bytes) + # Number of physical volumes: 1 + # Number of logical volumes: 2 # # Physical Volume (PV): 1 - # Name: pv0 - # Identifier: l051NA-ZitO-CRvE-QizU-JsB2-CqmX-LNDICw - # Device path: /dev/loop99 - # Volume size: 10 MiB (10485760 bytes) + # Name: pv0 + # Identifier: V9N6H5-MXlo-JmEE-TLHs-KyAo-kLv5-JL0RY7 + # Device path: /dev/loop99 + # Volume size: 10 MiB (10485760 bytes) # # Logical Volume (LV): 1 - # Name: test_logical_volume1 - # Identifier: RI0pgm-rdy4-XxcL-5eoK-Easc-fgPq-CWaEJb - # Number of segments: 1 - # Segment: 1 - # Offset: 0x00000000 (0) - # Size: 4.0 MiB (4194304 bytes) - # Number of stripes: 1 - # Stripe: 1 - # Physical volume: pv0 - # Data area offset: 0x00000000 (0) + # Name: test_logical_volume1 + # Identifier: EMfcGR-KAOf-VrvI-yqth-fmz0-Ylmx-xepAJq + # Number of segments: 1 + # Segment: 1 + # Offset: 0x00000000 (0) + # Size: 4.0 MiB (4194304 bytes) + # Number of stripes: 1 + # Stripe: 1 + # Physical volume: pv0 + # Data area offset: 0x00000000 (0) # # Logical Volume (LV): 2 - # Name: test_logical_volume2 - # Identifier: 2ySlpP-g1fn-qwMH-h7y9-3u4n-GInp-Pfvvxo - # Number of segments: 1 - # Segment: 1 - # Offset: 0x00000000 (0) - # Size: 4.0 MiB (4194304 bytes) - # Number of stripes: 1 - # Stripe: 1 - # Physical volume: pv0 - # Data area offset: 0x00400000 (4194304) + # Name: test_logical_volume2 + # Identifier: UbmaM4-4OCn-m0mb-uw5D-kCjp-2hi1-M6kWCX + # Number of segments: 1 + # Segment: 1 + # Offset: 0x00000000 (0) + # Size: 4.0 MiB (4194304 bytes) + # Number of stripes: 1 + # Stripe: 1 + # Physical volume: pv0 + # Data area offset: 0x00400000 (4194304) def testIterateVolumes(self): """Test the iterate volumes functionality.""" @@ -86,7 +87,7 @@ def testIterateVolumes(self): self.assertEqual(volume.number_of_attributes, 1) self.assertEqual(volume.identifier, 'lvm1') - expected_value = 'RI0pgm-rdy4-XxcL-5eoK-Easc-fgPq-CWaEJb' + expected_value = 'EMfcGR-KAOf-VrvI-yqth-fmz0-Ylmx-xepAJq' volume_attribute = volume.GetAttribute('identifier') self.assertIsNotNone(volume_attribute) self.assertEqual(volume_attribute.value, expected_value) diff --git a/utils/generate_test_data_linux.sh b/utils/generate_test_data_linux.sh index ecea3683..393cc1f3 100755 --- a/utils/generate_test_data_linux.sh +++ b/utils/generate_test_data_linux.sh @@ -31,12 +31,12 @@ assert_availability_binary() fi } -# Creates test file entries. +# Creates test file entries without a symbolic link. # # Arguments: # a string containing the mount point # -create_test_file_entries() +create_test_file_entries_without_link() { MOUNT_POINT=$1; @@ -60,39 +60,34 @@ EOT cat >${MOUNT_POINT}/a_directory/another_file <${MOUNT_POINT}/a_directory/a_file <${MOUNT_POINT}/passwords.txt <${MOUNT_POINT}/a_directory/another_file <${MOUNT_POINT}/a_directory/a_file <${MOUNT_POINT}/passwords.txt <