Ejemplo n.º 1
0
 def setUp(self, **kwargs):
     super(HintDefinitionTests, self).setUp(**kwargs)
     if not self.configs:
         config_file = os.path.join(CONFIGS, "sw.yaml")
         with open(config_file) as data:
             cfg = yaml.safe_load(data)
     chk = checks.Check(**cfg)
     self.lin_method, self.win_method, self.foo_method = list(chk.method)
Ejemplo n.º 2
0
 def testGenerateTriggerMap(self):
     chk = checks.Check(**self.cfg)
     expect = [TRIGGER_1, TRIGGER_3]
     result = [c.attr for c in chk.triggers.Search("SoftwarePackage")]
     self.assertItemsEqual(expect, result)
     expect = [TRIGGER_2]
     result = [c.attr for c in chk.triggers.Search("WMIInstalledSoftware")]
     self.assertItemsEqual(expect, result)
Ejemplo n.º 3
0
 def testParseCheckFromConfig(self):
     chk = checks.Check(**self.cfg)
     # Triggers 1 (linux packages) & 2 (windows software) should return results.
     # Trigger 3 should not return results as no host data has the label 'foo'.
     result_1 = chk.Parse([TRIGGER_1], self.host_data)
     result_2 = chk.Parse([TRIGGER_2], self.host_data)
     result_3 = chk.Parse([TRIGGER_3], self.host_data)
     self.assertTrue(result_1)
     self.assertTrue(result_2)
     self.assertFalse(result_3)
Ejemplo n.º 4
0
 def testInitializeCheck(self):
     chk = checks.Check(**self.cfg)
     self.assertEqual("SW-CHECK", chk.check_id)
     self.assertItemsEqual(["ANY"], [str(c) for c in chk.match])
Ejemplo n.º 5
0
def _LoadCheck(cfg_file, check_id):
    configs = checks.LoadConfigsFromFile(os.path.join(CHECKS_DIR, cfg_file))
    cfg = configs.get(check_id)
    return checks_rdf.Check(**cfg)