Beispiel #1
0
    def test_multibuild(self):
        builds = ['yum-3.2.1-1.fc7', 'httpd-2.2.4-4.1.fc7']
        package_builds = []
        release = get_rel()
        update = PackageUpdate(title=','.join(builds), release=release,
                               submitter='*****@*****.**', notes='Testing!',
                               type='bugfix')
        for build in builds:
            nvr = get_nvr(build)
            pkg = Package(name=nvr[0])
            b = PackageBuild(nvr=build, package=pkg)
            package_builds.append(b)

        map(update.addPackageBuild, package_builds)

        assert update.builds[0].nvr == builds[0]
        assert update.builds[1].nvr == builds[1]
        assert update.title == ','.join(builds)
        assert update.release.name == 'fc7'
        assert release.updates[0] == update
        assert update.status == 'pending'
        assert update.type == 'bugfix'
        assert update.notes == 'Testing!'

        for build in package_builds:
            assert build.updates[0] == update
Beispiel #2
0
    def test_multibuild(self):
        builds = ['yum-3.2.1-1.fc7', 'httpd-2.2.4-4.1.fc7']
        package_builds = []
        release = get_rel()
        update = PackageUpdate(title=','.join(builds), release=release,
                               submitter='*****@*****.**', notes='Testing!',
                               type='bugfix')
        for build in builds:
            nvr = get_nvr(build)
            pkg = Package(name=nvr[0])
            b = PackageBuild(nvr=build, package=pkg)
            package_builds.append(b)

        map(update.addPackageBuild, package_builds)

        assert update.builds[0].nvr == builds[0]
        assert update.builds[1].nvr == builds[1]
        assert update.title == ','.join(builds)
        assert update.release.name == 'fc7'
        assert release.updates[0] == update
        assert update.status == 'pending'
        assert update.type == 'bugfix'
        assert update.notes == 'Testing!'

        for build in package_builds:
            assert build.updates[0] == update
Beispiel #3
0
    def test_extended_metadata_updating_with_old_stable_security(self):
        testutil.capture_log(['bodhi.metadata'])

        koji = get_session()
        del(koji.__untag__[:])
        assert not koji.__untag__, koji.__untag__
        builds = koji.listTagged('dist-f7-updates', latest=True)

        # Create all of the necessary database entries
        release = Release(name='F17', long_name='Fedora 17', id_prefix='FEDORA',
                          dist_tag='dist-f17')
        package = Package(name='TurboGears')
        update = PackageUpdate(title='TurboGears-1.0.2.2-2.fc7',
                               release=release,
                               submitter=builds[0]['owner_name'],
                               status='stable',
                               notes='foobar',
                               type='security')
        build = PackageBuild(nvr='TurboGears-1.0.2.2-2.fc7', package=package)
        update.addPackageBuild(build)

        update.assign_id()
        assert update.updateid

        ## Initialize our temporary repo
        temprepo = join(tempfile.mkdtemp('bodhi'), 'f7-updates')
        print "Inserting updateinfo into temprepo: %s" % temprepo
        mkmetadatadir(join(temprepo, 'i386'))
        repodata = join(temprepo, 'i386', 'repodata')
        assert exists(join(repodata, 'repomd.xml'))

        ## Generate the XML
        md = ExtendedMetadata(temprepo)

        ## Insert the updateinfo.xml into the repository
        md.insert_updateinfo()
        updateinfo = self.__verify_updateinfo(repodata)

        # Create a new non-security update for the same package
        newbuild = 'TurboGears-1.0.2.2-3.fc7'
        update = PackageUpdate(title=newbuild,
                               release=release,
                               submitter=builds[0]['owner_name'],
                               status='stable',
                               notes='foobar',
                               type='enhancement')
        build = PackageBuild(nvr=newbuild, package=package)
        update.addPackageBuild(build)
        update.assign_id()

        koji.__untag__.append('TurboGears-1.0.2.2-2.fc7')

        ## Test out updateinfo.xml updating via our ExtendedMetadata
        md = ExtendedMetadata(temprepo, updateinfo)
        md.insert_updateinfo()
        updateinfo = self.__verify_updateinfo(repodata)

        ## Read an verify the updateinfo.xml.gz
        uinfo = UpdateMetadata()
        uinfo.add(updateinfo)

        print(testutil.get_log())

        assert len(uinfo.get_notices()) == 2, len(uinfo.get_notices())
        assert uinfo.get_notice(get_nvr('TurboGears-1.0.2.2-2.fc7'))
        notice = uinfo.get_notice(get_nvr(update.title))
        assert notice, 'Cannot find update for %r' % get_nvr(update.title)
        assert notice['status'] == update.status
        assert notice['updated'] == update.date_modified
        assert notice['from'] == str(config.get('bodhi_email'))
        assert notice['description'] == update.notes
        assert notice['issued'] is not None
        assert notice['update_id'] == update.updateid

        ## Clean up
        shutil.rmtree(temprepo)
        del(koji.__untag__[:])
