Keystone REST handles default role incorrectly

The keystone REST currently assigns a role to the user even if the role is the
default role (_member_). This causes keystone client v2 to return an error.
This patch fixes this issue.

Change-Id: I6de6c66eb88abfd23a171c0f13aeff2f707991e2
Closes-bug: #1453245
Co-Authored-By: Richard Jones <r1chardj0n3s@gmail.com>
This commit is contained in:
Thai Tran 2015-05-08 11:57:59 -07:00 committed by Richard Jones
parent a21329d98a
commit 9347cb43cc
2 changed files with 2 additions and 10 deletions

View File

@ -80,14 +80,6 @@ class Users(generic.View):
domain=domain.id
)
# assign role to user
api.keystone.add_tenant_user_role(
request,
project=request.DATA.get('project_id'),
user=new_user.id,
role=request.DATA.get('role_id')
)
return rest_utils.CreatedResponse(
'/api/keystone/users/%s' % new_user.id,
new_user.to_dict()

View File

@ -125,7 +125,7 @@ class KeystoneRestTestCase(test.TestCase):
)
@mock.patch.object(keystone.api, 'keystone')
def _test_user_create(self, supplied_body, expected_call, kc):
def _test_user_create(self, supplied_body, add_user_call, kc):
request = self.mock_rest_request(body=supplied_body)
kc.get_default_domain.return_value = mock.Mock(**{'id': 'the_domain'})
kc.user_create.return_value.id = 'user123'
@ -140,7 +140,7 @@ class KeystoneRestTestCase(test.TestCase):
'/api/keystone/users/user123')
self.assertEqual(response.content, '{"id": "user123", '
'"name": "bob"}')
kc.user_create.assert_called_once_with(request, **expected_call)
kc.user_create.assert_called_once_with(request, **add_user_call)
@mock.patch.object(keystone.api, 'keystone')
def test_user_delete_many(self, kc):