def test_push_to_new_short_branch_alias(self): # We can also push branches to URLs like /+branch/firefox # Hack 'firefox' so we have permission to do this. ZopelessAppServerLayer.txn.begin() firefox = Product.selectOneBy(name='firefox') testuser = Person.selectOneBy(name='testuser') firefox.development_focus.owner = testuser ZopelessAppServerLayer.txn.commit() remote_url = self.getTransportURL('+branch/firefox') self.push(self.local_branch_path, remote_url) self.assertBranchesMatch(self.local_branch_path, remote_url)
def test_cant_access_private_branch(self): # Trying to get information about a private branch should fail as if # the branch doesn't exist. # 'salgado' is a member of landscape-developers. salgado = Person.selectOneBy(name='salgado') landscape_dev = Person.selectOneBy(name='landscape-developers') self.assertTrue( salgado.inTeam(landscape_dev), "salgado should be a member of landscape-developers, but isn't.") # Make a private branch. branch_url = self.createBazaarBranch('landscape-developers', 'landscape', 'some-branch', creator='salgado') # Sanity checking that the branch is actually there. We don't care # about the result, only that the call succeeds. self.getLastRevision(branch_url) # Check that testuser can't access the branch. remote_url = self.getTransportURL( '~landscape-developers/landscape/some-branch') self.assertNotBranch(remote_url)
def test_cant_access_private_branch(self): # Trying to get information about a private branch should fail as if # the branch doesn't exist. # 'salgado' is a member of landscape-developers. salgado = Person.selectOneBy(name='salgado') landscape_dev = Person.selectOneBy( name='landscape-developers') self.assertTrue( salgado.inTeam(landscape_dev), "salgado should be a member of landscape-developers, but isn't.") # Make a private branch. branch_url = self.createBazaarBranch( 'landscape-developers', 'landscape', 'some-branch', creator='salgado') # Sanity checking that the branch is actually there. We don't care # about the result, only that the call succeeds. self.getLastRevision(branch_url) # Check that testuser can't access the branch. remote_url = self.getTransportURL( '~landscape-developers/landscape/some-branch') self.assertNotBranch(remote_url)
def makeDatabaseBranch(self, owner_name, product_name, branch_name, branch_type=BranchType.HOSTED): """Create a new branch in the database.""" owner = Person.selectOneBy(name=owner_name) if product_name == '+junk': product = None else: product = Product.selectOneBy(name=product_name) if branch_type == BranchType.MIRRORED: url = 'http://example.com' else: url = None namespace = get_branch_namespace(owner, product) return namespace.createBranch( branch_type=branch_type, name=branch_name, registrant=owner, url=url)