'Tests for the ParseMultiple() method.'

def testParseMultiple(self):

    parser = linux_pam_parser.PAMParser()
    (stats, file_objs) = checks_test_lib.HostCheckTest.GenStatFileData(TELNET_ONLY_CONFIG)
    out = list(parser.ParseMultiple(stats, file_objs, self.kb))
    self.assertEqual(len(out), 1)
    self.assertTrue(isinstance(out[0], rdf_config.PamConfig))
    self.assertItemsEqual(TELNET_ONLY_CONFIG_EXPECTED, self._EntriesToTuples(out[0].entries))
    self.assertEqual([], out[0].external_config)
    (stats, file_objs) = checks_test_lib.HostCheckTest.GenStatFileData(TELNET_WITH_PAMCONF)
    out = list(parser.ParseMultiple(stats, file_objs, self.kb))
    self.assertEqual(len(out), 1)
    self.assertTrue(isinstance(out[0], rdf_config.PamConfig))
    entry = out[0].entries[0]
    self.assertEqual(('telnet', 'auth', '[success=ok    new_authtok_reqd=ok    ignore=ignore    default=bad]', 'testing.so', 'module    arguments'), self._EntryToTuple(entry))
    self.assertItemsEqual(TELNET_WITH_PAMCONF_EXPECTED, self._EntriesToTuples(out[0].entries))
    self.assertEqual([], out[0].external_config)
    (stats, file_objs) = checks_test_lib.HostCheckTest.GenStatFileData(PAM_CONF_SIMPLE)
    out = list(parser.ParseMultiple(stats, file_objs, self.kb))
    self.assertEqual(len(out), 1)
    self.assertTrue(isinstance(out[0], rdf_config.PamConfig))
    self.assertItemsEqual(PAM_CONF_SIMPLE_EXPECTED, self._EntriesToTuples(out[0].entries))
    self.assertEqual([], out[0].external_config)
    (stats, file_objs) = checks_test_lib.HostCheckTest.GenStatFileData(PAM_CONF_OVERRIDE)
    out = list(parser.ParseMultiple(stats, file_objs, self.kb))
    self.assertEqual(len(out), 1)
    self.assertTrue(isinstance(out[0], rdf_config.PamConfig))
    self.assertItemsEqual(PAM_CONF_OVERRIDE_EXPECTED, self._EntriesToTuples(out[0].entries))
    self.assertEqual([], out[0].external_config)
    (stats, file_objs) = checks_test_lib.HostCheckTest.GenStatFileData(PAM_CONF_OVERRIDE_COMPLEX)
    out = list(parser.ParseMultiple(stats, file_objs, self.kb))
    self.assertEqual(len(out), 1)
    self.assertTrue(isinstance(out[0], rdf_config.PamConfig))
    self.assertItemsEqual(PAM_CONF_OVERRIDE_COMPLEX_EXPECTED, self._EntriesToTuples(out[0].entries))
    self.assertEqual([], out[0].external_config)
    (stats, file_objs) = checks_test_lib.HostCheckTest.GenStatFileData(PAM_CONF_TYPICAL)
    out = list(parser.ParseMultiple(stats, file_objs, self.kb))
    self.assertEqual(len(out), 1)
    self.assertTrue(isinstance(out[0], rdf_config.PamConfig))
    self.assertItemsEqual(PAM_CONF_TYPICAL_EXPECTED, self._EntriesToTuples(out[0].entries))
    self.assertEqual([], out[0].external_config)
    (stats, file_objs) = checks_test_lib.HostCheckTest.GenStatFileData(PAM_CONF_EXTERNAL_REF)
    out = list(parser.ParseMultiple(stats, file_objs, self.kb))
    self.assertEqual(len(out), 1)
    self.assertTrue(isinstance(out[0], rdf_config.PamConfig))
    self.assertItemsEqual(PAM_CONF_EXTERNAL_REF_EXPECTED, self._EntriesToTuples(out[0].entries))
    self.assertItemsEqual(PAM_CONF_EXTERNAL_REF_ERRORS, list(out[0].external_config))
