def setUp(self): RuleTest.setUp(self) self.rule = SSHTimeout(self.config, self.environ, self.logdispatch, self.statechglogger) self.rulename = self.rule.rulename self.rulenumber = self.rule.rulenumber self.ch = CommandHelper(self.logdispatch)
class zzzTestRuleSSHTimeout(RuleTest): def setUp(self): RuleTest.setUp(self) self.rule = SSHTimeout(self.config, self.environ, self.logdispatch, self.statechglogger) self.rulename = self.rule.rulename self.rulenumber = self.rule.rulenumber self.ch = CommandHelper(self.logdispatch) def tearDown(self): pass def runTest(self): self.simpleRuleTest() def setConditionsForRule(self): ''' Configure system for the unit test @param self: essential if you override this definition @return: boolean - If successful True; If failure False @author: Eric Ball ''' success = True # Run report() to get variables self.rule.report() ssh = {"ClientAliveInterval": "0", "ClientAliveCountMax": "900"} if os.path.exists(self.rule.path): kvtype = "conf" intent = "present" self.editor = KVEditorStonix(self.statechglogger, self.logdispatch, kvtype, self.rule.path, self.rule.tpath, ssh, intent, "space") if not self.editor.report(): if self.editor.fixables: if self.editor.fix(): if not self.editor.commit(): success = False debug = "KVEditor commit did not succeed" self.logdispatch.log(LogPriority.DEBUG, debug) else: success = False debug = "KVEditor fix() did not succeed" self.logdispatch.log(LogPriority.DEBUG, debug) self.rule.iditerator = 0 myid = iterate(self.rule.iditerator, self.rule.rulenumber) if not setPerms(self.rule.path, [99, 99, 0770], self.logdispatch, self.statechglogger, myid): success = False debug = "Could not set permissions" self.logdispatch.log(LogPriority.DEBUG, debug) return success
class zzzTestRuleSSHTimeout(RuleTest): def setUp(self): RuleTest.setUp(self) self.rule = SSHTimeout(self.config, self.environ, self.logdispatch, self.statechglogger) self.rulename = self.rule.rulename self.rulenumber = self.rule.rulenumber self.ch = CommandHelper(self.logdispatch) def tearDown(self): pass def runTest(self): self.simpleRuleTest() def setConditionsForRule(self): '''Configure system for the unit test :param self: essential if you override this definition :returns: boolean - If successful True; If failure False @author: Eric Ball ''' success = True # Run report() to get variables self.rule.report() ssh = {"ClientAliveInterval": "0", "ClientAliveCountMax": "900"} if os.path.exists(self.rule.path): kvtype = "conf" intent = "present" self.editor = KVEditorStonix(self.statechglogger, self.logdispatch, kvtype, self.rule.path, self.rule.tpath, ssh, intent, "space") if not self.editor.report(): if self.editor.fixables: if self.editor.fix(): if not self.editor.commit(): success = False debug = "KVEditor commit did not succeed" self.logdispatch.log(LogPriority.DEBUG, debug) else: success = False debug = "KVEditor fix() did not succeed" self.logdispatch.log(LogPriority.DEBUG, debug) self.rule.iditerator = 0 myid = iterate(self.rule.iditerator, self.rule.rulenumber) if not setPerms(self.rule.path, [99, 99, 0o770], self.logdispatch, self.statechglogger, myid): success = False debug = "Could not set permissions" self.logdispatch.log(LogPriority.DEBUG, debug) return success def checkReportForRule(self, pCompliance, pRuleSuccess): '''check on whether report was correct :param self: essential if you override this definition :param pCompliance: the self.iscompliant value of rule :param pRuleSuccess: did report run successfully :returns: boolean - If successful True; If failure False @author: ekkehard j. koch ''' self.logdispatch.log(LogPriority.DEBUG, "pCompliance = " + str(pCompliance) + ".") self.logdispatch.log(LogPriority.DEBUG, "pRuleSuccess = " + str(pRuleSuccess) + ".") success = True return success def checkFixForRule(self, pRuleSuccess): '''check on whether fix was correct :param self: essential if you override this definition :param pRuleSuccess: did report run successfully :returns: boolean - If successful True; If failure False @author: ekkehard j. koch ''' self.logdispatch.log(LogPriority.DEBUG, "pRuleSuccess = " + str(pRuleSuccess) + ".") success = True return success def checkUndoForRule(self, pRuleSuccess): '''check on whether undo was correct :param self: essential if you override this definition :param pRuleSuccess: did report run successfully :returns: boolean - If successful True; If failure False @author: ekkehard j. koch ''' self.logdispatch.log(LogPriority.DEBUG, "pRuleSuccess = " + str(pRuleSuccess) + ".") success = True return success