Merge lp:~adeuring/launchpad/product-sharing-sec-adapter into lp:launchpad
| Status: | Merged |
|---|---|
| Approved by: | Abel Deuring on 2012-10-02 |
| Approved revision: | no longer in the source branch. |
| Merged at revision: | 16090 |
| Proposed branch: | lp:~adeuring/launchpad/product-sharing-sec-adapter |
| Merge into: | lp:launchpad |
| Diff against target: |
688 lines (+373/-53) 8 files modified
lib/lp/registry/configure.zcml (+24/-12) lib/lp/registry/interfaces/product.py (+23/-17) lib/lp/registry/model/product.py (+18/-9) lib/lp/registry/tests/test_product.py (+254/-0) lib/lp/registry/tests/test_product_webservice.py (+22/-13) lib/lp/security.py (+25/-0) lib/lp/testing/factory.py (+4/-1) lib/lp/testing/pages.py (+3/-1) |
| To merge this branch: | bzr merge lp:~adeuring/launchpad/product-sharing-sec-adapter |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Francesco Banconi (community) | 2012-10-02 | Approve on 2012-10-02 | |
|
Review via email:
|
|||
Commit Message
require the permission launchpad.View for formerly public properties of IProduct; replace the permission launchpad.
Description of the Change
This branch changes the security configuration for IProduct.
Access to most properties of IProduct now requires the permission
launchpad.
publicly available properties are id, information_type and a new method
userCanView()
Details:
- A new interface class IProductLimited
properties that were previously defined in IProductPublic
- IProductPublic now defines only the properties id, information_type
and userCanView()
- registry/
or launchpad.
- new security adapters ViewProduct (for the permission lp.LimitedView)
and ChangeProduct (for the permission lp.AnyAllowedPe
These security adapters check if a project is public; if so, they allow
access for any logged in person; ViewProduct also allws access for
anonymous users in this case. For non-public projects, these adapters
use the new method IProduct.
may be given access.
- the implementation of userCanView() is obviously incomplete: Only
a project owner can currently access data of a private project.
I will change this in a follow-up branch so that userCanView() will
check if the user has an access policy grant for the given product.
(The implementation of this change would have made the diff of this
branch a bit too large ;)
The implementation of IProduct.
incomplete (the DB patch that adds a column Product.
has not yet been applied). Products are by default public; only some
new tests set information_type to a non-public state, but this
change is obviously not permanent. Hence there on risk that properties
of any existing product become accidentally inaccessible.
- the tests test_get_
bit excessive, but having the permissions neede for all properties
documented in the dictionaries expected_
me to check that I did not leave any property publicly accessible.
- I had to change some websevice tests: webservice_
endInteraction(), so we don't have any user/principal defined when
this function finishes. This mean that access to an attribute of a
product will fail, if no new interaction is created. This is why the
changes store for example product.owner in alocal variable right after
the product has been generated. For assertions that access
product attributes, I used the context manager person_logged_in().
tests:
bin/test -vvt lp.registry.
bin/test -vvt lp.registry.
bin/test -vvt lp.registry.
bin/test -vvt lp.registry.
bin/test -vvt lp.registry.
no lint.

Looks good Abel, thank you. Some minor details follow.
256 + def check_permissio ns(self, expected_ permissions, used_permissions,
257 + type_):
There is a check_permissions function in lp.blueprints. tests.test_ specification, which is very similar. Maybe we could abstract them out.
420 + def test_access_ launchpad_ View_proprietar y_product( self):
421 + # Only people with grants for a prviate product can access
422 + # attributes protected by the permission launchapd.View.
Typos: private, launchpad. The same below in test_access_ launchpad_ AnyAllowedPerso n_proprietary_ product and in launchpad_ AnyAllowedPerso n_proprietary_ product.
test_set_
439 + def test_access_ launchpad_ AnyAllowedPerso n_public_ product( self):
440 + # Only logged in persons hav access to properties of public products
Typo: have
475 + def test_set_ launchpad_ AnyAllowedPerso n_public_ product( self): AnyAllowedPerso n.
476 + # Only logged in users can set attributes protected by the
477 + # permission launchapd.
Typo: launchpad