예제 #1
0
class CustomPartitioningKickstartTestCase(unittest.TestCase):
    """Test the custom partitioning module with kickstart."""
    def setUp(self):
        """Set up the module."""
        self.storage_module = StorageModule()
        self.storage_interface = StorageInterface(self.storage_module)

        self.module = self.storage_module._custom_part_module
        self.interface = CustomPartitioningInterface(self.module)

    def _process_kickstart(self, ks_in):
        check_kickstart_interface(self, self.storage_interface, ks_in)

    def requires_passphrase_test(self):
        """Test RequiresPassphrase."""
        self._process_kickstart("part /")
        self.assertEqual(self.interface.RequiresPassphrase(), False)
        self._process_kickstart("part / --encrypted")
        self.assertEqual(self.interface.RequiresPassphrase(), True)
        self.interface.SetPassphrase("123456")
        self.assertEqual(self.interface.RequiresPassphrase(), False)
예제 #2
0
class CustomPartitioningKickstartTestCase(unittest.TestCase):
    """Test the custom partitioning module with kickstart."""
    def setUp(self):
        """Set up the module."""
        self.module = CustomPartitioningModule()
        self.interface = CustomPartitioningInterface(self.module)

    def _process_kickstart(self, ks_in):
        """Process the kickstart."""
        storage_module = StorageModule()
        handler = storage_module.get_kickstart_handler()
        parser = storage_module.get_kickstart_parser(handler)
        parser.readKickstartFromString(ks_in)
        self.module.process_kickstart(handler)

    def _setup_kickstart(self):
        """Set up the kickstart."""
        storage_module = StorageModule()
        handler = storage_module.get_kickstart_handler()
        self.module.setup_kickstart(handler)
        return handler

    @patch_dbus_publish_object
    def requires_passphrase_test(self, publisher):
        """Test RequiresPassphrase."""
        self._process_kickstart("part /")
        self.assertEqual(self.interface.RequiresPassphrase(), False)
        self._process_kickstart("part / --encrypted")
        self.assertEqual(self.interface.RequiresPassphrase(), True)
        self.interface.SetPassphrase("123456")
        self.assertEqual(self.interface.RequiresPassphrase(), False)

    @patch('pyanaconda.dbus.DBus.get_proxy')
    @patch('pyanaconda.storage.osinstall.InstallerStorage.mountpoints',
           new_callable=PropertyMock)
    def test_prepboot_bootloader_in_kickstart(self, mock_mountpoints, dbus):
        """Test that a prepboot bootloader shows up in the ks data."""
        # set up prepboot partition
        bootloader_device_obj = PartitionDevice("test_partition_device")
        bootloader_device_obj.size = Size('5 MiB')
        bootloader_device_obj.format = get_format("prepboot")

        # mountpoints must exist for update_ksdata to run
        mock_mountpoints.values.return_value = []

        # set up the storage
        self.module.on_storage_reset(create_storage())
        self.assertTrue(self.module.storage)

        self.module.storage.bootloader.stage1_device = bootloader_device_obj

        # initialize ksdata
        ksdata = self._setup_kickstart()
        self.assertIn("part prepboot", str(ksdata))

    @patch('pyanaconda.dbus.DBus.get_proxy')
    @patch('pyanaconda.storage.osinstall.InstallerStorage.devices',
           new_callable=PropertyMock)
    @patch('pyanaconda.storage.osinstall.InstallerStorage.mountpoints',
           new_callable=PropertyMock)
    def test_biosboot_bootloader_in_kickstart(self, mock_mountpoints,
                                              mock_devices, dbus):
        """Test that a biosboot bootloader shows up in the ks data."""
        # set up biosboot partition
        biosboot_device_obj = PartitionDevice("biosboot_partition_device")
        biosboot_device_obj.size = Size('1MiB')
        biosboot_device_obj.format = get_format("biosboot")

        # mountpoints must exist for updateKSData to run
        mock_devices.return_value = [biosboot_device_obj]
        mock_mountpoints.values.return_value = []

        # set up the storage
        self.module.on_storage_reset(create_storage())
        self.assertTrue(self.module.storage)

        # initialize ksdata
        ksdata = self._setup_kickstart()
        self.assertIn("part biosboot", str(ksdata))