Merge lp:~wallyworld/launchpad/new-project-sharing-policies-1040989 into lp:launchpad
- new-project-sharing-policies-1040989
- Merge into devel
Proposed by
Ian Booth
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Ian Booth | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 15879 | ||||
Proposed branch: | lp:~wallyworld/launchpad/new-project-sharing-policies-1040989 | ||||
Merge into: | lp:launchpad | ||||
Diff against target: |
472 lines (+117/-36) 14 files modified
lib/lp/bugs/browser/tests/test_bug_views.py (+8/-3) lib/lp/bugs/browser/tests/test_bugs.py (+13/-3) lib/lp/bugs/browser/tests/test_bugtarget_filebug.py (+3/-3) lib/lp/bugs/tests/test_bugs_webservice.py (+3/-3) lib/lp/code/browser/tests/test_branch.py (+10/-5) lib/lp/code/browser/tests/test_product.py (+1/-2) lib/lp/code/model/tests/test_branch.py (+5/-2) lib/lp/code/model/tests/test_branchnamespace.py (+7/-5) lib/lp/registry/model/product.py (+12/-0) lib/lp/registry/services/tests/test_sharingservice.py (+0/-1) lib/lp/registry/tests/test_product.py (+26/-1) lib/lp/registry/tests/test_product_webservice.py (+2/-2) lib/lp/scripts/tests/test_garbo.py (+6/-4) lib/lp/testing/factory.py (+21/-2) |
||||
To merge this branch: | bzr merge lp:~wallyworld/launchpad/new-project-sharing-policies-1040989 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
William Grant | code | Approve | |
Review via email: mp+121532@code.launchpad.net |
Commit message
New projects are created with sensible default sharing policies.
Description of the change
== Implementation ==
The IProductSet createProduct() API is updated to ensure projects are created with the correct default sharing policies.
Open (non-proprietary) projects get PUBLIC for bugs and branches.
Proprietary projects get PROPRIETARY for bugs and branches.
== Tests ==
Update TestProduct:
- test_open_
- test_proprietar
== Lint ==
Checking for conflicts and issues in changed files.
Linting changed files:
lib/lp/
lib/lp/
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/bugs/browser/tests/test_bug_views.py' | |||
2 | --- lib/lp/bugs/browser/tests/test_bug_views.py 2012-08-28 09:49:44 +0000 | |||
3 | +++ lib/lp/bugs/browser/tests/test_bug_views.py 2012-08-29 21:47:18 +0000 | |||
4 | @@ -23,6 +23,10 @@ | |||
5 | 23 | InformationType, | 23 | InformationType, |
6 | 24 | BugSharingPolicy, | 24 | BugSharingPolicy, |
7 | 25 | ) | 25 | ) |
8 | 26 | from lp.registry.interfaces.accesspolicy import ( | ||
9 | 27 | IAccessPolicyGrantSource, | ||
10 | 28 | IAccessPolicySource, | ||
11 | 29 | ) | ||
12 | 26 | from lp.registry.interfaces.person import PersonVisibility | 30 | from lp.registry.interfaces.person import PersonVisibility |
13 | 27 | from lp.services.webapp.interfaces import IOpenLaunchBag | 31 | from lp.services.webapp.interfaces import IOpenLaunchBag |
14 | 28 | from lp.services.webapp.publisher import canonical_url | 32 | from lp.services.webapp.publisher import canonical_url |
15 | @@ -403,7 +407,6 @@ | |||
16 | 403 | # bug will become invisible but and no visibility check is performed. | 407 | # bug will become invisible but and no visibility check is performed. |
17 | 404 | product = self.factory.makeProduct( | 408 | product = self.factory.makeProduct( |
18 | 405 | bug_sharing_policy=BugSharingPolicy.PUBLIC_OR_PROPRIETARY) | 409 | bug_sharing_policy=BugSharingPolicy.PUBLIC_OR_PROPRIETARY) |
19 | 406 | self.factory.makeAccessPolicy(pillar=product) | ||
20 | 407 | bug = self.factory.makeBug(target=product) | 410 | bug = self.factory.makeBug(target=product) |
21 | 408 | self._assert_secrecy_view_ajax_render(bug, 'PROPRIETARY', False) | 411 | self._assert_secrecy_view_ajax_render(bug, 'PROPRIETARY', False) |
22 | 409 | 412 | ||
23 | @@ -414,14 +417,16 @@ | |||
24 | 414 | bug_owner = self.factory.makePerson() | 417 | bug_owner = self.factory.makePerson() |
25 | 415 | product = self.factory.makeProduct( | 418 | product = self.factory.makeProduct( |
26 | 416 | bug_sharing_policy=BugSharingPolicy.PUBLIC_OR_PROPRIETARY) | 419 | bug_sharing_policy=BugSharingPolicy.PUBLIC_OR_PROPRIETARY) |
27 | 417 | self.factory.makeCommercialSubscription(product) | ||
28 | 418 | bug = self.factory.makeBug(target=product, owner=bug_owner) | 420 | bug = self.factory.makeBug(target=product, owner=bug_owner) |
29 | 421 | userdata_policy = getUtility(IAccessPolicySource).find( | ||
30 | 422 | [(product, InformationType.USERDATA)]) | ||
31 | 423 | getUtility(IAccessPolicyGrantSource).revokeByPolicy(userdata_policy) | ||
32 | 419 | 424 | ||
33 | 420 | extra = {'HTTP_X_REQUESTED_WITH': 'XMLHttpRequest'} | 425 | extra = {'HTTP_X_REQUESTED_WITH': 'XMLHttpRequest'} |
34 | 421 | request = LaunchpadTestRequest( | 426 | request = LaunchpadTestRequest( |
35 | 422 | method='POST', form={ | 427 | method='POST', form={ |
36 | 423 | 'field.actions.change': 'Change', | 428 | 'field.actions.change': 'Change', |
38 | 424 | 'field.information_type': 'PROPRIETARY', | 429 | 'field.information_type': 'USERDATA', |
39 | 425 | 'field.validate_change': 'on'}, | 430 | 'field.validate_change': 'on'}, |
40 | 426 | **extra) | 431 | **extra) |
41 | 427 | with person_logged_in(bug_owner): | 432 | with person_logged_in(bug_owner): |
42 | 428 | 433 | ||
43 | === modified file 'lib/lp/bugs/browser/tests/test_bugs.py' | |||
44 | --- lib/lp/bugs/browser/tests/test_bugs.py 2012-08-22 14:23:12 +0000 | |||
45 | +++ lib/lp/bugs/browser/tests/test_bugs.py 2012-08-29 21:47:18 +0000 | |||
46 | @@ -160,7 +160,7 @@ | |||
47 | 160 | 160 | ||
48 | 161 | def test_createBug_default_private_bugs_true(self): | 161 | def test_createBug_default_private_bugs_true(self): |
49 | 162 | # createBug() does not adapt the default kwargs when they are none. | 162 | # createBug() does not adapt the default kwargs when they are none. |
51 | 163 | project = self.factory.makeProduct( | 163 | project = self.factory.makeLegacyProduct( |
52 | 164 | licenses=[License.OTHER_PROPRIETARY]) | 164 | licenses=[License.OTHER_PROPRIETARY]) |
53 | 165 | with person_logged_in(project.owner): | 165 | with person_logged_in(project.owner): |
54 | 166 | project.setPrivateBugs(True, project.owner) | 166 | project.setPrivateBugs(True, project.owner) |
55 | @@ -170,7 +170,7 @@ | |||
56 | 170 | 170 | ||
57 | 171 | def test_createBug_public_bug_private_bugs_true(self): | 171 | def test_createBug_public_bug_private_bugs_true(self): |
58 | 172 | # createBug() adapts a kwarg to InformationType if one is is not None. | 172 | # createBug() adapts a kwarg to InformationType if one is is not None. |
60 | 173 | project = self.factory.makeProduct( | 173 | project = self.factory.makeLegacyProduct( |
61 | 174 | licenses=[License.OTHER_PROPRIETARY]) | 174 | licenses=[License.OTHER_PROPRIETARY]) |
62 | 175 | with person_logged_in(project.owner): | 175 | with person_logged_in(project.owner): |
63 | 176 | project.setPrivateBugs(True, project.owner) | 176 | project.setPrivateBugs(True, project.owner) |
64 | @@ -202,13 +202,23 @@ | |||
65 | 202 | 202 | ||
66 | 203 | def test_createBug_default_private_bugs_false(self): | 203 | def test_createBug_default_private_bugs_false(self): |
67 | 204 | # createBug() does not adapt the default kwargs when they are none. | 204 | # createBug() does not adapt the default kwargs when they are none. |
68 | 205 | project = self.factory.makeLegacyProduct( | ||
69 | 206 | licenses=[License.OTHER_PROPRIETARY]) | ||
70 | 207 | with person_logged_in(project.owner): | ||
71 | 208 | project.setPrivateBugs(False, project.owner) | ||
72 | 209 | bug = self.application.createBug( | ||
73 | 210 | project.owner, 'title', 'description', project) | ||
74 | 211 | self.assertEqual(InformationType.PUBLIC, bug.information_type) | ||
75 | 212 | |||
76 | 213 | def test_createBug_proprietary_project(self): | ||
77 | 214 | # crateBug() make proprietary bugs for proprietary projects. | ||
78 | 205 | project = self.factory.makeProduct( | 215 | project = self.factory.makeProduct( |
79 | 206 | licenses=[License.OTHER_PROPRIETARY]) | 216 | licenses=[License.OTHER_PROPRIETARY]) |
80 | 207 | with person_logged_in(project.owner): | 217 | with person_logged_in(project.owner): |
81 | 208 | project.setPrivateBugs(False, project.owner) | 218 | project.setPrivateBugs(False, project.owner) |
82 | 209 | bug = self.application.createBug( | 219 | bug = self.application.createBug( |
83 | 210 | project.owner, 'title', 'description', project) | 220 | project.owner, 'title', 'description', project) |
85 | 211 | self.assertEqual(InformationType.PUBLIC, bug.information_type) | 221 | self.assertEqual(InformationType.PROPRIETARY, bug.information_type) |
86 | 212 | 222 | ||
87 | 213 | def test_createBug_private_bug_private_bugs_false(self): | 223 | def test_createBug_private_bug_private_bugs_false(self): |
88 | 214 | # createBug() adapts a kwarg to InformationType if one is is not None. | 224 | # createBug() adapts a kwarg to InformationType if one is is not None. |
89 | 215 | 225 | ||
90 | === modified file 'lib/lp/bugs/browser/tests/test_bugtarget_filebug.py' | |||
91 | --- lib/lp/bugs/browser/tests/test_bugtarget_filebug.py 2012-08-22 14:23:12 +0000 | |||
92 | +++ lib/lp/bugs/browser/tests/test_bugtarget_filebug.py 2012-08-29 21:47:18 +0000 | |||
93 | @@ -362,7 +362,7 @@ | |||
94 | 362 | } | 362 | } |
95 | 363 | if information_type: | 363 | if information_type: |
96 | 364 | form['field.information_type'] = information_type | 364 | form['field.information_type'] = information_type |
98 | 365 | product = self.factory.makeProduct(official_malone=True) | 365 | product = self.factory.makeLegacyProduct(official_malone=True) |
99 | 366 | if private_bugs: | 366 | if private_bugs: |
100 | 367 | removeSecurityProxy(product).private_bugs = True | 367 | removeSecurityProxy(product).private_bugs = True |
101 | 368 | if bug_sharing_policy: | 368 | if bug_sharing_policy: |
102 | @@ -490,7 +490,7 @@ | |||
103 | 490 | 'field.security_related': 'on' if security_related else '', | 490 | 'field.security_related': 'on' if security_related else '', |
104 | 491 | 'field.actions.submit_bug': 'Submit Bug Request', | 491 | 'field.actions.submit_bug': 'Submit Bug Request', |
105 | 492 | } | 492 | } |
107 | 493 | product = self.factory.makeProduct(official_malone=True) | 493 | product = self.factory.makeLegacyProduct(official_malone=True) |
108 | 494 | if private_bugs: | 494 | if private_bugs: |
109 | 495 | removeSecurityProxy(product).private_bugs = True | 495 | removeSecurityProxy(product).private_bugs = True |
110 | 496 | if bug_sharing_policy: | 496 | if bug_sharing_policy: |
111 | @@ -657,7 +657,7 @@ | |||
112 | 657 | self._assert_cache_values(view, True) | 657 | self._assert_cache_values(view, True) |
113 | 658 | 658 | ||
114 | 659 | def test_product_private_bugs(self): | 659 | def test_product_private_bugs(self): |
116 | 660 | project = self.factory.makeProduct( | 660 | project = self.factory.makeLegacyProduct( |
117 | 661 | official_malone=True, private_bugs=True) | 661 | official_malone=True, private_bugs=True) |
118 | 662 | user = self.factory.makePerson() | 662 | user = self.factory.makePerson() |
119 | 663 | login_person(user) | 663 | login_person(user) |
120 | 664 | 664 | ||
121 | === modified file 'lib/lp/bugs/tests/test_bugs_webservice.py' | |||
122 | --- lib/lp/bugs/tests/test_bugs_webservice.py 2012-08-22 14:23:12 +0000 | |||
123 | +++ lib/lp/bugs/tests/test_bugs_webservice.py 2012-08-29 21:47:18 +0000 | |||
124 | @@ -380,7 +380,7 @@ | |||
125 | 380 | # Verify the path through user submission, to MaloneApplication to | 380 | # Verify the path through user submission, to MaloneApplication to |
126 | 381 | # BugSet, and back to the user creates a private bug according | 381 | # BugSet, and back to the user creates a private bug according |
127 | 382 | # to the project's bugs are private by default rule. | 382 | # to the project's bugs are private by default rule. |
129 | 383 | project = self.factory.makeProduct( | 383 | project = self.factory.makeLegacyProduct( |
130 | 384 | licenses=[License.OTHER_PROPRIETARY]) | 384 | licenses=[License.OTHER_PROPRIETARY]) |
131 | 385 | with person_logged_in(project.owner): | 385 | with person_logged_in(project.owner): |
132 | 386 | project.setPrivateBugs(True, project.owner) | 386 | project.setPrivateBugs(True, project.owner) |
133 | @@ -392,9 +392,9 @@ | |||
134 | 392 | 392 | ||
135 | 393 | def test_explicit_private_private_bugs_true(self): | 393 | def test_explicit_private_private_bugs_true(self): |
136 | 394 | # Verify the path through user submission, to MaloneApplication to | 394 | # Verify the path through user submission, to MaloneApplication to |
138 | 395 | # BugSet, and back to the user creates a private bug beause the | 395 | # BugSet, and back to the user creates a private bug because the |
139 | 396 | # user commands it. | 396 | # user commands it. |
141 | 397 | project = self.factory.makeProduct( | 397 | project = self.factory.makeLegacyProduct( |
142 | 398 | licenses=[License.OTHER_PROPRIETARY]) | 398 | licenses=[License.OTHER_PROPRIETARY]) |
143 | 399 | with person_logged_in(project.owner): | 399 | with person_logged_in(project.owner): |
144 | 400 | project.setPrivateBugs(True, project.owner) | 400 | project.setPrivateBugs(True, project.owner) |
145 | 401 | 401 | ||
146 | === modified file 'lib/lp/code/browser/tests/test_branch.py' | |||
147 | --- lib/lp/code/browser/tests/test_branch.py 2012-08-29 04:48:13 +0000 | |||
148 | +++ lib/lp/code/browser/tests/test_branch.py 2012-08-29 21:47:18 +0000 | |||
149 | @@ -919,7 +919,7 @@ | |||
150 | 919 | def test_forbidden_owner_is_error(self): | 919 | def test_forbidden_owner_is_error(self): |
151 | 920 | # An error is displayed if a branch's owner is changed to | 920 | # An error is displayed if a branch's owner is changed to |
152 | 921 | # a value forbidden by the visibility policy. | 921 | # a value forbidden by the visibility policy. |
154 | 922 | product = self.factory.makeProduct(displayname='Some Product') | 922 | product = self.factory.makeLegacyProduct(displayname='Some Product') |
155 | 923 | person = self.factory.makePerson() | 923 | person = self.factory.makePerson() |
156 | 924 | branch = self.factory.makeBranch(product=product, owner=person) | 924 | branch = self.factory.makeBranch(product=product, owner=person) |
157 | 925 | self.factory.makeTeam( | 925 | self.factory.makeTeam( |
158 | @@ -944,7 +944,8 @@ | |||
159 | 944 | # A branch's owner can be changed to a private team permitted by the | 944 | # A branch's owner can be changed to a private team permitted by the |
160 | 945 | # visibility policy. | 945 | # visibility policy. |
161 | 946 | person = self.factory.makePerson() | 946 | person = self.factory.makePerson() |
163 | 947 | branch = self.factory.makeProductBranch(owner=person) | 947 | product = self.factory.makeLegacyProduct() |
164 | 948 | branch = self.factory.makeProductBranch(product=product, owner=person) | ||
165 | 948 | team = self.factory.makeTeam( | 949 | team = self.factory.makeTeam( |
166 | 949 | owner=person, displayname="Private team", | 950 | owner=person, displayname="Private team", |
167 | 950 | visibility=PersonVisibility.PRIVATE) | 951 | visibility=PersonVisibility.PRIVATE) |
168 | @@ -1027,14 +1028,16 @@ | |||
169 | 1027 | self.assertContentEqual(types, view.getInformationTypesToShow()) | 1028 | self.assertContentEqual(types, view.getInformationTypesToShow()) |
170 | 1028 | 1029 | ||
171 | 1029 | def test_public_branch(self): | 1030 | def test_public_branch(self): |
174 | 1030 | # A normal public branch on a public project can only be a public | 1031 | # A normal public branch on a public project can be any information |
175 | 1031 | # information type. | 1032 | # type except embargoed and proprietary. |
176 | 1032 | # The model doesn't enforce this, so it's just a UI thing. | 1033 | # The model doesn't enforce this, so it's just a UI thing. |
177 | 1033 | branch = self.factory.makeBranch( | 1034 | branch = self.factory.makeBranch( |
178 | 1034 | information_type=InformationType.PUBLIC) | 1035 | information_type=InformationType.PUBLIC) |
179 | 1035 | self.assertShownTypes( | 1036 | self.assertShownTypes( |
180 | 1036 | [InformationType.PUBLIC, | 1037 | [InformationType.PUBLIC, |
182 | 1037 | InformationType.PUBLICSECURITY], | 1038 | InformationType.PUBLICSECURITY, |
183 | 1039 | InformationType.PRIVATESECURITY, | ||
184 | 1040 | InformationType.USERDATA], | ||
185 | 1038 | branch) | 1041 | branch) |
186 | 1039 | 1042 | ||
187 | 1040 | def test_branch_with_disallowed_type(self): | 1043 | def test_branch_with_disallowed_type(self): |
188 | @@ -1048,6 +1051,8 @@ | |||
189 | 1048 | self.assertShownTypes( | 1051 | self.assertShownTypes( |
190 | 1049 | [InformationType.PUBLIC, | 1052 | [InformationType.PUBLIC, |
191 | 1050 | InformationType.PUBLICSECURITY, | 1053 | InformationType.PUBLICSECURITY, |
192 | 1054 | InformationType.PRIVATESECURITY, | ||
193 | 1055 | InformationType.USERDATA, | ||
194 | 1051 | InformationType.PROPRIETARY], | 1056 | InformationType.PROPRIETARY], |
195 | 1052 | branch) | 1057 | branch) |
196 | 1053 | 1058 | ||
197 | 1054 | 1059 | ||
198 | === modified file 'lib/lp/code/browser/tests/test_product.py' | |||
199 | --- lib/lp/code/browser/tests/test_product.py 2012-07-17 03:51:38 +0000 | |||
200 | +++ lib/lp/code/browser/tests/test_product.py 2012-08-29 21:47:18 +0000 | |||
201 | @@ -22,7 +22,6 @@ | |||
202 | 22 | from lp.code.interfaces.revision import IRevisionSet | 22 | from lp.code.interfaces.revision import IRevisionSet |
203 | 23 | from lp.code.publisher import CodeLayer | 23 | from lp.code.publisher import CodeLayer |
204 | 24 | from lp.registry.enums import InformationType | 24 | from lp.registry.enums import InformationType |
205 | 25 | from lp.services.features.testing import FeatureFixture | ||
206 | 26 | from lp.services.webapp import canonical_url | 25 | from lp.services.webapp import canonical_url |
207 | 27 | from lp.testing import ( | 26 | from lp.testing import ( |
208 | 28 | ANONYMOUS, | 27 | ANONYMOUS, |
209 | @@ -355,7 +354,7 @@ | |||
210 | 355 | def test_is_private(self): | 354 | def test_is_private(self): |
211 | 356 | team_owner = self.factory.makePerson() | 355 | team_owner = self.factory.makePerson() |
212 | 357 | team = self.factory.makeTeam(team_owner) | 356 | team = self.factory.makeTeam(team_owner) |
214 | 358 | product = self.factory.makeProduct(owner=team_owner) | 357 | product = self.factory.makeLegacyProduct(owner=team_owner) |
215 | 359 | branch = self.factory.makeProductBranch(product=product) | 358 | branch = self.factory.makeProductBranch(product=product) |
216 | 360 | login_person(product.owner) | 359 | login_person(product.owner) |
217 | 361 | product.development_focus.branch = branch | 360 | product.development_focus.branch = branch |
218 | 362 | 361 | ||
219 | === modified file 'lib/lp/code/model/tests/test_branch.py' | |||
220 | --- lib/lp/code/model/tests/test_branch.py 2012-08-22 14:23:12 +0000 | |||
221 | +++ lib/lp/code/model/tests/test_branch.py 2012-08-29 21:47:18 +0000 | |||
222 | @@ -2481,7 +2481,8 @@ | |||
223 | 2481 | def test_public_to_private_not_allowed(self): | 2481 | def test_public_to_private_not_allowed(self): |
224 | 2482 | # If there are no privacy policies allowing private branches, then | 2482 | # If there are no privacy policies allowing private branches, then |
225 | 2483 | # BranchCannotChangeInformationType is rasied. | 2483 | # BranchCannotChangeInformationType is rasied. |
227 | 2484 | branch = self.factory.makeProductBranch() | 2484 | product = self.factory.makeLegacyProduct() |
228 | 2485 | branch = self.factory.makeBranch(product=product) | ||
229 | 2485 | self.assertRaises( | 2486 | self.assertRaises( |
230 | 2486 | BranchCannotChangeInformationType, | 2487 | BranchCannotChangeInformationType, |
231 | 2487 | branch.setPrivate, | 2488 | branch.setPrivate, |
232 | @@ -2523,7 +2524,9 @@ | |||
233 | 2523 | # If the namespace policy does not allow public branches, attempting | 2524 | # If the namespace policy does not allow public branches, attempting |
234 | 2524 | # to change the branch to be public raises | 2525 | # to change the branch to be public raises |
235 | 2525 | # BranchCannotChangeInformationType. | 2526 | # BranchCannotChangeInformationType. |
237 | 2526 | branch = self.factory.makeProductBranch( | 2527 | product = self.factory.makeLegacyProduct() |
238 | 2528 | branch = self.factory.makeBranch( | ||
239 | 2529 | product=product, | ||
240 | 2527 | information_type=InformationType.USERDATA) | 2530 | information_type=InformationType.USERDATA) |
241 | 2528 | branch.product.setBranchVisibilityTeamPolicy( | 2531 | branch.product.setBranchVisibilityTeamPolicy( |
242 | 2529 | None, BranchVisibilityRule.FORBIDDEN) | 2532 | None, BranchVisibilityRule.FORBIDDEN) |
243 | 2530 | 2533 | ||
244 | === modified file 'lib/lp/code/model/tests/test_branchnamespace.py' | |||
245 | --- lib/lp/code/model/tests/test_branchnamespace.py 2012-08-24 05:09:51 +0000 | |||
246 | +++ lib/lp/code/model/tests/test_branchnamespace.py 2012-08-29 21:47:18 +0000 | |||
247 | @@ -385,7 +385,7 @@ | |||
248 | 385 | # and the namespace owner is in that team, then the team is | 385 | # and the namespace owner is in that team, then the team is |
249 | 386 | # subscribed. | 386 | # subscribed. |
250 | 387 | person = self.factory.makePerson() | 387 | person = self.factory.makePerson() |
252 | 388 | product = self.factory.makeProduct() | 388 | product = self.factory.makeLegacyProduct() |
253 | 389 | namespace = ProductNamespace(person, product) | 389 | namespace = ProductNamespace(person, product) |
254 | 390 | team = self.factory.makeTeam(owner=person) | 390 | team = self.factory.makeTeam(owner=person) |
255 | 391 | product.setBranchVisibilityTeamPolicy( | 391 | product.setBranchVisibilityTeamPolicy( |
256 | @@ -399,7 +399,7 @@ | |||
257 | 399 | team = self.factory.makeTeam( | 399 | team = self.factory.makeTeam( |
258 | 400 | membership_policy=TeamMembershipPolicy.MODERATED, | 400 | membership_policy=TeamMembershipPolicy.MODERATED, |
259 | 401 | owner=person) | 401 | owner=person) |
261 | 402 | product = self.factory.makeProduct() | 402 | product = self.factory.makeLegacyProduct() |
262 | 403 | namespace = ProductNamespace(team, product) | 403 | namespace = ProductNamespace(team, product) |
263 | 404 | product.setBranchVisibilityTeamPolicy( | 404 | product.setBranchVisibilityTeamPolicy( |
264 | 405 | team, BranchVisibilityRule.PRIVATE) | 405 | team, BranchVisibilityRule.PRIVATE) |
265 | @@ -436,7 +436,7 @@ | |||
266 | 436 | # those rules is private, then the team that has the private rule is | 436 | # those rules is private, then the team that has the private rule is |
267 | 437 | # the subscriber. | 437 | # the subscriber. |
268 | 438 | person = self.factory.makePerson() | 438 | person = self.factory.makePerson() |
270 | 439 | product = self.factory.makeProduct() | 439 | product = self.factory.makeLegacyProduct() |
271 | 440 | namespace = ProductNamespace(person, product) | 440 | namespace = ProductNamespace(person, product) |
272 | 441 | product.setBranchVisibilityTeamPolicy( | 441 | product.setBranchVisibilityTeamPolicy( |
273 | 442 | self.factory.makeTeam(owner=person), BranchVisibilityRule.PUBLIC) | 442 | self.factory.makeTeam(owner=person), BranchVisibilityRule.PUBLIC) |
274 | @@ -985,7 +985,7 @@ | |||
275 | 985 | BaseCanCreateBranchesMixin): | 985 | BaseCanCreateBranchesMixin): |
276 | 986 | 986 | ||
277 | 987 | def _getNamespace(self, owner): | 987 | def _getNamespace(self, owner): |
279 | 988 | product = self.factory.makeProduct() | 988 | product = self.factory.makeLegacyProduct() |
280 | 989 | return ProductNamespace(owner, product) | 989 | return ProductNamespace(owner, product) |
281 | 990 | 990 | ||
282 | 991 | def setUp(self): | 991 | def setUp(self): |
283 | @@ -1097,7 +1097,8 @@ | |||
284 | 1097 | 1097 | ||
285 | 1098 | def setUp(self): | 1098 | def setUp(self): |
286 | 1099 | TestCaseWithFactory.setUp(self) | 1099 | TestCaseWithFactory.setUp(self) |
288 | 1100 | self.product = self.factory.makeProduct() | 1100 | self.product = self.factory.makeLegacyProduct() |
289 | 1101 | removeSecurityProxy(self.product).branch_sharing_policy = None | ||
290 | 1101 | 1102 | ||
291 | 1102 | def _getNamespace(self, owner): | 1103 | def _getNamespace(self, owner): |
292 | 1103 | return ProductNamespace(owner, self.product) | 1104 | return ProductNamespace(owner, self.product) |
293 | @@ -1299,6 +1300,7 @@ | |||
294 | 1299 | 'admin@canonical.com') | 1300 | 'admin@canonical.com') |
295 | 1300 | # Our test product. | 1301 | # Our test product. |
296 | 1301 | self.product = self.factory.makeProduct() | 1302 | self.product = self.factory.makeProduct() |
297 | 1303 | removeSecurityProxy(self.product).branch_sharing_policy = None | ||
298 | 1302 | # Create some test people. | 1304 | # Create some test people. |
299 | 1303 | self.albert = self.factory.makePerson( | 1305 | self.albert = self.factory.makePerson( |
300 | 1304 | name='albert', displayname='Albert Tester') | 1306 | name='albert', displayname='Albert Tester') |
301 | 1305 | 1307 | ||
302 | === modified file 'lib/lp/registry/model/product.py' | |||
303 | --- lib/lp/registry/model/product.py 2012-08-23 02:52:31 +0000 | |||
304 | +++ lib/lp/registry/model/product.py 2012-08-29 21:47:18 +0000 | |||
305 | @@ -1552,8 +1552,20 @@ | |||
306 | 1552 | project_reviewed=project_reviewed, | 1552 | project_reviewed=project_reviewed, |
307 | 1553 | icon=icon, logo=logo, mugshot=mugshot, license_info=license_info) | 1553 | icon=icon, logo=logo, mugshot=mugshot, license_info=license_info) |
308 | 1554 | 1554 | ||
309 | 1555 | # Set up the sharing policies and product licence. | ||
310 | 1556 | bug_sharing_policy_to_use = BugSharingPolicy.PUBLIC | ||
311 | 1557 | branch_sharing_policy_to_use = BranchSharingPolicy.PUBLIC | ||
312 | 1555 | if len(licenses) > 0: | 1558 | if len(licenses) > 0: |
313 | 1556 | product._setLicenses(licenses, reset_project_reviewed=False) | 1559 | product._setLicenses(licenses, reset_project_reviewed=False) |
314 | 1560 | # By default, new non-proprietary projects use public bugs and | ||
315 | 1561 | # branches. Proprietary projects are given a complimentary 30 day | ||
316 | 1562 | # commercial subscription and so may use proprietary sharing | ||
317 | 1563 | # policies. | ||
318 | 1564 | if License.OTHER_PROPRIETARY in licenses: | ||
319 | 1565 | bug_sharing_policy_to_use = BugSharingPolicy.PROPRIETARY | ||
320 | 1566 | branch_sharing_policy_to_use = BranchSharingPolicy.PROPRIETARY | ||
321 | 1567 | product.setBugSharingPolicy(bug_sharing_policy_to_use) | ||
322 | 1568 | product.setBranchSharingPolicy(branch_sharing_policy_to_use) | ||
323 | 1557 | 1569 | ||
324 | 1558 | # Create a default trunk series and set it as the development focus | 1570 | # Create a default trunk series and set it as the development focus |
325 | 1559 | trunk = product.newSeries( | 1571 | trunk = product.newSeries( |
326 | 1560 | 1572 | ||
327 | === modified file 'lib/lp/registry/services/tests/test_sharingservice.py' | |||
328 | --- lib/lp/registry/services/tests/test_sharingservice.py 2012-08-28 23:25:43 +0000 | |||
329 | +++ lib/lp/registry/services/tests/test_sharingservice.py 2012-08-29 21:47:18 +0000 | |||
330 | @@ -183,7 +183,6 @@ | |||
331 | 183 | # if it is not in the nominally allowed policy list. | 183 | # if it is not in the nominally allowed policy list. |
332 | 184 | product = self.factory.makeProduct( | 184 | product = self.factory.makeProduct( |
333 | 185 | branch_sharing_policy=BranchSharingPolicy.EMBARGOED_OR_PROPRIETARY) | 185 | branch_sharing_policy=BranchSharingPolicy.EMBARGOED_OR_PROPRIETARY) |
334 | 186 | self.factory.makeCommercialSubscription(product) | ||
335 | 187 | self._assert_getBranchSharingPolicies( | 186 | self._assert_getBranchSharingPolicies( |
336 | 188 | product, | 187 | product, |
337 | 189 | [BranchSharingPolicy.PUBLIC, | 188 | [BranchSharingPolicy.PUBLIC, |
338 | 190 | 189 | ||
339 | === modified file 'lib/lp/registry/tests/test_product.py' | |||
340 | --- lib/lp/registry/tests/test_product.py 2012-08-23 02:52:31 +0000 | |||
341 | +++ lib/lp/registry/tests/test_product.py 2012-08-29 21:47:18 +0000 | |||
342 | @@ -363,6 +363,31 @@ | |||
343 | 363 | grantees = set([grant.grantee for grant in grants]) | 363 | grantees = set([grant.grantee for grant in grants]) |
344 | 364 | self.assertEqual(expected_grantess, grantees) | 364 | self.assertEqual(expected_grantess, grantees) |
345 | 365 | 365 | ||
346 | 366 | def test_open_product_creation_sharing_policies(self): | ||
347 | 367 | # Creating a new open (non-proprietary) product sets the bug and branch | ||
348 | 368 | # sharing polices to public. | ||
349 | 369 | owner = self.factory.makePerson() | ||
350 | 370 | with person_logged_in(owner): | ||
351 | 371 | product = getUtility(IProductSet).createProduct( | ||
352 | 372 | owner, 'carrot', 'Carrot', 'Carrot', 'testing', | ||
353 | 373 | licenses=[License.MIT]) | ||
354 | 374 | self.assertEqual(BugSharingPolicy.PUBLIC, product.bug_sharing_policy) | ||
355 | 375 | self.assertEqual( | ||
356 | 376 | BranchSharingPolicy.PUBLIC, product.branch_sharing_policy) | ||
357 | 377 | |||
358 | 378 | def test_proprietary_product_creation_sharing_policies(self): | ||
359 | 379 | # Creating a new proprietary product sets the bug and branch sharing | ||
360 | 380 | # polices to proprietary. | ||
361 | 381 | owner = self.factory.makePerson() | ||
362 | 382 | with person_logged_in(owner): | ||
363 | 383 | product = getUtility(IProductSet).createProduct( | ||
364 | 384 | owner, 'carrot', 'Carrot', 'Carrot', 'testing', | ||
365 | 385 | licenses=[License.OTHER_PROPRIETARY]) | ||
366 | 386 | self.assertEqual( | ||
367 | 387 | BugSharingPolicy.PROPRIETARY, product.bug_sharing_policy) | ||
368 | 388 | self.assertEqual( | ||
369 | 389 | BranchSharingPolicy.PROPRIETARY, product.branch_sharing_policy) | ||
370 | 390 | |||
371 | 366 | 391 | ||
372 | 367 | class TestProductBugInformationTypes(TestCaseWithFactory): | 392 | class TestProductBugInformationTypes(TestCaseWithFactory): |
373 | 368 | 393 | ||
374 | @@ -387,7 +412,7 @@ | |||
375 | 387 | def test_legacy_private_bugs(self): | 412 | def test_legacy_private_bugs(self): |
376 | 388 | # The deprecated private_bugs attribute overrides the default | 413 | # The deprecated private_bugs attribute overrides the default |
377 | 389 | # information type to USERDATA. | 414 | # information type to USERDATA. |
379 | 390 | product = self.factory.makeProduct(private_bugs=True) | 415 | product = self.factory.makeLegacyProduct(private_bugs=True) |
380 | 391 | self.assertContentEqual( | 416 | self.assertContentEqual( |
381 | 392 | FREE_INFORMATION_TYPES, product.getAllowedBugInformationTypes()) | 417 | FREE_INFORMATION_TYPES, product.getAllowedBugInformationTypes()) |
382 | 393 | self.assertEqual( | 418 | self.assertEqual( |
383 | 394 | 419 | ||
384 | === modified file 'lib/lp/registry/tests/test_product_webservice.py' | |||
385 | --- lib/lp/registry/tests/test_product_webservice.py 2012-08-22 13:57:25 +0000 | |||
386 | +++ lib/lp/registry/tests/test_product_webservice.py 2012-08-29 21:47:18 +0000 | |||
387 | @@ -67,7 +67,7 @@ | |||
388 | 67 | def test_branch_sharing_policy_non_commercial(self): | 67 | def test_branch_sharing_policy_non_commercial(self): |
389 | 68 | # An API attempt to set a commercial-only branch_sharing_policy | 68 | # An API attempt to set a commercial-only branch_sharing_policy |
390 | 69 | # on a non-commercial project returns Forbidden. | 69 | # on a non-commercial project returns Forbidden. |
392 | 70 | product = self.factory.makeProduct() | 70 | product = self.factory.makeLegacyProduct() |
393 | 71 | webservice = webservice_for_person( | 71 | webservice = webservice_for_person( |
394 | 72 | product.owner, permission=OAuthPermission.WRITE_PRIVATE) | 72 | product.owner, permission=OAuthPermission.WRITE_PRIVATE) |
395 | 73 | response = self.patch( | 73 | response = self.patch( |
396 | @@ -93,7 +93,7 @@ | |||
397 | 93 | def test_bug_sharing_policy_non_commercial(self): | 93 | def test_bug_sharing_policy_non_commercial(self): |
398 | 94 | # An API attempt to set a commercial-only bug_sharing_policy | 94 | # An API attempt to set a commercial-only bug_sharing_policy |
399 | 95 | # on a non-commercial project returns Forbidden. | 95 | # on a non-commercial project returns Forbidden. |
401 | 96 | product = self.factory.makeProduct() | 96 | product = self.factory.makeLegacyProduct() |
402 | 97 | webservice = webservice_for_person( | 97 | webservice = webservice_for_person( |
403 | 98 | product.owner, permission=OAuthPermission.WRITE_PRIVATE) | 98 | product.owner, permission=OAuthPermission.WRITE_PRIVATE) |
404 | 99 | response = self.patch( | 99 | response = self.patch( |
405 | 100 | 100 | ||
406 | === modified file 'lib/lp/scripts/tests/test_garbo.py' | |||
407 | --- lib/lp/scripts/tests/test_garbo.py 2012-08-29 14:16:30 +0000 | |||
408 | +++ lib/lp/scripts/tests/test_garbo.py 2012-08-29 21:47:18 +0000 | |||
409 | @@ -1036,14 +1036,16 @@ | |||
410 | 1036 | # set. | 1036 | # set. |
411 | 1037 | with dbuser('testadmin'): | 1037 | with dbuser('testadmin'): |
412 | 1038 | non_commercial_products = [ | 1038 | non_commercial_products = [ |
414 | 1039 | self.factory.makeProduct() | 1039 | self.factory.makeLegacyProduct() |
415 | 1040 | for i in range(10)] | 1040 | for i in range(10)] |
417 | 1041 | commercial_project = self.factory.makeProduct() | 1041 | commercial_project = self.factory.makeLegacyProduct() |
418 | 1042 | self.factory.makeCommercialSubscription(commercial_project) | 1042 | self.factory.makeCommercialSubscription(commercial_project) |
419 | 1043 | configured_project = self.factory.makeProduct( | 1043 | configured_project = self.factory.makeProduct( |
420 | 1044 | bug_sharing_policy=BugSharingPolicy.PROPRIETARY) | 1044 | bug_sharing_policy=BugSharingPolicy.PROPRIETARY) |
423 | 1045 | private_project = self.factory.makeProduct(private_bugs=True) | 1045 | removeSecurityProxy( |
424 | 1046 | project_with_bvp = self.factory.makeProduct() | 1046 | configured_project).branch_sharing_policy = None |
425 | 1047 | private_project = self.factory.makeLegacyProduct(private_bugs=True) | ||
426 | 1048 | project_with_bvp = self.factory.makeLegacyProduct() | ||
427 | 1047 | project_with_bvp.setBranchVisibilityTeamPolicy( | 1049 | project_with_bvp.setBranchVisibilityTeamPolicy( |
428 | 1048 | None, BranchVisibilityRule.FORBIDDEN) | 1050 | None, BranchVisibilityRule.FORBIDDEN) |
429 | 1049 | 1051 | ||
430 | 1050 | 1052 | ||
431 | === modified file 'lib/lp/testing/factory.py' | |||
432 | --- lib/lp/testing/factory.py 2012-08-28 00:00:47 +0000 | |||
433 | +++ lib/lp/testing/factory.py 2012-08-29 21:47:18 +0000 | |||
434 | @@ -137,6 +137,8 @@ | |||
435 | 137 | IHWSubmissionSet, | 137 | IHWSubmissionSet, |
436 | 138 | ) | 138 | ) |
437 | 139 | from lp.registry.enums import ( | 139 | from lp.registry.enums import ( |
438 | 140 | BranchSharingPolicy, | ||
439 | 141 | BugSharingPolicy, | ||
440 | 140 | DistroSeriesDifferenceStatus, | 142 | DistroSeriesDifferenceStatus, |
441 | 141 | DistroSeriesDifferenceType, | 143 | DistroSeriesDifferenceType, |
442 | 142 | InformationType, | 144 | InformationType, |
443 | @@ -995,10 +997,27 @@ | |||
444 | 995 | naked_product.driver = driver | 997 | naked_product.driver = driver |
445 | 996 | if private_bugs: | 998 | if private_bugs: |
446 | 997 | naked_product.private_bugs = private_bugs | 999 | naked_product.private_bugs = private_bugs |
447 | 1000 | if ((branch_sharing_policy and | ||
448 | 1001 | branch_sharing_policy != BranchSharingPolicy.PUBLIC) or | ||
449 | 1002 | (bug_sharing_policy and | ||
450 | 1003 | bug_sharing_policy != BugSharingPolicy.PUBLIC)): | ||
451 | 1004 | self.makeCommercialSubscription(product) | ||
452 | 998 | if branch_sharing_policy: | 1005 | if branch_sharing_policy: |
454 | 999 | naked_product.branch_sharing_policy = branch_sharing_policy | 1006 | naked_product.setBranchSharingPolicy(branch_sharing_policy) |
455 | 1000 | if bug_sharing_policy: | 1007 | if bug_sharing_policy: |
457 | 1001 | naked_product.bug_sharing_policy = bug_sharing_policy | 1008 | naked_product.setBugSharingPolicy(bug_sharing_policy) |
458 | 1009 | |||
459 | 1010 | return product | ||
460 | 1011 | |||
461 | 1012 | def makeLegacyProduct(self, **kwargs): | ||
462 | 1013 | # Create a product which does not have any of the new bug and branch | ||
463 | 1014 | # sharing policies set. New products have these set to default values | ||
464 | 1015 | # but we need to test for existing products which have not yet been | ||
465 | 1016 | # migrated. | ||
466 | 1017 | # XXX This method can be removed when branch visibility policy dies. | ||
467 | 1018 | product = self.makeProduct(**kwargs) | ||
468 | 1019 | removeSecurityProxy(product).bug_sharing_policy = None | ||
469 | 1020 | removeSecurityProxy(product).branch_sharing_policy = None | ||
470 | 1002 | return product | 1021 | return product |
471 | 1003 | 1022 | ||
472 | 1004 | def makeProductSeries(self, product=None, name=None, owner=None, | 1023 | def makeProductSeries(self, product=None, name=None, owner=None, |