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
=== modified file 'lib/lp/soyuz/browser/archive.py'
--- lib/lp/soyuz/browser/archive.py 2009-11-03 00:37:42 +0000
+++ lib/lp/soyuz/browser/archive.py 2009-11-03 19:10:27 +0000
@@ -286,14 +286,28 @@
286 # See if "item" is a source package name.286 # See if "item" is a source package name.
287 the_item = getUtility(ISourcePackageNameSet).queryByName(item)287 the_item = getUtility(ISourcePackageNameSet).queryByName(item)
288 elif item_type == 'packageset':288 elif item_type == 'packageset':
289 # See if "item" is a package set.289 the_item = None
290 the_item = getUtility(IPackagesetSet).getByName(item)290 # Was a 'series' URL param passed?
291 series = get_url_param('series')
292 if series is not None:
293 # Get the requested distro series.
294 try:
295 series = self.context.distribution[series]
296 except NotFoundError:
297 series = None
298 if series is not None:
299 the_item = getUtility(IPackagesetSet).getByName(
300 item, distroseries=series)
291 else:301 else:
292 the_item = None302 the_item = None
293303
294 if the_item is not None:304 if the_item is not None:
295 return getUtility(IArchivePermissionSet).checkAuthenticated(305 result_set = getUtility(IArchivePermissionSet).checkAuthenticated(
296 user, self.context, permission_type, the_item)[0]306 user, self.context, permission_type, the_item)
307 if result_set.count() > 0:
308 return result_set[0]
309 else:
310 return None
297 else:311 else:
298 return None312 return None
299313
300314
=== modified file 'lib/lp/soyuz/browser/archivepermission.py'
--- lib/lp/soyuz/browser/archivepermission.py 2009-07-17 00:26:05 +0000
+++ lib/lp/soyuz/browser/archivepermission.py 2009-11-03 19:10:27 +0000
@@ -45,7 +45,9 @@
45 item = (45 item = (
46 "type=packagename&item=%s" % self.context.source_package_name)46 "type=packagename&item=%s" % self.context.source_package_name)
47 elif self.context.package_set_name is not None:47 elif self.context.package_set_name is not None:
48 item = "type=packageset&item=%s" % self.context.package_set_name48 item = ("type=packageset&item=%s&series=%s" %
49 (self.context.package_set_name,
50 self.context.distro_series_name))
49 else:51 else:
50 raise AssertionError, (52 raise AssertionError, (
51 "One of component, sourcepackagename or package set should "53 "One of component, sourcepackagename or package set should "
5254
=== modified file 'lib/lp/soyuz/interfaces/archivepermission.py'
--- lib/lp/soyuz/interfaces/archivepermission.py 2009-11-02 08:07:41 +0000
+++ lib/lp/soyuz/interfaces/archivepermission.py 2009-11-03 19:10:27 +0000
@@ -123,6 +123,13 @@
123 title=_("Package set name"),123 title=_("Package set name"),
124 required=True))124 required=True))
125125
126 distro_series_name = exported(
127 TextLine(
128 title=_(
129 "The name of the distro series associated with the "
130 "package set."),
131 required=True))
132
126133
127class IArchiveUploader(IArchivePermission):134class IArchiveUploader(IArchivePermission):
128 """Marker interface for URL traversal of uploader permissions."""135 """Marker interface for URL traversal of uploader permissions."""
129136
=== modified file 'lib/lp/soyuz/model/archivepermission.py'
--- lib/lp/soyuz/model/archivepermission.py 2009-11-02 08:07:41 +0000
+++ lib/lp/soyuz/model/archivepermission.py 2009-11-03 19:10:27 +0000
@@ -112,6 +112,14 @@
112 else:112 else:
113 return None113 return None
114114
115 @property
116 def distro_series_name(self):
117 """See `IArchivePermission`"""
118 if self.packageset:
119 return self.packageset.distroseries.name
120 else:
121 return None
122
115123
116class ArchivePermissionSet:124class ArchivePermissionSet:
117 """See `IArchivePermissionSet`."""125 """See `IArchivePermissionSet`."""
118126
=== modified file 'lib/lp/soyuz/stories/webservice/xx-packageset.txt'
--- lib/lp/soyuz/stories/webservice/xx-packageset.txt 2009-11-03 14:43:22 +0000
+++ lib/lp/soyuz/stories/webservice/xx-packageset.txt 2009-11-03 19:10:27 +0000
@@ -559,7 +559,7 @@
559 permission: u'Archive Upload Rights'559 permission: u'Archive Upload Rights'
560 person_link: u'http://.../~name12'560 person_link: u'http://.../~name12'
561 resource_type_link: ...561 resource_type_link: ...
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'
563 source_package_name: None563 source_package_name: None
564564
565Grant upload privileges to 'name12' for package set 'mozilla' in the Ubuntu565Grant upload privileges to 'name12' for package set 'mozilla' in the Ubuntu
@@ -580,7 +580,7 @@
580 ... ubuntu['main_archive_link'], 'getUploadersForPackageset', {},580 ... ubuntu['main_archive_link'], 'getUploadersForPackageset', {},
581 ... packageset=firefox['self_link'])581 ... packageset=firefox['self_link'])
582 >>> print_payload(response)582 >>> print_payload(response)
583 http://.../+archive/primary/+upload/name12?type=packageset&item=firefox583 http://.../+archive/primary/+upload/name12?type=packageset&item=firefox&series=hoary
584584
585Same query, this time allowing the use of the package set hierarchy, finds585Same query, this time allowing the use of the package set hierarchy, finds
586the permission for the 'mozilla' package set as well.586the permission for the 'mozilla' package set as well.
@@ -589,8 +589,8 @@
589 ... ubuntu['main_archive_link'], 'getUploadersForPackageset', {},589 ... ubuntu['main_archive_link'], 'getUploadersForPackageset', {},
590 ... packageset=firefox['self_link'], direct_permissions=False)590 ... packageset=firefox['self_link'], direct_permissions=False)
591 >>> print_payload(response)591 >>> print_payload(response)
592 http://.../+archive/primary/+upload/name12?type=packageset&item=firefox592 http://.../+archive/primary/+upload/name12?type=packageset&item=firefox&series=hoary
593 http://.../+archive/primary/+upload/name12?type=packageset&item=mozilla593 http://.../+archive/primary/+upload/name12?type=packageset&item=mozilla&series=hoary
594594
595Let's delete the upload privilege for the 'mozilla' package set.595Let's delete the upload privilege for the 'mozilla' package set.
596596
@@ -609,7 +609,7 @@
609 ... ubuntu['main_archive_link'], 'getUploadersForPackageset', {},609 ... ubuntu['main_archive_link'], 'getUploadersForPackageset', {},
610 ... packageset=firefox['self_link'], direct_permissions=False)610 ... packageset=firefox['self_link'], direct_permissions=False)
611 >>> print_payload(response)611 >>> print_payload(response)
612 http://.../+archive/primary/+upload/name12?type=packageset&item=firefox612 http://.../+archive/primary/+upload/name12?type=packageset&item=firefox&series=hoary
613613
614Let's grant 'cprov' an upload permission to 'mozilla' and 'thunderbird'.614Let's grant 'cprov' an upload permission to 'mozilla' and 'thunderbird'.
615615
@@ -636,8 +636,8 @@
636 ... ubuntu['main_archive_link'], 'getPackagesetsForUploader', {},636 ... ubuntu['main_archive_link'], 'getPackagesetsForUploader', {},
637 ... person=cprov['self_link'])637 ... person=cprov['self_link'])
638 >>> print_payload(response)638 >>> print_payload(response)
639 http://.../+archive/primary/+upload/cprov?type=packageset&item=mozilla639 http://.../+archive/primary/+upload/cprov?type=packageset&item=mozilla&series=hoary
640 http://.../+archive/primary/+upload/cprov?type=packageset&item=thunderbird640 http://.../+archive/primary/+upload/cprov?type=packageset&item=thunderbird&series=hoary
641641
642Let's check what package set based upload permissions 'cprov' has for the642Let's check what package set based upload permissions 'cprov' has for the
643'mozilla-firefox' package.643'mozilla-firefox' package.
@@ -647,8 +647,8 @@
647 ... {}, sourcepackagename='thunderbird',647 ... {}, sourcepackagename='thunderbird',
648 ... person=cprov['self_link'])648 ... person=cprov['self_link'])
649 >>> print_payload(response)649 >>> print_payload(response)
650 http://.../+archive/primary/+upload/cprov?type=packageset&item=mozilla650 http://.../+archive/primary/+upload/cprov?type=packageset&item=mozilla&series=hoary
651 http://.../+archive/primary/+upload/cprov?type=packageset&item=thunderbird651 http://.../+archive/primary/+upload/cprov?type=packageset&item=thunderbird&series=hoary
652652
653As we expected 'cprov' may upload either via the 'thunderbird' package set653As we expected 'cprov' may upload either via the 'thunderbird' package set
654that directly contains the source package in question or via the 'mozilla'654that directly contains the source package in question or via the 'mozilla'
@@ -662,7 +662,7 @@
662 ... {}, sourcepackagename='mozilla-firefox',662 ... {}, sourcepackagename='mozilla-firefox',
663 ... person=cprov['self_link'])663 ... person=cprov['self_link'])
664 >>> print_payload(response)664 >>> print_payload(response)
665 http://.../+archive/primary/+upload/cprov?type=packageset&item=mozilla665 http://.../+archive/primary/+upload/cprov?type=packageset&item=mozilla&series=hoary
666666
667Yes, and, again via the 'mozilla' package set.667Yes, and, again via the 'mozilla' package set.
668668
@@ -736,11 +736,11 @@
736 ...736 ...
737 false737 false
738738
739Create a new package set ('grouchy-thunderbird') in 'grumpy'.739Create a new package set ('thunderbird') in 'grumpy'.
740740
741 >>> response = webservice.named_post(741 >>> response = webservice.named_post(
742 ... '/package-sets', 'new', {},742 ... '/package-sets', 'new', {},
743 ... name=u'grouchy-thunderbird',743 ... name=u'thunderbird',
744 ... description=u'Contains all thunderbird packages in grumpy',744 ... description=u'Contains all thunderbird packages in grumpy',
745 ... owner=name12['self_link'], distroseries=grumpy['self_link'],745 ... owner=name12['self_link'], distroseries=grumpy['self_link'],
746 ... related_set=thunderbird['self_link'])746 ... related_set=thunderbird['self_link'])
@@ -751,21 +751,21 @@
751 >>> response = webservice.named_get(751 >>> response = webservice.named_get(
752 ... thunderbird['self_link'], 'relatedSets', {})752 ... thunderbird['self_link'], 'relatedSets', {})
753 >>> print_payload(response)753 >>> print_payload(response)
754 http://api.launchpad.dev/beta/package-sets/grumpy/grouchy-thunderbird754 http://api.launchpad.dev/beta/package-sets/grumpy/thunderbird
755755
756Associate 'grouchy-thunderbird' with the appropriate source packages.756Associate 'thunderbird' with the appropriate source packages.
757757
758 >>> response = webservice.named_post(758 >>> response = webservice.named_post(
759 ... '/package-sets/grumpy/grouchy-thunderbird', 'addSources', {},759 ... '/package-sets/grumpy/thunderbird', 'addSources', {},
760 ... names=['thunderbird', 'language-pack-de'])760 ... names=['thunderbird', 'language-pack-de'])
761 >>> print response761 >>> print response
762 HTTP/1.1 200 Ok762 HTTP/1.1 200 Ok
763 ...763 ...
764764
765Grant 'name12' upload permissions to 'grouchy-thunderbird' in 'grumpy'.765Grant 'name12' upload permissions to 'thunderbird' in 'grumpy'.
766766
767 >>> grouchy_bird = webservice.get(767 >>> grouchy_bird = webservice.get(
768 ... "/package-sets/grumpy/grouchy-thunderbird").jsonBody()768 ... "/package-sets/grumpy/thunderbird").jsonBody()
769769
770 >>> response = webservice.named_post(770 >>> response = webservice.named_post(
771 ... ubuntu['main_archive_link'], 'newPackagesetUploader', {},771 ... ubuntu['main_archive_link'], 'newPackagesetUploader', {},
@@ -781,8 +781,8 @@
781 ... ubuntu['main_archive_link'], 'getPackagesetsForUploader', {},781 ... ubuntu['main_archive_link'], 'getPackagesetsForUploader', {},
782 ... person=name12['self_link'])782 ... person=name12['self_link'])
783 >>> print_payload(response)783 >>> print_payload(response)
784 http://...+archive/primary/+upload/name12?type=packageset&item=firefox784 http://...+archive/primary/+upload/name12?type=packageset&item=firefox&series=hoary
785 http://...+archive/primary/+upload/name12?type=packageset&item=grouchy-thunderbird785 http://...+archive/primary/+upload/name12?type=packageset&item=thunderbird&series=grumpy
786786
787And now 'name12' should be authorized to upload source package787And now 'name12' should be authorized to upload source package
788'thunderbird' in 'grumpy'.788'thunderbird' in 'grumpy'.
@@ -803,7 +803,7 @@
803 ... ubuntu['main_archive_link'], 'getPackagesetsForSource',803 ... ubuntu['main_archive_link'], 'getPackagesetsForSource',
804 ... {}, sourcepackagename='mozilla-firefox')804 ... {}, sourcepackagename='mozilla-firefox')
805 >>> print_payload(response)805 >>> print_payload(response)
806 http://.../+archive/primary/+upload/name12?type=packageset&item=firefox806 http://.../+archive/primary/+upload/name12?type=packageset&item=firefox&series=hoary
807807
808The listing above only shows the *direct* upload permission granted to808The listing above only shows the *direct* upload permission granted to
809'name12' via the 'firefox' package set.809'name12' via the 'firefox' package set.
@@ -815,8 +815,62 @@
815 ... ubuntu['main_archive_link'], 'getPackagesetsForSource',815 ... ubuntu['main_archive_link'], 'getPackagesetsForSource',
816 ... {}, sourcepackagename='mozilla-firefox', direct_permissions=False)816 ... {}, sourcepackagename='mozilla-firefox', direct_permissions=False)
817 >>> print_payload(response)817 >>> print_payload(response)
818 http://.../+archive/primary/+upload/name12?type=packageset&item=firefox818 http://.../+archive/primary/+upload/name12?type=packageset&item=firefox&series=hoary
819 http://.../+archive/primary/+upload/cprov?type=packageset&item=mozilla819 http://.../+archive/primary/+upload/cprov?type=packageset&item=mozilla&series=hoary
820820
821Now we see the upload permission granted to 'cprov' via the 'mozilla' package821Now we see the upload permission granted to 'cprov' via the 'mozilla' package
822set listed as well.822set listed as well.
823
824
825== Archive permission URLs ==
826
827Archive permissions can be accessed via their URLs in direct fashion.
828
829If we do *not* specify the distro series for package set based archive
830permission URLs a 404 will result.
831
832 >>> url = '/ubuntu/+archive/primary/+upload/name12?type=packageset&item=thunderbird'
833 >>> response = webservice.get(url)
834 >>> print response
835 HTTP/1.1 404 Not Found
836 ...
837
838The same happens if a user tries to doctor an URL with an invalid distro
839series.
840
841 >>> url = '/ubuntu/+archive/primary/+upload/name12?type=packageset&item=thunderbird&series=foobar'
842 >>> response = webservice.get(url)
843 >>> print response
844 HTTP/1.1 404 Not Found
845 ...
846
847The user 'name12' has no upload permission for 'thunderbird' in 'hoary'..
848
849 >>> url = '/ubuntu/+archive/primary/+upload/name12?type=packageset&item=thunderbird&series=hoary'
850 >>> response = webservice.get(url)
851 >>> print response
852 HTTP/1.1 404 Not Found
853 ...
854
855.. but is allowed to upload to 'thunderbird' in 'grumpy'.
856
857 >>> url = '/ubuntu/+archive/primary/+upload/name12?type=packageset&item=thunderbird&series=grumpy'
858 >>> permission = webservice.get(url).jsonBody()
859 >>> print permission['package_set_name']
860 thunderbird
861 >>> print permission['distro_series_name']
862 grumpy
863
864The user 'cprov' has no upload permission for 'thunderbird' in 'hoary'.
865
866 >>> url = '/ubuntu/+archive/primary/+upload/cprov?type=packageset&item=thunderbird&series=hoary'
867 >>> permission = webservice.get(url).jsonBody()
868 >>> pprint_entry(permission)
869 archive_link: u'http://api.launchpad.dev/beta/ubuntu/+archive/primary'
870 ...
871 distro_series_name: u'hoary'
872 ...
873 package_set_name: u'thunderbird'
874 permission: u'Archive Upload Rights'
875 person_link: u'http://api.launchpad.dev/beta/~cprov'
876 ...

Subscribers

People subscribed via source and target branches

to status/vote changes: