Merge lp:~rockstar/launchpad/not-logged-in-recipes into lp:launchpad

Proposed by Paul Hummer
Status: Merged
Approved by: Aaron Bentley
Approved revision: no longer in the source branch.
Merged at revision: 11603
Proposed branch: lp:~rockstar/launchpad/not-logged-in-recipes
Merge into: lp:launchpad
Diff against target: 90 lines (+27/-11)
3 files modified
lib/lp/code/browser/configure.zcml (+1/-1)
lib/lp/code/browser/tests/test_sourcepackagerecipe.py (+17/-8)
lib/lp/testing/__init__.py (+9/-2)
To merge this branch: bzr merge lp:~rockstar/launchpad/not-logged-in-recipes
Reviewer Review Type Date Requested Status
Aaron Bentley (community) Approve
Review via email: mp+36049@code.launchpad.net

Description of the change

This branch just fixes an issue where a user that wasn't logged in was able to see the +request-builds page.

To post a comment you must log in.
Revision history for this message
Aaron Bentley (abentley) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/browser/configure.zcml'
2--- lib/lp/code/browser/configure.zcml 2010-08-24 02:17:19 +0000
3+++ lib/lp/code/browser/configure.zcml 2010-09-20 19:16:56 +0000
4@@ -1208,7 +1208,7 @@
5 class="lp.code.browser.sourcepackagerecipe.SourcePackageRecipeRequestBuildsView"
6 name="+request-builds"
7 template="../templates/sourcepackagerecipe-request-builds.pt"
8- permission="launchpad.View"/>
9+ permission="launchpad.AnyPerson"/>
10 </facet>
11 <facet facet="branches">
12 <browser:defaultView
13
14=== modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipe.py'
15--- lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2010-09-01 03:25:36 +0000
16+++ lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2010-09-20 19:16:56 +0000
17@@ -46,7 +46,6 @@
18 ANONYMOUS,
19 BrowserTestCase,
20 login,
21- logout,
22 person_logged_in,
23 )
24 from lp.testing.factory import remove_security_proxy_and_shout_at_engineer
25@@ -103,17 +102,12 @@
26 return branch
27
28 def test_create_new_recipe_not_logged_in(self):
29- from canonical.launchpad.testing.pages import setupBrowser
30 product = self.factory.makeProduct(
31 name='ratatouille', displayname='Ratatouille')
32 branch = self.factory.makeBranch(
33 owner=self.chef, product=product, name='veggies')
34- branch_url = canonical_url(branch)
35- logout()
36-
37- browser = setupBrowser()
38- browser.open(branch_url)
39-
40+
41+ browser = self.getViewBrowser(branch, no_login=True)
42 self.assertRaises(
43 Unauthorized, browser.getLink('Create packaging recipe').click)
44
45@@ -689,6 +683,21 @@
46 set([2605]),
47 set(build.buildqueue_record.lastscore for build in builds))
48
49+ def test_request_builds_action_not_logged_in(self):
50+ """Requesting a build creates pending builds."""
51+ woody = self.factory.makeDistroSeries(
52+ name='woody', displayname='Woody',
53+ distribution=self.ppa.distribution)
54+ naked_woody = removeSecurityProxy(woody)
55+ naked_woody.nominatedarchindep = woody.newArch(
56+ 'i386', ProcessorFamily.get(1), False, self.factory.makePerson(),
57+ supports_virtualized=True)
58+ recipe = self.makeRecipe()
59+
60+ browser = self.getViewBrowser(recipe, no_login=True)
61+ self.assertRaises(
62+ Unauthorized, browser.getLink('Request build(s)').click)
63+
64 def test_request_builds_archive(self):
65 recipe = self.factory.makeSourcePackageRecipe()
66 ppa2 = self.factory.makeArchive(
67
68=== modified file 'lib/lp/testing/__init__.py'
69--- lib/lp/testing/__init__.py 2010-09-20 12:56:53 +0000
70+++ lib/lp/testing/__init__.py 2010-09-20 19:16:56 +0000
71@@ -691,10 +691,17 @@
72 self.assertIsNot(
73 None, pattern.search(normalise_whitespace(text)), text)
74
75- def getViewBrowser(self, context, view_name=None):
76+ def getViewBrowser(self, context, view_name=None, no_login=False):
77 login(ANONYMOUS)
78 url = canonical_url(context, view_name=view_name)
79- return self.getUserBrowser(url, self.user)
80+ logout()
81+ if no_login:
82+ from canonical.launchpad.testing.pages import setupBrowser
83+ browser = setupBrowser()
84+ browser.open(url)
85+ return browser
86+ else:
87+ return self.getUserBrowser(url, self.user)
88
89 def getMainText(self, context, view_name=None):
90 """Return the main text of a context's page."""