def testPathIdLookupShortcut(self): # CNY-1911 self.openRepository(1) self.openRepository(2) label2 = Label('localhost2@rpl:devel') label1 = Label('localhost1@rpl:devel') shadowLabel = Label('localhost@rpl:shadow') self.makeSourceTrove('test', simpleRecipe, buildLabel = label2) built = self.cookFromRepository('test', buildLabel = label2) self.assertEqual(built[0][1], '/localhost2@rpl:devel/1.0-1-1') # Now shadow self.mkbranch(['test:source=' + label2.asString()], label1, shadow=True) # Noop change newRecipe = simpleRecipe.replace("mode=0755", "contents='foobar\\n', mode=0755") self.updateSourceTrove('test', newRecipe, versionStr = label1.asString()) # And build in the repo built = self.cookFromRepository('test', buildLabel = label1) self.assertEqual(built[0][1], '/localhost2@rpl:devel//localhost1@rpl:devel/1.0-1.1-1') # Now shadow again self.mkbranch(['test:source=' + label1.asString()], shadowLabel, shadow=True) # And build in the repo built = self.cookFromRepository('test', buildLabel = shadowLabel) # Stop the ancestor repo self.stopRepository(2) # We should still be able to cook built = self.cookFromRepository('test', buildLabel = shadowLabel)
def testPathIdLookupShortcut(self): # CNY-1911 self.openRepository(1) self.openRepository(2) label2 = Label('localhost2@rpl:devel') label1 = Label('localhost1@rpl:devel') shadowLabel = Label('localhost@rpl:shadow') self.makeSourceTrove('test', simpleRecipe, buildLabel=label2) built = self.cookFromRepository('test', buildLabel=label2) self.assertEqual(built[0][1], '/localhost2@rpl:devel/1.0-1-1') # Now shadow self.mkbranch(['test:source=' + label2.asString()], label1, shadow=True) # Noop change newRecipe = simpleRecipe.replace("mode=0755", "contents='foobar\\n', mode=0755") self.updateSourceTrove('test', newRecipe, versionStr=label1.asString()) # And build in the repo built = self.cookFromRepository('test', buildLabel=label1) self.assertEqual( built[0][1], '/localhost2@rpl:devel//localhost1@rpl:devel/1.0-1.1-1') # Now shadow again self.mkbranch(['test:source=' + label1.asString()], shadowLabel, shadow=True) # And build in the repo built = self.cookFromRepository('test', buildLabel=shadowLabel) # Stop the ancestor repo self.stopRepository(2) # We should still be able to cook built = self.cookFromRepository('test', buildLabel=shadowLabel)
def testPathIdLookupPermissions(self): # CNY-1911 label2 = Label('localhost2@rpl:devel') label1 = Label('localhost1@rpl:devel') shadowLabel = Label('localhost@rpl:shadow') self.openRepository(0) self.openRepository(1) # Remove anonymous user repos = self.openRepository(2) repos.deleteUserByName(label2.asString(), "anonymous") # Add a file that disappears recipe1 = simpleRecipe + " r.Create('/usr/blip', contents='abc\\n')\n" self.makeSourceTrove('test', recipe1, buildLabel = label2) built = self.cookFromRepository('test', buildLabel = label2) # Extra file goes away self.updateSourceTrove('test', simpleRecipe, versionStr = label2.asString()) built = self.cookFromRepository('test', buildLabel = label2) self.assertEqual(built[0][1], '/localhost2@rpl:devel/1.0-2-1') # Now shadow self.mkbranch(['test:source=' + label2.asString()], label1, shadow=True) # Noop change newRecipe = simpleRecipe.replace("mode=0755", "contents='foobar\\n', mode=0755") self.updateSourceTrove('test', newRecipe, versionStr = label1.asString()) # And build in the repo built = self.cookFromRepository('test', buildLabel = label1) self.assertEqual(built[0][1], '/localhost2@rpl:devel//localhost1@rpl:devel/1.0-2.1-1') # Now shadow again self.mkbranch(['test:source=' + label1.asString()], shadowLabel, shadow=True) # Add the original file back self.updateSourceTrove('test', recipe1, versionStr = shadowLabel.asString()) # Reset users, client-side self.cfg.user.addServerGlob('localhost2', ('test', 'wrongpass')) client = conaryclient.ConaryClient(self.cfg) repos = client.getRepos() # And build in the repo built = self.cookFromRepository('test', buildLabel = shadowLabel, repos = repos) self.assertEqual(built[0][1], '/localhost2@rpl:devel//localhost1@rpl:devel//localhost@rpl:shadow/1.0-2.1.1-1') trvList = repos.getTroves([ (x[0], VFS(x[1]), x[2]) for x in built ]) trv = trvList[0] # Iterate over all files for _, _, _, vr in trv.iterFileList(): # Make sure the file version is the same as the trove version. If # the originating repo didn't reject the request (and the client # didn't ignore the reject), then we'd see the file version be on # the /localhost2 branch. self.assertEqual(vr.asString(), built[0][1])
def testPathIdLookupPermissions(self): # CNY-1911 label2 = Label('localhost2@rpl:devel') label1 = Label('localhost1@rpl:devel') shadowLabel = Label('localhost@rpl:shadow') self.openRepository(0) self.openRepository(1) # Remove anonymous user repos = self.openRepository(2) repos.deleteUserByName(label2.asString(), "anonymous") # Add a file that disappears recipe1 = simpleRecipe + " r.Create('/usr/blip', contents='abc\\n')\n" self.makeSourceTrove('test', recipe1, buildLabel=label2) built = self.cookFromRepository('test', buildLabel=label2) # Extra file goes away self.updateSourceTrove('test', simpleRecipe, versionStr=label2.asString()) built = self.cookFromRepository('test', buildLabel=label2) self.assertEqual(built[0][1], '/localhost2@rpl:devel/1.0-2-1') # Now shadow self.mkbranch(['test:source=' + label2.asString()], label1, shadow=True) # Noop change newRecipe = simpleRecipe.replace("mode=0755", "contents='foobar\\n', mode=0755") self.updateSourceTrove('test', newRecipe, versionStr=label1.asString()) # And build in the repo built = self.cookFromRepository('test', buildLabel=label1) self.assertEqual( built[0][1], '/localhost2@rpl:devel//localhost1@rpl:devel/1.0-2.1-1') # Now shadow again self.mkbranch(['test:source=' + label1.asString()], shadowLabel, shadow=True) # Add the original file back self.updateSourceTrove('test', recipe1, versionStr=shadowLabel.asString()) # Reset users, client-side self.cfg.user.addServerGlob('localhost2', ('test', 'wrongpass')) client = conaryclient.ConaryClient(self.cfg) repos = client.getRepos() # And build in the repo built = self.cookFromRepository('test', buildLabel=shadowLabel, repos=repos) self.assertEqual( built[0][1], '/localhost2@rpl:devel//localhost1@rpl:devel//localhost@rpl:shadow/1.0-2.1.1-1' ) trvList = repos.getTroves([(x[0], VFS(x[1]), x[2]) for x in built]) trv = trvList[0] # Iterate over all files for _, _, _, vr in trv.iterFileList(): # Make sure the file version is the same as the trove version. If # the originating repo didn't reject the request (and the client # didn't ignore the reject), then we'd see the file version be on # the /localhost2 branch. self.assertEqual(vr.asString(), built[0][1])