

def testPackageSourceData(self):
    test_data = '\n    # comment 1\n    [centosdvdiso]\n    name=CentOS DVD ISO\n    baseurl=file:///mnt\n    http://mirror1.centos.org/CentOS/6/os/i386/\n    baseurl =ssh://mirror2.centos.org/CentOS/6/os/i386/\n    enabled=1\n    gpgcheck=1\n    gpgkey=file:///mnt/RPM-GPG-KEY-CentOS-6\n\n    # comment2\n    [examplerepo]\n    name=Example Repository\n    baseurl = https://mirror3.centos.org/CentOS/6/os/i386/\n    enabled=1\n    gpgcheck=1\n    gpgkey=http://mirror.centos.org/CentOS/6/os/i386/RPM-GPG-KEY-CentOS-6\n\n    '
    file_obj = StringIO.StringIO(test_data)
    pathspec = rdf_paths.PathSpec(path='/etc/yum.repos.d/test1.repo')
    stat = rdf_client.StatEntry(pathspec=pathspec)
    parser = config_file.YumPackageSourceParser()
    results = list(parser.Parse(stat, file_obj, None))
    result = [d for d in results if isinstance(d, rdf_protodict.AttributedDict)][0]
    self.assertEqual('/etc/yum.repos.d/test1.repo', result.filename)
    self.assertEqual(4, len(result.uris))
    self.assertEqual('file', result.uris[0].transport)
    self.assertEqual('', result.uris[0].host)
    self.assertEqual('/mnt', result.uris[0].path)
    self.assertEqual('http', result.uris[1].transport)
    self.assertEqual('mirror1.centos.org', result.uris[1].host)
    self.assertEqual('/CentOS/6/os/i386/', result.uris[1].path)
    self.assertEqual('ssh', result.uris[2].transport)
    self.assertEqual('mirror2.centos.org', result.uris[2].host)
    self.assertEqual('/CentOS/6/os/i386/', result.uris[2].path)
    self.assertEqual('https', result.uris[3].transport)
    self.assertEqual('mirror3.centos.org', result.uris[3].host)
    self.assertEqual('/CentOS/6/os/i386/', result.uris[3].path)

dataset/ETHPy150Open google/grr/grr/parsers/config_file_test.py YumPackageSourceParserTests.testPackageSourceData/original