launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #14245
[Merge] lp:~adeuring/launchpad/product-lp-limitedview-branch-view into lp:launchpad
Abel Deuring has proposed merging lp:~adeuring/launchpad/product-lp-limitedview-branch-view into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~adeuring/launchpad/product-lp-limitedview-branch-view/+merge/134315
This branch adds tests to show that users having only an artifact
grant for blueprint or a branch related to a private product can
access the related LP pages.
The test for the branch failed at first because access to IProduct.icon
is required, so I made IHasIcon a base class of IProductLimitedView
instead of IProductView.
tests:
./bin/test blueprints -vvt test_view_for_user_with_artifact_grant
./bin/test code -vvt test_view_for_user_with_artifact_grant
no lint
--
https://code.launchpad.net/~adeuring/launchpad/product-lp-limitedview-branch-view/+merge/134315
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~adeuring/launchpad/product-lp-limitedview-branch-view into lp:launchpad.
=== modified file 'lib/lp/blueprints/browser/tests/test_specification.py'
--- lib/lp/blueprints/browser/tests/test_specification.py 2012-11-13 15:20:28 +0000
+++ lib/lp/blueprints/browser/tests/test_specification.py 2012-11-14 15:35:24 +0000
@@ -184,6 +184,26 @@
extract_text(html), DocTestMatches(
"... Registered by Some Person ... ago ..."))
+ def test_view_for_user_with_artifact_grant(self):
+ # Users with an artifact grant for a specification related to a
+ # private product can view the specification page.
+ owner = self.factory.makePerson()
+ user = self.factory.makePerson()
+ product = self.factory.makeProduct(
+ owner=owner,
+ information_type=InformationType.PROPRIETARY)
+ with person_logged_in(owner):
+ spec = self.factory.makeSpecification(
+ product=product, owner=owner,
+ information_type=InformationType.PROPRIETARY)
+ getUtility(IService, 'sharing').ensureAccessGrants(
+ [user], owner, specifications=[spec])
+ with person_logged_in(user):
+ view = create_initialized_view(
+ spec, name='+index', principal=user, rootsite='blueprints')
+ # Calling render() does not raise any exceptions.
+ self.assertIn(spec.name, view.render())
+
def set_blueprint_information_type(test_case, enabled):
value = 'true' if enabled else ''
=== modified file 'lib/lp/code/browser/tests/test_branch.py'
--- lib/lp/code/browser/tests/test_branch.py 2012-10-31 00:54:33 +0000
+++ lib/lp/code/browser/tests/test_branch.py 2012-11-14 15:35:24 +0000
@@ -17,6 +17,7 @@
from lp.app.enums import InformationType
from lp.app.interfaces.headings import IRootContext
from lp.app.interfaces.launchpad import ILaunchpadCelebrities
+from lp.app.interfaces.services import IService
from lp.bugs.interfaces.bugtask import (
BugTaskStatus,
UNRESOLVED_BUGTASK_STATUSES,
@@ -519,6 +520,27 @@
self.assertEqual(linked_bug_urls[0], links[3]['href'])
self.assertEqual(linked_bug_urls[1], links[4]['href'])
+ def test_view_for_user_with_artifact_grant(self):
+ # Users with an artifact grant for a branch related to a private
+ # product can view the main branch page.
+ owner = self.factory.makePerson()
+ user = self.factory.makePerson()
+ product = self.factory.makeProduct(
+ owner=owner,
+ information_type=InformationType.PROPRIETARY)
+ with person_logged_in(owner):
+ product_name = product.name
+ branch = self.factory.makeBranch(
+ product=product, owner=owner,
+ information_type=InformationType.PROPRIETARY)
+ getUtility(IService, 'sharing').ensureAccessGrants(
+ [user], owner, branches=[branch])
+ with person_logged_in(user):
+ url = canonical_url(branch)
+ # The main check: No Unautorized error should be raised.
+ browser = self.getUserBrowser(url, user=user)
+ self.assertIn(product_name, browser.contents)
+
class TestBranchViewPrivateArtifacts(BrowserTestCase):
""" Tests that branches with private team artifacts can be viewed.
=== modified file 'lib/lp/registry/interfaces/product.py'
--- lib/lp/registry/interfaces/product.py 2012-11-12 23:03:24 +0000
+++ lib/lp/registry/interfaces/product.py 2012-11-14 15:35:24 +0000
@@ -428,7 +428,7 @@
"""True if the given user has access to this product."""
-class IProductLimitedView(IHasLogo, IHasOwner, ILaunchpadUsage):
+class IProductLimitedView(IHasIcon, IHasLogo, IHasOwner, ILaunchpadUsage):
"""Attributes that must be visible for person with artifact grants
on bugs, branches or specifications for the product.
"""
@@ -440,6 +440,16 @@
paragraph.""")),
exported_as='display_name')
+ icon = exported(
+ IconImageUpload(
+ title=_("Icon"), required=False,
+ default_image_resource='/@@/product',
+ description=_(
+ "A small image of exactly 14x14 pixels and at most 5kb in "
+ "size, that can be used to identify this project. The icon "
+ "will be displayed next to the project name everywhere in "
+ "Launchpad that we refer to the project and link to it.")))
+
logo = exported(
LogoImageUpload(
title=_("Logo"), required=False,
@@ -491,7 +501,7 @@
class IProductView(
ICanGetMilestonesDirectly, IHasAppointedDriver, IHasBranches,
- IHasDrivers, IHasExternalBugTracker, IHasIcon,
+ IHasDrivers, IHasExternalBugTracker,
IHasMergeProposals, IHasMilestones, IHasExpirableBugs,
IHasMugshot, IHasSprints, IHasTranslationImports,
ITranslationPolicy, IKarmaContext, IMakesAnnouncements,
@@ -613,16 +623,6 @@
"be displayed for all the world to see. It is NOT a wiki "
"so you cannot undo changes."))
- icon = exported(
- IconImageUpload(
- title=_("Icon"), required=False,
- default_image_resource='/@@/product',
- description=_(
- "A small image of exactly 14x14 pixels and at most 5kb in "
- "size, that can be used to identify this project. The icon "
- "will be displayed next to the project name everywhere in "
- "Launchpad that we refer to the project and link to it.")))
-
mugshot = exported(
MugshotImageUpload(
title=_("Brand"), required=False,
=== modified file 'lib/lp/registry/tests/test_product.py'
--- lib/lp/registry/tests/test_product.py 2012-11-12 23:03:24 +0000
+++ lib/lp/registry/tests/test_product.py 2012-11-14 15:35:24 +0000
@@ -553,7 +553,7 @@
'userCanView',)),
'launchpad.LimitedView': set((
'bugtargetdisplayname', 'displayname', 'enable_bug_expiration',
- 'logo', 'name', 'official_answers', 'official_anything',
+ 'icon', 'logo', 'name', 'official_answers', 'official_anything',
'official_blueprints', 'official_codehosting', 'official_malone',
'owner', 'parent_subscription_target', 'project', 'title', )),
'launchpad.View': set((
@@ -595,7 +595,7 @@
'getVersionSortedSeries',
'has_current_commercial_subscription',
'has_custom_language_codes', 'has_milestones', 'homepage_content',
- 'homepageurl', 'icon', 'invitesTranslationEdits',
+ 'homepageurl', 'invitesTranslationEdits',
'invitesTranslationSuggestions',
'license_info', 'license_status', 'licenses', 'milestones',
'mugshot', 'name_with_project', 'newCodeImport',
Follow ups