Beispiel #4
0
    def test_extended_metadata(self):
        # grab the name of a build in updates-testing, and create it in our db
        koji = get_session()
        builds = koji.listTagged('dist-f13-updates-testing', latest=True)

        # Create all of the necessary database entries
        release = Release(name='F13', long_name='Fedora 13',
                          id_prefix='FEDORA', dist_tag='dist-f13')
        package = Package(name=builds[0]['package_name'])
        update = PackageUpdate(title=builds[0]['nvr'],
                               release=release,
                               submitter=builds[0]['owner_name'],
                               status='testing',
                               notes='foobar',
                               type='bugfix')
        build = PackageBuild(nvr=builds[0]['nvr'], package=package)
        update.addPackageBuild(build)

        bug = Bugzilla(bz_id=1)
        update.addBugzilla(bug)
        cve = CVE(cve_id="CVE-2007-0000")
        update.addCVE(cve)
        update.assign_id()
        print update

        ## Initialize our temporary repo
        temprepo = join(tempfile.mkdtemp('bodhi'), 'f13-updates-testing')
        print "Inserting updateinfo into temprepo: %s" % temprepo
        mkmetadatadir(join(temprepo, 'i386'))
        repodata = join(temprepo, 'i386', 'repodata')
        assert exists(join(repodata, 'repomd.xml'))

        ## Generate the XML
        md = ExtendedMetadata(temprepo)

        ## Insert the updateinfo.xml into the repository
        md.insert_updateinfo()
        updateinfo = self.__verify_updateinfo(repodata)

        ## Read an verify the updateinfo.xml.gz
        uinfo = UpdateMetadata()
        uinfo.add(updateinfo)
        notice = uinfo.get_notice(('mutt', '1.5.14', '1.fc13'))
        assert not notice
        notice = uinfo.get_notice(get_nvr(update.title))
        assert notice
        assert notice['status'] == update.status
        assert notice['updated'] == update.date_modified
        assert notice['from'] == str(config.get('bodhi_email'))
        assert notice['description'] == update.notes
        assert notice['issued'] is not None
        assert notice['update_id'] == update.updateid
        assert notice['epoch'] is None
        cve = notice['references'][0]
        assert cve['type'] == 'cve'
        assert cve['href'] == update.cves[0].get_url()
        assert cve['id'] == update.cves[0].cve_id
        bug = notice['references'][1]
        assert bug['href'] == update.bugs[0].get_url()
        assert bug['id'] == '1'
        assert bug['type'] == 'bugzilla'

        # FC6's yum update metadata parser doesn't know about some stuff
        from yum import __version__
        if __version__ >= '3.0.6':
            assert notice['title'] == update.title
            assert notice['release'] == update.release.long_name
            assert cve['title'] is None

        ## Clean up
        shutil.rmtree(temprepo)
