Merge lp:~allenap/launchpad/fix-permissions-bug-547063 into lp:launchpad/db-devel

Proposed by Gavin Panella
Status: Merged
Approved by: Gavin Panella
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~allenap/launchpad/fix-permissions-bug-547063
Merge into: lp:launchpad/db-devel
Diff against target: 170 lines (+50/-10)
6 files modified
lib/lp/bugs/configure.zcml (+2/-2)
lib/lp/bugs/doc/bug-branch.txt (+28/-4)
lib/lp/code/browser/tests/test_branchlisting.py (+5/-1)
lib/lp/code/model/tests/test_branch.py (+1/-0)
lib/lp/code/model/tests/test_branchmergeproposals.py (+5/-0)
lib/lp/code/windmill/tests/test_branch_popupdiff.py (+9/-3)
To merge this branch: bzr merge lp:~allenap/launchpad/fix-permissions-bug-547063
Reviewer Review Type Date Requested Status
Deryck Hodge (community) release-critical Approve
Abel Deuring (community) code Approve
Review via email: mp+22369@code.launchpad.net

Commit message

Fix permissions so that only users who can modify the bug can link or unlink branches.

Description of the change

Fixes the permissions for Bug.linkBranch and Bug.unlinkBranch so that only users who have permissions to modify the bug can link or unlink branches.

