Merge lp:~adeuring/launchpad/bug-1056881-2 into lp:launchpad

Proposed by Abel Deuring on 2012-11-26
Status: Merged
Approved by: Abel Deuring on 2012-11-26
Approved revision: no longer in the source branch.
Merged at revision: 16312
Proposed branch: lp:~adeuring/launchpad/bug-1056881-2
Merge into: lp:launchpad
Diff against target: 166 lines (+47/-21)
4 files modified
lib/lp/blueprints/browser/tests/test_specification.py (+7/-9)
lib/lp/registry/configure.zcml (+25/-0)
lib/lp/registry/interfaces/product.py (+11/-9)
lib/lp/registry/tests/test_product.py (+4/-3)
To merge this branch: bzr merge lp:~adeuring/launchpad/bug-1056881-2
Reviewer Review Type Date Requested Status
Richard Harding (community) 2012-11-26 Approve on 2012-11-26
Review via email: mp+136194@code.launchpad.net

Commit Message

fix permissions issues so that subscribers to a blueprint can view the blueprint page.

Description of the Change

This branch allows subscribers to a proprietary blueprint to view
te blueprint page. (bug 1056881)

My first attempt to fix this bug missed two important points:

1. The main view test, test_view_for_user_with_artifact_grant() --
   now called test_view_for_subscriber_with_artifact_grant() --
   did not require traversal,
2. it just tested that people with an artifact grant can view the
   page. Hence the subscribers portlet was empty, which meant that
   another permission problem to render the subscribers portlet
   was not detected.

So test_view_for_subscriber_with_artifact_grant() no calls
getViewBrowser() instead create_initialized_view() to ensure
that "proper traversal" is done in the test. This reveealed that
Product.getSPecification() needs the permission lp.LimitedView.

Redering the subscribers portlet requires access to IProduct.drivers,
so this attribute now alsoe requires the permission lp.LimitedView.

I removed the base classes IHasDrivers and ISpecificationTarget
from IProductView and added them to IProduct.

There are no permission settings for IProduct itself, only for
several base classes. Since somes attributes defined in IHasDrivers
and ISpecificationTarget now need the permission lp.LimitedView,
while others still required lp.View, I specified the permission
attribute-by-attribue in configure.zcml.

tests:

./bin/test blueprints -vvt test_view_for_subscriber_with_artifact_grant
./bin/test registry -vvt test_product.*test_.et_permissions

no lint

To post a comment you must log in.
Richard Harding (rharding) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/blueprints/browser/tests/test_specification.py'
2--- lib/lp/blueprints/browser/tests/test_specification.py 2012-11-14 14:10:13 +0000
3+++ lib/lp/blueprints/browser/tests/test_specification.py 2012-11-26 14:57:33 +0000
4@@ -157,7 +157,7 @@
5 self.specification.getBranchLink(branch), self.traverse(segments))
6
7
8-class TestSpecificationView(TestCaseWithFactory):
9+class TestSpecificationView(BrowserTestCase):
10 """Test the SpecificationView."""
11
12 layer = DatabaseFunctionalLayer
13@@ -184,7 +184,7 @@
14 extract_text(html), DocTestMatches(
15 "... Registered by Some Person ... ago ..."))
16
17- def test_view_for_user_with_artifact_grant(self):
18+ def test_view_for_subscriber_with_artifact_grant(self):
19 # Users with an artifact grant for a specification related to a
20 # private product can view the specification page.
21 owner = self.factory.makePerson()
22@@ -196,13 +196,11 @@
23 spec = self.factory.makeSpecification(
24 product=product, owner=owner,
25 information_type=InformationType.PROPRIETARY)
26- getUtility(IService, 'sharing').ensureAccessGrants(
27- [user], owner, specifications=[spec])
28- with person_logged_in(user):
29- view = create_initialized_view(
30- spec, name='+index', principal=user, rootsite='blueprints')
31- # Calling render() does not raise any exceptions.
32- self.assertIn(spec.name, view.render())
33+ spec.subscribe(user, subscribed_by=owner)
34+ spec_name = spec.name
35+ # Creating the view does not raise any exceptions.
36+ view = self.getViewBrowser(spec, user=user)
37+ self.assertIn(spec_name, view.contents)
38
39
40 def set_blueprint_information_type(test_case, enabled):
41
42=== modified file 'lib/lp/registry/configure.zcml'
43--- lib/lp/registry/configure.zcml 2012-11-22 16:26:40 +0000
44+++ lib/lp/registry/configure.zcml 2012-11-26 14:57:33 +0000
45@@ -1436,6 +1436,31 @@
46 <require
47 permission="launchpad.Edit"
48 set_attributes="bug_supervisor"/>
49+
50+ <!-- ISpecificationTarget -->
51+ <require
52+ permission="launchpad.LimitedView"
53+ attributes="
54+ getSpecification" />
55+ <require
56+ permission="launchpad.View"
57+ attributes="
58+ _all_specifications
59+ _valid_specifications
60+ getAllowedSpecificationInformationTypes
61+ getDefaultSpecificationInformationType
62+ specifications" />
63+
64+ <!-- IHasDrivers -->
65+ <require
66+ permission="launchpad.LimitedView"
67+ attributes="
68+ drivers" />
69+ <require
70+ permission="launchpad.View"
71+ attributes="
72+ personHasDriverRights" />
73+
74 </class>
75
76 <!-- ProductWithLicenses
77
78=== modified file 'lib/lp/registry/interfaces/product.py'
79--- lib/lp/registry/interfaces/product.py 2012-11-24 17:49:30 +0000
80+++ lib/lp/registry/interfaces/product.py 2012-11-26 14:57:33 +0000
81@@ -501,12 +501,12 @@
82
83 class IProductView(
84 ICanGetMilestonesDirectly, IHasAppointedDriver, IHasBranches,
85- IHasDrivers, IHasExternalBugTracker,
86+ IHasExternalBugTracker,
87 IHasMergeProposals, IHasMilestones, IHasExpirableBugs,
88 IHasMugshot, IHasSprints, IHasTranslationImports,
89 ITranslationPolicy, IKarmaContext, IMakesAnnouncements,
90 IOfficialBugTagTargetPublic, IHasOOPSReferences,
91- ISpecificationTarget, IHasRecipes, IHasCodeImports, IServiceUsage):
92+ IHasRecipes, IHasCodeImports, IServiceUsage):
93 """Public IProduct properties."""
94
95 registrant = exported(
96@@ -529,11 +529,6 @@
97 "than having one project team that does it all."),
98 required=False, vocabulary='ValidPersonOrTeam'))
99
100- drivers = Attribute(
101- "Presents the drivers of this project as a list. A list is "
102- "required because there might be a project driver and also a "
103- "driver appointed in the overarching project group.")
104-
105 summary = exported(
106 Summary(
107 title=_('Summary'),
108@@ -917,10 +912,11 @@
109
110
111 class IProduct(
112- IBugTarget, IHasBugSupervisor, IProductEditRestricted,
113+ IBugTarget, IHasBugSupervisor, IHasDrivers, IProductEditRestricted,
114 IProductModerateRestricted, IProductDriverRestricted, IProductView,
115 IProductLimitedView, IProductPublic, IQuestionTarget, IRootContext,
116- IStructuralSubscriptionTarget, IInformationType, IPillar):
117+ ISpecificationTarget, IStructuralSubscriptionTarget, IInformationType,
118+ IPillar):
119 """A Product.
120
121 The Launchpad Registry describes the open source world as ProjectGroups
122@@ -931,6 +927,12 @@
123
124 export_as_webservice_entry('project')
125
126+ drivers = Attribute(
127+ "Presents the drivers of this project as a list. A list is "
128+ "required because there might be a project driver and also a "
129+ "driver appointed in the overarching project group.")
130+
131+
132 # Fix cyclic references.
133 IProjectGroup['products'].value_type = Reference(IProduct)
134 IProductRelease['product'].schema = IProduct
135
136=== modified file 'lib/lp/registry/tests/test_product.py'
137--- lib/lp/registry/tests/test_product.py 2012-11-26 08:33:03 +0000
138+++ lib/lp/registry/tests/test_product.py 2012-11-26 14:57:33 +0000
139@@ -663,7 +663,8 @@
140 'active', 'id', 'information_type', 'pillar_category', 'private',
141 'userCanView',)),
142 'launchpad.LimitedView': set((
143- 'bugtargetdisplayname', 'displayname', 'enable_bug_expiration',
144+ 'bugtargetdisplayname', 'displayname', 'drivers',
145+ 'enable_bug_expiration', 'getSpecification',
146 'icon', 'logo', 'name', 'official_answers', 'official_anything',
147 'official_blueprints', 'official_codehosting', 'official_malone',
148 'owner', 'parent_subscription_target', 'project', 'title', )),
149@@ -684,7 +685,7 @@
150 'date_next_suggest_packaging', 'datecreated', 'description',
151 'development_focus', 'development_focusID',
152 'direct_answer_contacts', 'distrosourcepackages',
153- 'downloadurl', 'driver', 'drivers',
154+ 'downloadurl', 'driver',
155 'enable_bugfiling_duplicate_search', 'findReferencedOOPS',
156 'findSimilarFAQs', 'findSimilarQuestions', 'freshmeatproject',
157 'getAllowedBugInformationTypes',
158@@ -698,7 +699,7 @@
159 'getFAQ', 'getFirstEntryToImport', 'getLinkedBugWatches',
160 'getMergeProposals', 'getMilestone', 'getMilestonesAndReleases',
161 'getQuestion', 'getQuestionLanguages', 'getPackage', 'getRelease',
162- 'getSeries', 'getSpecification', 'getSubscription',
163+ 'getSeries', 'getSubscription',
164 'getSubscriptions', 'getSupportedLanguages', 'getTimeline',
165 'getTopContributors', 'getTopContributorsGroupedByCategory',
166 'getTranslationGroups', 'getTranslationImportQueueEntries',