def test_wrong_content_scenario(self):
        """
        Basic test for whole program
        """
        conf = {
            "contents": "tests/FOOBAR6_7A/dummy_preupg/all-xccdf.xml",
            "profile": "xccdf_preupg_profile_default",
            "result_dir": self.temp_dir,
            "skip_common": True,
            "temp_dir": self.temp_dir,
            "id": None,
            "debug": True,  # so root check won't fail
        }

        dc = DummyConf(**conf)
        cli = CLI(["--contents", "tests/FOOBAR6_7A/dummy_preupg/all-xccdf.xml"])
        a = Application(Conf(dc, settings, cli))
        # Prepare all variables for test
        a.conf.source_dir = os.getcwd()
        a.content = a.conf.contents
        a.basename = os.path.basename(a.content)
        self.assertEqual(a.get_scenario(), None)
def setup_preupg_environment(args, content, tmp_dir, mode=None):
    conf = {
        "contents": content,
        "profile": "xccdf_preupg_profile_default",
        "assessment_results_dir": tmp_dir,
        "skip_common": True,
        "temp_dir": tmp_dir,
        "id": None,
        "debug": True,  # so root check won't fail
        "mode": mode,
    }
    dc = DummyConf(**conf)
    cli = CLI(args)
    a = Application(Conf(dc, settings, cli))
    # Prepare all variables for test
    a.conf.source_dir = os.getcwd()
    a.content = a.conf.contents
    a.basename = os.path.basename(a.content)
    a.openscap_helper = OpenSCAPHelper(
        a.conf.assessment_results_dir, a.conf.result_prefix, a.conf.xml_result_name, a.conf.html_result_name, a.content
    )
    return a
def setup_preupg_environment(args, content, tmp_dir, mode=None):
    conf = {
        "contents": content,
        "profile": "xccdf_preupg_profile_default",
        "assessment_results_dir": tmp_dir,
        "skip_common": True,
        "temp_dir": tmp_dir,
        "id": None,
        "debug": True,  # so root check won't fail
        "mode": mode,
    }
    dc = DummyConf(**conf)
    cli = CLI(args)
    a = Application(Conf(dc, settings, cli))
    # Prepare all variables for test
    a.conf.source_dir = os.getcwd()
    a.determine_module_set_location()
    a.openscap_helper = OpenSCAPHelper(a.conf.assessment_results_dir,
                                       a.conf.result_prefix,
                                       a.conf.xml_result_name,
                                       a.conf.html_result_name,
                                       a.all_xccdf_xml_path)
    return a
Ejemplo n.º 4
0
    def test_wrong_content_scenario(self):
        """
        Basic test for whole program
        """
        conf = {
            "contents": "tests/FOOBAR6_7A/dummy_preupg/all-xccdf.xml",
            "profile": "xccdf_preupg_profile_default",
            "result_dir": self.temp_dir,
            "skip_common": True,
            "temp_dir": self.temp_dir,
            "id": None,
            "debug": True,  # so root check won't fail
        }

        dc = DummyConf(**conf)
        cli = CLI(
            ["--contents", "tests/FOOBAR6_7A/dummy_preupg/all-xccdf.xml"])
        a = Application(Conf(dc, settings, cli))
        # Prepare all variables for test
        a.conf.source_dir = os.getcwd()
        a.content = a.conf.contents
        a.basename = os.path.basename(a.content)
        self.assertEqual(a.get_scenario(), None)
Ejemplo n.º 5
0
    def test_opts(self):
        """ basic test of several options """
        conf = {
            "scan": "FOOBAR6_7",
            "skip_common": False,
            "id": 1,
            "list_contents_set": True,
            "verbose": 1,
            "text": True,
            "contents": "content/FOOBAR6_7",
            "cleanup": True,
            "mode": 'upgrade',
            "select_rules": "abc",
            "list_rules": True,
            "version": True,
            "force": True,
            "riskcheck": True,
        }
        dc = DummyConf(**conf)
        cli = CLI([
            "--scan", "FOOBAR6_7", "--skip-common", "--list-contents-set",
            "--verbose", "--text", "--contents", "content/FOOBAR6_7",
            "--cleanup", "--mode", "upgrade", "--select-rules", "abc",
            "--list-rules", "--version", "--force", "--riskcheck"
        ])
        a = Application(Conf(cli.opts, dc, cli))

        self.assertTrue(a.conf.skip_common)
        self.assertEqual(a.conf.contents, "content/FOOBAR6_7")
        self.assertTrue(a.conf.list_contents_set)
        self.assertTrue(a.conf.list_rules)
        self.assertTrue(a.conf.force)
        self.assertTrue(a.conf.text)
        self.assertTrue(a.conf.cleanup)
        self.assertEqual(int(a.conf.verbose), 1)
        self.assertEqual(a.conf.scan, "FOOBAR6_7")
        self.assertEqual(a.conf.mode, "upgrade")
        self.assertEqual(a.conf.select_rules, "abc")
        self.assertTrue(a.conf.riskcheck)
 def test_correct_module_set(self):
     '''
     Test to get right module directory with contents option,
     directory with modules are the same where all-xccdf file is located
     '''
     conf = {
         "contents": "tests/Modules/all-xccdf.xml",
     }
     dummy_conf = DummyConf(**conf)
     cli = CLI(["--contents", "tests/Modules/all-xccdf.xml"])
     app = Application(Conf(dummy_conf, settings, cli))
     # Prepare all variables for test
     app.conf.source_dir = os.getcwd()
     app.content = app.conf.contents
     app.basename = os.path.basename(app.content)
     app.determine_module_set_location()
     self.assertEqual(app.module_set_dirname, 'Modules')