Merge lp:~al-maisan/launchpad/uploadurl-472929 into lp:launchpad/db-devel
- uploadurl-472929
- Merge into 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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Francis J. Lacoste (community) | release-critical | Approve | |
Brad Crittenden (community) | code | Approve | |
Review via email:
|
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Muharem Hrnjadovic (al-maisan) wrote : | # |
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Brad Crittenden (bac) wrote : | # |
Looks good Muharem. Good luck getting the r-c for it.
review:
Approve
(code)
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
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 | 286 | # See if "item" is a source package name. | 286 | # See if "item" is a source package name. |
6 | 287 | the_item = getUtility(ISourcePackageNameSet).queryByName(item) | 287 | the_item = getUtility(ISourcePackageNameSet).queryByName(item) |
7 | 288 | elif item_type == 'packageset': | 288 | elif item_type == 'packageset': |
10 | 289 | # See if "item" is a package set. | 289 | the_item = None |
11 | 290 | the_item = getUtility(IPackagesetSet).getByName(item) | 290 | # Was a 'series' URL param passed? |
12 | 291 | series = get_url_param('series') | ||
13 | 292 | if series is not None: | ||
14 | 293 | # Get the requested distro series. | ||
15 | 294 | try: | ||
16 | 295 | series = self.context.distribution[series] | ||
17 | 296 | except NotFoundError: | ||
18 | 297 | series = None | ||
19 | 298 | if series is not None: | ||
20 | 299 | the_item = getUtility(IPackagesetSet).getByName( | ||
21 | 300 | item, distroseries=series) | ||
22 | 291 | else: | 301 | else: |
23 | 292 | the_item = None | 302 | the_item = None |
24 | 293 | 303 | ||
25 | 294 | if the_item is not None: | 304 | if the_item is not None: |
28 | 295 | return getUtility(IArchivePermissionSet).checkAuthenticated( | 305 | result_set = getUtility(IArchivePermissionSet).checkAuthenticated( |
29 | 296 | user, self.context, permission_type, the_item)[0] | 306 | user, self.context, permission_type, the_item) |
30 | 307 | if result_set.count() > 0: | ||
31 | 308 | return result_set[0] | ||
32 | 309 | else: | ||
33 | 310 | return None | ||
34 | 297 | else: | 311 | else: |
35 | 298 | return None | 312 | return None |
36 | 299 | 313 | ||
37 | 300 | 314 | ||
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 | 45 | item = ( | 45 | item = ( |
43 | 46 | "type=packagename&item=%s" % self.context.source_package_name) | 46 | "type=packagename&item=%s" % self.context.source_package_name) |
44 | 47 | elif self.context.package_set_name is not None: | 47 | elif self.context.package_set_name is not None: |
46 | 48 | item = "type=packageset&item=%s" % self.context.package_set_name | 48 | item = ("type=packageset&item=%s&series=%s" % |
47 | 49 | (self.context.package_set_name, | ||
48 | 50 | self.context.distro_series_name)) | ||
49 | 49 | else: | 51 | else: |
50 | 50 | raise AssertionError, ( | 52 | raise AssertionError, ( |
51 | 51 | "One of component, sourcepackagename or package set should " | 53 | "One of component, sourcepackagename or package set should " |
52 | 52 | 54 | ||
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 | 123 | title=_("Package set name"), | 123 | title=_("Package set name"), |
58 | 124 | required=True)) | 124 | required=True)) |
59 | 125 | 125 | ||
60 | 126 | distro_series_name = exported( | ||
61 | 127 | TextLine( | ||
62 | 128 | title=_( | ||
63 | 129 | "The name of the distro series associated with the " | ||
64 | 130 | "package set."), | ||
65 | 131 | required=True)) | ||
66 | 132 | |||
67 | 126 | 133 | ||
68 | 127 | class IArchiveUploader(IArchivePermission): | 134 | class IArchiveUploader(IArchivePermission): |
69 | 128 | """Marker interface for URL traversal of uploader permissions.""" | 135 | """Marker interface for URL traversal of uploader permissions.""" |
70 | 129 | 136 | ||
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 | 112 | else: | 112 | else: |
76 | 113 | return None | 113 | return None |
77 | 114 | 114 | ||
78 | 115 | @property | ||
79 | 116 | def distro_series_name(self): | ||
80 | 117 | """See `IArchivePermission`""" | ||
81 | 118 | if self.packageset: | ||
82 | 119 | return self.packageset.distroseries.name | ||
83 | 120 | else: | ||
84 | 121 | return None | ||
85 | 122 | |||
86 | 115 | 123 | ||
87 | 116 | class ArchivePermissionSet: | 124 | class ArchivePermissionSet: |
88 | 117 | """See `IArchivePermissionSet`.""" | 125 | """See `IArchivePermissionSet`.""" |
89 | 118 | 126 | ||
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 | 559 | permission: u'Archive Upload Rights' | 559 | permission: u'Archive Upload Rights' |
95 | 560 | person_link: u'http://.../~name12' | 560 | person_link: u'http://.../~name12' |
96 | 561 | resource_type_link: ... | 561 | resource_type_link: ... |
98 | 562 | self_link: u'http://.../+archive/primary/+upload/name12?type=packageset&item=firefox' | 562 | self_link: u'http://.../+archive/primary/+upload/name12?type=packageset&item=firefox&series=hoary' |
99 | 563 | source_package_name: None | 563 | source_package_name: None |
100 | 564 | 564 | ||
101 | 565 | Grant upload privileges to 'name12' for package set 'mozilla' in the Ubuntu | 565 | Grant upload privileges to 'name12' for package set 'mozilla' in the Ubuntu |
102 | @@ -580,7 +580,7 @@ | |||
103 | 580 | ... ubuntu['main_archive_link'], 'getUploadersForPackageset', {}, | 580 | ... ubuntu['main_archive_link'], 'getUploadersForPackageset', {}, |
104 | 581 | ... packageset=firefox['self_link']) | 581 | ... packageset=firefox['self_link']) |
105 | 582 | >>> print_payload(response) | 582 | >>> print_payload(response) |
107 | 583 | http://.../+archive/primary/+upload/name12?type=packageset&item=firefox | 583 | http://.../+archive/primary/+upload/name12?type=packageset&item=firefox&series=hoary |
108 | 584 | 584 | ||
109 | 585 | Same query, this time allowing the use of the package set hierarchy, finds | 585 | Same query, this time allowing the use of the package set hierarchy, finds |
110 | 586 | the permission for the 'mozilla' package set as well. | 586 | the permission for the 'mozilla' package set as well. |
111 | @@ -589,8 +589,8 @@ | |||
112 | 589 | ... ubuntu['main_archive_link'], 'getUploadersForPackageset', {}, | 589 | ... ubuntu['main_archive_link'], 'getUploadersForPackageset', {}, |
113 | 590 | ... packageset=firefox['self_link'], direct_permissions=False) | 590 | ... packageset=firefox['self_link'], direct_permissions=False) |
114 | 591 | >>> print_payload(response) | 591 | >>> print_payload(response) |
117 | 592 | http://.../+archive/primary/+upload/name12?type=packageset&item=firefox | 592 | http://.../+archive/primary/+upload/name12?type=packageset&item=firefox&series=hoary |
118 | 593 | http://.../+archive/primary/+upload/name12?type=packageset&item=mozilla | 593 | http://.../+archive/primary/+upload/name12?type=packageset&item=mozilla&series=hoary |
119 | 594 | 594 | ||
120 | 595 | Let's delete the upload privilege for the 'mozilla' package set. | 595 | Let's delete the upload privilege for the 'mozilla' package set. |
121 | 596 | 596 | ||
122 | @@ -609,7 +609,7 @@ | |||
123 | 609 | ... ubuntu['main_archive_link'], 'getUploadersForPackageset', {}, | 609 | ... ubuntu['main_archive_link'], 'getUploadersForPackageset', {}, |
124 | 610 | ... packageset=firefox['self_link'], direct_permissions=False) | 610 | ... packageset=firefox['self_link'], direct_permissions=False) |
125 | 611 | >>> print_payload(response) | 611 | >>> print_payload(response) |
127 | 612 | http://.../+archive/primary/+upload/name12?type=packageset&item=firefox | 612 | http://.../+archive/primary/+upload/name12?type=packageset&item=firefox&series=hoary |
128 | 613 | 613 | ||
129 | 614 | Let's grant 'cprov' an upload permission to 'mozilla' and 'thunderbird'. | 614 | Let's grant 'cprov' an upload permission to 'mozilla' and 'thunderbird'. |
130 | 615 | 615 | ||
131 | @@ -636,8 +636,8 @@ | |||
132 | 636 | ... ubuntu['main_archive_link'], 'getPackagesetsForUploader', {}, | 636 | ... ubuntu['main_archive_link'], 'getPackagesetsForUploader', {}, |
133 | 637 | ... person=cprov['self_link']) | 637 | ... person=cprov['self_link']) |
134 | 638 | >>> print_payload(response) | 638 | >>> print_payload(response) |
137 | 639 | http://.../+archive/primary/+upload/cprov?type=packageset&item=mozilla | 639 | http://.../+archive/primary/+upload/cprov?type=packageset&item=mozilla&series=hoary |
138 | 640 | http://.../+archive/primary/+upload/cprov?type=packageset&item=thunderbird | 640 | http://.../+archive/primary/+upload/cprov?type=packageset&item=thunderbird&series=hoary |
139 | 641 | 641 | ||
140 | 642 | Let's check what package set based upload permissions 'cprov' has for the | 642 | Let's check what package set based upload permissions 'cprov' has for the |
141 | 643 | 'mozilla-firefox' package. | 643 | 'mozilla-firefox' package. |
142 | @@ -647,8 +647,8 @@ | |||
143 | 647 | ... {}, sourcepackagename='thunderbird', | 647 | ... {}, sourcepackagename='thunderbird', |
144 | 648 | ... person=cprov['self_link']) | 648 | ... person=cprov['self_link']) |
145 | 649 | >>> print_payload(response) | 649 | >>> print_payload(response) |
148 | 650 | http://.../+archive/primary/+upload/cprov?type=packageset&item=mozilla | 650 | http://.../+archive/primary/+upload/cprov?type=packageset&item=mozilla&series=hoary |
149 | 651 | http://.../+archive/primary/+upload/cprov?type=packageset&item=thunderbird | 651 | http://.../+archive/primary/+upload/cprov?type=packageset&item=thunderbird&series=hoary |
150 | 652 | 652 | ||
151 | 653 | As we expected 'cprov' may upload either via the 'thunderbird' package set | 653 | As we expected 'cprov' may upload either via the 'thunderbird' package set |
152 | 654 | that directly contains the source package in question or via the 'mozilla' | 654 | that directly contains the source package in question or via the 'mozilla' |
153 | @@ -662,7 +662,7 @@ | |||
154 | 662 | ... {}, sourcepackagename='mozilla-firefox', | 662 | ... {}, sourcepackagename='mozilla-firefox', |
155 | 663 | ... person=cprov['self_link']) | 663 | ... person=cprov['self_link']) |
156 | 664 | >>> print_payload(response) | 664 | >>> print_payload(response) |
158 | 665 | http://.../+archive/primary/+upload/cprov?type=packageset&item=mozilla | 665 | http://.../+archive/primary/+upload/cprov?type=packageset&item=mozilla&series=hoary |
159 | 666 | 666 | ||
160 | 667 | Yes, and, again via the 'mozilla' package set. | 667 | Yes, and, again via the 'mozilla' package set. |
161 | 668 | 668 | ||
162 | @@ -736,11 +736,11 @@ | |||
163 | 736 | ... | 736 | ... |
164 | 737 | false | 737 | false |
165 | 738 | 738 | ||
167 | 739 | Create a new package set ('grouchy-thunderbird') in 'grumpy'. | 739 | Create a new package set ('thunderbird') in 'grumpy'. |
168 | 740 | 740 | ||
169 | 741 | >>> response = webservice.named_post( | 741 | >>> response = webservice.named_post( |
170 | 742 | ... '/package-sets', 'new', {}, | 742 | ... '/package-sets', 'new', {}, |
172 | 743 | ... name=u'grouchy-thunderbird', | 743 | ... name=u'thunderbird', |
173 | 744 | ... description=u'Contains all thunderbird packages in grumpy', | 744 | ... description=u'Contains all thunderbird packages in grumpy', |
174 | 745 | ... owner=name12['self_link'], distroseries=grumpy['self_link'], | 745 | ... owner=name12['self_link'], distroseries=grumpy['self_link'], |
175 | 746 | ... related_set=thunderbird['self_link']) | 746 | ... related_set=thunderbird['self_link']) |
176 | @@ -751,21 +751,21 @@ | |||
177 | 751 | >>> response = webservice.named_get( | 751 | >>> response = webservice.named_get( |
178 | 752 | ... thunderbird['self_link'], 'relatedSets', {}) | 752 | ... thunderbird['self_link'], 'relatedSets', {}) |
179 | 753 | >>> print_payload(response) | 753 | >>> print_payload(response) |
181 | 754 | http://api.launchpad.dev/beta/package-sets/grumpy/grouchy-thunderbird | 754 | http://api.launchpad.dev/beta/package-sets/grumpy/thunderbird |
182 | 755 | 755 | ||
184 | 756 | Associate 'grouchy-thunderbird' with the appropriate source packages. | 756 | Associate 'thunderbird' with the appropriate source packages. |
185 | 757 | 757 | ||
186 | 758 | >>> response = webservice.named_post( | 758 | >>> response = webservice.named_post( |
188 | 759 | ... '/package-sets/grumpy/grouchy-thunderbird', 'addSources', {}, | 759 | ... '/package-sets/grumpy/thunderbird', 'addSources', {}, |
189 | 760 | ... names=['thunderbird', 'language-pack-de']) | 760 | ... names=['thunderbird', 'language-pack-de']) |
190 | 761 | >>> print response | 761 | >>> print response |
191 | 762 | HTTP/1.1 200 Ok | 762 | HTTP/1.1 200 Ok |
192 | 763 | ... | 763 | ... |
193 | 764 | 764 | ||
195 | 765 | Grant 'name12' upload permissions to 'grouchy-thunderbird' in 'grumpy'. | 765 | Grant 'name12' upload permissions to 'thunderbird' in 'grumpy'. |
196 | 766 | 766 | ||
197 | 767 | >>> grouchy_bird = webservice.get( | 767 | >>> grouchy_bird = webservice.get( |
199 | 768 | ... "/package-sets/grumpy/grouchy-thunderbird").jsonBody() | 768 | ... "/package-sets/grumpy/thunderbird").jsonBody() |
200 | 769 | 769 | ||
201 | 770 | >>> response = webservice.named_post( | 770 | >>> response = webservice.named_post( |
202 | 771 | ... ubuntu['main_archive_link'], 'newPackagesetUploader', {}, | 771 | ... ubuntu['main_archive_link'], 'newPackagesetUploader', {}, |
203 | @@ -781,8 +781,8 @@ | |||
204 | 781 | ... ubuntu['main_archive_link'], 'getPackagesetsForUploader', {}, | 781 | ... ubuntu['main_archive_link'], 'getPackagesetsForUploader', {}, |
205 | 782 | ... person=name12['self_link']) | 782 | ... person=name12['self_link']) |
206 | 783 | >>> print_payload(response) | 783 | >>> print_payload(response) |
209 | 784 | http://...+archive/primary/+upload/name12?type=packageset&item=firefox | 784 | http://...+archive/primary/+upload/name12?type=packageset&item=firefox&series=hoary |
210 | 785 | http://...+archive/primary/+upload/name12?type=packageset&item=grouchy-thunderbird | 785 | http://...+archive/primary/+upload/name12?type=packageset&item=thunderbird&series=grumpy |
211 | 786 | 786 | ||
212 | 787 | And now 'name12' should be authorized to upload source package | 787 | And now 'name12' should be authorized to upload source package |
213 | 788 | 'thunderbird' in 'grumpy'. | 788 | 'thunderbird' in 'grumpy'. |
214 | @@ -803,7 +803,7 @@ | |||
215 | 803 | ... ubuntu['main_archive_link'], 'getPackagesetsForSource', | 803 | ... ubuntu['main_archive_link'], 'getPackagesetsForSource', |
216 | 804 | ... {}, sourcepackagename='mozilla-firefox') | 804 | ... {}, sourcepackagename='mozilla-firefox') |
217 | 805 | >>> print_payload(response) | 805 | >>> print_payload(response) |
219 | 806 | http://.../+archive/primary/+upload/name12?type=packageset&item=firefox | 806 | http://.../+archive/primary/+upload/name12?type=packageset&item=firefox&series=hoary |
220 | 807 | 807 | ||
221 | 808 | The listing above only shows the *direct* upload permission granted to | 808 | The listing above only shows the *direct* upload permission granted to |
222 | 809 | 'name12' via the 'firefox' package set. | 809 | 'name12' via the 'firefox' package set. |
223 | @@ -815,8 +815,62 @@ | |||
224 | 815 | ... ubuntu['main_archive_link'], 'getPackagesetsForSource', | 815 | ... ubuntu['main_archive_link'], 'getPackagesetsForSource', |
225 | 816 | ... {}, sourcepackagename='mozilla-firefox', direct_permissions=False) | 816 | ... {}, sourcepackagename='mozilla-firefox', direct_permissions=False) |
226 | 817 | >>> print_payload(response) | 817 | >>> print_payload(response) |
229 | 818 | http://.../+archive/primary/+upload/name12?type=packageset&item=firefox | 818 | http://.../+archive/primary/+upload/name12?type=packageset&item=firefox&series=hoary |
230 | 819 | http://.../+archive/primary/+upload/cprov?type=packageset&item=mozilla | 819 | http://.../+archive/primary/+upload/cprov?type=packageset&item=mozilla&series=hoary |
231 | 820 | 820 | ||
232 | 821 | Now we see the upload permission granted to 'cprov' via the 'mozilla' package | 821 | Now we see the upload permission granted to 'cprov' via the 'mozilla' package |
233 | 822 | set listed as well. | 822 | set listed as well. |
234 | 823 | |||
235 | 824 | |||
236 | 825 | == Archive permission URLs == | ||
237 | 826 | |||
238 | 827 | Archive permissions can be accessed via their URLs in direct fashion. | ||
239 | 828 | |||
240 | 829 | If we do *not* specify the distro series for package set based archive | ||
241 | 830 | permission URLs a 404 will result. | ||
242 | 831 | |||
243 | 832 | >>> url = '/ubuntu/+archive/primary/+upload/name12?type=packageset&item=thunderbird' | ||
244 | 833 | >>> response = webservice.get(url) | ||
245 | 834 | >>> print response | ||
246 | 835 | HTTP/1.1 404 Not Found | ||
247 | 836 | ... | ||
248 | 837 | |||
249 | 838 | The same happens if a user tries to doctor an URL with an invalid distro | ||
250 | 839 | series. | ||
251 | 840 | |||
252 | 841 | >>> url = '/ubuntu/+archive/primary/+upload/name12?type=packageset&item=thunderbird&series=foobar' | ||
253 | 842 | >>> response = webservice.get(url) | ||
254 | 843 | >>> print response | ||
255 | 844 | HTTP/1.1 404 Not Found | ||
256 | 845 | ... | ||
257 | 846 | |||
258 | 847 | The user 'name12' has no upload permission for 'thunderbird' in 'hoary'.. | ||
259 | 848 | |||
260 | 849 | >>> url = '/ubuntu/+archive/primary/+upload/name12?type=packageset&item=thunderbird&series=hoary' | ||
261 | 850 | >>> response = webservice.get(url) | ||
262 | 851 | >>> print response | ||
263 | 852 | HTTP/1.1 404 Not Found | ||
264 | 853 | ... | ||
265 | 854 | |||
266 | 855 | .. but is allowed to upload to 'thunderbird' in 'grumpy'. | ||
267 | 856 | |||
268 | 857 | >>> url = '/ubuntu/+archive/primary/+upload/name12?type=packageset&item=thunderbird&series=grumpy' | ||
269 | 858 | >>> permission = webservice.get(url).jsonBody() | ||
270 | 859 | >>> print permission['package_set_name'] | ||
271 | 860 | thunderbird | ||
272 | 861 | >>> print permission['distro_series_name'] | ||
273 | 862 | grumpy | ||
274 | 863 | |||
275 | 864 | The user 'cprov' has no upload permission for 'thunderbird' in 'hoary'. | ||
276 | 865 | |||
277 | 866 | >>> url = '/ubuntu/+archive/primary/+upload/cprov?type=packageset&item=thunderbird&series=hoary' | ||
278 | 867 | >>> permission = webservice.get(url).jsonBody() | ||
279 | 868 | >>> pprint_entry(permission) | ||
280 | 869 | archive_link: u'http://api.launchpad.dev/beta/ubuntu/+archive/primary' | ||
281 | 870 | ... | ||
282 | 871 | distro_series_name: u'hoary' | ||
283 | 872 | ... | ||
284 | 873 | package_set_name: u'thunderbird' | ||
285 | 874 | permission: u'Archive Upload Rights' | ||
286 | 875 | person_link: u'http://api.launchpad.dev/beta/~cprov' | ||
287 | 876 | ... |
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