def get_partitioning_test(self, platform, suggest_swap_size):
        storage = create_storage()

        # Set the platform specs.
        platform.set_default_partitioning.return_value = [
            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"])

        self.assertEqual(["/"], [spec.mountpoint for spec in requests])

        requests = AutomaticPartitioningTask._get_partitioning(
            storage=storage, excluded_mount_points=[])

        self.assertEqual(["/boot", "/", "/home", None],
                         [spec.mountpoint for spec in requests])
        self.assertEqual(["xfs", "ext4", "ext4", "swap"],
                         [spec.fstype for spec in requests])
        self.assertEqual(
            [Size("1GiB"),
             Size("1GiB"),
             Size("500MiB"),
             Size("1024MiB")], [spec.size for spec in requests])
    def luks2_format_args_test(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")

        self.assertEqual(
            args, {
                "passphrase": "default",
                "cipher": "",
                "luks_version": "luks2",
                "escrow_cert": None,
                "add_backup_passphrase": False,
            })

        self.assertIsInstance(pbkdf_args, LUKS2PBKDFArgs)
        self.assertEqual(pbkdf_args.type, "argon2i")
        self.assertEqual(pbkdf_args.max_memory_kb, 256)
        self.assertEqual(pbkdf_args.iterations, 1000)
        self.assertEqual(pbkdf_args.time_ms, 100)
    def no_luks_format_args_test(self):
        storage = create_storage()
        request = PartitioningRequest()

        args = AutomaticPartitioningTask._get_luks_format_args(
            storage, request)
        self.assertEqual(args, {})
Exemple #4
0
    def configure_with_task(self):
        """Schedule the partitioning actions."""
        task = AutomaticPartitioningTask(
            storage=self.storage,
            scheme=self.type.value,
            encrypted=self.encrypted,
            luks_format_args=self.luks_format_args)

        path = self.publish_task(AUTO_PARTITIONING.namespace, task)
        return path
Exemple #5
0
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)

    if interactive:
        task = InteractivePartitioningTask(storage)
    elif auto_part_proxy.Enabled:
        luks_version = auto_part_proxy.LUKSVersion or storage.default_luks_version
        passphrase = auto_part_proxy.Passphrase or storage.encryption_passphrase
        escrow_cert = storage.get_escrow_certificate(auto_part_proxy.Escrowcert)

        pbkdf_args = get_pbkdf_args(
            luks_version=luks_version,
            pbkdf_type=auto_part_proxy.PBKDF or None,
            max_memory_kb=auto_part_proxy.PBKDFMemory,
            iterations=auto_part_proxy.PBKDFIterations,
            time_ms=auto_part_proxy.PBKDFTime
        )

        luks_format_args = {
            "passphrase": passphrase,
            "cipher": auto_part_proxy.Cipher,
            "luks_version": luks_version,
            "pbkdf_args": pbkdf_args,
            "escrow_cert": escrow_cert,
            "add_backup_passphrase": auto_part_proxy.BackupPassphraseEnabled,
            "min_luks_entropy": MIN_CREATE_ENTROPY,
        }

        task = AutomaticPartitioningTask(
            storage,
            auto_part_proxy.Type,
            auto_part_proxy.Encrypted,
            luks_format_args
        )
    elif STORAGE.get_proxy(MANUAL_PARTITIONING).Enabled:
        task = ManualPartitioningTask(storage)
    else:
        task = CustomPartitioningTask(storage, data)

    task.run()
Exemple #6
0
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)

    if interactive:
        task = InteractivePartitioningTask(storage)
    elif auto_part_proxy.Enabled:
        request = PartitioningRequest.from_structure(auto_part_proxy.Request)
        task = AutomaticPartitioningTask(storage, request)
    elif STORAGE.get_proxy(MANUAL_PARTITIONING).Enabled:
        task = ManualPartitioningTask(storage)
    else:
        task = CustomPartitioningTask(storage, data)

    task.run()
    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,
            })
Exemple #8
0
 def configure_with_task(self):
     """Schedule the partitioning actions."""
     return AutomaticPartitioningTask(self.storage, self.request)