def setUp(self):
     RuleTest.setUp(self)
     self.rule = SecureDHCPServer(self.config,
                                  self.environ,
                                  self.logdispatch,
                                  self.statechglogger)
     self.rulename = self.rule.rulename
     self.rulenumber = self.rule.rulenumber
예제 #2
0
 def setUp(self):
     RuleTest.setUp(self)
     self.rule = SecureDHCPServer(self.config, self.environ,
                                  self.logdispatch, self.statechglogger)
     self.rulename = self.rule.rulename
     self.rulenumber = self.rule.rulenumber
예제 #3
0
class zzzTestRuleSecureDHCPServer(RuleTest):
    def setUp(self):
        RuleTest.setUp(self)
        self.rule = SecureDHCPServer(self.config, self.environ,
                                     self.logdispatch, self.statechglogger)
        self.rulename = self.rule.rulename
        self.rulenumber = self.rule.rulenumber

    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 populate self.rule.path
        self.rule.report()
        if success:
            badoptionstring = '''option domain-name example.com;
option domain-name-servers servers.example.com;
option nis-domain          example.com;
option nis-servers servers.example.com;
option ntp-servers\tntp.example.com;
option routers 127.0.0.1;
option time-offset -18000;
'''
            open(self.rule.path, "a").write(badoptionstring)
            # Rule wants 644 perms, set to 770
            success = setPerms(self.rule.path, [0, 0, 0770], self.logdispatch)
        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
        @return: 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
        @return: 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
        @return: boolean - If successful True; If failure False
        @author: ekkehard j. koch
        '''
        self.logdispatch.log(LogPriority.DEBUG,
                             "pRuleSuccess = " + str(pRuleSuccess) + ".")
        success = True
        return success
class zzzTestRuleSecureDHCPServer(RuleTest):

    def setUp(self):
        RuleTest.setUp(self)
        self.rule = SecureDHCPServer(self.config,
                                     self.environ,
                                     self.logdispatch,
                                     self.statechglogger)
        self.rulename = self.rule.rulename
        self.rulenumber = self.rule.rulenumber

    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 populate self.rule.path
        self.rule.report()
        if success:
            badoptionstring = '''option domain-name example.com;
option domain-name-servers servers.example.com;
option nis-domain          example.com;
option nis-servers servers.example.com;
option ntp-servers\tntp.example.com;
option routers 127.0.0.1;
option time-offset -18000;
'''
            open(self.rule.path, "a").write(badoptionstring)
            # Rule wants 644 perms, set to 770
            success = setPerms(self.rule.path, [0, 0, 0770], self.logdispatch)
        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
        @return: 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
        @return: 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
        @return: boolean - If successful True; If failure False
        @author: ekkehard j. koch
        '''
        self.logdispatch.log(LogPriority.DEBUG, "pRuleSuccess = " +
                             str(pRuleSuccess) + ".")
        success = True
        return success