Beispiel #5
0
    def test_extended_metadata_updating_with_edited_updates(self):
        testutil.capture_log(['bodhi.metadata'])

        # grab the name of a build in updates-testing, and create it in our db
        koji = get_session()
        builds = koji.listTagged('dist-f13-updates-testing', latest=True)

        # Create all of the necessary database entries
        release = Release(name='F13', long_name='Fedora 13', id_prefix='FEDORA',
                          dist_tag='dist-f13')
        package = Package(name=builds[0]['package_name'])
        update = PackageUpdate(title=builds[0]['nvr'],
                               release=release,
                               submitter=builds[0]['owner_name'],
                               status='testing',
                               notes='foobar',
                               type='bugfix')
        build = PackageBuild(nvr=builds[0]['nvr'], package=package)
        update.addPackageBuild(build)
        update.assign_id()

        ## Initialize our temporary repo
        temprepo = join(tempfile.mkdtemp('bodhi'), 'f13-updates-testing')
        print "Inserting updateinfo into temprepo: %s" % temprepo
        mkmetadatadir(join(temprepo, 'i386'))
        repodata = join(temprepo, 'i386', 'repodata')
        assert exists(join(repodata, 'repomd.xml'))

        ## Generate the XML
        md = ExtendedMetadata(temprepo)

        ## Insert the updateinfo.xml into the repository
        md.insert_updateinfo()
        updateinfo = self.__verify_updateinfo(repodata)

        ## Read an verify the updateinfo.xml.gz
        uinfo = UpdateMetadata()
        uinfo.add(updateinfo)
        notice = uinfo.get_notice(('mutt', '1.5.14', '1.fc13'))
        assert not notice
        notice = uinfo.get_notice(get_nvr(update.title))
        assert notice
        assert notice['status'] == update.status
        assert notice['updated'] == update.date_modified
        assert notice['from'] == str(config.get('bodhi_email'))
        assert notice['description'] == update.notes
        assert notice['issued'] is not None
        assert notice['update_id'] == update.updateid
        assert notice['title'] == update.title
        assert notice['release'] == update.release.long_name

        ## Edit the update and bump the build revision
        nvr = 'TurboGears-1.0.2.2-3.fc7'
        newbuild = PackageBuild(nvr=nvr, package=package)
        update.removePackageBuild(build)
        update.addPackageBuild(newbuild)
        update.title = nvr
        update.date_modified = datetime.utcnow()

        # Pretend -2 was unpushed
        assert len(koji.__untag__) == 0
        koji.__untag__.append('TurboGears-1.0.2.2-2.fc7')

        ## Test out updateinfo.xml updating via our ExtendedMetadata
        md = ExtendedMetadata(temprepo, updateinfo)
        md.insert_updateinfo()
        updateinfo = self.__verify_updateinfo(repodata)

        ## Read an verify the updateinfo.xml.gz
        uinfo = UpdateMetadata()
        uinfo.add(updateinfo)

        print(testutil.get_log())

        notice = uinfo.get_notice(('TurboGears', '1.0.2.2', '2.fc7'))
        assert not notice, "Old TG notice did not get pruned: %s" % notice
        notice = uinfo.get_notice(('TurboGears', '1.0.2.2', '3.fc7'))
        assert notice, uinfo
        assert notice['title'] == update.title

        num_notices = len(uinfo.get_notices())
        assert num_notices == 1, num_notices

        ## Clean up
        shutil.rmtree(temprepo)
        del(koji.__untag__[:])
Beispiel #6
0
                flash("Cannot set an expiration in the past")
                if request_format() == "json":
                    return dict()
                raise redirect("/override/new")

        try:
            koji = get_session()
        except Exception, e:
            flash("Unable to connect to Koji")
            if request_format() == "json":
                return dict()
            raise redirect("/override/new")

        for build in iterate(builds):
            release = None
            n, v, r = get_nvr(build)

            # Make sure the build is tagged correctly
            try:
                tags = [tag["name"] for tag in koji.listTags(build)]
            except Exception, e:
                flash(str(e))
                if request_format() == "json":
                    return dict()
                raise redirect("/override/new")

            # Determine the release by the tag, and sanity check the builds
            for tag in tags:
                for rel in Release.select():
                    if tag in (rel.candidate_tag, rel.testing_tag):
                        release = last_release = rel
