def _generate_result(self, content_temp): conf = { "contents": content_temp, "profile": "xccdf_preupg_profile_default", "result_dir": os.path.dirname(content_temp), "skip_common": True, "temp_dir": os.path.dirname(content_temp), "id": None, "debug": True, # so root check won't fail } dc = DummyConf(**conf) cli = CLI(["--contents", content_temp]) 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.run_scan(), 0)
def test_all(self): """Basic test for whole program""" conf = { "contents": "tests/FOOBAR6_7/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_7/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.run_scan(), 0)
def test_upgrade(self): """Basic test for whole program""" conf = { "contents": "tests/FOOBAR6_7/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 "mode": "upgrade", } dc = DummyConf(**conf) cli = CLI(["--contents", "tests/FOOBAR6_7/dummy_preupg/all-xccdf.xml", "--mode", "upgrade"]) 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.run_scan(), 0) rp = ReportParser(os.path.join(self.temp_dir, "result.xml")) rp.modify_result_path(self.temp_dir, "FOOBAR6_7", "upgrade") found_migrate = 0 found_upgrade = 0 for values in rp.get_nodes(rp.target_tree, "Value", ".//"): if values.get("id").endswith("_preupg_state_migrate"): for value in rp.get_nodes(values, "value"): if int(value.text) == 0: found_migrate = 1 if values.get("id").endswith("_preupg_state_upgrade"): for value in rp.get_nodes(values, "value"): if int(value.text) == 1: found_upgrade = 1 self.assertEquals(found_migrate, 1) self.assertEquals(found_upgrade, 1)
def test_upgrade(self): """Basic test for whole program""" conf = { "contents": "tests/FOOBAR6_7/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 "mode": 'upgrade' } dc = DummyConf(**conf) cli = CLI(["--contents", "tests/FOOBAR6_7/dummy_preupg/all-xccdf.xml", "--mode", "upgrade"]) 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.run_scan(), 0) rp = ReportParser(os.path.join(self.temp_dir, "result.xml")) rp.modify_result_path(self.temp_dir, "FOOBAR6_7", 'upgrade') found_migrate = 0 found_upgrade = 0 for values in rp.get_nodes(rp.target_tree, "Value", ".//"): if values.get("id").endswith("_preupg_state_migrate"): for value in rp.get_nodes(values, "value"): if int(value.text) == 0: found_migrate = 1 if values.get("id").endswith("_preupg_state_upgrade"): for value in rp.get_nodes(values, "value"): if int(value.text) == 1: found_upgrade = 1 self.assertEquals(found_migrate, 1) self.assertEquals(found_upgrade, 1)