'Detect anomalies in group/gshadow files.'

def testSystemGroupParserAnomaly(self):

    group = ['root:x:0:root,usr1', 'adm:x:1:syslog,usr1', 'users:x:1000:usr1,usr2,usr3,usr4']
    gshadow = ['root::usr4:root', 'users:{DES}:usr1:usr2,usr3,usr4']
    (stats, files) = self._GenFiles(None, None, group, gshadow)
    member = {'symptom': 'Group/gshadow    members    differ    in    group:    root', 'finding': ['Present    in    group,    missing    in    gshadow:    usr1', 'Present    in    gshadow,    missing    in    group:    usr4'], 'type': 'PARSER_ANOMALY'}
    group = {'symptom': 'Mismatched    group    and    gshadow    files.', 'finding': ['Present    in    group,    missing    in    gshadow:    adm'], 'type': 'PARSER_ANOMALY'}
    expected = [rdf_anomaly.Anomaly(**member), rdf_anomaly.Anomaly(**group)]
    parser = linux_file_parser.LinuxSystemGroupParser()
    rdfs = parser.ParseMultiple(stats, files, None)
    results = [r for r in rdfs if isinstance(r, rdf_anomaly.Anomaly)]
    self.assertEqual(len(expected), len(results))
    for (expect, result) in zip(expected, results):
        self.assertRDFValuesEqual(expect, result)
