1
2
3 import turbogears
4 from turbogears import testutil, database, config
5 turbogears.update_config(configfile='dev.cfg', modulename='bodhi.config')
6 database.set_db_uri("sqlite:///:memory:")
7
8 import os
9 import sys
10 import time
11 import shutil
12 import tempfile
13
14 from os.path import join, exists, basename
15 from bodhi.util import mkmetadatadir
16 from bodhi.model import (Release, Package, PackageUpdate, Bugzilla, CVE,
17 PackageBuild, Comment, User)
18 from bodhi.exceptions import (DuplicateEntryError, SQLiteIntegrityError,
19 PostgresIntegrityError, RPMNotFound)
20
21 from yum.update_md import UpdateMetadata
22
24
25 - def get_pkg(self, name='TurboGears'):
27
32
33 - def get_build(self, nvr='TurboGears-1.0.2.2-2.fc7'):
37
38 - def get_update(self, name='TurboGears-1.0.2.2-2.fc7'):
48
51
54
57
59 update1 = self.get_update()
60 try:
61 update2 = self.get_update()
62 except (DuplicateEntryError, PostgresIntegrityError,
63 SQLiteIntegrityError):
64 return
65 assert False
66
75
91
97
120
133
135 """ Verify that the updateinfo.xml.gz for a given repo matches the
136 data for a given update
137 """
138 print "_verify_updateinfo(%s, %s)" % (update.nvr, repo)
139 uinfo = UpdateMetadata()
140 uinfo.add(repo)
141 notice = uinfo.get_notice(update.nvr)
142 assert notice
143 assert notice['from'] == 'updates@fedora.com'
144 assert notice['title'] == update.nvr
145 assert notice['release'] == update.release.long_name
146 assert notice['type'] == update.type
147 assert notice['status'] == update.status
148 assert notice['update_id'] == update.update_id
149 assert notice['issued'] == str(update.date_pushed)
150 assert notice['description'] == update.notes
151 for collection in notice['pkglist']:
152 numfiles = 0
153 for archfiles in update.filelist.values():
154 for file in archfiles:
155 numfiles += 1
156 assert len(collection['packages']) == numfiles
157 for pkg in collection['packages']:
158 assert pkg['arch'] in update.filelist.keys()
159 found = False
160 for file in update.filelist[pkg['arch']]:
161 if pkg['filename'] in file:
162 found = True
163 break
164 assert found
165
167 from bodhi import mail
168 update = self.get_update(name='TurboGears-1.0.2.2-2.fc7')
169 bug = self.get_bug()
170 cve = self.get_cve()
171 update.addBugzilla(bug)
172 update.addCVE(cve)
173 update.assign_id()
174 print update
175 try:
176 templates = mail.get_template(update)
177 except RPMNotFound:
178
179
180 if config.get('buildsystem') == 'dev':
181 return
182 else:
183 raise
184 assert templates
185 from pprint import pprint
186 pprint(templates)
187 assert templates[0][0] == u'[SECURITY] Fedora 7 Test Update: TurboGears-1.0.2.2-2.fc7'
188 assert templates[0][1] == u'--------------------------------------------------------------------------------\nFedora Test Update Notification\nFEDORA-2007-0001\nNone\n--------------------------------------------------------------------------------\n\nName : TurboGears\nProduct : Fedora 7\nVersion : 1.0.2.2\nRelease : 2.fc7\nURL : http://www.turbogears.org\nSummary : Back-to-front web development in Python\nDescription :\nTurboGears brings together four major pieces to create an\neasy to install, easy to use web megaframework. It covers\neverything from front end (MochiKit JavaScript for the browser,\nKid for templates in Python) to the controllers (CherryPy) to\nthe back end (SQLObject).\n\nThe TurboGears project is focused on providing documentation\nand integration with these tools without losing touch\nwith the communities that already exist around those tools.\n\nTurboGears is easy to use for a wide range of web applications.\n\n--------------------------------------------------------------------------------\nUpdate Information:\n\nfoobar\n--------------------------------------------------------------------------------\nReferences:\n\n [ 1 ] Bug #1 - test bug\n https://bugzilla.redhat.com/show_bug.cgi?id=1\n [ 2 ] CVE-2007-0000\n http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-0000\n--------------------------------------------------------------------------------\nUpdated packages:\n\n57e80ee8eb6d666c79c498e0b2efecd74ab52063 TurboGears-1.0.2.2-2.fc7.src.rpm\n85e05a4d52143ce38f43f7fdd244251e18f9d408 TurboGears-1.0.2.2-2.fc7.noarch.rpm\n\nThis update can be installed with the "yum" update program. Use \nsu -c \'yum update TurboGears\' \nat the command line. For more information, refer to "Managing Software\nwith yum", available at http://docs.fedoraproject.org/yum/.\n--------------------------------------------------------------------------------\n' or templates[0][1] == u'--------------------------------------------------------------------------------\nFedora Test Update Notification\nFEDORA-2007-0001\nNone\n--------------------------------------------------------------------------------\n\nName : TurboGears\nProduct : Fedora 7\nVersion : 1.0.2.2\nRelease : 2.fc7\nURL : http://www.turbogears.org\nSummary : Back-to-front web development in Python\nDescription :\nTurboGears brings together four major pieces to create an\neasy to install, easy to use web megaframework. It covers\neverything from front end (MochiKit JavaScript for the browser,\nKid for templates in Python) to the controllers (CherryPy) to\nthe back end (SQLObject).\n\nThe TurboGears project is focused on providing documentation\nand integration with these tools without losing touch\nwith the communities that already exist around those tools.\n\nTurboGears is easy to use for a wide range of web applications.\n\n--------------------------------------------------------------------------------\nUpdate Information:\n\nfoobar\n--------------------------------------------------------------------------------\nReferences:\n\n [ 1 ] Bug #1 - None\n https://bugzilla.redhat.com/show_bug.cgi?id=1\n [ 2 ] CVE-2007-0000\n http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-0000\n--------------------------------------------------------------------------------\nUpdated packages:\n\n57e80ee8eb6d666c79c498e0b2efecd74ab52063 TurboGears-1.0.2.2-2.fc7.src.rpm\n85e05a4d52143ce38f43f7fdd244251e18f9d408 TurboGears-1.0.2.2-2.fc7.noarch.rpm\n\nThis update can be installed with the "yum" update program. Use \nsu -c \'yum update TurboGears\' \nat the command line. For more information, refer to "Managing Software\nwith yum", available at http://docs.fedoraproject.org/yum/.\n--------------------------------------------------------------------------------\n' or templates[0][1] == u'--------------------------------------------------------------------------------\nFedora Test Update Notification\nFEDORA-2007-0001\nNone\n--------------------------------------------------------------------------------\n\nName : TurboGears\nProduct : Fedora 7\nVersion : 1.0.2.2\nRelease : 2.fc7\nURL : http://www.turbogears.org\nSummary : Back-to-front web development in Python\nDescription :\nTurboGears brings together four major pieces to create an\neasy to install, easy to use web megaframework. It covers\neverything from front end (MochiKit JavaScript for the browser,\nKid for templates in Python) to the controllers (CherryPy) to\nthe back end (SQLObject).\n\nThe TurboGears project is focused on providing documentation\nand integration with these tools without losing touch\nwith the communities that already exist around those tools.\n\nTurboGears is easy to use for a wide range of web applications.\n\n--------------------------------------------------------------------------------\nUpdate Information:\n\nfoobar\n--------------------------------------------------------------------------------\nReferences:\n\n [ 1 ] Bug #1 - None\n https://bugzilla.redhat.com/show_bug.cgi?id=1\n [ 2 ] CVE-2007-0000\n http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-0000\n--------------------------------------------------------------------------------\nUpdated packages:\n\n57e80ee8eb6d666c79c498e0b2efecd74ab52063 TurboGears-1.0.2.2-2.fc7.src.rpm\n85e05a4d52143ce38f43f7fdd244251e18f9d408 TurboGears-1.0.2.2-2.fc7.noarch.rpm\n\nThis update can be installed with the "yum" update program. Use \nsu -c \'yum --enablerepo=updates-testing update TurboGears\' \nat the command line. For more information, refer to "Managing Software\nwith yum", available at http://docs.fedoraproject.org/yum/.\n--------------------------------------------------------------------------------\n'
189
190
192 update = self.get_update(name='yum-3.2.1-1.fc7')
193 if config.get('buildsystem') == 'koji':
194 latest = update.builds[0].get_latest()
195 assert latest
196 assert latest == '/mnt/koji/packages/yum/3.2.0/1.fc7/src/yum-3.2.0-1.fc7.src.rpm'
197
209
210
212
215
218
220 bug = Bugzilla(bz_id=237533)
221 assert bug
222 if config.get('bodhi_password'):
223 assert bug.title == 'CVE-2007-2165: proftpd auth bypass vulnerability'
224 assert bug.security == True
225 assert bug.bz_id == 237533
226