Merge lp:~stevenk/launchpad/forbid-proprietary-api into lp:launchpad

Proposed by Steve Kowalik on 2012-04-16
Status: Merged
Approved by: Steve Kowalik on 2012-04-17
Approved revision: no longer in the source branch.
Merged at revision: 15106
Proposed branch: lp:~stevenk/launchpad/forbid-proprietary-api
Merge into: lp:launchpad
Diff against target: 55 lines (+17/-3)
3 files modified
lib/lp/bugs/interfaces/bug.py (+2/-2)
lib/lp/bugs/model/bug.py (+5/-1)
lib/lp/bugs/model/tests/test_bug.py (+10/-0)
To merge this branch: bzr merge lp:~stevenk/launchpad/forbid-proprietary-api
Reviewer Review Type Date Requested Status
William Grant code 2012-04-16 Approve on 2012-04-17
Review via email: mp+102201@code.launchpad.net

Commit Message

Forbid IBug.transistionToInformationType(Proprietary) over the API.

Description of the Change

Currently users can call IBug.transistionToInformationType(Proprietary) over the API currently, and as it stands right now, we don't want to allow that at all until we make some design level decisions about when proprietary is shown.

To post a comment you must log in.
William Grant (wgrant) wrote :

I believe the preferred spelling these days is "cannot", but otherwise this looks good.

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/interfaces/bug.py'
2--- lib/lp/bugs/interfaces/bug.py 2012-03-28 01:14:17 +0000
3+++ lib/lp/bugs/interfaces/bug.py 2012-04-17 01:15:25 +0000
4@@ -892,10 +892,10 @@
5 @operation_parameters(
6 information_type=copy_field(IBugPublic['information_type']),
7 )
8- @call_with(who=REQUEST_USER)
9+ @call_with(who=REQUEST_USER, from_api=True)
10 @export_write_operation()
11 @operation_for_version("devel")
12- def transitionToInformationType(information_type, who):
13+ def transitionToInformationType(information_type, who, from_api=False):
14 """Set the information type for this bug.
15
16 :information_type: The `InformationType` to transition to.
17
18=== modified file 'lib/lp/bugs/model/bug.py'
19--- lib/lp/bugs/model/bug.py 2012-04-03 06:14:09 +0000
20+++ lib/lp/bugs/model/bug.py 2012-04-17 01:15:25 +0000
21@@ -1724,9 +1724,13 @@
22 return self.transitionToInformationType(
23 convert_to_information_type(self.private, security_related), who)
24
25- def transitionToInformationType(self, information_type, who):
26+ def transitionToInformationType(self, information_type, who,
27+ from_api=False):
28 """See `IBug`."""
29 bug_before_modification = Snapshot(self, providing=providedBy(self))
30+ if from_api and information_type == InformationType.PROPRIETARY:
31+ raise BugCannotBePrivate(
32+ "Cannot transition the information type to proprietary.")
33 if self.information_type == information_type:
34 return False
35 f_flag_str = 'disclosure.enhanced_private_bug_subscriptions.enabled'
36
37=== modified file 'lib/lp/bugs/model/tests/test_bug.py'
38--- lib/lp/bugs/model/tests/test_bug.py 2012-04-03 06:14:09 +0000
39+++ lib/lp/bugs/model/tests/test_bug.py 2012-04-17 01:15:25 +0000
40@@ -552,6 +552,16 @@
41 self.assertThat(
42 recorder2, HasQueryCount(Equals(recorder1.count)))
43
44+ def test_transitionToInformationType_forbids_proprietary(self):
45+ # Calling IBug.transitionToInformationType(PROPRIETARY) over the API
46+ # is forbidden currently.
47+ bug = self.factory.makeBug()
48+ with person_logged_in(bug.owner):
49+ self.assertRaisesWithContent(
50+ BugCannotBePrivate, "Cannot transition the information type "
51+ "to proprietary.", bug.transitionToInformationType,
52+ InformationType.PROPRIETARY, bug.owner, True)
53+
54
55 class TestBugPrivateAndSecurityRelatedUpdatesMixin:
56