Merge lp:~sinzui/launchpad/entitle-branch-sharing into lp:launchpad
- entitle-branch-sharing
- Merge into devel
Status: | Merged |
---|---|
Merged at revision: | 15846 |
Proposed branch: | lp:~sinzui/launchpad/entitle-branch-sharing |
Merge into: | lp:launchpad |
Prerequisite: | lp:~sinzui/launchpad/project-branch-permissions |
Diff against target: |
473 lines (+27/-99) 13 files modified
lib/lp/bugs/browser/tests/test_bugs.py (+2/-6) lib/lp/bugs/browser/tests/test_bugtarget_filebug.py (+4/-10) lib/lp/bugs/mail/tests/test_handler.py (+2/-4) lib/lp/bugs/tests/test_bugs_webservice.py (+1/-5) lib/lp/code/browser/tests/test_branch.py (+4/-8) lib/lp/code/browser/tests/test_branchlisting.py (+3/-3) lib/lp/code/model/tests/test_branch.py (+4/-8) lib/lp/code/model/tests/test_branchnamespace.py (+1/-4) lib/lp/registry/model/product.py (+0/-8) lib/lp/registry/tests/test_product.py (+1/-4) lib/lp/registry/tests/test_product_webservice.py (+2/-32) lib/lp/soyuz/tests/test_archive.py (+3/-4) lib/lp/testing/sampledata.py (+0/-3) |
To merge this branch: | bzr merge lp:~sinzui/launchpad/entitle-branch-sharing |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
William Grant (community) | code | Approve | |
Review via email: mp+120225@code.launchpad.net |
Commit message
Allow project maintainers to call setBranchSharin
Description of the change
Launchpad must let users reconfigure their projects to use sharing
which enters beta next week.
-------
RULES
Pre-
* Remove the guard in setBranchSharin
deprecated rule that restricts branch policies to be set by a
commercial admin.
* Simplify tests that use a commmercial admin to setup the conditions.
QA
As a non-commercial admin
* Visit http://
* Verify you can change the branch sharing policy.
LINT
lib/
lib/
lib/
lib/
TEST
./bin/test -vvc -t transitionToInf
./bin/test -vvc -t WithInformationType lp.code.
./bin/test -vvc -t EditViewInforma
IMPLEMENTATION
Remove the commerncial admin guard from setBranchSharin
lib/
Update tests to use the project owner instead of a commecial admin to
setup the test conditions.
lib/
lib/
lib/
Curtis Hovey (sinzui) wrote : | # |
I agree it needs to land with the other branch. I noticed the user arg and pondered if we wanted to keep it to either log or queue a notification to the project maintainer to inform who made the change. Cody is very concerned that several oh his projects had policy changes he would not permit. A might have helped him close the potential hole before something went through it. What do you think?
William Grant (wgrant) wrote : | # |
We should certainly hook it into an auditing mechanism at some point, but it's relatively easy to readd the argument later. I don't have a strong opinion either way.
Preview Diff
1 | === modified file 'lib/lp/bugs/browser/tests/test_bugs.py' | |||
2 | --- lib/lp/bugs/browser/tests/test_bugs.py 2012-08-20 13:12:45 +0000 | |||
3 | +++ lib/lp/bugs/browser/tests/test_bugs.py 2012-08-21 15:01:20 +0000 | |||
4 | @@ -16,7 +16,6 @@ | |||
5 | 16 | BugSharingPolicy, | 16 | BugSharingPolicy, |
6 | 17 | InformationType, | 17 | InformationType, |
7 | 18 | ) | 18 | ) |
8 | 19 | from lp.registry.interfaces.person import IPersonSet | ||
9 | 20 | from lp.registry.interfaces.product import License | 19 | from lp.registry.interfaces.product import License |
10 | 21 | from lp.services.webapp.publisher import canonical_url | 20 | from lp.services.webapp.publisher import canonical_url |
11 | 22 | from lp.testing import ( | 21 | from lp.testing import ( |
12 | @@ -28,7 +27,6 @@ | |||
13 | 28 | ) | 27 | ) |
14 | 29 | from lp.testing.layers import DatabaseFunctionalLayer | 28 | from lp.testing.layers import DatabaseFunctionalLayer |
15 | 30 | from lp.testing.pages import find_tag_by_id | 29 | from lp.testing.pages import find_tag_by_id |
16 | 31 | from lp.testing.sampledata import COMMERCIAL_ADMIN_EMAIL | ||
17 | 32 | from lp.testing.views import create_initialized_view | 30 | from lp.testing.views import create_initialized_view |
18 | 33 | 31 | ||
19 | 34 | 32 | ||
20 | @@ -184,9 +182,8 @@ | |||
21 | 184 | # createBug() does not adapt the default kwargs when they are none. | 182 | # createBug() does not adapt the default kwargs when they are none. |
22 | 185 | project = self.factory.makeProduct( | 183 | project = self.factory.makeProduct( |
23 | 186 | licenses=[License.OTHER_PROPRIETARY]) | 184 | licenses=[License.OTHER_PROPRIETARY]) |
24 | 187 | comadmin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL) | ||
25 | 188 | project.setBugSharingPolicy( | 185 | project.setBugSharingPolicy( |
27 | 189 | BugSharingPolicy.PROPRIETARY_OR_PUBLIC, comadmin) | 186 | BugSharingPolicy.PROPRIETARY_OR_PUBLIC, project.owner) |
28 | 190 | bug = self.application.createBug( | 187 | bug = self.application.createBug( |
29 | 191 | project.owner, 'title', 'description', project) | 188 | project.owner, 'title', 'description', project) |
30 | 192 | self.assertEqual(InformationType.PROPRIETARY, bug.information_type) | 189 | self.assertEqual(InformationType.PROPRIETARY, bug.information_type) |
31 | @@ -195,9 +192,8 @@ | |||
32 | 195 | # createBug() adapts a kwarg to InformationType if one is is not None. | 192 | # createBug() adapts a kwarg to InformationType if one is is not None. |
33 | 196 | project = self.factory.makeProduct( | 193 | project = self.factory.makeProduct( |
34 | 197 | licenses=[License.OTHER_PROPRIETARY]) | 194 | licenses=[License.OTHER_PROPRIETARY]) |
35 | 198 | comadmin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL) | ||
36 | 199 | project.setBugSharingPolicy( | 195 | project.setBugSharingPolicy( |
38 | 200 | BugSharingPolicy.PROPRIETARY_OR_PUBLIC, comadmin) | 196 | BugSharingPolicy.PROPRIETARY_OR_PUBLIC, project.owner) |
39 | 201 | bug = self.application.createBug( | 197 | bug = self.application.createBug( |
40 | 202 | project.owner, 'title', 'description', project, private=False) | 198 | project.owner, 'title', 'description', project, private=False) |
41 | 203 | self.assertEqual(InformationType.PUBLIC, bug.information_type) | 199 | self.assertEqual(InformationType.PUBLIC, bug.information_type) |
42 | 204 | 200 | ||
43 | === modified file 'lib/lp/bugs/browser/tests/test_bugtarget_filebug.py' | |||
44 | --- lib/lp/bugs/browser/tests/test_bugtarget_filebug.py 2012-08-20 13:26:21 +0000 | |||
45 | +++ lib/lp/bugs/browser/tests/test_bugtarget_filebug.py 2012-08-21 15:01:20 +0000 | |||
46 | @@ -29,7 +29,6 @@ | |||
47 | 29 | InformationType, | 29 | InformationType, |
48 | 30 | PRIVATE_INFORMATION_TYPES, | 30 | PRIVATE_INFORMATION_TYPES, |
49 | 31 | ) | 31 | ) |
50 | 32 | from lp.registry.interfaces.person import IPersonSet | ||
51 | 33 | from lp.registry.interfaces.projectgroup import IProjectGroup | 32 | from lp.registry.interfaces.projectgroup import IProjectGroup |
52 | 34 | from lp.services.webapp.servers import LaunchpadTestRequest | 33 | from lp.services.webapp.servers import LaunchpadTestRequest |
53 | 35 | from lp.testing import ( | 34 | from lp.testing import ( |
54 | @@ -43,7 +42,6 @@ | |||
55 | 43 | find_main_content, | 42 | find_main_content, |
56 | 44 | find_tag_by_id, | 43 | find_tag_by_id, |
57 | 45 | ) | 44 | ) |
58 | 46 | from lp.testing.sampledata import COMMERCIAL_ADMIN_EMAIL | ||
59 | 47 | from lp.testing.views import ( | 45 | from lp.testing.views import ( |
60 | 48 | create_initialized_view, | 46 | create_initialized_view, |
61 | 49 | create_view, | 47 | create_view, |
62 | @@ -369,9 +367,7 @@ | |||
63 | 369 | removeSecurityProxy(product).private_bugs = True | 367 | removeSecurityProxy(product).private_bugs = True |
64 | 370 | if bug_sharing_policy: | 368 | if bug_sharing_policy: |
65 | 371 | self.factory.makeCommercialSubscription(product=product) | 369 | self.factory.makeCommercialSubscription(product=product) |
69 | 372 | comadmin = getUtility(IPersonSet).getByEmail( | 370 | product.setBugSharingPolicy(bug_sharing_policy, product.owner) |
67 | 373 | COMMERCIAL_ADMIN_EMAIL) | ||
68 | 374 | product.setBugSharingPolicy(bug_sharing_policy, comadmin) | ||
70 | 375 | with person_logged_in(product.owner): | 371 | with person_logged_in(product.owner): |
71 | 376 | view = create_view( | 372 | view = create_view( |
72 | 377 | product, '+filebug', method='POST', form=form, | 373 | product, '+filebug', method='POST', form=form, |
73 | @@ -447,8 +443,8 @@ | |||
74 | 447 | # correctly for a project with a proprietary sharing policy. | 443 | # correctly for a project with a proprietary sharing policy. |
75 | 448 | product = self.factory.makeProduct(official_malone=True) | 444 | product = self.factory.makeProduct(official_malone=True) |
76 | 449 | self.factory.makeCommercialSubscription(product=product) | 445 | self.factory.makeCommercialSubscription(product=product) |
79 | 450 | comadmin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL) | 446 | product.setBugSharingPolicy( |
80 | 451 | product.setBugSharingPolicy(BugSharingPolicy.PROPRIETARY, comadmin) | 447 | BugSharingPolicy.PROPRIETARY, product.owner) |
81 | 452 | with person_logged_in(product.owner): | 448 | with person_logged_in(product.owner): |
82 | 453 | view = create_initialized_view( | 449 | view = create_initialized_view( |
83 | 454 | product, '+filebug', principal=product.owner) | 450 | product, '+filebug', principal=product.owner) |
84 | @@ -499,9 +495,7 @@ | |||
85 | 499 | removeSecurityProxy(product).private_bugs = True | 495 | removeSecurityProxy(product).private_bugs = True |
86 | 500 | if bug_sharing_policy: | 496 | if bug_sharing_policy: |
87 | 501 | self.factory.makeCommercialSubscription(product=product) | 497 | self.factory.makeCommercialSubscription(product=product) |
91 | 502 | comadmin = getUtility(IPersonSet).getByEmail( | 498 | product.setBugSharingPolicy(bug_sharing_policy, product.owner) |
89 | 503 | COMMERCIAL_ADMIN_EMAIL) | ||
90 | 504 | product.setBugSharingPolicy(bug_sharing_policy, comadmin) | ||
92 | 505 | anyone = self.factory.makePerson() | 499 | anyone = self.factory.makePerson() |
93 | 506 | with person_logged_in(anyone): | 500 | with person_logged_in(anyone): |
94 | 507 | view = create_initialized_view( | 501 | view = create_initialized_view( |
95 | 508 | 502 | ||
96 | === modified file 'lib/lp/bugs/mail/tests/test_handler.py' | |||
97 | --- lib/lp/bugs/mail/tests/test_handler.py 2012-08-20 13:12:45 +0000 | |||
98 | +++ lib/lp/bugs/mail/tests/test_handler.py 2012-08-21 15:01:20 +0000 | |||
99 | @@ -32,7 +32,6 @@ | |||
100 | 32 | BugSharingPolicy, | 32 | BugSharingPolicy, |
101 | 33 | InformationType, | 33 | InformationType, |
102 | 34 | ) | 34 | ) |
103 | 35 | from lp.registry.interfaces.person import IPersonSet | ||
104 | 36 | from lp.services.config import config | 35 | from lp.services.config import config |
105 | 37 | from lp.services.identity.interfaces.emailaddress import EmailAddressStatus | 36 | from lp.services.identity.interfaces.emailaddress import EmailAddressStatus |
106 | 38 | from lp.services.mail import stub | 37 | from lp.services.mail import stub |
107 | @@ -52,7 +51,6 @@ | |||
108 | 52 | LaunchpadZopelessLayer, | 51 | LaunchpadZopelessLayer, |
109 | 53 | ) | 52 | ) |
110 | 54 | from lp.testing.mail_helpers import pop_notifications | 53 | from lp.testing.mail_helpers import pop_notifications |
111 | 55 | from lp.testing.sampledata import COMMERCIAL_ADMIN_EMAIL | ||
112 | 56 | 54 | ||
113 | 57 | 55 | ||
114 | 58 | class TestMaloneHandler(TestCaseWithFactory): | 56 | class TestMaloneHandler(TestCaseWithFactory): |
115 | @@ -261,8 +259,8 @@ | |||
116 | 261 | def test_new_bug_with_sharing_policy_proprietary(self): | 259 | def test_new_bug_with_sharing_policy_proprietary(self): |
117 | 262 | project = self.factory.makeProduct(name='fnord') | 260 | project = self.factory.makeProduct(name='fnord') |
118 | 263 | self.factory.makeCommercialSubscription(product=project) | 261 | self.factory.makeCommercialSubscription(product=project) |
121 | 264 | comadmin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL) | 262 | project.setBugSharingPolicy( |
122 | 265 | project.setBugSharingPolicy(BugSharingPolicy.PROPRIETARY, comadmin) | 263 | BugSharingPolicy.PROPRIETARY, project.owner) |
123 | 266 | transaction.commit() | 264 | transaction.commit() |
124 | 267 | handler = MaloneHandler() | 265 | handler = MaloneHandler() |
125 | 268 | with person_logged_in(project.owner): | 266 | with person_logged_in(project.owner): |
126 | 269 | 267 | ||
127 | === modified file 'lib/lp/bugs/tests/test_bugs_webservice.py' | |||
128 | --- lib/lp/bugs/tests/test_bugs_webservice.py 2012-08-20 13:12:45 +0000 | |||
129 | +++ lib/lp/bugs/tests/test_bugs_webservice.py 2012-08-21 15:01:20 +0000 | |||
130 | @@ -21,7 +21,6 @@ | |||
131 | 21 | ) | 21 | ) |
132 | 22 | from zope.component import ( | 22 | from zope.component import ( |
133 | 23 | getMultiAdapter, | 23 | getMultiAdapter, |
134 | 24 | getUtility, | ||
135 | 25 | ) | 24 | ) |
136 | 26 | 25 | ||
137 | 27 | from lp.bugs.browser.bugtask import get_comments_for_bugtask | 26 | from lp.bugs.browser.bugtask import get_comments_for_bugtask |
138 | @@ -30,7 +29,6 @@ | |||
139 | 30 | BugSharingPolicy, | 29 | BugSharingPolicy, |
140 | 31 | InformationType, | 30 | InformationType, |
141 | 32 | ) | 31 | ) |
142 | 33 | from lp.registry.interfaces.person import IPersonSet | ||
143 | 34 | from lp.registry.interfaces.product import License | 32 | from lp.registry.interfaces.product import License |
144 | 35 | from lp.services.webapp import snapshot | 33 | from lp.services.webapp import snapshot |
145 | 36 | from lp.services.webapp.servers import LaunchpadTestRequest | 34 | from lp.services.webapp.servers import LaunchpadTestRequest |
146 | @@ -52,7 +50,6 @@ | |||
147 | 52 | from lp.testing.pages import LaunchpadWebServiceCaller | 50 | from lp.testing.pages import LaunchpadWebServiceCaller |
148 | 53 | from lp.testing.sampledata import ( | 51 | from lp.testing.sampledata import ( |
149 | 54 | ADMIN_EMAIL, | 52 | ADMIN_EMAIL, |
150 | 55 | COMMERCIAL_ADMIN_EMAIL, | ||
151 | 56 | USER_EMAIL, | 53 | USER_EMAIL, |
152 | 57 | ) | 54 | ) |
153 | 58 | 55 | ||
154 | @@ -414,9 +411,8 @@ | |||
155 | 414 | # to the project's bug sharing policy. | 411 | # to the project's bug sharing policy. |
156 | 415 | project = self.factory.makeProduct( | 412 | project = self.factory.makeProduct( |
157 | 416 | licenses=[License.OTHER_PROPRIETARY]) | 413 | licenses=[License.OTHER_PROPRIETARY]) |
158 | 417 | comadmin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL) | ||
159 | 418 | project.setBugSharingPolicy( | 414 | project.setBugSharingPolicy( |
161 | 419 | BugSharingPolicy.PROPRIETARY_OR_PUBLIC, comadmin) | 415 | BugSharingPolicy.PROPRIETARY_OR_PUBLIC, project.owner) |
162 | 420 | webservice = launchpadlib_for('test', 'salgado') | 416 | webservice = launchpadlib_for('test', 'salgado') |
163 | 421 | bugs_collection = webservice.load('/bugs') | 417 | bugs_collection = webservice.load('/bugs') |
164 | 422 | bug = bugs_collection.createBug( | 418 | bug = bugs_collection.createBug( |
165 | 423 | 419 | ||
166 | === modified file 'lib/lp/code/browser/tests/test_branch.py' | |||
167 | --- lib/lp/code/browser/tests/test_branch.py 2012-08-16 06:24:32 +0000 | |||
168 | +++ lib/lp/code/browser/tests/test_branch.py 2012-08-21 15:01:20 +0000 | |||
169 | @@ -41,7 +41,6 @@ | |||
170 | 41 | ) | 41 | ) |
171 | 42 | from lp.registry.interfaces.accesspolicy import IAccessPolicySource | 42 | from lp.registry.interfaces.accesspolicy import IAccessPolicySource |
172 | 43 | from lp.registry.interfaces.person import ( | 43 | from lp.registry.interfaces.person import ( |
173 | 44 | IPersonSet, | ||
174 | 45 | PersonVisibility, | 44 | PersonVisibility, |
175 | 46 | ) | 45 | ) |
176 | 47 | from lp.services.config import config | 46 | from lp.services.config import config |
177 | @@ -72,7 +71,6 @@ | |||
178 | 72 | setupBrowser, | 71 | setupBrowser, |
179 | 73 | setupBrowserForUser, | 72 | setupBrowserForUser, |
180 | 74 | ) | 73 | ) |
181 | 75 | from lp.testing.sampledata import COMMERCIAL_ADMIN_EMAIL | ||
182 | 76 | from lp.testing.views import create_initialized_view | 74 | from lp.testing.views import create_initialized_view |
183 | 77 | 75 | ||
184 | 78 | 76 | ||
185 | @@ -1086,10 +1084,9 @@ | |||
186 | 1086 | owner = self.factory.makePerson() | 1084 | owner = self.factory.makePerson() |
187 | 1087 | product = self.factory.makeProduct(owner=owner) | 1085 | product = self.factory.makeProduct(owner=owner) |
188 | 1088 | self.factory.makeCommercialSubscription(product=product) | 1086 | self.factory.makeCommercialSubscription(product=product) |
189 | 1089 | comadmin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL) | ||
190 | 1090 | product.setBranchSharingPolicy( | ||
191 | 1091 | BranchSharingPolicy.EMBARGOED_OR_PROPRIETARY, comadmin) | ||
192 | 1092 | with person_logged_in(owner): | 1087 | with person_logged_in(owner): |
193 | 1088 | product.setBranchSharingPolicy( | ||
194 | 1089 | BranchSharingPolicy.EMBARGOED_OR_PROPRIETARY, owner) | ||
195 | 1093 | branch = self.factory.makeBranch( | 1090 | branch = self.factory.makeBranch( |
196 | 1094 | product=product, owner=owner, | 1091 | product=product, owner=owner, |
197 | 1095 | information_type=InformationType.PROPRIETARY) | 1092 | information_type=InformationType.PROPRIETARY) |
198 | @@ -1102,10 +1099,9 @@ | |||
199 | 1102 | owner = self.factory.makePerson() | 1099 | owner = self.factory.makePerson() |
200 | 1103 | product = self.factory.makeProduct(owner=owner) | 1100 | product = self.factory.makeProduct(owner=owner) |
201 | 1104 | self.factory.makeCommercialSubscription(product=product) | 1101 | self.factory.makeCommercialSubscription(product=product) |
202 | 1105 | comadmin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL) | ||
203 | 1106 | product.setBranchSharingPolicy( | ||
204 | 1107 | BranchSharingPolicy.PROPRIETARY, comadmin) | ||
205 | 1108 | with person_logged_in(owner): | 1102 | with person_logged_in(owner): |
206 | 1103 | product.setBranchSharingPolicy( | ||
207 | 1104 | BranchSharingPolicy.PROPRIETARY, owner) | ||
208 | 1109 | branch = self.factory.makeBranch( | 1105 | branch = self.factory.makeBranch( |
209 | 1110 | product=product, owner=owner, | 1106 | product=product, owner=owner, |
210 | 1111 | information_type=InformationType.PROPRIETARY) | 1107 | information_type=InformationType.PROPRIETARY) |
211 | 1112 | 1108 | ||
212 | === modified file 'lib/lp/code/browser/tests/test_branchlisting.py' | |||
213 | --- lib/lp/code/browser/tests/test_branchlisting.py 2012-08-14 23:27:07 +0000 | |||
214 | +++ lib/lp/code/browser/tests/test_branchlisting.py 2012-08-21 15:01:20 +0000 | |||
215 | @@ -46,6 +46,7 @@ | |||
216 | 46 | from lp.services.webapp.servers import LaunchpadTestRequest | 46 | from lp.services.webapp.servers import LaunchpadTestRequest |
217 | 47 | from lp.testing import ( | 47 | from lp.testing import ( |
218 | 48 | BrowserTestCase, | 48 | BrowserTestCase, |
219 | 49 | celebrity_logged_in, | ||
220 | 49 | login_person, | 50 | login_person, |
221 | 50 | normalize_whitespace, | 51 | normalize_whitespace, |
222 | 51 | person_logged_in, | 52 | person_logged_in, |
223 | @@ -66,7 +67,6 @@ | |||
224 | 66 | ) | 67 | ) |
225 | 67 | from lp.testing.sampledata import ( | 68 | from lp.testing.sampledata import ( |
226 | 68 | ADMIN_EMAIL, | 69 | ADMIN_EMAIL, |
227 | 69 | COMMERCIAL_ADMIN_EMAIL, | ||
228 | 70 | ) | 70 | ) |
229 | 71 | from lp.testing.views import ( | 71 | from lp.testing.views import ( |
230 | 72 | create_initialized_view, | 72 | create_initialized_view, |
231 | @@ -752,8 +752,8 @@ | |||
232 | 752 | def test_branch_visibility_link_commercial_admin(self): | 752 | def test_branch_visibility_link_commercial_admin(self): |
233 | 753 | # A commercial admin will be displayed a link to define branch | 753 | # A commercial admin will be displayed a link to define branch |
234 | 754 | # visibility in the action portlet. | 754 | # visibility in the action portlet. |
237 | 755 | admin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL) | 755 | with celebrity_logged_in('commercial_admin') as admin: |
238 | 756 | self._testBranchVisibilityLink(admin) | 756 | self._testBranchVisibilityLink(admin) |
239 | 757 | 757 | ||
240 | 758 | def test_branch_visibility_link_non_admin(self): | 758 | def test_branch_visibility_link_non_admin(self): |
241 | 759 | # A non-admin will not see the action portlet. | 759 | # A non-admin will not see the action portlet. |
242 | 760 | 760 | ||
243 | === modified file 'lib/lp/code/model/tests/test_branch.py' | |||
244 | --- lib/lp/code/model/tests/test_branch.py 2012-08-20 14:03:01 +0000 | |||
245 | +++ lib/lp/code/model/tests/test_branch.py 2012-08-21 15:01:20 +0000 | |||
246 | @@ -2601,10 +2601,9 @@ | |||
247 | 2601 | def test_methods_smoketest(self): | 2601 | def test_methods_smoketest(self): |
248 | 2602 | # Users with launchpad.Moderate can call transitionToInformationType. | 2602 | # Users with launchpad.Moderate can call transitionToInformationType. |
249 | 2603 | branch = self.factory.makeProductBranch() | 2603 | branch = self.factory.makeProductBranch() |
251 | 2604 | with celebrity_logged_in('commercial_admin') as admin: | 2604 | with person_logged_in(branch.product.owner): |
252 | 2605 | branch.product.setBranchSharingPolicy( | 2605 | branch.product.setBranchSharingPolicy( |
255 | 2606 | BranchSharingPolicy.PUBLIC, admin) | 2606 | BranchSharingPolicy.PUBLIC, branch.product.owner) |
254 | 2607 | with person_logged_in(branch.product.owner): | ||
256 | 2608 | branch.transitionToInformationType( | 2607 | branch.transitionToInformationType( |
257 | 2609 | InformationType.PRIVATESECURITY, branch.product.owner) | 2608 | InformationType.PRIVATESECURITY, branch.product.owner) |
258 | 2610 | self.assertEqual( | 2609 | self.assertEqual( |
259 | @@ -3283,12 +3282,9 @@ | |||
260 | 3283 | """Test transitionToInformationType() API arguments.""" | 3282 | """Test transitionToInformationType() API arguments.""" |
261 | 3284 | product = self.factory.makeProduct() | 3283 | product = self.factory.makeProduct() |
262 | 3285 | self.factory.makeCommercialSubscription(product) | 3284 | self.factory.makeCommercialSubscription(product) |
266 | 3286 | with celebrity_logged_in('commercial_admin') as admin: | 3285 | with person_logged_in(product.owner): |
264 | 3287 | # XXX sinzui 2012-08-16: setBranchSharingPolicy() is guarded | ||
265 | 3288 | # at this moment. | ||
267 | 3289 | product.setBranchSharingPolicy( | 3286 | product.setBranchSharingPolicy( |
270 | 3290 | BranchSharingPolicy.PUBLIC_OR_PROPRIETARY, admin) | 3287 | BranchSharingPolicy.PUBLIC_OR_PROPRIETARY, product.owner) |
269 | 3291 | with person_logged_in(product.owner): | ||
271 | 3292 | db_branch = self.factory.makeBranch(product=product) | 3288 | db_branch = self.factory.makeBranch(product=product) |
272 | 3293 | launchpad = launchpadlib_for('test', db_branch.owner, | 3289 | launchpad = launchpadlib_for('test', db_branch.owner, |
273 | 3294 | service_root=self.layer.appserver_root_url('api')) | 3290 | service_root=self.layer.appserver_root_url('api')) |
274 | 3295 | 3291 | ||
275 | === modified file 'lib/lp/code/model/tests/test_branchnamespace.py' | |||
276 | --- lib/lp/code/model/tests/test_branchnamespace.py 2012-08-20 13:26:21 +0000 | |||
277 | +++ lib/lp/code/model/tests/test_branchnamespace.py 2012-08-21 15:01:20 +0000 | |||
278 | @@ -53,7 +53,6 @@ | |||
279 | 53 | ) | 53 | ) |
280 | 54 | from lp.registry.interfaces.distribution import NoSuchDistribution | 54 | from lp.registry.interfaces.distribution import NoSuchDistribution |
281 | 55 | from lp.registry.interfaces.person import ( | 55 | from lp.registry.interfaces.person import ( |
282 | 56 | IPersonSet, | ||
283 | 57 | NoSuchPerson, | 56 | NoSuchPerson, |
284 | 58 | ) | 57 | ) |
285 | 59 | from lp.registry.interfaces.product import NoSuchProduct | 58 | from lp.registry.interfaces.product import NoSuchProduct |
286 | @@ -64,7 +63,6 @@ | |||
287 | 64 | TestCaseWithFactory, | 63 | TestCaseWithFactory, |
288 | 65 | ) | 64 | ) |
289 | 66 | from lp.testing.layers import DatabaseFunctionalLayer | 65 | from lp.testing.layers import DatabaseFunctionalLayer |
290 | 67 | from lp.testing.sampledata import COMMERCIAL_ADMIN_EMAIL | ||
291 | 68 | 66 | ||
292 | 69 | 67 | ||
293 | 70 | class NamespaceMixin: | 68 | class NamespaceMixin: |
294 | @@ -470,8 +468,7 @@ | |||
295 | 470 | person = self.factory.makePerson() | 468 | person = self.factory.makePerson() |
296 | 471 | product = self.factory.makeProduct() | 469 | product = self.factory.makeProduct() |
297 | 472 | self.factory.makeCommercialSubscription(product=product) | 470 | self.factory.makeCommercialSubscription(product=product) |
300 | 473 | comadmin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL) | 471 | product.setBranchSharingPolicy(sharing_policy, product.owner) |
299 | 474 | product.setBranchSharingPolicy(sharing_policy, comadmin) | ||
301 | 475 | namespace = ProductNamespace(person, product) | 472 | namespace = ProductNamespace(person, product) |
302 | 476 | return namespace | 473 | return namespace |
303 | 477 | 474 | ||
304 | 478 | 475 | ||
305 | === modified file 'lib/lp/registry/model/product.py' | |||
306 | --- lib/lp/registry/model/product.py 2012-08-20 13:26:21 +0000 | |||
307 | +++ lib/lp/registry/model/product.py 2012-08-21 15:01:20 +0000 | |||
308 | @@ -567,10 +567,6 @@ | |||
309 | 567 | 567 | ||
310 | 568 | def setBranchSharingPolicy(self, branch_sharing_policy, user): | 568 | def setBranchSharingPolicy(self, branch_sharing_policy, user): |
311 | 569 | """See `IProductPublic`.""" | 569 | """See `IProductPublic`.""" |
312 | 570 | if not user or not IPersonRoles(user).in_commercial_admin: | ||
313 | 571 | raise Unauthorized( | ||
314 | 572 | "Only commercial admins can configure sharing policies right " | ||
315 | 573 | "now.") | ||
316 | 574 | if branch_sharing_policy != BranchSharingPolicy.PUBLIC: | 570 | if branch_sharing_policy != BranchSharingPolicy.PUBLIC: |
317 | 575 | if not self.has_current_commercial_subscription: | 571 | if not self.has_current_commercial_subscription: |
318 | 576 | raise CommercialSubscribersOnly( | 572 | raise CommercialSubscribersOnly( |
319 | @@ -585,10 +581,6 @@ | |||
320 | 585 | 581 | ||
321 | 586 | def setBugSharingPolicy(self, bug_sharing_policy, user): | 582 | def setBugSharingPolicy(self, bug_sharing_policy, user): |
322 | 587 | """See `IProductPublic`.""" | 583 | """See `IProductPublic`.""" |
323 | 588 | if not user or not IPersonRoles(user).in_commercial_admin: | ||
324 | 589 | raise Unauthorized( | ||
325 | 590 | "Only commercial admins can configure sharing policies right " | ||
326 | 591 | "now.") | ||
327 | 592 | if bug_sharing_policy != BugSharingPolicy.PUBLIC: | 584 | if bug_sharing_policy != BugSharingPolicy.PUBLIC: |
328 | 593 | if not self.has_current_commercial_subscription: | 585 | if not self.has_current_commercial_subscription: |
329 | 594 | raise CommercialSubscribersOnly( | 586 | raise CommercialSubscribersOnly( |
330 | 595 | 587 | ||
331 | === modified file 'lib/lp/registry/tests/test_product.py' | |||
332 | --- lib/lp/registry/tests/test_product.py 2012-08-20 13:26:21 +0000 | |||
333 | +++ lib/lp/registry/tests/test_product.py 2012-08-21 15:01:20 +0000 | |||
334 | @@ -45,7 +45,6 @@ | |||
335 | 45 | IAccessPolicySource, | 45 | IAccessPolicySource, |
336 | 46 | ) | 46 | ) |
337 | 47 | from lp.registry.interfaces.oopsreferences import IHasOOPSReferences | 47 | from lp.registry.interfaces.oopsreferences import IHasOOPSReferences |
338 | 48 | from lp.registry.interfaces.person import IPersonSet | ||
339 | 49 | from lp.registry.interfaces.product import ( | 48 | from lp.registry.interfaces.product import ( |
340 | 50 | IProduct, | 49 | IProduct, |
341 | 51 | IProductSet, | 50 | IProductSet, |
342 | @@ -81,7 +80,6 @@ | |||
343 | 81 | get_feedback_messages, | 80 | get_feedback_messages, |
344 | 82 | setupBrowser, | 81 | setupBrowser, |
345 | 83 | ) | 82 | ) |
346 | 84 | from lp.testing.sampledata import COMMERCIAL_ADMIN_EMAIL | ||
347 | 85 | from lp.translations.enums import TranslationPermission | 83 | from lp.translations.enums import TranslationPermission |
348 | 86 | from lp.translations.interfaces.customlanguagecode import ( | 84 | from lp.translations.interfaces.customlanguagecode import ( |
349 | 87 | IHasCustomLanguageCodes, | 85 | IHasCustomLanguageCodes, |
350 | @@ -388,8 +386,7 @@ | |||
351 | 388 | def makeProductWithPolicy(self, bug_sharing_policy, private_bugs=False): | 386 | def makeProductWithPolicy(self, bug_sharing_policy, private_bugs=False): |
352 | 389 | product = self.factory.makeProduct(private_bugs=private_bugs) | 387 | product = self.factory.makeProduct(private_bugs=private_bugs) |
353 | 390 | self.factory.makeCommercialSubscription(product=product) | 388 | self.factory.makeCommercialSubscription(product=product) |
356 | 391 | comadmin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL) | 389 | product.setBugSharingPolicy(bug_sharing_policy, product.owner) |
355 | 392 | product.setBugSharingPolicy(bug_sharing_policy, comadmin) | ||
357 | 393 | return product | 390 | return product |
358 | 394 | 391 | ||
359 | 395 | def test_no_policy(self): | 392 | def test_no_policy(self): |
360 | 396 | 393 | ||
361 | === modified file 'lib/lp/registry/tests/test_product_webservice.py' | |||
362 | --- lib/lp/registry/tests/test_product_webservice.py 2012-08-10 06:40:08 +0000 | |||
363 | +++ lib/lp/registry/tests/test_product_webservice.py 2012-08-21 15:01:20 +0000 | |||
364 | @@ -57,8 +57,7 @@ | |||
365 | 57 | product = self.factory.makeProduct() | 57 | product = self.factory.makeProduct() |
366 | 58 | self.factory.makeCommercialSubscription(product=product) | 58 | self.factory.makeCommercialSubscription(product=product) |
367 | 59 | webservice = webservice_for_person( | 59 | webservice = webservice_for_person( |
370 | 60 | self.factory.makeCommercialAdmin(), | 60 | product.owner, permission=OAuthPermission.WRITE_PRIVATE) |
369 | 61 | permission=OAuthPermission.WRITE_PRIVATE) | ||
371 | 62 | response = self.patch( | 61 | response = self.patch( |
372 | 63 | webservice, product, branch_sharing_policy='Proprietary') | 62 | webservice, product, branch_sharing_policy='Proprietary') |
373 | 64 | self.assertEqual(209, response.status) | 63 | self.assertEqual(209, response.status) |
374 | @@ -80,27 +79,12 @@ | |||
375 | 80 | 'proprietary branches.'))) | 79 | 'proprietary branches.'))) |
376 | 81 | self.assertIs(None, product.branch_sharing_policy) | 80 | self.assertIs(None, product.branch_sharing_policy) |
377 | 82 | 81 | ||
378 | 83 | def test_branch_sharing_policy_random_user(self): | ||
379 | 84 | # Arbitrary users can't set branch_sharing_policy. | ||
380 | 85 | product = self.factory.makeProduct() | ||
381 | 86 | webservice = webservice_for_person( | ||
382 | 87 | self.factory.makePerson(), | ||
383 | 88 | permission=OAuthPermission.WRITE_PRIVATE) | ||
384 | 89 | response = self.patch( | ||
385 | 90 | webservice, product, branch_sharing_policy='Proprietary') | ||
386 | 91 | self.assertThat(response, MatchesStructure.byEquality( | ||
387 | 92 | status=401, | ||
388 | 93 | body=('Only commercial admins can configure sharing policies ' | ||
389 | 94 | 'right now.'))) | ||
390 | 95 | self.assertIs(None, product.branch_sharing_policy) | ||
391 | 96 | |||
392 | 97 | def test_bug_sharing_policy_can_be_set(self): | 82 | def test_bug_sharing_policy_can_be_set(self): |
393 | 98 | # bug_sharing_policy can be set via the API. | 83 | # bug_sharing_policy can be set via the API. |
394 | 99 | product = self.factory.makeProduct() | 84 | product = self.factory.makeProduct() |
395 | 100 | self.factory.makeCommercialSubscription(product=product) | 85 | self.factory.makeCommercialSubscription(product=product) |
396 | 101 | webservice = webservice_for_person( | 86 | webservice = webservice_for_person( |
399 | 102 | self.factory.makeCommercialAdmin(), | 87 | product.owner, permission=OAuthPermission.WRITE_PRIVATE) |
398 | 103 | permission=OAuthPermission.WRITE_PRIVATE) | ||
400 | 104 | response = self.patch( | 88 | response = self.patch( |
401 | 105 | webservice, product, bug_sharing_policy='Proprietary') | 89 | webservice, product, bug_sharing_policy='Proprietary') |
402 | 106 | self.assertEqual(209, response.status) | 90 | self.assertEqual(209, response.status) |
403 | @@ -121,17 +105,3 @@ | |||
404 | 121 | body=('A current commercial subscription is required to use ' | 105 | body=('A current commercial subscription is required to use ' |
405 | 122 | 'proprietary bugs.'))) | 106 | 'proprietary bugs.'))) |
406 | 123 | self.assertIs(None, product.bug_sharing_policy) | 107 | self.assertIs(None, product.bug_sharing_policy) |
407 | 124 | |||
408 | 125 | def test_bug_sharing_policy_random_user(self): | ||
409 | 126 | # Arbitrary users can't set bug_sharing_policy. | ||
410 | 127 | product = self.factory.makeProduct() | ||
411 | 128 | webservice = webservice_for_person( | ||
412 | 129 | self.factory.makePerson(), | ||
413 | 130 | permission=OAuthPermission.WRITE_PRIVATE) | ||
414 | 131 | response = self.patch( | ||
415 | 132 | webservice, product, bug_sharing_policy='Proprietary') | ||
416 | 133 | self.assertThat(response, MatchesStructure.byEquality( | ||
417 | 134 | status=401, | ||
418 | 135 | body=('Only commercial admins can configure sharing policies ' | ||
419 | 136 | 'right now.'))) | ||
420 | 137 | self.assertIs(None, product.bug_sharing_policy) | ||
421 | 138 | 108 | ||
422 | === modified file 'lib/lp/soyuz/tests/test_archive.py' | |||
423 | --- lib/lp/soyuz/tests/test_archive.py 2012-08-20 14:31:11 +0000 | |||
424 | +++ lib/lp/soyuz/tests/test_archive.py 2012-08-21 15:01:20 +0000 | |||
425 | @@ -98,7 +98,6 @@ | |||
426 | 98 | LaunchpadFunctionalLayer, | 98 | LaunchpadFunctionalLayer, |
427 | 99 | LaunchpadZopelessLayer, | 99 | LaunchpadZopelessLayer, |
428 | 100 | ) | 100 | ) |
429 | 101 | from lp.testing.sampledata import COMMERCIAL_ADMIN_EMAIL | ||
430 | 102 | 101 | ||
431 | 103 | 102 | ||
432 | 104 | class TestGetPublicationsInArchive(TestCaseWithFactory): | 103 | class TestGetPublicationsInArchive(TestCaseWithFactory): |
433 | @@ -1405,9 +1404,9 @@ | |||
434 | 1405 | 1404 | ||
435 | 1406 | def test_commercial_admin_can_set_build_debug_symbols(self): | 1405 | def test_commercial_admin_can_set_build_debug_symbols(self): |
436 | 1407 | # A commercial admin can set it. | 1406 | # A commercial admin can set it. |
440 | 1408 | login(COMMERCIAL_ADMIN_EMAIL) | 1407 | with celebrity_logged_in('commercial_admin'): |
441 | 1409 | self.setBuildDebugSymbols(self.archive, True) | 1408 | self.setBuildDebugSymbols(self.archive, True) |
442 | 1410 | self.assertTrue(self.archive.build_debug_symbols) | 1409 | self.assertTrue(self.archive.build_debug_symbols) |
443 | 1411 | 1410 | ||
444 | 1412 | 1411 | ||
445 | 1413 | class TestAddArchiveDependencies(TestCaseWithFactory): | 1412 | class TestAddArchiveDependencies(TestCaseWithFactory): |
446 | 1414 | 1413 | ||
447 | === modified file 'lib/lp/testing/sampledata.py' | |||
448 | --- lib/lp/testing/sampledata.py 2010-10-18 10:24:38 +0000 | |||
449 | +++ lib/lp/testing/sampledata.py 2012-08-21 15:01:20 +0000 | |||
450 | @@ -13,7 +13,6 @@ | |||
451 | 13 | 'BOB_THE_BUILDER_NAME', | 13 | 'BOB_THE_BUILDER_NAME', |
452 | 14 | 'BUILDD_ADMIN_USERNAME', | 14 | 'BUILDD_ADMIN_USERNAME', |
453 | 15 | 'CHROOT_LIBRARYFILEALIAS', | 15 | 'CHROOT_LIBRARYFILEALIAS', |
454 | 16 | 'COMMERCIAL_ADMIN_EMAIL', | ||
455 | 17 | 'FROG_THE_BUILDER_NAME', | 16 | 'FROG_THE_BUILDER_NAME', |
456 | 18 | 'HOARY_DISTROSERIES_NAME', | 17 | 'HOARY_DISTROSERIES_NAME', |
457 | 19 | 'I386_ARCHITECTURE_NAME', | 18 | 'I386_ARCHITECTURE_NAME', |
458 | @@ -25,7 +24,6 @@ | |||
459 | 25 | 'UBUNTU_DEVELOPER_ADMIN_NAME', | 24 | 'UBUNTU_DEVELOPER_ADMIN_NAME', |
460 | 26 | 'UBUNTU_DISTRIBUTION_NAME', | 25 | 'UBUNTU_DISTRIBUTION_NAME', |
461 | 27 | 'UBUNTU_UPLOAD_TEAM_NAME', | 26 | 'UBUNTU_UPLOAD_TEAM_NAME', |
462 | 28 | 'UBUNTUTEST_DISTRIBUTION_NAME', | ||
463 | 29 | 'USER_EMAIL', | 27 | 'USER_EMAIL', |
464 | 30 | 'WARTY_DISTROSERIES_NAME', | 28 | 'WARTY_DISTROSERIES_NAME', |
465 | 31 | 'WARTY_ONLY_SOURCEPACKAGENAME', | 29 | 'WARTY_ONLY_SOURCEPACKAGENAME', |
466 | @@ -57,7 +55,6 @@ | |||
467 | 57 | NO_PRIVILEGE_EMAIL = 'no-priv@canonical.com' | 55 | NO_PRIVILEGE_EMAIL = 'no-priv@canonical.com' |
468 | 58 | USER_EMAIL = 'test@canonical.com' | 56 | USER_EMAIL = 'test@canonical.com' |
469 | 59 | VCS_IMPORTS_MEMBER_EMAIL = 'david.allouche@canonical.com' | 57 | VCS_IMPORTS_MEMBER_EMAIL = 'david.allouche@canonical.com' |
470 | 60 | COMMERCIAL_ADMIN_EMAIL = 'commercial-member@canonical.com' | ||
471 | 61 | SAMPLE_PERSON_EMAIL = USER_EMAIL | 58 | SAMPLE_PERSON_EMAIL = USER_EMAIL |
472 | 62 | # A user that is an admin of ubuntu-team, which has upload rights | 59 | # A user that is an admin of ubuntu-team, which has upload rights |
473 | 63 | # to Ubuntu. | 60 | # to Ubuntu. |
This can't land before <https:/ /code.launchpad .net/~sinzui/ launchpad/ commercial- admin-sharing/ +merge/ 120464>, as in this branch there's no access check at all on setBugSharingPolicy or setBranchSharin gPolicy. If your new permission from the other branch is sufficient, perhaps remove the unused user argument from setFooSharingPo licy.