Beispiel #7
0
    def test_extended_metadata_updating(self):
        # grab the name of a build in updates-testing, and create it in our db
        koji = get_session()
        builds = koji.listTagged('dist-f13-updates-testing', latest=True)

        # Create all of the necessary database entries
        release = Release(name='F13',
                          long_name='Fedora 13',
                          id_prefix='FEDORA',
                          dist_tag='dist-f13')
        package = Package(name=builds[0]['package_name'])
        update = PackageUpdate(title=builds[0]['nvr'],
                               release=release,
                               submitter=builds[0]['owner_name'],
                               status='testing',
                               notes='foobar',
                               type='bugfix')
        build = PackageBuild(nvr=builds[0]['nvr'], package=package)
        update.addPackageBuild(build)

        bug = Bugzilla(bz_id=1)
        bug.title = u'test bug'
        update.addBugzilla(bug)
        cve = CVE(cve_id="CVE-2007-0000")
        update.addCVE(cve)
        update.assign_id()

        ## Initialize our temporary repo
        temprepo = join(tempfile.mkdtemp('bodhi'), 'f7-updates-testing')
        print "Inserting updateinfo into temprepo: %s" % temprepo
        mkmetadatadir(join(temprepo, 'i386'))
        repodata = join(temprepo, 'i386', 'repodata')
        assert exists(join(repodata, 'repomd.xml'))

        ## Generate the XML
        md = ExtendedMetadata(temprepo)

        ## Insert the updateinfo.xml into the repository
        md.insert_updateinfo()
        updateinfo = join(repodata, 'updateinfo.xml.gz')
        assert exists(updateinfo)

        ## Read an verify the updateinfo.xml.gz
        uinfo = UpdateMetadata()
        uinfo.add(updateinfo)
        notice = uinfo.get_notice(('mutt', '1.5.14', '1.fc13'))
        assert not notice
        notice = uinfo.get_notice(get_nvr(update.title))
        assert notice
        assert notice['status'] == update.status
        assert notice['updated'] == update.date_modified
        assert notice['from'] == str(config.get('bodhi_email'))
        assert notice['description'] == update.notes
        assert notice['issued'] != None
        assert notice['update_id'] == update.updateid
        cve = notice['references'][0]
        assert cve['type'] == 'cve'
        assert cve['href'] == update.cves[0].get_url()
        assert cve['id'] == update.cves[0].cve_id
        bug = notice['references'][1]
        assert bug['href'] == update.bugs[0].get_url()
        assert bug['id'] == '1'
        assert bug['type'] == 'bugzilla'
        assert bug['title'] == 'test bug'

        # FC6's yum update metadata parser doesn't know about some stuff
        from yum import __version__
        if __version__ >= '3.0.6':
            assert notice['title'] == update.title
            assert notice['release'] == update.release.long_name
            assert cve['title'] == None

        ## Test out updateinfo.xml updating via our ExtendedMetadata
        md = ExtendedMetadata(temprepo, updateinfo)
        md.insert_updateinfo()
        updateinfo = join(repodata, 'updateinfo.xml.gz')
        assert exists(updateinfo)

        ## Read an verify the updateinfo.xml.gz
        uinfo = UpdateMetadata()
        uinfo.add(updateinfo)
        notice = uinfo.get_notice(('mutt', '1.5.14', '1.fc13'))
        assert not notice
        notice = uinfo.get_notice(get_nvr(update.title))
        assert notice
        assert notice['status'] == update.status
        assert notice['updated'] == update.date_modified
        assert notice['from'] == str(config.get('bodhi_email'))
        assert notice['description'] == update.notes
        assert notice['issued'] != None
        assert notice['update_id'] == update.updateid
        cve = notice['references'][0]
        assert cve['type'] == 'cve'
        assert cve['href'] == update.cves[0].get_url()
        assert cve['id'] == update.cves[0].cve_id
        bug = notice['references'][1]
        assert bug['href'] == update.bugs[0].get_url()
        assert bug['id'] == '1'
        assert bug['type'] == 'bugzilla'
        assert bug['title'] == 'test bug', bug

        # FC6's yum update metadata parser doesn't know about some stuff
        from yum import __version__
        if __version__ >= '3.0.6':
            assert notice['title'] == update.title
            assert notice['release'] == update.release.long_name
            assert cve['title'] == None

        ## Clean up
        shutil.rmtree(temprepo)
Beispiel #8
0
            if datetime.utcnow() > expiration:
                flash('Cannot set an expiration in the past')
                if request_format() == 'json': return dict()
                raise redirect('/override/new')

        try:
            koji = get_session()
        except Exception, e:
            flash('Unable to connect to Koji')
            if request_format() == 'json':
                return dict()
            raise redirect('/override/new')

        for build in iterate(builds):
            release = None
            n, v, r = get_nvr(build)

            # Make sure the build is tagged correctly
            try:
                tags = [tag['name'] for tag in koji.listTags(build)]
            except Exception, e:
                flash(str(e))
                if request_format() == 'json': return dict()
                raise redirect('/override/new')

            # Determine the release by the tag, and sanity check the builds
            for tag in tags:
                for rel in Release.select():
                    if tag in (rel.candidate_tag, rel.testing_tag):
                        release = last_release = rel
                    elif tag == rel.stable_tag:
Beispiel #9
0
    def test_extended_metadata_updating_with_old_stable_security(self):
        testutil.capture_log(['bodhi.metadata'])

        koji = get_session()
        del (koji.__untag__[:])
        assert not koji.__untag__, koji.__untag__
        builds = koji.listTagged('dist-f7-updates', latest=True)

        # Create all of the necessary database entries
        release = Release(name='F17',
                          long_name='Fedora 17',
                          id_prefix='FEDORA',
                          dist_tag='dist-f17')
        package = Package(name='TurboGears')
        update = PackageUpdate(title='TurboGears-1.0.2.2-2.fc7',
                               release=release,
                               submitter=builds[0]['owner_name'],
                               status='stable',
                               notes='foobar',
                               type='security')
        build = PackageBuild(nvr='TurboGears-1.0.2.2-2.fc7', package=package)
        update.addPackageBuild(build)

        update.assign_id()
        assert update.updateid

        ## Initialize our temporary repo
        temprepo = join(tempfile.mkdtemp('bodhi'), 'f7-updates')
        print "Inserting updateinfo into temprepo: %s" % temprepo
        mkmetadatadir(join(temprepo, 'i386'))
        repodata = join(temprepo, 'i386', 'repodata')
        assert exists(join(repodata, 'repomd.xml'))

        ## Generate the XML
        md = ExtendedMetadata(temprepo)

        ## Insert the updateinfo.xml into the repository
        md.insert_updateinfo()
        updateinfo = self.__verify_updateinfo(repodata)

        # Create a new non-security update for the same package
        newbuild = 'TurboGears-1.0.2.2-3.fc7'
        update = PackageUpdate(title=newbuild,
                               release=release,
                               submitter=builds[0]['owner_name'],
                               status='stable',
                               notes='foobar',
                               type='enhancement')
        build = PackageBuild(nvr=newbuild, package=package)
        update.addPackageBuild(build)
        update.assign_id()

        koji.__untag__.append('TurboGears-1.0.2.2-2.fc7')

        ## Test out updateinfo.xml updating via our ExtendedMetadata
        md = ExtendedMetadata(temprepo, updateinfo)
        md.insert_updateinfo()
        updateinfo = self.__verify_updateinfo(repodata)

        ## Read an verify the updateinfo.xml.gz
        uinfo = UpdateMetadata()
        uinfo.add(updateinfo)

        print(testutil.get_log())

        assert len(uinfo.get_notices()) == 2, len(uinfo.get_notices())
        assert uinfo.get_notice(get_nvr('TurboGears-1.0.2.2-2.fc7'))
        notice = uinfo.get_notice(get_nvr(update.title))
        assert notice, 'Cannot find update for %r' % get_nvr(update.title)
        assert notice['status'] == update.status
        assert notice['updated'] == update.date_modified
        assert notice['from'] == str(config.get('bodhi_email'))
        assert notice['description'] == update.notes
        assert notice['issued'] is not None
        assert notice['update_id'] == update.updateid

        ## Clean up
        shutil.rmtree(temprepo)
        del (koji.__untag__[:])
Beispiel #10
0
    def test_extended_metadata_updating_with_edited_updates(self):
        testutil.capture_log(['bodhi.metadata'])

        # grab the name of a build in updates-testing, and create it in our db
        koji = get_session()
        builds = koji.listTagged('dist-f13-updates-testing', latest=True)

        # Create all of the necessary database entries
        release = Release(name='F13',
                          long_name='Fedora 13',
                          id_prefix='FEDORA',
                          dist_tag='dist-f13')
        package = Package(name=builds[0]['package_name'])
        update = PackageUpdate(title=builds[0]['nvr'],
                               release=release,
                               submitter=builds[0]['owner_name'],
                               status='testing',
                               notes='foobar',
                               type='bugfix')
        build = PackageBuild(nvr=builds[0]['nvr'], package=package)
        update.addPackageBuild(build)
        update.assign_id()

        ## Initialize our temporary repo
        temprepo = join(tempfile.mkdtemp('bodhi'), 'f13-updates-testing')
        print "Inserting updateinfo into temprepo: %s" % temprepo
        mkmetadatadir(join(temprepo, 'i386'))
        repodata = join(temprepo, 'i386', 'repodata')
        assert exists(join(repodata, 'repomd.xml'))

        ## Generate the XML
        md = ExtendedMetadata(temprepo)

        ## Insert the updateinfo.xml into the repository
        md.insert_updateinfo()
        updateinfo = self.__verify_updateinfo(repodata)

        ## Read an verify the updateinfo.xml.gz
        uinfo = UpdateMetadata()
        uinfo.add(updateinfo)
        notice = uinfo.get_notice(('mutt', '1.5.14', '1.fc13'))
        assert not notice
        notice = uinfo.get_notice(get_nvr(update.title))
        assert notice
        assert notice['status'] == update.status
        assert notice['updated'] == update.date_modified
        assert notice['from'] == str(config.get('bodhi_email'))
        assert notice['description'] == update.notes
        assert notice['issued'] is not None
        assert notice['update_id'] == update.updateid
        assert notice['title'] == update.title
        assert notice['release'] == update.release.long_name

        ## Edit the update and bump the build revision
        nvr = 'TurboGears-1.0.2.2-3.fc7'
        newbuild = PackageBuild(nvr=nvr, package=package)
        update.removePackageBuild(build)
        update.addPackageBuild(newbuild)
        update.title = nvr
        update.date_modified = datetime.utcnow()

        # Pretend -2 was unpushed
        assert len(koji.__untag__) == 0
        koji.__untag__.append('TurboGears-1.0.2.2-2.fc7')

        ## Test out updateinfo.xml updating via our ExtendedMetadata
        md = ExtendedMetadata(temprepo, updateinfo)
        md.insert_updateinfo()
        updateinfo = self.__verify_updateinfo(repodata)

        ## Read an verify the updateinfo.xml.gz
        uinfo = UpdateMetadata()
        uinfo.add(updateinfo)

        print(testutil.get_log())

        notice = uinfo.get_notice(('TurboGears', '1.0.2.2', '2.fc7'))
        assert not notice, "Old TG notice did not get pruned: %s" % notice
        notice = uinfo.get_notice(('TurboGears', '1.0.2.2', '3.fc7'))
        assert notice, uinfo
        assert notice['title'] == update.title

        num_notices = len(uinfo.get_notices())
        assert num_notices == 1, num_notices

        ## Clean up
        shutil.rmtree(temprepo)
        del (koji.__untag__[:])