Merge lp:~rockstar/launchpad/fix-queue-permissions into lp:launchpad/db-devel

Proposed by Paul Hummer
Status: Merged
Merged at revision: 9924
Proposed branch: lp:~rockstar/launchpad/fix-queue-permissions
Merge into: lp:launchpad/db-devel
Diff against target: 158 lines (+40/-11)
5 files modified
lib/canonical/launchpad/security.py (+13/-0)
lib/lp/code/configure.zcml (+13/-1)
lib/lp/code/model/branchmergequeue.py (+4/-0)
lib/lp/code/model/tests/test_branchmergequeue.py (+8/-8)
lib/lp/testing/factory.py (+2/-2)
To merge this branch: bzr merge lp:~rockstar/launchpad/fix-queue-permissions
Reviewer Review Type Date Requested Status
Henning Eggers (community) code Approve
Review via email: mp+39278@code.launchpad.net

Description of the change

This branch fixes a few stupid things I did with the original models, and Tim/Ian pointed them out to me.

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

<henninge> rockstar: Have you started your own Canonical spin-off? A bit obvious, don't you think?
<henninge> 136 -# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
<henninge> 137 +# Copyright 2009-2010 aanonical Ltd. This software is licensed under the
* jelmer hat die Verbindung getrennt (Ping timeout: 255 seconds)
<henninge> ;-)
<rockstar> henninge, huh. I'll fix that...

review: Approve (code)
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Hi, I think you can have the interface inherit from IHasOwner rather than adding that security class.

Also, I think the usedfor is wrong: it is for IBranchMergeQueue, but only IMultiBranchMergeQueue has an owner.

Revision history for this message
Paul Hummer (rockstar) wrote :

Michael-

  There is no IMultiBranchQueue anymore. A few branches before that deleted it. I'll change the interface to inherit from IHasOwner.

Cheers,
Paul

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

On Mon, 25 Oct 2010 20:34:45 -0000, Paul Hummer <email address hidden> wrote:
> There is no IMultiBranchQueue anymore. A few branches before that
> deleted it. I'll change the interface to inherit from IHasOwner.

Awesome. Sorry for the noise.

