Merge lp:~thumper/launchpad/code-email-permissions into lp:launchpad/db-devel

Proposed by Tim Penhey
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~thumper/launchpad/code-email-permissions
Merge into: lp:launchpad/db-devel
Diff against target: 51 lines (+30/-0)
2 files modified
database/schema/security.cfg (+1/-0)
lib/lp/code/mail/tests/test_codehandler.py (+29/-0)
To merge this branch: bzr merge lp:~thumper/launchpad/code-email-permissions
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle Approve
Review via email: mp+24390@code.launchpad.net

Commit message

Add codeimport to the select permissions for processmail.

Description of the change

Add a missing db permission for people trying to approve a branch using email.

tests:
  test_process_for_imported_branch

No pre-impl call, somewhat trivial.

To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Yes, seems fine. I'm not entirely sure this bit:

25 + The permission check needs to fall through from the owner, that is why
26 + we are using a non-reviewer for this test.

makes complete sense, can you expand it a bit?

Thanks for doing this and cooking up the test though :-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'database/schema/security.cfg'
2--- database/schema/security.cfg 2010-04-23 11:19:49 +0000
3+++ database/schema/security.cfg 2010-04-29 03:34:33 +0000
4@@ -1501,6 +1501,7 @@
5 public.branchsubscription = SELECT, INSERT
6 public.branchvisibilitypolicy = SELECT
7 public.bugbranch = SELECT
8+public.codeimport = SELECT
9 public.codereviewmessage = SELECT, INSERT
10 public.codereviewvote = SELECT, INSERT, UPDATE
11 public.diff = SELECT, INSERT, UPDATE
12
13=== modified file 'lib/lp/code/mail/tests/test_codehandler.py'
14--- lib/lp/code/mail/tests/test_codehandler.py 2010-04-23 08:33:14 +0000
15+++ lib/lp/code/mail/tests/test_codehandler.py 2010-04-29 03:34:33 +0000
16@@ -245,6 +245,35 @@
17 self.assertEqual(
18 mail['Reply-to'], self.code_handler._getReplyAddress(mail))
19
20+ def test_process_for_imported_branch(self):
21+ """Make sure that the database user is able refer to import branches.
22+
23+ Import branches have different permission checks than other branches.
24+
25+ Permission to mark a merge proposal as approved checks launchpad.Edit
26+ of the target branch, or membership of the review team on the target
27+ branch. For import branches launchpad.Edit also checks the registrant
28+ of the code import if there is one, and membership of vcs-imports. So
29+ if someone is attempting to review something on an import branch, but
30+ they don't have launchpad.Edit but are a member of the review team,
31+ then a check against the code import is done.
32+ """
33+ mail = self.factory.makeSignedMessage(body=' merge approved')
34+ code_import = self.factory.makeCodeImport()
35+ bmp = self.factory.makeBranchMergeProposal(
36+ target_branch=code_import.branch)
37+ email_addr = bmp.address
38+ self.switchDbUser(config.processmail.dbuser)
39+ pop_notifications()
40+ self.code_handler.process(mail, email_addr, None)
41+ notification = pop_notifications()[0]
42+ # The returned message is a multipart message, the first part is
43+ # the message, and the second is the original message.
44+ message, original = notification.get_payload()
45+ self.assertTrue(
46+ "You are not a reviewer for the branch" in
47+ message.get_payload(decode=True))
48+
49 def test_processVote(self):
50 """Process respects the vote command."""
51 mail = self.factory.makeSignedMessage(body=' vote Abstain EBAILIWICK')

Subscribers

People subscribed via source and target branches

to status/vote changes: