Override client() for RoleAssignment resources

It seems we've missed to override client() methods for some
keystone resource plugins.

This also fixes the tests for all keystone resources.

Change-Id: I97e4d4f0bbc9575109d9c8f59fe4795313d2f525
Closes-Bug: #1614400
changes/13/357013/3
rabi 7 years ago committed by Rabi Mishra
parent f238a6e1d5
commit cba109872b

@ -344,6 +344,9 @@ class KeystoneUserRoleAssignment(resource.Resource,
def __init__(self, *args, **kwargs):
super(KeystoneUserRoleAssignment, self).__init__(*args, **kwargs)
def client(self):
return super(KeystoneUserRoleAssignment, self).client().client
@property
def user_id(self):
return (self.client_plugin().get_user_id(
@ -398,6 +401,9 @@ class KeystoneGroupRoleAssignment(resource.Resource,
def __init__(self, *args, **kwargs):
super(KeystoneGroupRoleAssignment, self).__init__(*args, **kwargs)
def client(self):
return super(KeystoneGroupRoleAssignment, self).client().client
@property
def group_id(self):
return (self.client_plugin().get_group_id(

@ -100,7 +100,7 @@ class FakeKeystoneClient(object):
user_id='1234', access='4567', secret='8901',
credential_id='abcdxyz', auth_token='abcd1234',
context=None, stack_domain_id='4321', roles=None,
user_domain_id=None, project_domain_id=None):
user_domain_id=None, project_domain_id=None, client=None):
self.username = username
self.password = password
self.user_id = user_id
@ -115,6 +115,7 @@ class FakeKeystoneClient(object):
self.roles = roles or []
self.user_domain_id = user_domain_id
self.project_domain_id = project_domain_id
self.client = client
class FakeCred(object):
id = self.credential_id

@ -17,10 +17,12 @@ import mock
from heat.engine import constraints
from heat.engine import properties
from heat.engine import resource
from heat.engine.resources.openstack.keystone import endpoint
from heat.engine import stack
from heat.engine import template
from heat.tests import common
from heat.tests import fakes
from heat.tests import utils
keystone_endpoint_template = {
@ -50,7 +52,10 @@ class KeystoneEndpointTest(common.HeatTestCase):
self.ctx = utils.dummy_context()
# Mock client
self.keystoneclient = mock.MagicMock()
self.keystoneclient = mock.Mock()
self.patchobject(resource.Resource, 'client',
return_value=fakes.FakeKeystoneClient(
client=self.keystoneclient))
self.endpoints = self.keystoneclient.endpoints
# Mock client plugin

@ -15,10 +15,12 @@ import mock
from heat.engine import constraints
from heat.engine import properties
from heat.engine import resource
from heat.engine.resources.openstack.keystone import group
from heat.engine import stack
from heat.engine import template
from heat.tests import common
from heat.tests import fakes
from heat.tests import utils
keystone_group_template = {
@ -52,9 +54,10 @@ class KeystoneGroupTest(common.HeatTestCase):
self.test_group = self.stack['test_group']
# Mock client
self.keystoneclient = mock.MagicMock()
self.test_group.client = mock.MagicMock()
self.test_group.client.return_value = self.keystoneclient
self.keystoneclient = mock.Mock()
self.patchobject(resource.Resource, 'client',
return_value=fakes.FakeKeystoneClient(
client=self.keystoneclient))
self.groups = self.keystoneclient.groups
# Mock client plugin

@ -14,10 +14,12 @@
import mock
from six.moves.urllib import parse
from heat.engine import resource
from heat.engine.resources.openstack.keystone import region
from heat.engine import stack
from heat.engine import template
from heat.tests import common
from heat.tests import fakes
from heat.tests import utils
KEYSTONE_REGION_TEMPLATE = {
@ -52,9 +54,10 @@ class KeystoneRegionTest(common.HeatTestCase):
self.test_region = self.stack['test_region']
# Mock client
self.keystoneclient = mock.MagicMock()
self.test_region.client = mock.MagicMock()
self.test_region.client.return_value = self.keystoneclient
self.keystoneclient = mock.Mock()
self.patchobject(resource.Resource, 'client',
return_value=fakes.FakeKeystoneClient(
client=self.keystoneclient))
self.regions = self.keystoneclient.regions
keystone_client_plugin = mock.MagicMock()

@ -13,10 +13,12 @@
import mock
from heat.engine import resource
from heat.engine.resources.openstack.keystone import role
from heat.engine import stack
from heat.engine import template
from heat.tests import common
from heat.tests import fakes
from heat.tests import utils
keystone_role_template = {
@ -47,9 +49,11 @@ class KeystoneRoleTest(common.HeatTestCase):
self.test_role = self.stack['test_role']
self.keystoneclient = mock.MagicMock()
self.test_role.client = mock.MagicMock()
self.test_role.client.return_value = self.keystoneclient
# Mock client
self.keystoneclient = mock.Mock()
self.patchobject(resource.Resource, 'client',
return_value=fakes.FakeKeystoneClient(
client=self.keystoneclient))
self.roles = self.keystoneclient.roles
def _get_mock_role(self):

@ -21,6 +21,7 @@ from heat.engine.resources.openstack.keystone import role_assignments
from heat.engine import stack
from heat.engine import template
from heat.tests import common
from heat.tests import fakes
from heat.tests import generic_resource
from heat.tests import utils
@ -365,9 +366,10 @@ class KeystoneUserRoleAssignmentTest(common.HeatTestCase):
self.test_role_assignment = self.stack['test_role_assignment']
# Mock client
self.keystoneclient = mock.MagicMock()
self.test_role_assignment.client = mock.MagicMock()
self.test_role_assignment.client.return_value = self.keystoneclient
self.keystoneclient = mock.Mock()
self.patchobject(resource.Resource, 'client',
return_value=fakes.FakeKeystoneClient(
client=self.keystoneclient))
self.roles = self.keystoneclient.roles
# Mock client plugin
@ -478,9 +480,10 @@ class KeystoneGroupRoleAssignmentTest(common.HeatTestCase):
self.test_role_assignment = self.stack['test_role_assignment']
# Mock client
self.keystoneclient = mock.MagicMock()
self.test_role_assignment.client = mock.MagicMock()
self.test_role_assignment.client.return_value = self.keystoneclient
self.keystoneclient = mock.Mock()
self.patchobject(resource.Resource, 'client',
return_value=fakes.FakeKeystoneClient(
client=self.keystoneclient))
self.roles = self.keystoneclient.roles
# Mock client plugin

@ -16,10 +16,12 @@ import copy
import mock
from heat.engine import properties
from heat.engine import resource
from heat.engine.resources.openstack.keystone import service
from heat.engine import stack
from heat.engine import template
from heat.tests import common
from heat.tests import fakes
from heat.tests import utils
keystone_service_template = {
@ -47,7 +49,10 @@ class KeystoneServiceTest(common.HeatTestCase):
self.ctx = utils.dummy_context()
# Mock client
self.keystoneclient = mock.MagicMock()
self.keystoneclient = mock.Mock()
self.patchobject(resource.Resource, 'client',
return_value=fakes.FakeKeystoneClient(
client=self.keystoneclient))
self.services = self.keystoneclient.services
# Mock client plugin

@ -13,10 +13,12 @@
import mock
from heat.engine import resource
from heat.engine.resources.openstack.keystone import user
from heat.engine import stack
from heat.engine import template
from heat.tests import common
from heat.tests import fakes
from heat.tests import utils
keystone_user_template = {
@ -56,9 +58,10 @@ class KeystoneUserTest(common.HeatTestCase):
self.test_user = self.stack['test_user']
# Mock client
self.keystoneclient = mock.MagicMock()
self.test_user.client = mock.MagicMock()
self.test_user.client.return_value = self.keystoneclient
self.keystoneclient = mock.Mock()
self.patchobject(resource.Resource, 'client',
return_value=fakes.FakeKeystoneClient(
client=self.keystoneclient))
self.users = self.keystoneclient.users
# Mock client plugin

Loading…
Cancel
Save