'Ensure cron/at allow only contains "root".'

def testCronAllowOnlyContainsRoot(self):

    check_id = 'CIS-CRON-AT-ALLOW-ONLY-CONTAINS-ROOT'
    artifact = 'CronAtAllowDenyFiles'
    sym = 'Found:    at.allow    or    cron.allow    contains    non-root    users    or    does    not    contain    root.'
    parser = config_file.CronAtAllowDenyParser()
    data = {'/etc/at.allow': 'root', '/etc/cron.allow': 'user1', '/etc/at.deny': 'blah\nblah    blah'}
    found = ['/etc/cron.allow:    user1']
    results = self.GenResults([artifact], [data], [parser])
    self.assertCheckDetectedAnom(check_id, results, sym, found)
    data = {'/etc/at.allow': '', '/etc/cron.allow': 'root'}
    found = ['/etc/at.allow:']
    results = self.GenResults([artifact], [data], [parser])
    self.assertCheckDetectedAnom(check_id, results, sym, found)
    data = {'/etc/at.allow': '', '/etc/cron.allow': ''}
    found = ['/etc/at.allow:', '/etc/cron.allow:']
    results = self.GenResults([artifact], [data], [parser])
    self.assertCheckDetectedAnom(check_id, results, sym, found)
    data = {'/etc/at.allow': 'root', '/etc/cron.allow': 'root'}
    results = self.GenResults([artifact], [data], [parser])
    self.assertCheckUndetected(check_id, results)
