Merge "Convert heat_keystoneclient user enable/disable logic to v3 API"
This commit is contained in:
commit
b7bf3c8d20
@ -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)
|
||||
|
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user