Exemple #1
0
 def CheckACrontab(self, arguments):
   log = check.LogCounter()
   (exp_warn, exp_fail, exp_rc) = self.GetExpWFRs(arguments.crontab)
   self.assertEquals(check.check_crontab(arguments, log), exp_rc,
                     'Failed to return %d for crontab errors.' % exp_rc)
   self.assertEquals(log.warn_count, exp_warn,
                     'Found %d warns not %d.' % (log.warn_count, exp_warn))
   self.assertEquals(log.error_count, exp_fail,
                     'Found %d errors not %d.' % (log.error_count, exp_fail))
Exemple #2
0
 def CheckACrontab(self, crontab):
   log = check.LogCounter()
   crontab_file = os.path.join(BASE_PATH, crontab)
   (exp_warn, exp_fail, exp_rc) = self.GetExpWFRs(crontab_file)
   self.assertEquals(check.check_crontab(crontab_file, log), exp_rc,
                     'Failed to return %d for crontab errors.' % exp_rc)
   self.assertEquals(log.warn_count, exp_warn,
                     'Found %d warns not %d.' % (log.warn_count, exp_warn))
   self.assertEquals(log.error_count, exp_fail,
                     'Found %d errors not %d.' % (log.error_count, exp_fail))
Exemple #3
0
 def CheckACrontab(self, crontab, whitelisted_users=None):
     log = check.LogCounter()
     crontab_file = os.path.join(BASE_PATH, crontab)
     (exp_warn, exp_fail, exp_rc) = self.GetExpWFRs(crontab_file)
     self.assertEquals(
         check.check_crontab(crontab_file, log, whitelisted_users),
         exp_rc,
         "Failed to return %d for crontab errors." % exp_rc,
     )
     self.assertEquals(log.warn_count, exp_warn, "Found %d warns not %d." % (log.warn_count, exp_warn))
     self.assertEquals(log.error_count, exp_fail, "Found %d errors not %d." % (log.error_count, exp_fail))
Exemple #4
0
 def test_crontab_files_valid(self):
     """Crontab files should pass validation."""
     for filename in CRONTAB_FILES:
         cronlog = chkcrontab.LogCounter()
         return_value = chkcrontab.check_crontab(filename, cronlog)
         self.assertEqual(return_value, 0, 'Problem with ' + filename)
Exemple #5
0
 def test_crontab_files_valid(self):
     """Crontab files should pass validation."""
     for filename in CRONTAB_FILES:
         cronlog = chkcrontab.LogCounter()
         return_value = chkcrontab.check_crontab(filename, cronlog)
         self.assertEqual(return_value, 0, 'Problem with ' + filename)
Exemple #6
0
def validate_cron(file_path):
    whitelisted_users = None
    log = check.LogCounter()
    return check.check_crontab(file_path, log, whitelisted_users)
Exemple #7
0
def validate_cron(file_path):
    whitelisted_users = None
    log = check.LogCounter()
    return check.check_crontab(file_path, log, whitelisted_users)