def test_set_up_installation_sources_task(self, publisher):
        """Test Live OS is able to create a set up installation sources task."""
        self._prepare_and_use_source()

        task_path = self.live_os_interface.SetUpSourcesWithTask()

        check_task_creation(self, task_path, publisher, SetUpSourcesTask)
    def test_tear_down_installation_source_task(self, publisher):
        """Test Live OS is able to create a tear down installation sources task."""
        self._prepare_and_use_source()

        task_path = self.live_os_interface.TearDownSourcesWithTask()

        check_task_creation(self, task_path, publisher, TearDownSourcesTask)
 def test_configure_fips_with_task(self, publisher):
     """Test the ConfigureFIPSWithTask method."""
     task_path = self.security_interface.ConfigureFIPSWithTask()
     obj = check_task_creation(self, task_path, publisher,
                               ConfigureFIPSTask)
     self.assertEqual(obj.implementation._sysroot, "/mnt/sysroot")
     self.assertEqual(obj.implementation._fips_enabled, False)
    def test_discover_with_task(self, publisher):
        """Test DiscoverWithTask."""
        task_path = self.dasd_interface.DiscoverWithTask("0.0.A100")

        obj = check_task_creation(task_path, publisher, DASDDiscoverTask)

        assert obj.implementation._device_number == "0.0.A100"
 def test_realm_join_default(self, publisher):
     """Test module in default state with realm join task."""
     realm_join_task_path = self.security_interface.JoinRealmWithTask()
     obj = check_task_creation(self, realm_join_task_path, publisher, RealmJoinTask)
     self.assertEqual(obj.implementation._realm_data.discovered, False)
     self.assertEqual(obj.implementation._realm_data.name, "")
     self.assertEqual(obj.implementation._realm_data.join_options, [])
Exemple #6
0
    def test_validate_with_task(self, publisher):
        """Test ValidateWithTask."""
        self.module.on_storage_changed(Mock())
        task_path = self.interface.ValidateWithTask()

        obj = check_task_creation(task_path, publisher, StorageValidateTask)
        assert obj.implementation._storage == self.module.storage

        report = ValidationReport()
        report.error_messages = [
            "Something is wrong.", "Something is very wrong."
        ]
        report.warning_messages = ["Something might be wrong."]
        obj.implementation._set_result(report)

        result = obj.GetResult()
        expected_result = get_variant(
            Structure, {
                "error-messages":
                get_variant(
                    List[Str],
                    ["Something is wrong.", "Something is very wrong."]),
                "warning-messages":
                get_variant(List[Str], ["Something might be wrong."])
            })

        assert isinstance(result, Variant)
        assert get_native(result) == get_native(expected_result)
        assert result.equal(expected_result)
Exemple #7
0
    def test_finish_installation_with_tasks(self, publisher):
        """Test FinishInstallationWithTasks."""
        task_list = self.interface.FinishInstallationWithTasks()

        assert len(task_list) == 2

        task_path = task_list[0]
        task_proxy = check_task_creation(task_path, publisher, SetContextsTask,
                                         0)
        task = task_proxy.implementation
        assert task.name == "Set file contexts"

        task_path = task_list[1]
        task_proxy = check_task_creation(task_path, publisher, CopyLogsTask, 1)
        task = task_proxy.implementation
        assert task.name == "Copy installation logs"
Exemple #8
0
 def test_preconfigure_fips_with_task(self, publisher):
     """Test the PreconfigureFIPSWithTask method."""
     task_path = self.security_interface.PreconfigureFIPSWithTask(PAYLOAD_TYPE_DNF)
     obj = check_task_creation(task_path, publisher, PreconfigureFIPSTask)
     assert obj.implementation._sysroot == "/mnt/sysroot"
     assert obj.implementation._payload_type == PAYLOAD_TYPE_DNF
     assert obj.implementation._fips_enabled is False
Exemple #9
0
    def test_find_devices_with_task(self, publisher):
        """Test FindDevicesWithTask."""
        task_path = self.interface.FindDevicesWithTask()

        obj = check_task_creation(self, task_path, publisher, FindDevicesTask)

        self.assertEqual(obj.implementation._devicetree, self.module.storage.devicetree)
Exemple #10
0
    def test_realm_data_propagation(self, publisher):
        """Test that realm data changes propagate to realm join task."""
        # We connect to the realm_changed signal and update the realm data holder
        # in the realm join task when the signal is triggered.
        realm1 = RealmData()
        realm1.name = "domain.example.com"
        realm1.discover_options = ["--client-software=sssd"]
        realm1.discovered = False

        self.security_interface.SetRealm(RealmData.to_structure(realm1))
        realm_join_task_path = self.security_interface.JoinRealmWithTask()

        # realm join - after task creation
        obj = check_task_creation(realm_join_task_path, publisher,
                                  RealmJoinTask)
        assert obj.implementation._realm_data.discovered is False
        assert obj.implementation._realm_data.name == "domain.example.com"
        assert obj.implementation._realm_data.join_options == []

        # change realm data and check the changes propagate to the realm join task
        realm2 = RealmData()
        realm2.name = "domain.example.com"
        realm2.discover_options = ["--client-software=sssd"]
        realm2.join_options = ["--one-time-password=password"]
        realm2.discovered = True

        self.security_interface.SetRealm(RealmData.to_structure(realm2))

        # realm join - after realm data update
        assert obj.implementation._realm_data.discovered is True
        assert obj.implementation._realm_data.name == "domain.example.com"
        assert obj.implementation._realm_data.join_options == [
            "--one-time-password=password"
        ]
Exemple #11
0
 def test_realm_join_default(self, publisher):
     """Test module in default state with realm join task."""
     realm_join_task_path = self.security_interface.JoinRealmWithTask()
     obj = check_task_creation(realm_join_task_path, publisher, RealmJoinTask)
     assert obj.implementation._realm_data.discovered is False
     assert obj.implementation._realm_data.name == ""
     assert obj.implementation._realm_data.join_options == []
Exemple #12
0
    def test_tear_down_sources_with_task(self, publisher):
        """Test TearDownSourcesWithTask."""
        source = SourceFactory.create_source(SourceType.CDROM)
        self.module.add_source(source)

        task_path = self.interface.TearDownSourcesWithTask()
        obj = check_task_creation(task_path, publisher, TearDownSourcesTask)
        assert obj.implementation._sources == [source]
    def test_format_with_task(self, publisher):
        """Test the discover task."""
        task_path = self.dasd_interface.FormatWithTask(
            ["/dev/sda", "/dev/sdb"])

        obj = check_task_creation(task_path, publisher, DASDFormatTask)

        assert obj.implementation._dasds == ["/dev/sda", "/dev/sdb"]
Exemple #14
0
 def test_realm_discover_default(self, publisher):
     """Test module in default state with realm discover task."""
     realm_discover_task_path = self.security_interface.DiscoverRealmWithTask(
     )
     obj = check_task_creation(realm_discover_task_path, publisher,
                               RealmDiscoverTask)
     assert obj.implementation._realm_data.name == ""
     assert obj.implementation._realm_data.discover_options == []
    def test_set_up_sources_with_task(self, publisher):
        """Test SetUpSourcesWithTask."""
        source = SourceFactory.create_source(SourceType.CDROM)
        self.module.add_source(source)

        task_path = self.interface.SetUpSourcesWithTask()
        obj = check_task_creation(self, task_path, publisher, SetUpSourcesTask)
        self.assertEqual(obj.implementation._sources, [source])
Exemple #16
0
    def test_configure_with_task(self, publisher):
        """Test ConfigureWithTask."""
        self.module.on_storage_changed(Mock())
        task_path = self.interface.ConfigureWithTask()

        obj = check_task_creation(task_path, publisher, ManualPartitioningTask)

        assert obj.implementation._storage == self.module.storage
        assert obj.implementation._requests == self.module.requests
Exemple #17
0
    def test_install_with_tasks(self, publisher):
        """Test CopyLogsWithTask."""
        task_path = self.interface.CopyLogsWithTask()
        task_proxy = check_task_creation(task_path, publisher, CopyLogsTask)
        task = task_proxy.implementation
        assert task.name == "Copy installation logs"

        task = self.module.copy_logs_with_task()
        assert task.name == "Copy installation logs"
Exemple #18
0
    def test_configure_with_task(self, publisher):
        """Test ConfigureWithTask."""
        self.module.on_storage_changed(create_storage())
        task_path = self.interface.ConfigureWithTask()

        obj = check_task_creation(self, task_path, publisher,
                                  InteractivePartitioningTask)

        self.assertEqual(obj.implementation._storage, self.module.storage)
    def test_configure_with_task(self, publisher):
        """Test ConfigureWithTask."""
        self.module.on_storage_changed(Mock())
        self.module.process_kickstart(Mock())
        task_path = self.interface.ConfigureWithTask()

        obj = check_task_creation(task_path, publisher, CustomPartitioningTask)

        assert obj.implementation._storage == self.module.storage
Exemple #20
0
    def test_populate_missing_keyboard_configuration_with_task(self, publisher):
        """Test PopulateMissingKeyboardConfigurationWithTask."""
        self.localization_interface.SetVirtualConsoleKeymap('us')
        self.localization_interface.SetXLayouts(['cz', 'cz (qwerty)'])

        task_path = self.localization_interface.PopulateMissingKeyboardConfigurationWithTask()

        obj = check_task_creation(task_path, publisher, GetMissingKeyboardConfigurationTask)
        assert obj.implementation._vc_keymap == 'us'
        assert obj.implementation._x_layouts == ['cz', 'cz (qwerty)']
Exemple #21
0
    def test_mount_existing_system_with_task(self, publisher):
        """Test MountExistingSystemWithTask."""
        self._add_device(StorageDevice("dev1", fmt=get_format("ext4")))

        task_path = self.interface.MountExistingSystemWithTask("dev1", True)

        obj = check_task_creation(self, task_path, publisher, MountExistingSystemTask)

        self.assertEqual(obj.implementation._storage, self.module.storage)
        self.assertEqual(obj.implementation._device.name, "dev1")
        self.assertEqual(obj.implementation._read_only, True)
Exemple #22
0
    def test_apply_keyboard_with_task(self, publisher):
        """Test ApplyKeyboardWithTask."""
        self.localization_interface.SetVirtualConsoleKeymap('us')
        self.localization_interface.SetXLayouts(['cz', 'cz (qwerty)'])
        self.localization_interface.SetLayoutSwitchOptions(["grp:alt_shift_toggle"])

        task_path = self.localization_interface.ApplyKeyboardWithTask()

        obj = check_task_creation(task_path, publisher, ApplyKeyboardTask)
        assert obj.implementation._vc_keymap == 'us'
        assert obj.implementation._x_layouts == ['cz', 'cz (qwerty)']
        assert obj.implementation._switch_options == ["grp:alt_shift_toggle"]
Exemple #23
0
    def test_realm_discover_configured(self, publisher):
        """Test module in configured state with realm discover task."""
        realm = RealmData()
        realm.name = "domain.example.com"
        realm.discover_options = ["--client-software=sssd"]

        self.security_interface.SetRealm(RealmData.to_structure(realm))
        realm_discover_task_path = self.security_interface.DiscoverRealmWithTask()

        obj = check_task_creation(realm_discover_task_path, publisher, RealmDiscoverTask)
        assert obj.implementation._realm_data.name == "domain.example.com"
        assert obj.implementation._realm_data.discover_options == ["--client-software=sssd"]
Exemple #24
0
    def test_find_existing_systems_with_task(self, publisher):
        """Test FindExistingSystemsWithTask."""
        task_path = self.interface.FindExistingSystemsWithTask()

        obj = check_task_creation(self, task_path, publisher, FindExistingSystemsTask)

        self.assertEqual(obj.implementation._devicetree, self.module.storage.devicetree)

        roots = [Root(name="My Linux")]
        obj.implementation._set_result(roots)
        obj.implementation.succeeded_signal.emit()
        self.assertEqual(self.storage.roots, roots)
Exemple #25
0
    def test_login_with_task(self, publisher):
        """Test the login task."""
        task_path = self.iscsi_interface.LoginWithTask(
            Portal.to_structure(self._portal),
            Credentials.to_structure(self._credentials),
            Node.to_structure(self._node),
        )

        obj = check_task_creation(task_path, publisher, ISCSILoginTask)

        assert obj.implementation._portal == self._portal
        assert obj.implementation._credentials == self._credentials
        assert obj.implementation._node == self._node
Exemple #26
0
    def test_start_modules_with_task(self, publisher):
        """Test StartModulesWithTask."""
        task_path = self.interface.StartModulesWithTask()
        task_proxy = check_task_creation(task_path, publisher, StartModulesTask)
        task = task_proxy.implementation

        callback = Mock()
        self.module._module_manager.module_observers_changed.connect(callback)

        observers = [Mock(), Mock(), Mock()]
        task._set_result(observers)
        task.succeeded_signal.emit()
        callback.assert_called_once_with(observers)
Exemple #27
0
    def test_discover_with_task(self, publisher):
        """Test the discover task."""
        task_path = self.fcoe_interface.DiscoverWithTask(
            "eth0",  # nic
            False,  # dcb
            True  # auto_vlan
        )

        obj = check_task_creation(task_path, publisher, FCOEDiscoverTask)

        assert obj.implementation._nic == "eth0"
        assert obj.implementation._dcb is False
        assert obj.implementation._auto_vlan is True
    def test_create_with_task(self, publisher):
        """Test CreateWithTask."""
        with pytest.raises(UnavailableStorageError):
            self.interface.CreateWithTask(SNAPSHOT_WHEN_PRE_INSTALL)

        self.module.on_storage_changed(Mock())
        task_path = self.interface.CreateWithTask(SNAPSHOT_WHEN_PRE_INSTALL)

        obj = check_task_creation(task_path, publisher, SnapshotCreateTask)

        assert obj.implementation._storage == self.module.storage
        assert obj.implementation._requests == []
        assert obj.implementation._when == SNAPSHOT_WHEN_PRE_INSTALL
Exemple #29
0
    def test_discover_with_task(self, publisher):
        """Test the discover task."""
        task_path = self.fcoe_interface.DiscoverWithTask(
            "eth0",  # nic
            False,  # dcb
            True  # auto_vlan
        )

        obj = check_task_creation(self, task_path, publisher, FCOEDiscoverTask)

        self.assertEqual(obj.implementation._nic, "eth0")
        self.assertEqual(obj.implementation._dcb, False)
        self.assertEqual(obj.implementation._auto_vlan, True)
Exemple #30
0
    def test_discover_with_task(self, publisher):
        """Test the discover task."""
        task_path = self.zfcp_interface.DiscoverWithTask(
            "0.0.fc00",
            "0x5105074308c212e9",
            "0x401040a000000000"
        )

        obj = check_task_creation(task_path, publisher, ZFCPDiscoverTask)

        assert obj.implementation._device_number == "0.0.fc00"
        assert obj.implementation._wwpn == "0x5105074308c212e9"
        assert obj.implementation._lun == "0x401040a000000000"