Merge lp:~jml/launchpad/create-private-ppa-814567-2 into lp:launchpad

Proposed by Jonathan Lange
Status: Merged
Approved by: Henning Eggers
Approved revision: no longer in the source branch.
Merged at revision: 13588
Proposed branch: lp:~jml/launchpad/create-private-ppa-814567-2
Merge into: lp:launchpad
Diff against target: 116 lines (+44/-4)
5 files modified
lib/lp/registry/model/person.py (+1/-1)
lib/lp/soyuz/interfaces/archive.py (+3/-1)
lib/lp/soyuz/model/archive.py (+3/-1)
lib/lp/soyuz/stories/webservice/xx-person-createppa.txt (+36/-0)
lib/lp/soyuz/tests/test_archive.py (+1/-1)
To merge this branch: bzr merge lp:~jml/launchpad/create-private-ppa-814567-2
Reviewer Review Type Date Requested Status
Henning Eggers (community) Approve
Review via email: mp+70028@code.launchpad.net

Commit message

[r=henninge][bug=814567] Allow certain users to create private PPAs over the API. This time for sure.

Description of the change

This branch corrects a key mistake from https://code.launchpad.net/~jml/launchpad/create-private-ppa-814567/+merge/69539: not actually making the PPAs private.

The updated pagetest actually guarantees that the PPA can be created and that it is set to private. Other than that, the changes are minimal: pass 'private' through, and set the attribute as needed. We don't need to worry about zope security blowing up, because validatePPA needs to pass before we can get there, and it does the same check.

To post a comment you must log in.
Revision history for this message
Henning Eggers (henninge) :
review: Approve
Revision history for this message
Steve Kowalik (stevenk) wrote :

I'd *strongly* prefer that private=False is the default for the model code to the match the code in IArchive.

Revision history for this message
Jonathan Lange (jml) wrote :

Oh yeah, me too. Typo.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/model/person.py'
2--- lib/lp/registry/model/person.py 2011-07-29 06:29:13 +0000
3+++ lib/lp/registry/model/person.py 2011-08-02 09:36:46 +0000
4@@ -2749,7 +2749,7 @@
5 return getUtility(IArchiveSet).new(
6 owner=self, purpose=ArchivePurpose.PPA,
7 distribution=ubuntu, name=name, displayname=displayname,
8- description=description)
9+ description=description, private=private)
10
11 def isBugContributor(self, user=None):
12 """See `IPerson`."""
13
14=== modified file 'lib/lp/soyuz/interfaces/archive.py'
15--- lib/lp/soyuz/interfaces/archive.py 2011-07-22 11:38:44 +0000
16+++ lib/lp/soyuz/interfaces/archive.py 2011-08-02 09:36:46 +0000
17@@ -1658,7 +1658,8 @@
18 """
19
20 def new(purpose, owner, name=None, displayname=None, distribution=None,
21- description=None, enabled=True, require_virtualized=True):
22+ description=None, enabled=True, require_virtualized=True,
23+ private=False):
24 """Create a new archive.
25
26 On named-ppa creation, the signing key for the default PPA for the
27@@ -1680,6 +1681,7 @@
28 :param enabled: whether the archive shall be enabled post creation
29 :param require_virtualized: whether builds for the new archive shall
30 be carried out on virtual builders
31+ :param private: whether or not to make the PPA private
32
33 :return: an `IArchive` object.
34 :raises AssertionError if name is already taken within distribution.
35
36=== modified file 'lib/lp/soyuz/model/archive.py'
37--- lib/lp/soyuz/model/archive.py 2011-08-01 15:51:32 +0000
38+++ lib/lp/soyuz/model/archive.py 2011-08-02 09:36:46 +0000
39@@ -2083,7 +2083,7 @@
40
41 def new(self, purpose, owner, name=None, displayname=None,
42 distribution=None, description=None, enabled=True,
43- require_virtualized=True):
44+ require_virtualized=True, private=False):
45 """See `IArchiveSet`."""
46 if distribution is None:
47 distribution = getUtility(ILaunchpadCelebrities).ubuntu
48@@ -2157,6 +2157,8 @@
49 new_archive.buildd_secret = create_unique_token_for_table(
50 20, Archive.buildd_secret)
51 new_archive.private = True
52+ else:
53+ new_archive.private = private
54
55 return new_archive
56
57
58=== modified file 'lib/lp/soyuz/stories/webservice/xx-person-createppa.txt'
59--- lib/lp/soyuz/stories/webservice/xx-person-createppa.txt 2011-07-27 19:13:40 +0000
60+++ lib/lp/soyuz/stories/webservice/xx-person-createppa.txt 2011-08-02 09:36:46 +0000
61@@ -1,5 +1,8 @@
62 = Creating a PPA =
63
64+ >>> from zope.component import getUtility
65+ >>> from lp.app.interfaces.launchpad import ILaunchpadCelebrities
66+ >>> from lp.testing import celebrity_logged_in
67 >>> from lp.testing.sampledata import ADMIN_EMAIL
68 >>> login(ADMIN_EMAIL)
69 >>> owner = factory.makePerson()
70@@ -58,3 +61,36 @@
71 ... ppa_owner['ppas_collection_link']).jsonBody())
72 http://api.launchpad.dev/beta/~.../+archive/ppa
73
74+However, we can grant them commercial admin access:
75+
76+ >>> with celebrity_logged_in('admin'):
77+ ... comm = getUtility(ILaunchpadCelebrities).commercial_admin
78+ ... comm.addMember(owner, comm.teamowner)
79+ (True, <DBItem TeamMembershipStatus.APPROVED, (2) Approved>)
80+
81+Once they have commercial access, they can create private PPAs:
82+
83+ >>> print ppa_owner_webservice.named_post(
84+ ... ppa_owner['self_link'], 'createPPA', {}, name='secret',
85+ ... displayname='My secret new PPA', description='Secretness!',
86+ ... private=True,
87+ ... )
88+ HTTP/1.1 201 Created
89+ Status: 201
90+ ...
91+ Location: http://api.launchpad.dev/.../+archive/secret
92+ ...
93+
94+And the PPA appears in their list of PPAs:
95+
96+ >>> print_self_link_of_entries(webservice.get(
97+ ... ppa_owner['ppas_collection_link']).jsonBody())
98+ http://api.launchpad.dev/.../+archive/ppa
99+ http://api.launchpad.dev/.../+archive/secret
100+
101+And the PPA is, of course, private:
102+
103+ >>> ppa = ppa_owner_webservice.named_get(
104+ ... ppa_owner['self_link'], 'getPPAByName', name='secret').jsonBody()
105+ >>> ppa['private']
106+ True
107
108=== modified file 'lib/lp/soyuz/tests/test_archive.py'
109--- lib/lp/soyuz/tests/test_archive.py 2011-08-01 15:49:59 +0000
110+++ lib/lp/soyuz/tests/test_archive.py 2011-08-02 09:36:46 +0000
111@@ -1,4 +1,4 @@
112-# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
113+# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
114 # GNU Affero General Public License version 3 (see the file LICENSE).
115
116 """Test Archive features."""