Merge lp:~al-maisan/launchpad/uploadurl-472929 into lp:launchpad/db-devel

Proposed by Muharem Hrnjadovic
Status: Merged
Merged at revision: not available
Proposed branch: lp:~al-maisan/launchpad/uploadurl-472929
Merge into: lp:launchpad/db-devel
Diff against target: 287 lines
5 files modified
lib/lp/soyuz/browser/archive.py (+18/-4)
lib/lp/soyuz/browser/archivepermission.py (+3/-1)
lib/lp/soyuz/interfaces/archivepermission.py (+7/-0)
lib/lp/soyuz/model/archivepermission.py (+8/-0)
lib/lp/soyuz/stories/webservice/xx-packageset.txt (+76/-22)
To merge this branch: bzr merge lp:~al-maisan/launchpad/uploadurl-472929
Reviewer Review Type Date Requested Status
Francis J. Lacoste (community) release-critical Approve
Brad Crittenden (community) code Approve
Review via email: mp+14382@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Muharem Hrnjadovic (al-maisan) wrote :

Hello there!

In the last week we changed package sets so that they are related to distro series. Package set names hence cease to be globally unique and are now only unambiguous in combination with a distro series.

The URLs for package set based archive permissions needed to be revised to reflect that. That's what the branch at hand does.

Tests to run:

    bin/test -vv -t archive -t upload -t permission -t package

Revision history for this message
Brad Crittenden (bac) wrote :

Looks good Muharem. Good luck getting the r-c for it.

review: Approve (code)
Revision history for this message
Francis J. Lacoste (flacoste) :
review: Approve (release-critical)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/soyuz/browser/archive.py'
2--- lib/lp/soyuz/browser/archive.py 2009-11-03 00:37:42 +0000
3+++ lib/lp/soyuz/browser/archive.py 2009-11-03 19:10:27 +0000
4@@ -286,14 +286,28 @@
5 # See if "item" is a source package name.
6 the_item = getUtility(ISourcePackageNameSet).queryByName(item)
7 elif item_type == 'packageset':
8- # See if "item" is a package set.
9- the_item = getUtility(IPackagesetSet).getByName(item)
10+ the_item = None
11+ # Was a 'series' URL param passed?
12+ series = get_url_param('series')
13+ if series is not None:
14+ # Get the requested distro series.
15+ try:
16+ series = self.context.distribution[series]
17+ except NotFoundError:
18+ series = None
19+ if series is not None:
20+ the_item = getUtility(IPackagesetSet).getByName(
21+ item, distroseries=series)
22 else:
23 the_item = None
24
25 if the_item is not None:
26- return getUtility(IArchivePermissionSet).checkAuthenticated(
27- user, self.context, permission_type, the_item)[0]
28+ result_set = getUtility(IArchivePermissionSet).checkAuthenticated(
29+ user, self.context, permission_type, the_item)
30+ if result_set.count() > 0:
31+ return result_set[0]
32+ else:
33+ return None
34 else:
35 return None
36
37
38=== modified file 'lib/lp/soyuz/browser/archivepermission.py'
39--- lib/lp/soyuz/browser/archivepermission.py 2009-07-17 00:26:05 +0000
40+++ lib/lp/soyuz/browser/archivepermission.py 2009-11-03 19:10:27 +0000
41@@ -45,7 +45,9 @@
42 item = (
43 "type=packagename&item=%s" % self.context.source_package_name)
44 elif self.context.package_set_name is not None:
45- item = "type=packageset&item=%s" % self.context.package_set_name
46+ item = ("type=packageset&item=%s&series=%s" %
47+ (self.context.package_set_name,
48+ self.context.distro_series_name))
49 else:
50 raise AssertionError, (
51 "One of component, sourcepackagename or package set should "
52
53=== modified file 'lib/lp/soyuz/interfaces/archivepermission.py'
54--- lib/lp/soyuz/interfaces/archivepermission.py 2009-11-02 08:07:41 +0000
55+++ lib/lp/soyuz/interfaces/archivepermission.py 2009-11-03 19:10:27 +0000
56@@ -123,6 +123,13 @@
57 title=_("Package set name"),
58 required=True))
59
60+ distro_series_name = exported(
61+ TextLine(
62+ title=_(
63+ "The name of the distro series associated with the "
64+ "package set."),
65+ required=True))
66+
67
68 class IArchiveUploader(IArchivePermission):
69 """Marker interface for URL traversal of uploader permissions."""
70
71=== modified file 'lib/lp/soyuz/model/archivepermission.py'
72--- lib/lp/soyuz/model/archivepermission.py 2009-11-02 08:07:41 +0000
73+++ lib/lp/soyuz/model/archivepermission.py 2009-11-03 19:10:27 +0000
74@@ -112,6 +112,14 @@
75 else:
76 return None
77
78+ @property
79+ def distro_series_name(self):
80+ """See `IArchivePermission`"""
81+ if self.packageset:
82+ return self.packageset.distroseries.name
83+ else:
84+ return None
85+
86
87 class ArchivePermissionSet:
88 """See `IArchivePermissionSet`."""
89
90=== modified file 'lib/lp/soyuz/stories/webservice/xx-packageset.txt'
91--- lib/lp/soyuz/stories/webservice/xx-packageset.txt 2009-11-03 14:43:22 +0000
92+++ lib/lp/soyuz/stories/webservice/xx-packageset.txt 2009-11-03 19:10:27 +0000
93@@ -559,7 +559,7 @@
94 permission: u'Archive Upload Rights'
95 person_link: u'http://.../~name12'
96 resource_type_link: ...
97- self_link: u'http://.../+archive/primary/+upload/name12?type=packageset&item=firefox'
98+ self_link: u'http://.../+archive/primary/+upload/name12?type=packageset&item=firefox&series=hoary'
99 source_package_name: None
100
101 Grant upload privileges to 'name12' for package set 'mozilla' in the Ubuntu
102@@ -580,7 +580,7 @@
103 ... ubuntu['main_archive_link'], 'getUploadersForPackageset', {},
104 ... packageset=firefox['self_link'])
105 >>> print_payload(response)
106- http://.../+archive/primary/+upload/name12?type=packageset&item=firefox
107+ http://.../+archive/primary/+upload/name12?type=packageset&item=firefox&series=hoary
108
109 Same query, this time allowing the use of the package set hierarchy, finds
110 the permission for the 'mozilla' package set as well.
111@@ -589,8 +589,8 @@
112 ... ubuntu['main_archive_link'], 'getUploadersForPackageset', {},
113 ... packageset=firefox['self_link'], direct_permissions=False)
114 >>> print_payload(response)
115- http://.../+archive/primary/+upload/name12?type=packageset&item=firefox
116- http://.../+archive/primary/+upload/name12?type=packageset&item=mozilla
117+ http://.../+archive/primary/+upload/name12?type=packageset&item=firefox&series=hoary
118+ http://.../+archive/primary/+upload/name12?type=packageset&item=mozilla&series=hoary
119
120 Let's delete the upload privilege for the 'mozilla' package set.
121
122@@ -609,7 +609,7 @@
123 ... ubuntu['main_archive_link'], 'getUploadersForPackageset', {},
124 ... packageset=firefox['self_link'], direct_permissions=False)
125 >>> print_payload(response)
126- http://.../+archive/primary/+upload/name12?type=packageset&item=firefox
127+ http://.../+archive/primary/+upload/name12?type=packageset&item=firefox&series=hoary
128
129 Let's grant 'cprov' an upload permission to 'mozilla' and 'thunderbird'.
130
131@@ -636,8 +636,8 @@
132 ... ubuntu['main_archive_link'], 'getPackagesetsForUploader', {},
133 ... person=cprov['self_link'])
134 >>> print_payload(response)
135- http://.../+archive/primary/+upload/cprov?type=packageset&item=mozilla
136- http://.../+archive/primary/+upload/cprov?type=packageset&item=thunderbird
137+ http://.../+archive/primary/+upload/cprov?type=packageset&item=mozilla&series=hoary
138+ http://.../+archive/primary/+upload/cprov?type=packageset&item=thunderbird&series=hoary
139
140 Let's check what package set based upload permissions 'cprov' has for the
141 'mozilla-firefox' package.
142@@ -647,8 +647,8 @@
143 ... {}, sourcepackagename='thunderbird',
144 ... person=cprov['self_link'])
145 >>> print_payload(response)
146- http://.../+archive/primary/+upload/cprov?type=packageset&item=mozilla
147- http://.../+archive/primary/+upload/cprov?type=packageset&item=thunderbird
148+ http://.../+archive/primary/+upload/cprov?type=packageset&item=mozilla&series=hoary
149+ http://.../+archive/primary/+upload/cprov?type=packageset&item=thunderbird&series=hoary
150
151 As we expected 'cprov' may upload either via the 'thunderbird' package set
152 that directly contains the source package in question or via the 'mozilla'
153@@ -662,7 +662,7 @@
154 ... {}, sourcepackagename='mozilla-firefox',
155 ... person=cprov['self_link'])
156 >>> print_payload(response)
157- http://.../+archive/primary/+upload/cprov?type=packageset&item=mozilla
158+ http://.../+archive/primary/+upload/cprov?type=packageset&item=mozilla&series=hoary
159
160 Yes, and, again via the 'mozilla' package set.
161
162@@ -736,11 +736,11 @@
163 ...
164 false
165
166-Create a new package set ('grouchy-thunderbird') in 'grumpy'.
167+Create a new package set ('thunderbird') in 'grumpy'.
168
169 >>> response = webservice.named_post(
170 ... '/package-sets', 'new', {},
171- ... name=u'grouchy-thunderbird',
172+ ... name=u'thunderbird',
173 ... description=u'Contains all thunderbird packages in grumpy',
174 ... owner=name12['self_link'], distroseries=grumpy['self_link'],
175 ... related_set=thunderbird['self_link'])
176@@ -751,21 +751,21 @@
177 >>> response = webservice.named_get(
178 ... thunderbird['self_link'], 'relatedSets', {})
179 >>> print_payload(response)
180- http://api.launchpad.dev/beta/package-sets/grumpy/grouchy-thunderbird
181+ http://api.launchpad.dev/beta/package-sets/grumpy/thunderbird
182
183-Associate 'grouchy-thunderbird' with the appropriate source packages.
184+Associate 'thunderbird' with the appropriate source packages.
185
186 >>> response = webservice.named_post(
187- ... '/package-sets/grumpy/grouchy-thunderbird', 'addSources', {},
188+ ... '/package-sets/grumpy/thunderbird', 'addSources', {},
189 ... names=['thunderbird', 'language-pack-de'])
190 >>> print response
191 HTTP/1.1 200 Ok
192 ...
193
194-Grant 'name12' upload permissions to 'grouchy-thunderbird' in 'grumpy'.
195+Grant 'name12' upload permissions to 'thunderbird' in 'grumpy'.
196
197 >>> grouchy_bird = webservice.get(
198- ... "/package-sets/grumpy/grouchy-thunderbird").jsonBody()
199+ ... "/package-sets/grumpy/thunderbird").jsonBody()
200
201 >>> response = webservice.named_post(
202 ... ubuntu['main_archive_link'], 'newPackagesetUploader', {},
203@@ -781,8 +781,8 @@
204 ... ubuntu['main_archive_link'], 'getPackagesetsForUploader', {},
205 ... person=name12['self_link'])
206 >>> print_payload(response)
207- http://...+archive/primary/+upload/name12?type=packageset&item=firefox
208- http://...+archive/primary/+upload/name12?type=packageset&item=grouchy-thunderbird
209+ http://...+archive/primary/+upload/name12?type=packageset&item=firefox&series=hoary
210+ http://...+archive/primary/+upload/name12?type=packageset&item=thunderbird&series=grumpy
211
212 And now 'name12' should be authorized to upload source package
213 'thunderbird' in 'grumpy'.
214@@ -803,7 +803,7 @@
215 ... ubuntu['main_archive_link'], 'getPackagesetsForSource',
216 ... {}, sourcepackagename='mozilla-firefox')
217 >>> print_payload(response)
218- http://.../+archive/primary/+upload/name12?type=packageset&item=firefox
219+ http://.../+archive/primary/+upload/name12?type=packageset&item=firefox&series=hoary
220
221 The listing above only shows the *direct* upload permission granted to
222 'name12' via the 'firefox' package set.
223@@ -815,8 +815,62 @@
224 ... ubuntu['main_archive_link'], 'getPackagesetsForSource',
225 ... {}, sourcepackagename='mozilla-firefox', direct_permissions=False)
226 >>> print_payload(response)
227- http://.../+archive/primary/+upload/name12?type=packageset&item=firefox
228- http://.../+archive/primary/+upload/cprov?type=packageset&item=mozilla
229+ http://.../+archive/primary/+upload/name12?type=packageset&item=firefox&series=hoary
230+ http://.../+archive/primary/+upload/cprov?type=packageset&item=mozilla&series=hoary
231
232 Now we see the upload permission granted to 'cprov' via the 'mozilla' package
233 set listed as well.
234+
235+
236+== Archive permission URLs ==
237+
238+Archive permissions can be accessed via their URLs in direct fashion.
239+
240+If we do *not* specify the distro series for package set based archive
241+permission URLs a 404 will result.
242+
243+ >>> url = '/ubuntu/+archive/primary/+upload/name12?type=packageset&item=thunderbird'
244+ >>> response = webservice.get(url)
245+ >>> print response
246+ HTTP/1.1 404 Not Found
247+ ...
248+
249+The same happens if a user tries to doctor an URL with an invalid distro
250+series.
251+
252+ >>> url = '/ubuntu/+archive/primary/+upload/name12?type=packageset&item=thunderbird&series=foobar'
253+ >>> response = webservice.get(url)
254+ >>> print response
255+ HTTP/1.1 404 Not Found
256+ ...
257+
258+The user 'name12' has no upload permission for 'thunderbird' in 'hoary'..
259+
260+ >>> url = '/ubuntu/+archive/primary/+upload/name12?type=packageset&item=thunderbird&series=hoary'
261+ >>> response = webservice.get(url)
262+ >>> print response
263+ HTTP/1.1 404 Not Found
264+ ...
265+
266+.. but is allowed to upload to 'thunderbird' in 'grumpy'.
267+
268+ >>> url = '/ubuntu/+archive/primary/+upload/name12?type=packageset&item=thunderbird&series=grumpy'
269+ >>> permission = webservice.get(url).jsonBody()
270+ >>> print permission['package_set_name']
271+ thunderbird
272+ >>> print permission['distro_series_name']
273+ grumpy
274+
275+The user 'cprov' has no upload permission for 'thunderbird' in 'hoary'.
276+
277+ >>> url = '/ubuntu/+archive/primary/+upload/cprov?type=packageset&item=thunderbird&series=hoary'
278+ >>> permission = webservice.get(url).jsonBody()
279+ >>> pprint_entry(permission)
280+ archive_link: u'http://api.launchpad.dev/beta/ubuntu/+archive/primary'
281+ ...
282+ distro_series_name: u'hoary'
283+ ...
284+ package_set_name: u'thunderbird'
285+ permission: u'Archive Upload Rights'
286+ person_link: u'http://api.launchpad.dev/beta/~cprov'
287+ ...

Subscribers

People subscribed via source and target branches

to status/vote changes: