Merge "Fix modifying a role with same name using LDAP"

This commit is contained in:
Jenkins 2014-12-17 03:35:48 +00:00 committed by Gerrit Code Review
commit 18304c52f6
2 changed files with 4 additions and 11 deletions

View File

@ -686,9 +686,10 @@ class RoleApi(common_ldap.BaseLdap):
new_name = role.get('name')
if new_name is not None:
try:
old_name = self.get_by_name(new_name)
raise exception.Conflict(
_('Cannot duplicate name %s') % old_name)
old_role = self.get_by_name(new_name)
if old_role['id'] != role_id:
raise exception.Conflict(
_('Cannot duplicate name %s') % old_role)
except exception.NotFound:
pass
return super(RoleApi, self).update(role_id, role)

View File

@ -1916,14 +1916,6 @@ class LDAPIdentity(BaseLDAPIdentity, tests.TestCase):
self.assertEqual('crap', user_ref['id'])
self.assertEqual('Foo Bar', user_ref['name'])
def test_update_role_same_name(self):
# Override
# This test is failing using the LDAP assignment backend, see
# bug 1401721.
# FIXME(blk-u): This should work.
self.assertRaises(exception.Conflict,
super(LDAPIdentity, self).test_update_role_same_name)
class LDAPIdentityEnabledEmulation(LDAPIdentity):
def setUp(self):