← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cprov/launchpad/ppa-copies-with-custom into lp:launchpad

 

Celso Providelo has proposed merging lp:~cprov/launchpad/ppa-copies-with-custom into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cprov/launchpad/ppa-copies-with-custom/+merge/211620

Fixing permission problem when copying (syncSource{,s}) packages with custom uploads (debian-installer) to a PPA.

Processing custom uploads copies requires lp.Edit in on the context PackageUpload, and it this was only granted correctly for archives with granular (component-based) permissions (primary, partner, etc). PPAs do not use this extension and permission is granted based simply on ownership.  
-- 
https://code.launchpad.net/~cprov/launchpad/ppa-copies-with-custom/+merge/211620
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cprov/launchpad/ppa-copies-with-custom into lp:launchpad.
=== modified file 'lib/lp/security.py'
--- lib/lp/security.py	2014-03-17 21:50:33 +0000
+++ lib/lp/security.py	2014-03-18 22:10:54 +0000
@@ -1803,6 +1803,10 @@
         if AdminByAdminsTeam.checkAuthenticated(self, user):
             return True
 
+        if (self.obj.archive.is_ppa and
+            self.obj.archive.checkArchivePermission(user.person)):
+            return True
+
         return self.obj.archive.canAdministerQueue(
             user.person, self.obj.components, self.obj.pocket,
             self.obj.distroseries)

=== modified file 'lib/lp/soyuz/stories/webservice/xx-archive.txt'
--- lib/lp/soyuz/stories/webservice/xx-archive.txt	2013-09-16 04:17:25 +0000
+++ lib/lp/soyuz/stories/webservice/xx-archive.txt	2014-03-18 22:10:54 +0000
@@ -1090,6 +1090,57 @@
     HTTP/1.1 401 Unauthorized
     ...
 
+PPAs can contain custom uploads (debian-intaller, dist-upgrader, etc) and
+'syncSource{,s}' methods consider them for synchronization.
+
+    # Create a testing source and binary publication with a
+    # custom debian-installer upload. 
+    >>> login('foo.bar@xxxxxxxxxxxxx')
+    >>> di_source = test_publisher.getPubSource(
+    ...     sourcename="haz-di", version="1.0",
+    ...     archive=ubuntu_db.main_archive)
+    >>> ignore = test_publisher.getPubBinaries(
+    ...     binaryname='haz-di', pub_source=di_source)
+    >>> a_build = di_source.getBuilds()[0]
+    >>> naked_package_upload = removeSecurityProxy(a_build.package_upload)
+    >>> custom_file = test_publisher.addMockFile('fake.di')
+    >>> from lp.soyuz.enums import PackageUploadCustomFormat
+    >>> ignore = naked_package_upload.addCustom(
+    ...     custom_file, PackageUploadCustomFormat.DEBIAN_INSTALLER) 
+    >>> logout()
+
+    >>> print cprov_webservice.named_post(
+    ...     cprov_archive['self_link'], 'syncSources', {},
+    ...     source_names=['haz-di'], to_pocket='release',
+    ...     from_archive=ubuntu['main_archive_link'],
+    ...     to_series="warty", include_binaries=True)
+    HTTP/1.1 200 Ok
+    ...
+
+Source, binary and custom uploads were copied.
+
+    >>> cprov_webservice.named_get(
+    ...     cprov_archive['self_link'], 'getPublishedSources',
+    ...     source_name="haz-di").jsonBody()['total_size']
+    1
+
+    >>> cprov_webservice.named_get(
+    ...     cprov_archive['self_link'], 'getPublishedBinaries',
+    ...     source_name="haz-di").jsonBody()['total_size']
+    6
+
+    # Currently we have to dig deep for finding the reference of a
+    # published (DONE) custom upload for a PPA.
+    >>> login('foo.bar@xxxxxxxxxxxxx')
+    >>> from lp.registry.interfaces.person import IPersonSet
+    >>> ppa = getUtility(IPersonSet).getByName('cprov').archive
+    >>> for bin in ppa.getPublishedOnDiskBinaries(name='haz-di'):
+    ...     upload = bin.binarypackagerelease.build.package_upload
+    ...     print '{.status.name}: {.displayname}'.format(upload, upload)
+    DONE: haz-di, fake.di
+
+    >>> logout()
+
 Non-virtualized archives
 ~~~~~~~~~~~~~~~~~~~~~~~~
 


Follow ups