Merge lp:~jpds/launchpad/fix_517020 into lp:launchpad
| Status: | Merged | ||||
|---|---|---|---|---|---|
| Approved by: | Michael Nelson on 2010-02-05 | ||||
| Approved revision: | not available | ||||
| Merged at revision: | 10283 | ||||
| Proposed branch: | lp:~jpds/launchpad/fix_517020 | ||||
| Merge into: | lp:launchpad | ||||
| Diff against target: |
247 lines (+113/-20) 3 files modified
lib/lp/registry/interfaces/distributionmirror.py (+22/-16) lib/lp/registry/stories/webservice/xx-distribution-mirror.txt (+88/-3) lib/lp/registry/stories/webservice/xx-distribution.txt (+3/-1) |
||||
| To merge this branch: | bzr merge lp:~jpds/launchpad/fix_517020 | ||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Brad Crittenden (community) | code | Approve on 2010-02-05 | |
| Michael Nelson (community) | code | 2010-02-04 | Approve on 2010-02-05 |
|
Review via email:
|
|||
Commit Message
Various fixes to exported() values in the newly exposed distribution_
| Jonathan Davies (jpds) wrote : | # |
| Michael Nelson (michael.nelson) wrote : | # |
Hi Jonathan,
It's great that you're so quick to get in there and fix his. Other than some formatting issues, the only point that I think needs addressing here is testing the writable of the fields you're changing/exporting.
> === modified file 'lib/lp/
> --- a/lib/lp/
> +++ b/lib/lp/
> @@ -287,17 +287,19 @@
>
> id = Int(title=_('The unique id'), required=True, readonly=True)
> owner = exported(
> - title=_('Owner'), required=False, readonly=True,
> - vocabulary=
> - reviewer = PublicPersonChoice(
> - title=_
> - vocabulary=
> + title=_('Owner'), description=_("The person who is set as the "
> + "current administrator of this mirror."), required=True,
> + readonly=False, vocabulary=
So the owner attribute is no-longer readonly? If that's intentional, we really
should have that tested/documented (ie. who can/can't write to it).
Also, just a few small indentation things looking at
the style guide. It might be easier to format this like:
title=
"The person who is set as the current administrator of this mirror."),
required=True, readonly=False, vocabulary=
or
title=
description=_(
"The person who is set as the current administrator of this mirror."))
> + reviewer = exported(
> + title=_
> + "mirror."), required=False, readonly=True,
> + vocabulary=
So the main change is that readonly is now true. Please ensure this is tested
also.
Similar formatting issues here. Although, I can't see anything in the
style-guide, but I thought that concatenated strings needed to be aligned (if
you have to break them).
> distribution = exported(
> Reference(
> Interface,
> # Really IDistribution, circular import fixed in
> # _schema_
> - title=_
> + title=_
Again, this needs to be tested (so it doesn't happen again).
> description=_("The distribution that is mirrored")))
> name = exported(
> title=_('Name'), required=True, readonly=False,
> @@ -325,7 +327,7 @@
> description=
> enabled = exported(Bool(
> title=_('This mirror was probed successfully.'),
> - required=False, readonly=False, default=False))
> + required=False, readonly=True, default=False))
And here too.
> speed = exported(Choice(
> title=_('Link Speed'), required=True, readonly=False,
> vocabulary=
> @@ -343,7 +345,8 @@
> title=_('Apply to...
| Jonathan Davies (jpds) wrote : | # |
> === modified file 'lib/lp/
> > --- a/lib/lp/
> > +++ b/lib/lp/
> > @@ -287,17 +287,19 @@
> >
> > id = Int(title=_('The unique id'), required=True, readonly=True)
> > owner = exported(
> > - title=_('Owner'), required=False, readonly=True,
> > - vocabulary=
> > - reviewer = PublicPersonChoice(
> > - title=_
> > - vocabulary=
> > + title=_('Owner'), description=_("The person who is set as the "
> > + "current administrator of this mirror."), required=True,
> > + readonly=False, vocabulary=
>
> So the owner attribute is no-longer readonly? If that's intentional, we really
> should have that tested/documented (ie. who can/can't write to it).
This is now tested in registry/
> Also, just a few small indentation things looking at
> the style guide. It might be easier to format this like:
>
> title=_('Owner'), description=_(
> "The person who is set as the current administrator of this mirror."),
> required=True, readonly=False, vocabulary=
>
> or
>
> title=_('Owner'), required=True, readonly=False, vocabulary=
> description=_(
> "The person who is set as the current administrator of this mirror."))
I've changed all the fields to the latter.
> > + reviewer = exported(
> > + title=_
> > + "mirror."), required=False, readonly=True,
> > + vocabulary=
>
> So the main change is that readonly is now true. Please ensure this is tested
> also.
Also done.
> Similar formatting issues here. Although, I can't see anything in the
> style-guide, but I thought that concatenated strings needed to be aligned (if
> you have to break them).
>
> > distribution = exported(
> > Reference(
> > Interface,
> > # Really IDistribution, circular import fixed in
> > # _schema_
> > - title=_
> > + title=_
>
> Again, this needs to be tested (so it doesn't happen again).
This is now tested.
> > description=_("The distribution that is mirrored")))
> > name = exported(
> > title=_('Name'), required=True, readonly=False,
> > @@ -325,7 +327,7 @@
> > description=
> > enabled = exported(Bool(
> > title=_('This mirror was probed successfully.'),
> > - required=False, readonly=False, default=False))
> > + required=False, readonly=True, default=False))
>
> And here too.
Likewise.
> > speed = exported(Choice(
> > title=_('Link Speed'), required=True, readonly=False,
> > vocabul...
| Michael Nelson (michael.nelson) wrote : | # |
Thanks for the changes Jonathan. I've approved the review, but do have a couple of things below that I'm interested to hear back on (they could be just oversights on my part).
> Done and full diff since r10278:
> === modified file 'lib/lp/
> mirror.txt'
> --- lib/lp/
> 2010-02-04 12:22:19 +0000
> +++ lib/lp/
> 2010-02-05 11:32:41 +0000
> @@ -57,6 +57,88 @@
> status: u'Official'
> whiteboard: None
>
> += Security checks =
> +
> +People who are not mirror listing admins or the mirrors registrar may not
> +change the owner's of mirrors:
> +
> + >>> from canonical.
> + >>> from canonical.
> + >>> from zope.component import getUtility
> + >>> from lp.registry.
> + >>> from simplejson import dumps
> + >>> login(ANONYMOUS)
> + >>> karl_db = getUtility(
> + >>> test_db = getUtility(
> + >>> karl_webservice = webservice_
> + ... permission=
> + >>> test_webservice = webservice_
> + ... permission=
> + >>> logout()
> + >>> karl = webservice.
> + >>> patch = {
> + ... u'owner_link': karl['self_link']
> + ... }
> +
> +Now trying to set the owner using Sample Person's webservice is not
> authorized.
> +
> + >>> response = test_webservice
> + ... canonical_
> + >>> print response.
> + 401 Unauthorized
> +
> +But if we use Karl, the mirror listing admin's, webservice, we can update the
s/admin's,/admin's
> owner.
> +
> + >>> response = karl_webservice
> + ... canonical_
> + >>> print response.
> + 209 Content Returned
> +
> + >>> patched_
> + >>> print patched_
> + http://
> +
> +Some attributes are read-only via the API:
> +
> + >>> distros = webservice.
> + >>> distro = distros[
> + >>> debian = webservice.
I haven't checked, but is the above line necessary? you're getting distro['self_link'] which should be equivalent to distro? (ie. distro == debian?). Actually, you only seem to use debian['self_link'] below anyway (which should be equivalent to distro['self_link'] unless I'm missing something).
> + >>> patch = {
> + ... u'date_reviewed' : u'2010-
> + ... u'distribution_
> + ... u'enabled' : False,
> + ... u'reviewer_link' : karl['self_link']
> + ... }
> + >>> response = karl_webservice
> + ... canonical_
> dum...
| Jonathan Davies (jpds) wrote : | # |
The branch failed a test on distribution.txt, as I was just testing distribution-
=== modified file 'lib/lp/
--- lib/lp/
+++ lib/lp/
@@ -124,18 +124,20 @@
>>> pprint_
content: u'CD Image'
date_created: u'2006-
+ date_reviewed: None
description: None
displayname: None
distributi
enabled: True
ftp_base_url: None
- has_ftp_
http_base_url: u'http://
name: u'canonical-
official_
owner_link: u'http://
+ reviewer_link: None
resource_
rsync_
self_link: u'http://
speed: u'100 Mbps'
status: u'Official'
+ whiteboard: None
| Jonathan Davies (jpds) wrote : | # |
>> >>> is_official_mirror =
>> webservice.
>> ... 'isOfficial'
>> >>> print is_official_mirror
>> - True
>> + False
>
> I can't see anything that should have changed the expected value of this test? Why did it
> change here?
For the record:
<noodles> Also, I can't see why the expected value of is_official_mirror changed at the end of your diff?
<jpds> 13:47:01 <jpds> is_o_m> IT changes because I patch it with: u'status' : 'Unofficial'
| Brad Crittenden (bac) wrote : | # |
Your additional test changes look good. Thanks.

= Summary =
This branch fixes various problems with the newly exposed distribution_ mirror' s as described in bug #517020.
It also exposes various other things whose permissions to access are restricted by Zope's configuration.