Merge lp:~sinzui/launchpad/faq-mailing-list-permissions-0 into lp:launchpad
| Status: | Merged |
|---|---|
| Approved by: | Graham Binns on 2010-12-07 |
| Approved revision: | no longer in the source branch. |
| Merged at revision: | 12028 |
| Proposed branch: | lp:~sinzui/launchpad/faq-mailing-list-permissions-0 |
| Merge into: | lp:launchpad |
| Diff against target: |
251 lines (+195/-11) 4 files modified
lib/canonical/launchpad/security.py (+17/-4) lib/lp/answers/doc/faq.txt (+1/-7) lib/lp/answers/tests/test_faq.py (+77/-0) lib/lp/answers/tests/test_faqtarget.py (+100/-0) |
| To merge this branch: | bzr merge lp:~sinzui/launchpad/faq-mailing-list-permissions-0 |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Graham Binns (community) | code | 2010-12-06 | Approve on 2010-12-07 |
|
Review via email:
|
|||
Description of the Change
Allow answer contacts for packages to create/edit FAQs.
Launchpad bug: https:/
Pre-
Test command: ./bin/test -vv -t test_faqtarget -t test_faq
or to test all changes are kosher: -m lp.answers
Answer contacts for Ubuntu packages cannot create FAQs. There are cases where
the link is shown but the user gets an error when creating the FAQ. This
looked like a conflicting permission at first because the permissions were
changed a few months ago. Examining the history of the code and tests shows
that the permission has aways been broken.
The problem is in the security checker. The checker is based on the question
checker (answer_contacts), but the set of permitted users is larger.
Distribution users who can edit an FAQ are comprised of distro answer_contacts
+ the answer_contacts of all the packages.
That is a lot of inTeam() checks across a lot of packages. There is an
alternate way to solve this that will involve exactly two queries regardless
of the number of packages and answer_contacts. The checker can get the user's
direct and indirect questiontargets from the user and compare them to
the context.
-------
RULES
* Update the AppendFAQTarget method use the direct and team answer
contact methods to get all the question targets. Return True if any
are the context faq target.
* Update the AppendQuestion method to use the same principle to make
answers permission checks faster for large projects.
QA
* As an answer contact for a package, but not ubuntu. Verify you can
create an FAQ from a question.
* Verify you can edit that FAQ.
LINT
lib/
lib/
lib/
lib/
IMPLEMENTATION
Added tests to verify the expect permissions for IFAQTarget and IFAQ. The
format is similar to the Question target tests that verify that all the
implementations have the same behaviour. The test confirmed the permissions
were broken. The change in the security check addressed the issue.
lib/
lib/
lib/
Removed the redundant and incomplete permissions check.
lib/
Update the Question permission rules to reduce the number of queries called
in answers for large projects. test_questiontarget is the specific test that
covers permission, but I ran all lp.answers to ensure that there were no
behavioral changes.
lib/
| Curtis Hovey (sinzui) wrote : | # |
On Tue, 2010-12-07 at 11:01 +0000, Graham Binns wrote:
> Review: Needs Fixing code
> Hi Curtis,
>
> Two comments, one small, one big:
>
> Small:
>
> > 19 + # object is being examined; the implementers are no synonymous.
>
> s/no/not/
Fixed.
> Big:
>
> Also, your tests need comments or docstrings explaining what they're
> testing.
I added docstrings to the methods that users might want to reuse. I
added comments to the test methods.
{{{
=== modified file 'lib/canonical/
--- lib/canonical/
+++ lib/canonical/
@@ -1684,7 +1684,7 @@
return True
if IQuestionTarget
# Adapt QuestionTargets to FAQTargets to ensure the correct
- # object is being examined; the implementers are no synonymous.
+ # object is being examined; the implementers are not synonymous.
for target in questions_
=== modified file 'lib/lp/
--- lib/lp/
+++ lib/lp/
@@ -18,6 +18,7 @@
class TestFAQPermissi
+ """Test who can edit FAQs."""
layer = DatabaseFunctio
@@ -29,29 +30,36 @@
def addAnswerContac
+ """Add the test person to the faq target's answer contacts."""
def assertCanEdit(self, user, faq):
+ """Assert that the user can edit an FAQ."""
can_edit = check_permissio
def assertCannotEdi
+ """Assert that the user cannot edit an FAQ."""
can_edit = check_permissio
def test_owner_
+ # The owner of an FAQ target can edit its FAQs.
def test_direct_
+ # A direct answer contact for an FAQ target can edit its FAQs.
def test_indirect_
+ # A indirect answer contact (a member of a team that is an answer
+ # contact) for an FAQ target can edit its FAQs.
with person_
@@ -...

Hi Curtis,
Two comments, one small, one big:
Small:
> 19 + # object is being examined; the implementers are no synonymous.
s/no/not/
Big:
Also, your tests need comments or docstrings explaining what they're
testing.