To post a comment you must log in.
Revision history for this message
Abel Deuring (adeuring) :
review: Approve (code)
Revision history for this message
Deryck Hodge (deryck) :
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/bugs/configure.zcml'
--- lib/lp/bugs/configure.zcml 2010-03-26 13:48:53 +0000
+++ lib/lp/bugs/configure.zcml 2010-03-30 10:36:33 +0000
@@ -583,8 +583,6 @@
583 getDirectSubscribers583 getDirectSubscribers
584 getDirectSubscriptions584 getDirectSubscriptions
585 getIndirectSubscribers585 getIndirectSubscribers
586 linkBranch
587 unlinkBranch
588 mentoring_offers586 mentoring_offers
589 canMentor587 canMentor
590 isMentor588 isMentor
@@ -690,6 +688,8 @@
690 markAsDuplicate688 markAsDuplicate
691 linkHWSubmission689 linkHWSubmission
692 unlinkHWSubmission690 unlinkHWSubmission
691 linkBranch
692 unlinkBranch
693 linkAttachment"693 linkAttachment"
694 set_attributes="694 set_attributes="
695 activity initial_message695 activity initial_message
696696
=== modified file 'lib/lp/bugs/doc/bug-branch.txt'
--- lib/lp/bugs/doc/bug-branch.txt 2009-08-13 15:12:16 +0000
+++ lib/lp/bugs/doc/bug-branch.txt 2010-03-30 10:36:33 +0000
@@ -66,14 +66,12 @@
66 >>> branch = getUtility(IBranchLookup).get(1)66 >>> branch = getUtility(IBranchLookup).get(1)
67 >>> bug_branch_three = bug.linkBranch(branch, user)67 >>> bug_branch_three = bug.linkBranch(branch, user)
6868
6969If we make the bug private, no-priv won't be allowed to edit either
70If we make the bug private, no-priv won't be allowed to edit neither the70the bug or the BugBranch.
71bug nor the BugBranch.
7271
73 >>> login('foo.bar@canonical.com')72 >>> login('foo.bar@canonical.com')
74 >>> bug.setPrivate(True, getUtility(ILaunchBag).user)73 >>> bug.setPrivate(True, getUtility(ILaunchBag).user)
75 True74 True
76
77 >>> login('no-priv@canonical.com')75 >>> login('no-priv@canonical.com')
7876
79 >>> bug.description = 'Yet another description.'77 >>> bug.description = 'Yet another description.'
@@ -81,9 +79,35 @@
81 ...79 ...
82 Unauthorized:...80 Unauthorized:...
8381
82 >>> bug.unlinkBranch(branch, getUtility(ILaunchBag).user)
83 Traceback (most recent call last):
84 ...
85 Unauthorized:...
86
87 >>> another_branch = factory.makeAnyBranch()
88 >>> bug.linkBranch(another_branch, getUtility(ILaunchBag).user)
89 Traceback (most recent call last):
90 ...
91 Unauthorized:...
92
84 >>> login('foo.bar@canonical.com')93 >>> login('foo.bar@canonical.com')
85 >>> bug.setPrivate(False, getUtility(ILaunchBag).user)94 >>> bug.setPrivate(False, getUtility(ILaunchBag).user)
86 True95 True
96
97Likewise, anonymous users cannot link or unlink branches.
98
99 >>> login(ANONYMOUS)
100
101 >>> bug.unlinkBranch(branch, getUtility(ILaunchBag).user)
102 Traceback (most recent call last):
103 ...
104 Unauthorized:...
105
106 >>> bug.linkBranch(another_branch, getUtility(ILaunchBag).user)
107 Traceback (most recent call last):
108 ...
109 Unauthorized:...
110
87 >>> login('no-priv@canonical.com')111 >>> login('no-priv@canonical.com')
88112
89You can unlink a branch from a bug using unlinkBranch().113You can unlink a branch from a bug using unlinkBranch().
90114
=== modified file 'lib/lp/code/browser/tests/test_branchlisting.py'
--- lib/lp/code/browser/tests/test_branchlisting.py 2009-11-06 21:06:38 +0000
+++ lib/lp/code/browser/tests/test_branchlisting.py 2010-03-30 10:36:33 +0000
@@ -26,7 +26,8 @@
26from lp.registry.model.person import Owner26from lp.registry.model.person import Owner
27from lp.registry.model.product import Product27from lp.registry.model.product import Product
28from lp.registry.interfaces.pocket import PackagePublishingPocket28from lp.registry.interfaces.pocket import PackagePublishingPocket
29from lp.testing import TestCase, TestCaseWithFactory, time_counter29from lp.testing import (
30 TestCase, TestCaseWithFactory, login_person, time_counter)
30from lp.testing.views import create_initialized_view31from lp.testing.views import create_initialized_view
31from canonical.launchpad.webapp import canonical_url32from canonical.launchpad.webapp import canonical_url
32from canonical.launchpad.webapp.servers import LaunchpadTestRequest33from canonical.launchpad.webapp.servers import LaunchpadTestRequest
@@ -98,6 +99,9 @@
9899
99 def setUp(self):100 def setUp(self):
100 TestCaseWithFactory.setUp(self)101 TestCaseWithFactory.setUp(self)
102 self.user = self.factory.makePerson()
103 login_person(self.user)
104
101 self.barney = self.factory.makePerson(name='barney')105 self.barney = self.factory.makePerson(name='barney')
102 self.bambam = self.factory.makeProduct(name='bambam')106 self.bambam = self.factory.makeProduct(name='bambam')
103107
104108
=== modified file 'lib/lp/code/model/tests/test_branch.py'
--- lib/lp/code/model/tests/test_branch.py 2010-03-18 17:49:21 +0000
+++ lib/lp/code/model/tests/test_branch.py 2010-03-30 10:36:33 +0000
@@ -1732,6 +1732,7 @@
1732 def setUp(self):1732 def setUp(self):
1733 TestCaseWithFactory.setUp(self)1733 TestCaseWithFactory.setUp(self)
1734 self.user = self.factory.makePerson()1734 self.user = self.factory.makePerson()
1735 login_person(self.user)
17351736
1736 def test_bug_link(self):1737 def test_bug_link(self):
1737 # Branches can be linked to bugs through the Branch interface.1738 # Branches can be linked to bugs through the Branch interface.
17381739
=== modified file 'lib/lp/code/model/tests/test_branchmergeproposals.py'
--- lib/lp/code/model/tests/test_branchmergeproposals.py 2010-03-04 16:44:23 +0000
+++ lib/lp/code/model/tests/test_branchmergeproposals.py 2010-03-30 10:36:33 +0000
@@ -1146,6 +1146,11 @@
11461146
1147 layer = DatabaseFunctionalLayer1147 layer = DatabaseFunctionalLayer
11481148
1149 def setUp(self):
1150 TestCaseWithFactory.setUp(self)
1151 self.user = self.factory.makePerson()
1152 login_person(self.user)
1153
1149 def test_related_bugs_includes_source_bugs(self):1154 def test_related_bugs_includes_source_bugs(self):
1150 """related_bugs includes bugs linked to the source branch."""1155 """related_bugs includes bugs linked to the source branch."""
1151 bmp = self.factory.makeBranchMergeProposal()1156 bmp = self.factory.makeBranchMergeProposal()
11521157
=== modified file 'lib/lp/code/windmill/tests/test_branch_popupdiff.py'
--- lib/lp/code/windmill/tests/test_branch_popupdiff.py 2010-02-01 18:37:00 +0000
+++ lib/lp/code/windmill/tests/test_branch_popupdiff.py 2010-03-30 10:36:33 +0000
@@ -12,11 +12,12 @@
12import windmill12import windmill
1313
14from canonical.launchpad.windmill.testing.constants import PAGE_LOAD14from canonical.launchpad.windmill.testing.constants import PAGE_LOAD
15from canonical.launchpad.windmill.testing.lpuser import login_person15from canonical.launchpad.windmill.testing.lpuser import (
16 login_person as windmill_login_person)
16from lp.bugs.windmill.testing import BugsWindmillLayer17from lp.bugs.windmill.testing import BugsWindmillLayer
17from lp.code.tests.helpers import make_erics_fooix_project18from lp.code.tests.helpers import make_erics_fooix_project
18from lp.code.windmill.testing import CodeWindmillLayer19from lp.code.windmill.testing import CodeWindmillLayer
19from lp.testing import WindmillTestCase20from lp.testing import WindmillTestCase, login_person
2021
2122
22POPUP_DIFF = (23POPUP_DIFF = (
@@ -81,6 +82,11 @@
81 layer = BugsWindmillLayer82 layer = BugsWindmillLayer
82 name = "Bug popup diffs"83 name = "Bug popup diffs"
8384
85 def setUp(self):
86 WindmillTestCase.setUp(self)
87 self.user = self.factory.makePerson()
88 login_person(self.user)
89
84 def test_bug_popup_diff(self):90 def test_bug_popup_diff(self):
85 """Test bug page diff popups."""91 """Test bug page diff popups."""
86 client = self.client92 client = self.client
@@ -114,7 +120,7 @@
114 bug = self.factory.makeBug(product=objs['fooix'])120 bug = self.factory.makeBug(product=objs['fooix'])
115 transaction.commit()121 transaction.commit()
116122
117 login_person(objs['eric'], "test", client)123 windmill_login_person(objs['eric'], "test", client)
118124
119 start_url = (windmill.settings['TEST_URL'] + 'bugs/%d' % bug.id)125 start_url = (windmill.settings['TEST_URL'] + 'bugs/%d' % bug.id)
120 client.open(url=start_url)126 client.open(url=start_url)

Subscribers

People subscribed via source and target branches

to status/vote changes: