Exemple #1
0
    def test_configure_fips_task(self, mock_util):
        """Test the ConfigureFIPSTask task."""
        task = ConfigureFIPSTask(
            sysroot="/mnt/sysroot",
            fips_enabled=True,
        )

        task.run()

        mock_util.execWithRedirect.assert_called_once_with(
            "fips-mode-setup", ["--enable", "--no-bootcfg"],
            root="/mnt/sysroot")
Exemple #2
0
    def test_configure_fips_task_disabled(self):
        """Test the ConfigureFIPSTask task with disabled FIPS."""
        task = ConfigureFIPSTask(
            sysroot="/mnt/sysroot",
            fips_enabled=False,
        )

        with self.assertLogs(level="DEBUG") as cm:
            task.run()

        msg = "FIPS is not enabled. Skipping."
        assert any(map(lambda x: msg in x, cm.output))
Exemple #3
0
    def test_configure_fips_task_image(self, mock_conf):
        """Test the ConfigureFIPSTask task with image."""
        task = ConfigureFIPSTask(
            sysroot="/mnt/sysroot",
            fips_enabled=True,
        )

        mock_conf.target.is_hardware = False
        mock_conf.target.type = TargetType.IMAGE

        with self.assertLogs(level="DEBUG") as cm:
            task.run()

        msg = "Don't set up FIPS on IMAGE."
        assert any(map(lambda x: msg in x, cm.output))
Exemple #4
0
    def configure_fips_with_task(self):
        """Configure FIPS on the installed system.

        :return: an installation task
        """
        return ConfigureFIPSTask(sysroot=conf.target.system_root,
                                 fips_enabled=self.fips_enabled)