991
992
requester = self.factory.makePerson()
992
993
self.assertNotFound(requester, '/%s/.bzr' % BRANCH_ALIAS_PREFIX)
995
def test_translatePath_branch_id_alias_bzrdir_content(self):
996
# translatePath('/+branch-id/.bzr/.*') *must* return not found, otherwise
997
# bzr will look for it and we don't have a global bzr dir.
998
requester = self.factory.makePerson()
1000
requester, '/%s/.bzr/branch-format' % BRANCH_ID_ALIAS_PREFIX)
1002
def test_translatePath_branch_id_alias_bzrdir(self):
1003
# translatePath('/+branch-id/.bzr') *must* return not found, otherwise
1004
# bzr will look for it and we don't have a global bzr dir.
1005
requester = self.factory.makePerson()
1006
self.assertNotFound(requester, '/%s/.bzr' % BRANCH_ID_ALIAS_PREFIX)
1008
def test_translatePath_branch_id_alias_owned(self):
1009
# Even if the the requester is the owner, the branch is read only.
1010
requester = self.factory.makePerson()
1011
branch = self.factory.makeAnyBranch(
1012
branch_type=BranchType.HOSTED, owner=requester)
1013
path = escape(u'/%s/%s' % (BRANCH_ID_ALIAS_PREFIX, branch.id))
1014
translation = self.codehosting_api.translatePath(requester.id, path)
1016
(BRANCH_TRANSPORT, {'id': branch.id, 'writable': False}, ''),
1019
def test_translatePath_branch_id_alias_private_branch(self):
1020
requester = self.factory.makePerson()
1021
branch = removeSecurityProxy(
1022
self.factory.makeAnyBranch(
1023
branch_type=BranchType.HOSTED, private=True, owner=requester))
1024
path = escape(u'/%s/%s' % (BRANCH_ID_ALIAS_PREFIX, branch.id))
1025
translation = self.codehosting_api.translatePath(requester.id, path)
1027
(BRANCH_TRANSPORT, {'id': branch.id, 'writable': False}, ''),
1030
def test_translatePath_branch_id_alias_private_branch_no_access(self):
1031
requester = self.factory.makePerson()
1032
branch = removeSecurityProxy(
1033
self.factory.makeAnyBranch(
1034
branch_type=BranchType.HOSTED, private=True))
1035
path = escape(u'/%s/%s' % (BRANCH_ID_ALIAS_PREFIX, branch.id))
1036
self.assertPermissionDenied(requester, path)
994
1038
def assertTranslationIsControlDirectory(self, translation,
995
1039
default_stacked_on,