1
# Copyright 2012 Canonical Ltd. This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
6
from zope.security.proxy import removeSecurityProxy
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 (
15
from lp.testing.layers import DatabaseFunctionalLayer
18
class TestPrivateMaintainers(TestCaseWithFactory):
20
layer = DatabaseFunctionalLayer
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,
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,
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")