~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/archiveuploader/tests/test_private_maintainers.py

  • Committer: Steve Kowalik
  • Date: 2012-01-05 03:59:54 UTC
  • mto: This revision was merged to the branch mainline in revision 14637.
  • Revision ID: steve.kowalik@canonical.com-20120105035954-3slokx1abu950l0y
Reject uploads that have maintainers set as private teams.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2012 Canonical Ltd.  This software is licensed under the
 
2
# GNU Affero General Public License version 3 (see the file LICENSE).
 
3
 
 
4
__metaclass__ = type
 
5
 
 
6
from zope.security.proxy import removeSecurityProxy
 
7
 
 
8
from lp.archiveuploader.dscfile import SignableTagFile
 
9
from lp.archiveuploader.nascentuploadfile import UploadError
 
10
from lp.registry.interfaces.person import PersonVisibility
 
11
from lp.testing import (
 
12
    celebrity_logged_in,
 
13
    TestCaseWithFactory,
 
14
    )
 
15
from lp.testing.layers import DatabaseFunctionalLayer
 
16
 
 
17
 
 
18
class TestPrivateMaintainers(TestCaseWithFactory):
 
19
 
 
20
    layer = DatabaseFunctionalLayer
 
21
 
 
22
    def test_private_team_non_member(self):
 
23
        # Maintainers can not be private teams. If the uploader isn't set,
 
24
        # or isn't a member, the rejection message is delibrately vague.
 
25
        with celebrity_logged_in('admin'):
 
26
            team = self.factory.makeTeam(
 
27
                email="foo@bar.com", visibility=PersonVisibility.PRIVATE)
 
28
        sigfile = SignableTagFile()
 
29
        sigfile.changes = SignableTagFile()
 
30
        sigfile.changes.changed_by = {}
 
31
        self.assertRaisesWithContent(
 
32
            UploadError, 'Invalid Maintainer.', sigfile.parseAddress,
 
33
            "foo@bar.com")
 
34
 
 
35
    def test_private_team_member(self):
 
36
        # Maintainers can not be private teams. If the uploader is a member
 
37
        # of the team, the rejection message can be clear.
 
38
        uploader = self.factory.makePerson()
 
39
        with celebrity_logged_in('admin'):
 
40
            team = self.factory.makeTeam(
 
41
                email="foo@bar.com", visibility=PersonVisibility.PRIVATE,
 
42
                members=[uploader])
 
43
        sigfile = SignableTagFile()
 
44
        sigfile.changes = SignableTagFile()
 
45
        sigfile.changes.changed_by = {'person': uploader}
 
46
        self.assertRaisesWithContent(
 
47
            UploadError, 'Maintainer can not be set to a private team.',
 
48
            sigfile.parseAddress, "foo@bar.com")