Merge "Convert heat_keystoneclient user enable/disable logic to v3 API"

This commit is contained in:
Jenkins 2014-01-19 09:45:07 +00:00 committed by Gerrit Code Review
commit b7bf3c8d20
2 changed files with 36 additions and 4 deletions

View File

@ -283,12 +283,10 @@ class KeystoneClient(object):
return self.client_v2.ec2.create(uid, self.context.tenant_id)
def disable_stack_user(self, user_id):
# FIXME : This won't work with the v3 keystone API
self.client_v2.users.update_enabled(user_id, False)
self.client_v3.users.update(user=user_id, enabled=False)
def enable_stack_user(self, user_id):
# FIXME : This won't work with the v3 keystone API
self.client_v2.users.update_enabled(user_id, True)
self.client_v3.users.update(user=user_id, enabled=True)
def url_for(self, **kwargs):
return self.client_v2.service_catalog.url_for(**kwargs)

View File

@ -415,3 +415,37 @@ class KeystoneClientTest(HeatTestCase):
ctx = utils.dummy_context()
heat_ks_client = heat_keystoneclient.KeystoneClient(ctx)
self.assertIsNone(heat_ks_client.delete_trust(trust_id='atrust123'))
def test_disable_stack_user(self):
"""Test disabling a stack user."""
self._stubs_v3()
ctx = utils.dummy_context()
ctx.trust_id = None
# mock keystone client update function
self.mock_ks_v3_client.users = self.m.CreateMockAnything()
self.mock_ks_v3_client.users.update(user='atestuser', enabled=False
).AndReturn(None)
self.m.ReplayAll()
heat_ks_client = heat_keystoneclient.KeystoneClient(ctx)
heat_ks_client.disable_stack_user('atestuser')
def test_enable_stack_user(self):
"""Test enabling a stack user."""
self._stubs_v3()
ctx = utils.dummy_context()
ctx.trust_id = None
# mock keystone client update function
self.mock_ks_v3_client.users = self.m.CreateMockAnything()
self.mock_ks_v3_client.users.update(user='atestuser', enabled=True
).AndReturn(None)
self.m.ReplayAll()
heat_ks_client = heat_keystoneclient.KeystoneClient(ctx)
heat_ks_client.enable_stack_user('atestuser')