Merge lp:~sinzui/launchpad/entitle-branch-sharing into lp:launchpad

Proposed by Curtis Hovey
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
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 setBranchSharingPolicy().

Description of the change

Launchpad must let users reconfigure their projects to use sharing
which enters beta next week.

--------------------------------------------------------------------

RULES

    Pre-implementation: wgrant
    * Remove the guard in setBranchSharingPolicy() that enforces the
      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://qastaging.launchpad.net/lp-dev-utils/+sharing
    * Verify you can change the branch sharing policy.

LINT

    lib/lp/code/browser/tests/test_branch.py
    lib/lp/code/model/tests/test_branch.py
    lib/lp/code/model/tests/test_branchnamespace.py
    lib/lp/registry/model/product.py

TEST

    ./bin/test -vvc -t transitionToInformationType -t methods_smoketest lp.code.model.tests.test_branch
    ./bin/test -vvc -t WithInformationType lp.code.model.tests.test_branchnamespace
    ./bin/test -vvc -t EditViewInformationTypes lp.code.browser.tests.test_branch

IMPLEMENTATION

Remove the commerncial admin guard from setBranchSharingPolicy().
    lib/lp/registry/model/product.py

Update tests to use the project owner instead of a commecial admin to
setup the test conditions.
    lib/lp/code/browser/tests/test_branch.py
    lib/lp/code/model/tests/test_branch.py
    lib/lp/code/model/tests/test_branchnamespace.py

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

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 setBranchSharingPolicy. If your new permission from the other branch is sufficient, perhaps remove the unused user argument from setFooSharingPolicy.

review: Approve (code)
Revision history for this message
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?

Revision history for this message
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

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/bugs/browser/tests/test_bugs.py'
--- lib/lp/bugs/browser/tests/test_bugs.py 2012-08-20 13:12:45 +0000
+++ lib/lp/bugs/browser/tests/test_bugs.py 2012-08-21 15:01:20 +0000
@@ -16,7 +16,6 @@
16 BugSharingPolicy,16 BugSharingPolicy,
17 InformationType,17 InformationType,
18 )18 )
19from lp.registry.interfaces.person import IPersonSet
20from lp.registry.interfaces.product import License19from lp.registry.interfaces.product import License
21from lp.services.webapp.publisher import canonical_url20from lp.services.webapp.publisher import canonical_url
22from lp.testing import (21from lp.testing import (
@@ -28,7 +27,6 @@
28 )27 )
29from lp.testing.layers import DatabaseFunctionalLayer28from lp.testing.layers import DatabaseFunctionalLayer
30from lp.testing.pages import find_tag_by_id29from lp.testing.pages import find_tag_by_id
31from lp.testing.sampledata import COMMERCIAL_ADMIN_EMAIL
32from lp.testing.views import create_initialized_view30from lp.testing.views import create_initialized_view
3331
3432
@@ -184,9 +182,8 @@
184 # createBug() does not adapt the default kwargs when they are none.182 # createBug() does not adapt the default kwargs when they are none.
185 project = self.factory.makeProduct(183 project = self.factory.makeProduct(
186 licenses=[License.OTHER_PROPRIETARY])184 licenses=[License.OTHER_PROPRIETARY])
187 comadmin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL)
188 project.setBugSharingPolicy(185 project.setBugSharingPolicy(
189 BugSharingPolicy.PROPRIETARY_OR_PUBLIC, comadmin)186 BugSharingPolicy.PROPRIETARY_OR_PUBLIC, project.owner)
190 bug = self.application.createBug(187 bug = self.application.createBug(
191 project.owner, 'title', 'description', project)188 project.owner, 'title', 'description', project)
192 self.assertEqual(InformationType.PROPRIETARY, bug.information_type)189 self.assertEqual(InformationType.PROPRIETARY, bug.information_type)
@@ -195,9 +192,8 @@
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.
196 project = self.factory.makeProduct(193 project = self.factory.makeProduct(
197 licenses=[License.OTHER_PROPRIETARY])194 licenses=[License.OTHER_PROPRIETARY])
198 comadmin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL)
199 project.setBugSharingPolicy(195 project.setBugSharingPolicy(
200 BugSharingPolicy.PROPRIETARY_OR_PUBLIC, comadmin)196 BugSharingPolicy.PROPRIETARY_OR_PUBLIC, project.owner)
201 bug = self.application.createBug(197 bug = self.application.createBug(
202 project.owner, 'title', 'description', project, private=False)198 project.owner, 'title', 'description', project, private=False)
203 self.assertEqual(InformationType.PUBLIC, bug.information_type)199 self.assertEqual(InformationType.PUBLIC, bug.information_type)
204200
=== modified file 'lib/lp/bugs/browser/tests/test_bugtarget_filebug.py'
--- lib/lp/bugs/browser/tests/test_bugtarget_filebug.py 2012-08-20 13:26:21 +0000
+++ lib/lp/bugs/browser/tests/test_bugtarget_filebug.py 2012-08-21 15:01:20 +0000
@@ -29,7 +29,6 @@
29 InformationType,29 InformationType,
30 PRIVATE_INFORMATION_TYPES,30 PRIVATE_INFORMATION_TYPES,
31 )31 )
32from lp.registry.interfaces.person import IPersonSet
33from lp.registry.interfaces.projectgroup import IProjectGroup32from lp.registry.interfaces.projectgroup import IProjectGroup
34from lp.services.webapp.servers import LaunchpadTestRequest33from lp.services.webapp.servers import LaunchpadTestRequest
35from lp.testing import (34from lp.testing import (
@@ -43,7 +42,6 @@
43 find_main_content,42 find_main_content,
44 find_tag_by_id,43 find_tag_by_id,
45 )44 )
46from lp.testing.sampledata import COMMERCIAL_ADMIN_EMAIL
47from lp.testing.views import (45from lp.testing.views import (
48 create_initialized_view,46 create_initialized_view,
49 create_view,47 create_view,
@@ -369,9 +367,7 @@
369 removeSecurityProxy(product).private_bugs = True367 removeSecurityProxy(product).private_bugs = True
370 if bug_sharing_policy:368 if bug_sharing_policy:
371 self.factory.makeCommercialSubscription(product=product)369 self.factory.makeCommercialSubscription(product=product)
372 comadmin = getUtility(IPersonSet).getByEmail(370 product.setBugSharingPolicy(bug_sharing_policy, product.owner)
373 COMMERCIAL_ADMIN_EMAIL)
374 product.setBugSharingPolicy(bug_sharing_policy, comadmin)
375 with person_logged_in(product.owner):371 with person_logged_in(product.owner):
376 view = create_view(372 view = create_view(
377 product, '+filebug', method='POST', form=form,373 product, '+filebug', method='POST', form=form,
@@ -447,8 +443,8 @@
447 # correctly for a project with a proprietary sharing policy.443 # correctly for a project with a proprietary sharing policy.
448 product = self.factory.makeProduct(official_malone=True)444 product = self.factory.makeProduct(official_malone=True)
449 self.factory.makeCommercialSubscription(product=product)445 self.factory.makeCommercialSubscription(product=product)
450 comadmin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL)446 product.setBugSharingPolicy(
451 product.setBugSharingPolicy(BugSharingPolicy.PROPRIETARY, comadmin)447 BugSharingPolicy.PROPRIETARY, product.owner)
452 with person_logged_in(product.owner):448 with person_logged_in(product.owner):
453 view = create_initialized_view(449 view = create_initialized_view(
454 product, '+filebug', principal=product.owner)450 product, '+filebug', principal=product.owner)
@@ -499,9 +495,7 @@
499 removeSecurityProxy(product).private_bugs = True495 removeSecurityProxy(product).private_bugs = True
500 if bug_sharing_policy:496 if bug_sharing_policy:
501 self.factory.makeCommercialSubscription(product=product)497 self.factory.makeCommercialSubscription(product=product)
502 comadmin = getUtility(IPersonSet).getByEmail(498 product.setBugSharingPolicy(bug_sharing_policy, product.owner)
503 COMMERCIAL_ADMIN_EMAIL)
504 product.setBugSharingPolicy(bug_sharing_policy, comadmin)
505 anyone = self.factory.makePerson()499 anyone = self.factory.makePerson()
506 with person_logged_in(anyone):500 with person_logged_in(anyone):
507 view = create_initialized_view(501 view = create_initialized_view(
508502
=== modified file 'lib/lp/bugs/mail/tests/test_handler.py'
--- lib/lp/bugs/mail/tests/test_handler.py 2012-08-20 13:12:45 +0000
+++ lib/lp/bugs/mail/tests/test_handler.py 2012-08-21 15:01:20 +0000
@@ -32,7 +32,6 @@
32 BugSharingPolicy,32 BugSharingPolicy,
33 InformationType,33 InformationType,
34 )34 )
35from lp.registry.interfaces.person import IPersonSet
36from lp.services.config import config35from lp.services.config import config
37from lp.services.identity.interfaces.emailaddress import EmailAddressStatus36from lp.services.identity.interfaces.emailaddress import EmailAddressStatus
38from lp.services.mail import stub37from lp.services.mail import stub
@@ -52,7 +51,6 @@
52 LaunchpadZopelessLayer,51 LaunchpadZopelessLayer,
53 )52 )
54from lp.testing.mail_helpers import pop_notifications53from lp.testing.mail_helpers import pop_notifications
55from lp.testing.sampledata import COMMERCIAL_ADMIN_EMAIL
5654
5755
58class TestMaloneHandler(TestCaseWithFactory):56class TestMaloneHandler(TestCaseWithFactory):
@@ -261,8 +259,8 @@
261 def test_new_bug_with_sharing_policy_proprietary(self):259 def test_new_bug_with_sharing_policy_proprietary(self):
262 project = self.factory.makeProduct(name='fnord')260 project = self.factory.makeProduct(name='fnord')
263 self.factory.makeCommercialSubscription(product=project)261 self.factory.makeCommercialSubscription(product=project)
264 comadmin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL)262 project.setBugSharingPolicy(
265 project.setBugSharingPolicy(BugSharingPolicy.PROPRIETARY, comadmin)263 BugSharingPolicy.PROPRIETARY, project.owner)
266 transaction.commit()264 transaction.commit()
267 handler = MaloneHandler()265 handler = MaloneHandler()
268 with person_logged_in(project.owner):266 with person_logged_in(project.owner):
269267
=== modified file 'lib/lp/bugs/tests/test_bugs_webservice.py'
--- lib/lp/bugs/tests/test_bugs_webservice.py 2012-08-20 13:12:45 +0000
+++ lib/lp/bugs/tests/test_bugs_webservice.py 2012-08-21 15:01:20 +0000
@@ -21,7 +21,6 @@
21 )21 )
22from zope.component import (22from zope.component import (
23 getMultiAdapter,23 getMultiAdapter,
24 getUtility,
25 )24 )
2625
27from lp.bugs.browser.bugtask import get_comments_for_bugtask26from lp.bugs.browser.bugtask import get_comments_for_bugtask
@@ -30,7 +29,6 @@
30 BugSharingPolicy,29 BugSharingPolicy,
31 InformationType,30 InformationType,
32 )31 )
33from lp.registry.interfaces.person import IPersonSet
34from lp.registry.interfaces.product import License32from lp.registry.interfaces.product import License
35from lp.services.webapp import snapshot33from lp.services.webapp import snapshot
36from lp.services.webapp.servers import LaunchpadTestRequest34from lp.services.webapp.servers import LaunchpadTestRequest
@@ -52,7 +50,6 @@
52from lp.testing.pages import LaunchpadWebServiceCaller50from lp.testing.pages import LaunchpadWebServiceCaller
53from lp.testing.sampledata import (51from lp.testing.sampledata import (
54 ADMIN_EMAIL,52 ADMIN_EMAIL,
55 COMMERCIAL_ADMIN_EMAIL,
56 USER_EMAIL,53 USER_EMAIL,
57 )54 )
5855
@@ -414,9 +411,8 @@
414 # to the project's bug sharing policy.411 # to the project's bug sharing policy.
415 project = self.factory.makeProduct(412 project = self.factory.makeProduct(
416 licenses=[License.OTHER_PROPRIETARY])413 licenses=[License.OTHER_PROPRIETARY])
417 comadmin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL)
418 project.setBugSharingPolicy(414 project.setBugSharingPolicy(
419 BugSharingPolicy.PROPRIETARY_OR_PUBLIC, comadmin)415 BugSharingPolicy.PROPRIETARY_OR_PUBLIC, project.owner)
420 webservice = launchpadlib_for('test', 'salgado')416 webservice = launchpadlib_for('test', 'salgado')
421 bugs_collection = webservice.load('/bugs')417 bugs_collection = webservice.load('/bugs')
422 bug = bugs_collection.createBug(418 bug = bugs_collection.createBug(
423419
=== modified file 'lib/lp/code/browser/tests/test_branch.py'
--- lib/lp/code/browser/tests/test_branch.py 2012-08-16 06:24:32 +0000
+++ lib/lp/code/browser/tests/test_branch.py 2012-08-21 15:01:20 +0000
@@ -41,7 +41,6 @@
41 )41 )
42from lp.registry.interfaces.accesspolicy import IAccessPolicySource42from lp.registry.interfaces.accesspolicy import IAccessPolicySource
43from lp.registry.interfaces.person import (43from lp.registry.interfaces.person import (
44 IPersonSet,
45 PersonVisibility,44 PersonVisibility,
46 )45 )
47from lp.services.config import config46from lp.services.config import config
@@ -72,7 +71,6 @@
72 setupBrowser,71 setupBrowser,
73 setupBrowserForUser,72 setupBrowserForUser,
74 )73 )
75from lp.testing.sampledata import COMMERCIAL_ADMIN_EMAIL
76from lp.testing.views import create_initialized_view74from lp.testing.views import create_initialized_view
7775
7876
@@ -1086,10 +1084,9 @@
1086 owner = self.factory.makePerson()1084 owner = self.factory.makePerson()
1087 product = self.factory.makeProduct(owner=owner)1085 product = self.factory.makeProduct(owner=owner)
1088 self.factory.makeCommercialSubscription(product=product)1086 self.factory.makeCommercialSubscription(product=product)
1089 comadmin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL)
1090 product.setBranchSharingPolicy(
1091 BranchSharingPolicy.EMBARGOED_OR_PROPRIETARY, comadmin)
1092 with person_logged_in(owner):1087 with person_logged_in(owner):
1088 product.setBranchSharingPolicy(
1089 BranchSharingPolicy.EMBARGOED_OR_PROPRIETARY, owner)
1093 branch = self.factory.makeBranch(1090 branch = self.factory.makeBranch(
1094 product=product, owner=owner,1091 product=product, owner=owner,
1095 information_type=InformationType.PROPRIETARY)1092 information_type=InformationType.PROPRIETARY)
@@ -1102,10 +1099,9 @@
1102 owner = self.factory.makePerson()1099 owner = self.factory.makePerson()
1103 product = self.factory.makeProduct(owner=owner)1100 product = self.factory.makeProduct(owner=owner)
1104 self.factory.makeCommercialSubscription(product=product)1101 self.factory.makeCommercialSubscription(product=product)
1105 comadmin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL)
1106 product.setBranchSharingPolicy(
1107 BranchSharingPolicy.PROPRIETARY, comadmin)
1108 with person_logged_in(owner):1102 with person_logged_in(owner):
1103 product.setBranchSharingPolicy(
1104 BranchSharingPolicy.PROPRIETARY, owner)
1109 branch = self.factory.makeBranch(1105 branch = self.factory.makeBranch(
1110 product=product, owner=owner,1106 product=product, owner=owner,
1111 information_type=InformationType.PROPRIETARY)1107 information_type=InformationType.PROPRIETARY)
11121108
=== modified file 'lib/lp/code/browser/tests/test_branchlisting.py'
--- lib/lp/code/browser/tests/test_branchlisting.py 2012-08-14 23:27:07 +0000
+++ lib/lp/code/browser/tests/test_branchlisting.py 2012-08-21 15:01:20 +0000
@@ -46,6 +46,7 @@
46from lp.services.webapp.servers import LaunchpadTestRequest46from lp.services.webapp.servers import LaunchpadTestRequest
47from lp.testing import (47from lp.testing import (
48 BrowserTestCase,48 BrowserTestCase,
49 celebrity_logged_in,
49 login_person,50 login_person,
50 normalize_whitespace,51 normalize_whitespace,
51 person_logged_in,52 person_logged_in,
@@ -66,7 +67,6 @@
66 )67 )
67from lp.testing.sampledata import (68from lp.testing.sampledata import (
68 ADMIN_EMAIL,69 ADMIN_EMAIL,
69 COMMERCIAL_ADMIN_EMAIL,
70 )70 )
71from lp.testing.views import (71from lp.testing.views import (
72 create_initialized_view,72 create_initialized_view,
@@ -752,8 +752,8 @@
752 def test_branch_visibility_link_commercial_admin(self):752 def test_branch_visibility_link_commercial_admin(self):
753 # A commercial admin will be displayed a link to define branch753 # A commercial admin will be displayed a link to define branch
754 # visibility in the action portlet.754 # visibility in the action portlet.
755 admin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL)755 with celebrity_logged_in('commercial_admin') as admin:
756 self._testBranchVisibilityLink(admin)756 self._testBranchVisibilityLink(admin)
757757
758 def test_branch_visibility_link_non_admin(self):758 def test_branch_visibility_link_non_admin(self):
759 # A non-admin will not see the action portlet.759 # A non-admin will not see the action portlet.
760760
=== modified file 'lib/lp/code/model/tests/test_branch.py'
--- lib/lp/code/model/tests/test_branch.py 2012-08-20 14:03:01 +0000
+++ lib/lp/code/model/tests/test_branch.py 2012-08-21 15:01:20 +0000
@@ -2601,10 +2601,9 @@
2601 def test_methods_smoketest(self):2601 def test_methods_smoketest(self):
2602 # Users with launchpad.Moderate can call transitionToInformationType.2602 # Users with launchpad.Moderate can call transitionToInformationType.
2603 branch = self.factory.makeProductBranch()2603 branch = self.factory.makeProductBranch()
2604 with celebrity_logged_in('commercial_admin') as admin:2604 with person_logged_in(branch.product.owner):
2605 branch.product.setBranchSharingPolicy(2605 branch.product.setBranchSharingPolicy(
2606 BranchSharingPolicy.PUBLIC, admin)2606 BranchSharingPolicy.PUBLIC, branch.product.owner)
2607 with person_logged_in(branch.product.owner):
2608 branch.transitionToInformationType(2607 branch.transitionToInformationType(
2609 InformationType.PRIVATESECURITY, branch.product.owner)2608 InformationType.PRIVATESECURITY, branch.product.owner)
2610 self.assertEqual(2609 self.assertEqual(
@@ -3283,12 +3282,9 @@
3283 """Test transitionToInformationType() API arguments."""3282 """Test transitionToInformationType() API arguments."""
3284 product = self.factory.makeProduct()3283 product = self.factory.makeProduct()
3285 self.factory.makeCommercialSubscription(product)3284 self.factory.makeCommercialSubscription(product)
3286 with celebrity_logged_in('commercial_admin') as admin:3285 with person_logged_in(product.owner):
3287 # XXX sinzui 2012-08-16: setBranchSharingPolicy() is guarded
3288 # at this moment.
3289 product.setBranchSharingPolicy(3286 product.setBranchSharingPolicy(
3290 BranchSharingPolicy.PUBLIC_OR_PROPRIETARY, admin)3287 BranchSharingPolicy.PUBLIC_OR_PROPRIETARY, product.owner)
3291 with person_logged_in(product.owner):
3292 db_branch = self.factory.makeBranch(product=product)3288 db_branch = self.factory.makeBranch(product=product)
3293 launchpad = launchpadlib_for('test', db_branch.owner,3289 launchpad = launchpadlib_for('test', db_branch.owner,
3294 service_root=self.layer.appserver_root_url('api'))3290 service_root=self.layer.appserver_root_url('api'))
32953291
=== modified file 'lib/lp/code/model/tests/test_branchnamespace.py'
--- lib/lp/code/model/tests/test_branchnamespace.py 2012-08-20 13:26:21 +0000
+++ lib/lp/code/model/tests/test_branchnamespace.py 2012-08-21 15:01:20 +0000
@@ -53,7 +53,6 @@
53 )53 )
54from lp.registry.interfaces.distribution import NoSuchDistribution54from lp.registry.interfaces.distribution import NoSuchDistribution
55from lp.registry.interfaces.person import (55from lp.registry.interfaces.person import (
56 IPersonSet,
57 NoSuchPerson,56 NoSuchPerson,
58 )57 )
59from lp.registry.interfaces.product import NoSuchProduct58from lp.registry.interfaces.product import NoSuchProduct
@@ -64,7 +63,6 @@
64 TestCaseWithFactory,63 TestCaseWithFactory,
65 )64 )
66from lp.testing.layers import DatabaseFunctionalLayer65from lp.testing.layers import DatabaseFunctionalLayer
67from lp.testing.sampledata import COMMERCIAL_ADMIN_EMAIL
6866
6967
70class NamespaceMixin:68class NamespaceMixin:
@@ -470,8 +468,7 @@
470 person = self.factory.makePerson()468 person = self.factory.makePerson()
471 product = self.factory.makeProduct()469 product = self.factory.makeProduct()
472 self.factory.makeCommercialSubscription(product=product)470 self.factory.makeCommercialSubscription(product=product)
473 comadmin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL)471 product.setBranchSharingPolicy(sharing_policy, product.owner)
474 product.setBranchSharingPolicy(sharing_policy, comadmin)
475 namespace = ProductNamespace(person, product)472 namespace = ProductNamespace(person, product)
476 return namespace473 return namespace
477474
478475
=== modified file 'lib/lp/registry/model/product.py'
--- lib/lp/registry/model/product.py 2012-08-20 13:26:21 +0000
+++ lib/lp/registry/model/product.py 2012-08-21 15:01:20 +0000
@@ -567,10 +567,6 @@
567567
568 def setBranchSharingPolicy(self, branch_sharing_policy, user):568 def setBranchSharingPolicy(self, branch_sharing_policy, user):
569 """See `IProductPublic`."""569 """See `IProductPublic`."""
570 if not user or not IPersonRoles(user).in_commercial_admin:
571 raise Unauthorized(
572 "Only commercial admins can configure sharing policies right "
573 "now.")
574 if branch_sharing_policy != BranchSharingPolicy.PUBLIC:570 if branch_sharing_policy != BranchSharingPolicy.PUBLIC:
575 if not self.has_current_commercial_subscription:571 if not self.has_current_commercial_subscription:
576 raise CommercialSubscribersOnly(572 raise CommercialSubscribersOnly(
@@ -585,10 +581,6 @@
585581
586 def setBugSharingPolicy(self, bug_sharing_policy, user):582 def setBugSharingPolicy(self, bug_sharing_policy, user):
587 """See `IProductPublic`."""583 """See `IProductPublic`."""
588 if not user or not IPersonRoles(user).in_commercial_admin:
589 raise Unauthorized(
590 "Only commercial admins can configure sharing policies right "
591 "now.")
592 if bug_sharing_policy != BugSharingPolicy.PUBLIC:584 if bug_sharing_policy != BugSharingPolicy.PUBLIC:
593 if not self.has_current_commercial_subscription:585 if not self.has_current_commercial_subscription:
594 raise CommercialSubscribersOnly(586 raise CommercialSubscribersOnly(
595587
=== modified file 'lib/lp/registry/tests/test_product.py'
--- lib/lp/registry/tests/test_product.py 2012-08-20 13:26:21 +0000
+++ lib/lp/registry/tests/test_product.py 2012-08-21 15:01:20 +0000
@@ -45,7 +45,6 @@
45 IAccessPolicySource,45 IAccessPolicySource,
46 )46 )
47from lp.registry.interfaces.oopsreferences import IHasOOPSReferences47from lp.registry.interfaces.oopsreferences import IHasOOPSReferences
48from lp.registry.interfaces.person import IPersonSet
49from lp.registry.interfaces.product import (48from lp.registry.interfaces.product import (
50 IProduct,49 IProduct,
51 IProductSet,50 IProductSet,
@@ -81,7 +80,6 @@
81 get_feedback_messages,80 get_feedback_messages,
82 setupBrowser,81 setupBrowser,
83 )82 )
84from lp.testing.sampledata import COMMERCIAL_ADMIN_EMAIL
85from lp.translations.enums import TranslationPermission83from lp.translations.enums import TranslationPermission
86from lp.translations.interfaces.customlanguagecode import (84from lp.translations.interfaces.customlanguagecode import (
87 IHasCustomLanguageCodes,85 IHasCustomLanguageCodes,
@@ -388,8 +386,7 @@
388 def makeProductWithPolicy(self, bug_sharing_policy, private_bugs=False):386 def makeProductWithPolicy(self, bug_sharing_policy, private_bugs=False):
389 product = self.factory.makeProduct(private_bugs=private_bugs)387 product = self.factory.makeProduct(private_bugs=private_bugs)
390 self.factory.makeCommercialSubscription(product=product)388 self.factory.makeCommercialSubscription(product=product)
391 comadmin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL)389 product.setBugSharingPolicy(bug_sharing_policy, product.owner)
392 product.setBugSharingPolicy(bug_sharing_policy, comadmin)
393 return product390 return product
394391
395 def test_no_policy(self):392 def test_no_policy(self):
396393
=== modified file 'lib/lp/registry/tests/test_product_webservice.py'
--- lib/lp/registry/tests/test_product_webservice.py 2012-08-10 06:40:08 +0000
+++ lib/lp/registry/tests/test_product_webservice.py 2012-08-21 15:01:20 +0000
@@ -57,8 +57,7 @@
57 product = self.factory.makeProduct()57 product = self.factory.makeProduct()
58 self.factory.makeCommercialSubscription(product=product)58 self.factory.makeCommercialSubscription(product=product)
59 webservice = webservice_for_person(59 webservice = webservice_for_person(
60 self.factory.makeCommercialAdmin(),60 product.owner, permission=OAuthPermission.WRITE_PRIVATE)
61 permission=OAuthPermission.WRITE_PRIVATE)
62 response = self.patch(61 response = self.patch(
63 webservice, product, branch_sharing_policy='Proprietary')62 webservice, product, branch_sharing_policy='Proprietary')
64 self.assertEqual(209, response.status)63 self.assertEqual(209, response.status)
@@ -80,27 +79,12 @@
80 'proprietary branches.')))79 'proprietary branches.')))
81 self.assertIs(None, product.branch_sharing_policy)80 self.assertIs(None, product.branch_sharing_policy)
8281
83 def test_branch_sharing_policy_random_user(self):
84 # Arbitrary users can't set branch_sharing_policy.
85 product = self.factory.makeProduct()
86 webservice = webservice_for_person(
87 self.factory.makePerson(),
88 permission=OAuthPermission.WRITE_PRIVATE)
89 response = self.patch(
90 webservice, product, branch_sharing_policy='Proprietary')
91 self.assertThat(response, MatchesStructure.byEquality(
92 status=401,
93 body=('Only commercial admins can configure sharing policies '
94 'right now.')))
95 self.assertIs(None, product.branch_sharing_policy)
96
97 def test_bug_sharing_policy_can_be_set(self):82 def test_bug_sharing_policy_can_be_set(self):
98 # bug_sharing_policy can be set via the API.83 # bug_sharing_policy can be set via the API.
99 product = self.factory.makeProduct()84 product = self.factory.makeProduct()
100 self.factory.makeCommercialSubscription(product=product)85 self.factory.makeCommercialSubscription(product=product)
101 webservice = webservice_for_person(86 webservice = webservice_for_person(
102 self.factory.makeCommercialAdmin(),87 product.owner, permission=OAuthPermission.WRITE_PRIVATE)
103 permission=OAuthPermission.WRITE_PRIVATE)
104 response = self.patch(88 response = self.patch(
105 webservice, product, bug_sharing_policy='Proprietary')89 webservice, product, bug_sharing_policy='Proprietary')
106 self.assertEqual(209, response.status)90 self.assertEqual(209, response.status)
@@ -121,17 +105,3 @@
121 body=('A current commercial subscription is required to use '105 body=('A current commercial subscription is required to use '
122 'proprietary bugs.')))106 'proprietary bugs.')))
123 self.assertIs(None, product.bug_sharing_policy)107 self.assertIs(None, product.bug_sharing_policy)
124
125 def test_bug_sharing_policy_random_user(self):
126 # Arbitrary users can't set bug_sharing_policy.
127 product = self.factory.makeProduct()
128 webservice = webservice_for_person(
129 self.factory.makePerson(),
130 permission=OAuthPermission.WRITE_PRIVATE)
131 response = self.patch(
132 webservice, product, bug_sharing_policy='Proprietary')
133 self.assertThat(response, MatchesStructure.byEquality(
134 status=401,
135 body=('Only commercial admins can configure sharing policies '
136 'right now.')))
137 self.assertIs(None, product.bug_sharing_policy)
138108
=== modified file 'lib/lp/soyuz/tests/test_archive.py'
--- lib/lp/soyuz/tests/test_archive.py 2012-08-20 14:31:11 +0000
+++ lib/lp/soyuz/tests/test_archive.py 2012-08-21 15:01:20 +0000
@@ -98,7 +98,6 @@
98 LaunchpadFunctionalLayer,98 LaunchpadFunctionalLayer,
99 LaunchpadZopelessLayer,99 LaunchpadZopelessLayer,
100 )100 )
101from lp.testing.sampledata import COMMERCIAL_ADMIN_EMAIL
102101
103102
104class TestGetPublicationsInArchive(TestCaseWithFactory):103class TestGetPublicationsInArchive(TestCaseWithFactory):
@@ -1405,9 +1404,9 @@
14051404
1406 def test_commercial_admin_can_set_build_debug_symbols(self):1405 def test_commercial_admin_can_set_build_debug_symbols(self):
1407 # A commercial admin can set it.1406 # A commercial admin can set it.
1408 login(COMMERCIAL_ADMIN_EMAIL)1407 with celebrity_logged_in('commercial_admin'):
1409 self.setBuildDebugSymbols(self.archive, True)1408 self.setBuildDebugSymbols(self.archive, True)
1410 self.assertTrue(self.archive.build_debug_symbols)1409 self.assertTrue(self.archive.build_debug_symbols)
14111410
14121411
1413class TestAddArchiveDependencies(TestCaseWithFactory):1412class TestAddArchiveDependencies(TestCaseWithFactory):
14141413
=== modified file 'lib/lp/testing/sampledata.py'
--- lib/lp/testing/sampledata.py 2010-10-18 10:24:38 +0000
+++ lib/lp/testing/sampledata.py 2012-08-21 15:01:20 +0000
@@ -13,7 +13,6 @@
13 'BOB_THE_BUILDER_NAME',13 'BOB_THE_BUILDER_NAME',
14 'BUILDD_ADMIN_USERNAME',14 'BUILDD_ADMIN_USERNAME',
15 'CHROOT_LIBRARYFILEALIAS',15 'CHROOT_LIBRARYFILEALIAS',
16 'COMMERCIAL_ADMIN_EMAIL',
17 'FROG_THE_BUILDER_NAME',16 'FROG_THE_BUILDER_NAME',
18 'HOARY_DISTROSERIES_NAME',17 'HOARY_DISTROSERIES_NAME',
19 'I386_ARCHITECTURE_NAME',18 'I386_ARCHITECTURE_NAME',
@@ -25,7 +24,6 @@
25 'UBUNTU_DEVELOPER_ADMIN_NAME',24 'UBUNTU_DEVELOPER_ADMIN_NAME',
26 'UBUNTU_DISTRIBUTION_NAME',25 'UBUNTU_DISTRIBUTION_NAME',
27 'UBUNTU_UPLOAD_TEAM_NAME',26 'UBUNTU_UPLOAD_TEAM_NAME',
28 'UBUNTUTEST_DISTRIBUTION_NAME',
29 'USER_EMAIL',27 'USER_EMAIL',
30 'WARTY_DISTROSERIES_NAME',28 'WARTY_DISTROSERIES_NAME',
31 'WARTY_ONLY_SOURCEPACKAGENAME',29 'WARTY_ONLY_SOURCEPACKAGENAME',
@@ -57,7 +55,6 @@
57NO_PRIVILEGE_EMAIL = 'no-priv@canonical.com'55NO_PRIVILEGE_EMAIL = 'no-priv@canonical.com'
58USER_EMAIL = 'test@canonical.com'56USER_EMAIL = 'test@canonical.com'
59VCS_IMPORTS_MEMBER_EMAIL = 'david.allouche@canonical.com'57VCS_IMPORTS_MEMBER_EMAIL = 'david.allouche@canonical.com'
60COMMERCIAL_ADMIN_EMAIL = 'commercial-member@canonical.com'
61SAMPLE_PERSON_EMAIL = USER_EMAIL58SAMPLE_PERSON_EMAIL = USER_EMAIL
62# A user that is an admin of ubuntu-team, which has upload rights59# A user that is an admin of ubuntu-team, which has upload rights
63# to Ubuntu.60# to Ubuntu.