Merge lp:~cjwatson/launchpad/ppa-admins-private into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 17886
Proposed branch: lp:~cjwatson/launchpad/ppa-admins-private
Merge into: lp:launchpad
Diff against target: 85 lines (+20/-15)
3 files modified
lib/lp/soyuz/configure.zcml (+4/-6)
lib/lp/soyuz/stories/webservice/xx-archive.txt (+15/-8)
lib/lp/soyuz/tests/test_archive.py (+1/-1)
To merge this branch: bzr merge lp:~cjwatson/launchpad/ppa-admins-private
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+281647@code.launchpad.net

Commit message

Allow PPA admins to set Archive.private again.

Description of the change

Allow PPA admins to set Archive.private again.

This is conceptually a bit odd, but it matches behaviour from before https://code.launchpad.net/~cjwatson/launchpad/ppa-admins/+merge/278720, and ~lexbuilder makes use of this; it probably makes more sense to continue to let launchpad-ppa-self-admins set Archive.private for their own archives (and to newly allow launchpad-ppa-admins to do so for all archives) than to add lexbuilder to commercial-admins.

Note that this doesn't involve giving launchpad-ppa-admins access to any more private resources than before; it just lets them set Archive.private and Archive.buildd_secret.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/soyuz/configure.zcml'
2--- lib/lp/soyuz/configure.zcml 2015-11-26 15:46:38 +0000
3+++ lib/lp/soyuz/configure.zcml 2016-01-05 15:22:29 +0000
4@@ -370,19 +370,17 @@
5 <!--
6 NOTE: The 'private' permission controls who can turn a public
7 archive into a private one, and vice versa. The logic that
8- says this requires launchpad.Commercial permissions is duplicated
9+ says this requires launchpad.Admin permissions is duplicated
10 in validate_ppa.
11 -->
12 <require
13- permission="launchpad.Commercial"
14- set_attributes="buildd_secret private"/>
15- <require
16 permission="launchpad.Admin"
17 interface="lp.soyuz.interfaces.archive.IArchiveAdmin"
18- set_attributes="authorized_size enabled_restricted_processors
19+ set_attributes="authorized_size buildd_secret
20+ enabled_restricted_processors
21 external_dependencies name
22 permit_obsolete_series_uploads
23- require_virtualized"/>
24+ private require_virtualized"/>
25 <require
26 permission="launchpad.Moderate"
27 set_schema="lp.soyuz.interfaces.archive.IArchiveRestricted"/>
28
29=== modified file 'lib/lp/soyuz/stories/webservice/xx-archive.txt'
30--- lib/lp/soyuz/stories/webservice/xx-archive.txt 2015-11-26 15:46:38 +0000
31+++ lib/lp/soyuz/stories/webservice/xx-archive.txt 2016-01-05 15:22:29 +0000
32@@ -1330,14 +1330,19 @@
33 ~~~~~~~~~~~~~~~~~
34
35 Modifying the privacy flag through the API is not allowed except for
36-admins and commercial admins. Mere PPA admins can't do it.
37+admins, commercial admins, and PPA admins.
38
39- >>> mark_archive = webservice.get("/~mark/+archive/ubuntu/ppa").jsonBody()
40- >>> mark_archive['private'] = True
41- >>> print modify_archive(user_webservice, mark_archive)
42+ >>> login('foo.bar@canonical.com')
43+ >>> pubpriv_archive_db = factory.makeArchive(
44+ ... owner=cprov, distribution=ubuntu_db, name="pubpriv")
45+ >>> logout()
46+ >>> pubpriv_archive = webservice.get(
47+ ... "/~cprov/+archive/ubuntu/pubpriv").jsonBody()
48+ >>> pubpriv_archive['private'] = True
49+ >>> print modify_archive(user_webservice, pubpriv_archive)
50 HTTP/1.1 401 Unauthorized
51 ...
52- (<Archive at ...>, 'private', 'launchpad.Commercial')
53+ (<Archive at ...>, 'private', 'launchpad.Admin')
54
55 >>> login('foo.bar@canonical.com')
56 >>> ppa_admin = factory.makePerson(member_of=[
57@@ -1345,10 +1350,12 @@
58 >>> logout()
59 >>> ppa_admin_webservice = webservice_for_person(
60 ... ppa_admin, permission=OAuthPermission.WRITE_PRIVATE)
61- >>> print modify_archive(ppa_admin_webservice, mark_archive)
62- HTTP/1.1 401 Unauthorized
63+ >>> print modify_archive(ppa_admin_webservice, pubpriv_archive)
64+ HTTP/1.1 209 Content Returned
65 ...
66- (<Archive at ...>, 'private', 'launchpad.Commercial')
67+ >>> webservice.get(
68+ ... "/~cprov/+archive/ubuntu/pubpriv").jsonBody()['private']
69+ True
70
71
72 Copying private file to public archives
73
74=== modified file 'lib/lp/soyuz/tests/test_archive.py'
75--- lib/lp/soyuz/tests/test_archive.py 2015-11-26 15:46:38 +0000
76+++ lib/lp/soyuz/tests/test_archive.py 2016-01-05 15:22:29 +0000
77@@ -1211,7 +1211,7 @@
78 login(ANONYMOUS)
79 e = self.assertRaises(
80 Unauthorized, setattr, self.archive, "buildd_secret", "boing")
81- self.assertEqual("launchpad.Commercial", e.args[2])
82+ self.assertEqual("launchpad.Admin", e.args[2])
83
84 def test_commercial_admin_can_set_buildd_secret(self):
85 with celebrity_logged_in("commercial_admin"):