Cheers,
mwh

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/security.py'
2--- lib/canonical/launchpad/security.py 2010-10-21 01:42:14 +0000
3+++ lib/canonical/launchpad/security.py 2010-10-25 15:28:30 +0000
4@@ -67,6 +67,7 @@
5 user_has_special_branch_access,
6 )
7 from lp.code.interfaces.branchmergeproposal import IBranchMergeProposal
8+from lp.code.interfaces.branchmergequeue import IBranchMergeQueue
9 from lp.code.interfaces.codeimport import ICodeImport
10 from lp.code.interfaces.codeimportjob import (
11 ICodeImportJobSet,
12@@ -1162,6 +1163,18 @@
13 return user.in_bazaar_experts or user.in_buildd_admin
14
15
16+class EditBranchMergeQueue(AuthorizationBase):
17+ """Control who can edit a BranchMergeQueue.
18+
19+ Access is granted only to the owner of the queue.
20+ """
21+ permission = 'launchpad.Edit'
22+ usedfor = IBranchMergeQueue
23+
24+ def checkAuthenticated(self, user):
25+ return user.isOwner(self.obj)
26+
27+
28 class AdminDistributionTranslations(AuthorizationBase):
29 """Class for deciding who can administer distribution translations.
30
31
32=== modified file 'lib/lp/code/configure.zcml'
33--- lib/lp/code/configure.zcml 2010-10-21 00:49:21 +0000
34+++ lib/lp/code/configure.zcml 2010-10-25 15:28:30 +0000
35@@ -23,8 +23,20 @@
36 name="code" />
37
38 <!-- Branch Merge Queues -->
39+ <securedutility
40+ component="lp.code.model.branchmergequeue.BranchMergeQueue"
41+ provides="lp.code.interfaces.branchmergequeue.IBranchMergeQueueSource">
42+ <allow interface="lp.code.interfaces.branchmergequeue.IBranchMergeQueueSource"/>
43+
44+ </securedutility>
45+
46 <class class="lp.code.model.branchmergequeue.BranchMergeQueue">
47- <allow interface="lp.code.interfaces.branchmergequeue.IBranchMergeQueue" />
48+ <require permission="zope.Public"
49+ attributes="registrant owner name description configuration
50+ date_created branches" />
51+ <require permission="launchpad.Edit"
52+ attributes="setMergeQueueConfig"
53+ set_attributes="owner name description configuration" />
54 </class>
55
56 <class class="lp.code.model.codereviewvote.CodeReviewVoteReference">
57
58=== modified file 'lib/lp/code/model/branchmergequeue.py'
59--- lib/lp/code/model/branchmergequeue.py 2010-10-18 21:20:28 +0000
60+++ lib/lp/code/model/branchmergequeue.py 2010-10-25 15:28:30 +0000
61@@ -21,6 +21,7 @@
62 )
63
64 from canonical.database.datetimecol import UtcDateTimeCol
65+from canonical.launchpad.interfaces.lpstorm import IMasterStore
66 from lp.code.errors import InvalidMergeQueueConfig
67 from lp.code.interfaces.branchmergequeue import (
68 IBranchMergeQueue,
69@@ -69,6 +70,8 @@
70 def new(cls, name, owner, registrant, description=None,
71 configuration=None):
72 """See `IBranchMergeQueueSource`."""
73+ store = IMasterStore(BranchMergeQueue)
74+
75 queue = cls()
76 queue.name = name
77 queue.owner = owner
78@@ -76,4 +79,5 @@
79 queue.description = description
80 queue.configuration = configuration
81
82+ store.add(queue)
83 return queue
84
85=== modified file 'lib/lp/code/model/tests/test_branchmergequeue.py'
86--- lib/lp/code/model/tests/test_branchmergequeue.py 2010-10-20 17:48:51 +0000
87+++ lib/lp/code/model/tests/test_branchmergequeue.py 2010-10-25 15:28:30 +0000
88@@ -7,8 +7,6 @@
89
90 import simplejson
91
92-import transaction
93-
94 from canonical.launchpad.interfaces.lpstorm import IStore
95 from canonical.launchpad.webapp.testing import verifyObject
96 from canonical.testing.layers import (
97@@ -86,17 +84,20 @@
98 config = unicode(simplejson.dumps({
99 'test': 'make test'}))
100
101- queue.setMergeQueueConfig(config)
102+ with person_logged_in(queue.owner):
103+ queue.setMergeQueueConfig(config)
104
105 self.assertEqual(queue.configuration, config)
106
107 def test_setMergeQueueConfig_invalid_json(self):
108 """Test that invalid json can't be set as the config."""
109 queue = self.factory.makeBranchMergeQueue()
110- self.assertRaises(
111- InvalidMergeQueueConfig,
112- queue.setMergeQueueConfig,
113- 'abc')
114+
115+ with person_logged_in(queue.owner):
116+ self.assertRaises(
117+ InvalidMergeQueueConfig,
118+ queue.setMergeQueueConfig,
119+ 'abc')
120
121
122 class TestWebservice(TestCaseWithFactory):
123@@ -123,7 +124,6 @@
124 branch2.addToQueue(db_queue)
125 launchpad = launchpadlib_for('test', db_queue.owner,
126 service_root="http://api.launchpad.dev:8085")
127- transaction.commit()
128
129 queuer = ws_object(launchpad, queuer)
130 queue = ws_object(launchpad, db_queue)
131
132=== modified file 'lib/lp/testing/factory.py'
133--- lib/lp/testing/factory.py 2010-10-25 12:11:43 +0000
134+++ lib/lp/testing/factory.py 2010-10-25 15:28:30 +0000
135@@ -133,6 +133,7 @@
136 RevisionControlSystems,
137 )
138 from lp.code.errors import UnknownBranchTypeError
139+from lp.code.interfaces.branchmergequeue import IBranchMergeQueueSource
140 from lp.code.interfaces.branchnamespace import get_branch_namespace
141 from lp.code.interfaces.branchtarget import IBranchTarget
142 from lp.code.interfaces.codeimport import ICodeImportSet
143@@ -152,7 +153,6 @@
144 PreviewDiff,
145 StaticDiff,
146 )
147-from lp.code.model.branchmergequeue import BranchMergeQueue
148 from lp.codehosting.codeimport.worker import CodeImportSourceDetails
149 from lp.hardwaredb.interfaces.hwdb import (
150 HWSubmissionFormat,
151@@ -1114,7 +1114,7 @@
152 configuration = unicode(simplejson.dumps({
153 self.getUniqueString('key'): self.getUniqueString('value')}))
154
155- queue = BranchMergeQueue.new(
156+ queue = getUtility(IBranchMergeQueueSource).new(
157 name, registrant, owner, description, configuration)
158 return queue
159

Subscribers

People subscribed via source and target branches

to status/vote changes: