def test_get_partitioning(self, platform, suggest_swap_size): storage = create_storage() # Set the platform specs. platform.partitions = [PartSpec(mountpoint="/boot", size=Size("1GiB"))] # Set the file system type for /boot. storage._bootloader = Mock(stage2_format_types=["xfs"]) # Set the swap size. suggest_swap_size.return_value = Size("1024MiB") # Collect the requests. requests = AutomaticPartitioningTask._get_partitioning( storage=storage, excluded_mount_points=["/home", "/boot", "swap"]) assert ["/"] == [spec.mountpoint for spec in requests] requests = AutomaticPartitioningTask._get_partitioning( storage=storage, excluded_mount_points=[]) assert ["/boot", "/", "/home"] == \ [spec.mountpoint for spec in requests] assert ["xfs", "ext4", "ext4"] == \ [spec.fstype for spec in requests] assert [Size("1GiB"), Size("1GiB"), Size("500MiB")] == \ [spec.size for spec in requests]
def test_get_partitioning_btrfs_only(self, platform, mocked_conf): storage = create_storage() platform.partitions = [] # Set the default partitioning. mocked_conf.storage.default_partitioning = [{ 'name': '/', 'size': Size("50 GiB"), }, { 'name': '/var', 'btrfs': True, }] # Collect the requests for the Btrfs scheme. requests = AutomaticPartitioningTask._get_partitioning( storage=storage, scheme=AUTOPART_TYPE_BTRFS, ) assert ["/", "/var"] == [spec.mountpoint for spec in requests] # Collect the requests for the LVM scheme. requests = AutomaticPartitioningTask._get_partitioning( storage=storage, scheme=AUTOPART_TYPE_LVM, ) assert ["/"] == [spec.mountpoint for spec in requests]
def test_luks2_format_args(self): storage = create_storage() request = PartitioningRequest() request.encrypted = True request.passphrase = "default" request.luks_version = "luks2" request.pbkdf = "argon2i" request.pbkdf_memory = 256 request.pbkdf_iterations = 1000 request.pbkdf_time = 100 args = AutomaticPartitioningTask._get_luks_format_args( storage, request) pbkdf_args = args.pop("pbkdf_args") assert args == { "passphrase": "default", "cipher": "", "luks_version": "luks2", "escrow_cert": None, "add_backup_passphrase": False, } assert isinstance(pbkdf_args, LUKS2PBKDFArgs) assert pbkdf_args.type == "argon2i" assert pbkdf_args.max_memory_kb == 256 assert pbkdf_args.iterations == 1000 assert pbkdf_args.time_ms == 100
def test_no_luks_format_args(self): storage = create_storage() request = PartitioningRequest() args = AutomaticPartitioningTask._get_luks_format_args( storage, request) assert args == {}
def no_luks_format_args_test(self): storage = create_storage() request = PartitioningRequest() args = AutomaticPartitioningTask._get_luks_format_args( storage, request) self.assertEqual(args, {})
def luks1_format_args_test(self): storage = create_storage() storage._escrow_certificates["file:///tmp/escrow.crt"] = "CERTIFICATE" request = PartitioningRequest() request.encrypted = True request.passphrase = "passphrase" request.luks_version = "luks1" request.cipher = "aes-xts-plain64" request.escrow_certificate = "file:///tmp/escrow.crt" request.backup_passphrase_enabled = True args = AutomaticPartitioningTask._get_luks_format_args(storage, request) self.assertEqual(args, { "passphrase": "passphrase", "cipher": "aes-xts-plain64", "luks_version": "luks1", "pbkdf_args": None, "escrow_cert": "CERTIFICATE", "add_backup_passphrase": True, })
def configure_storage(storage, data=None, interactive=False): """Setup storage state from the kickstart data. :param storage: an instance of the Blivet's storage object :param data: an instance of kickstart data or None :param interactive: use a task for the interactive partitioning """ auto_part_proxy = STORAGE.get_proxy(AUTO_PARTITIONING) manual_part_proxy = STORAGE.get_proxy(MANUAL_PARTITIONING) if interactive: task = InteractivePartitioningTask(storage) elif auto_part_proxy.Enabled: request = PartitioningRequest.from_structure(auto_part_proxy.Request) task = AutomaticPartitioningTask(storage, request) elif manual_part_proxy.Enabled: requests = MountPointRequest.from_structure_list(manual_part_proxy.Requests) task = ManualPartitioningTask(storage, requests) else: task = CustomPartitioningTask(storage, data) task.run()
def configure_with_task(self): """Schedule the partitioning actions.""" return AutomaticPartitioningTask(self.storage, self.request)