summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDolph Mathews <dolph.mathews@gmail.com>2013-06-03 15:30:10 -0500
committerDolph Mathews <dolph.mathews@gmail.com>2013-06-03 15:41:42 -0500
commit2ff3ddd356d599677bfc2a1ad08009b2226357eb (patch)
tree7ce7e43c6f807a2c0d4eda35605818ebf1826f20
parentcd349711bc6210bf35952c5f71bb92ab7676bd2d (diff)
Ignore conflict on v2 auto role assignment (bug 1161963)
Change-Id: I10581a39325b4fcdb997ad704c3ee0de494b32e0
-rw-r--r--keystone/identity/controllers.py13
-rw-r--r--tests/test_keystoneclient.py13
2 files changed, 22 insertions, 4 deletions
diff --git a/keystone/identity/controllers.py b/keystone/identity/controllers.py
index 3e60272d..003ccbe4 100644
--- a/keystone/identity/controllers.py
+++ b/keystone/identity/controllers.py
@@ -242,10 +242,15 @@ class User(controller.V2Controller):
def update_user_project(self, context, user_id, user):
"""Update the default tenant."""
self.assert_admin(context)
- # ensure that we're a member of that tenant
- default_tenant_id = user.get('tenantId')
- self.identity_api.add_user_to_project(context,
- default_tenant_id, user_id)
+
+ try:
+ # ensure that we're a member of that tenant
+ self.identity_api.add_user_to_project(
+ context, user.get('tenantId'), user_id)
+ except exception.Conflict:
+ # we're already a member of that tenant
+ pass
+
return self.update_user(context, user_id, user)
diff --git a/tests/test_keystoneclient.py b/tests/test_keystoneclient.py
index 49e3bfc9..bd538700 100644
--- a/tests/test_keystoneclient.py
+++ b/tests/test_keystoneclient.py
@@ -482,6 +482,19 @@ class KeystoneClientTests(object):
tenant_id='bar')
self.assertEquals(user2.name, test_username)
+ def test_update_default_tenant_to_existing_value(self):
+ client = self.get_client(admin=True)
+
+ user = client.users.create(
+ name=uuid.uuid4().hex,
+ password=uuid.uuid4().hex,
+ email=uuid.uuid4().hex,
+ tenant_id=self.tenant_bar['id'])
+
+ # attempting to update the tenant with the existing value should work
+ user = client.users.update_tenant(
+ user=user, tenant=self.tenant_bar['id'])
+
def test_user_create_no_name(self):
from keystoneclient import exceptions as client_exceptions
client = self.get_client(admin=True)