def testRoleDeletion(self):
        bl = self.cfg.buildLabel
        repos = self.openRepository()
        repos.deleteUserByName(bl, 'anonymous')
                
        repos.addRole(bl, "special")
        repos.addRole(bl, "special1")
        self.assertTrue("special" in repos.listRoles(bl))
        self.assertTrue("special1" in repos.listRoles(bl))
        repos.addUser(bl, "special", "pass")
        specialClient = self.getRepositoryClient(user = "special", password = "pass")
        # a user with no groups raises InsufficientPermission
        self.assertRaises(errors.InsufficientPermission, specialClient.getRoles, bl)
        repos.updateRoleMembers(bl, "special1", ["special"])
        self.assertEqual(specialClient.getRoles(bl), ["special1"])
        repos.updateRoleMembers(bl, "special", ["special"])
        self.assertEqual(set(specialClient.getRoles(bl)), set(["special", "special1"]))
        repos.deleteUserByName(bl, "special")
        self.assertTrue("special1" in repos.listRoles(bl))
        self.assertFalse("special" in repos.listRoles(bl))

        # a role with nothing special will not survive
        repos.addRole(bl, "special")
        repos.addUser(bl, "special", "pass")
        repos.updateRoleMembers(bl, "special", ["special"])
        repos.deleteUserByName(bl, "special")
        self.assertFalse("special" in repos.listRoles(bl))

        # a role with mirror bits should survive
        repos.addRole(bl, "special")
        repos.addUser(bl, "special", "pass")
        repos.updateRoleMembers(bl, "special", ["special"])
        repos.setRoleCanMirror(bl, "special", True)
        repos.deleteUserByName(bl, "special")
        self.assertTrue("special" in repos.listRoles(bl))
        repos.deleteRole(bl, "special")
        
        # a role with admin bits should survive
        repos.addRole(bl, "special")
        repos.addUser(bl, "special", "pass")
        repos.updateRoleMembers(bl, "special", ["special"])
        repos.setRoleIsAdmin(bl, "special", True)
        repos.deleteUserByName(bl, "special")
        self.assertTrue("special" in repos.listRoles(bl))
        repos.deleteRole(bl, "special")

        # a role with more than one user should survive
        repos.addRole(bl, "special")
        repos.addUser(bl, "special", "pass")
        repos.addUser(bl, "special1", "pass1")
        repos.updateRoleMembers(bl, "special", ["special", "special1"])
        repos.deleteUserByName(bl, "special")
        self.assertTrue("special" in repos.listRoles(bl))
        repos.deleteUserByName(bl, "special1")
        self.assertTrue("special" in repos.listRoles(bl))
        repos.deleteRole(bl, "special")
        
        # a role with acls should survive
        repos.addRole(bl, "special")
        repos.addUser(bl, "special", "pass")
        repos.updateRoleMembers(bl, "special", ["special"])
        repos.addAcl(bl, "special", "ALL", "ALL")
        repos.deleteUserByName(bl, "special")
        self.assertTrue("special" in repos.listRoles(bl))
        repos.deleteRole(bl, "special")

        # a role with trove permissions should survive
        repos.addRole(bl, "special")
        trv = self.addComponent("foo:runtime")
        repos.addUser(bl, "special", "pass")
        repos.updateRoleMembers(bl, "special", ["special"])
        repos.addTroveAccess("special", [trv.getNameVersionFlavor()])
        repos.deleteUserByName(bl, "special")
        self.assertTrue("special" in repos.listRoles(bl))
        repos.deleteRole(bl, "special")
Get visible name of program byte
dataset/ETHPy150Open sassoftware/conary/conary_test/acltest.py/AclTest.testRoleDeletion--crossover with--dataset/ETHPy150Open EiNSTeiN-/idapython/python/idc.py/NameEx