Adds keystone.region constraint
implements blueprint: heat-keystone-region-resource Change-Id: I11a81bdd15035e76e0cfb9985a151c76aea9284d
This commit is contained in:
parent
a850d922b0
commit
7b5c7a118e
|
@ -179,3 +179,11 @@ class KeystoneUserConstraint(constraints.BaseCustomConstraint):
|
|||
|
||||
def validate_with_client(self, client, user):
|
||||
client.client_plugin('keystone').get_user_id(user)
|
||||
|
||||
|
||||
class KeystoneRegionConstraint(constraints.BaseCustomConstraint):
|
||||
|
||||
expected_exceptions = (exception.EntityNotFound,)
|
||||
|
||||
def validate_with_client(self, client, region):
|
||||
client.client_plugin('keystone').get_region_id(region)
|
||||
|
|
|
@ -145,6 +145,30 @@ class KeystoneUserConstraintTest(common.HeatTestCase):
|
|||
client_plugin_mock.get_user_id.assert_called_once_with('admin')
|
||||
|
||||
|
||||
class KeystoneRegionConstraintTest(common.HeatTestCase):
|
||||
|
||||
sample_uuid = '477e8273-60a7-4c41-b683-fdb0bc7cd151'
|
||||
|
||||
def test_expected_exceptions(self):
|
||||
self.assertEqual((exception.EntityNotFound,),
|
||||
client.KeystoneRegionConstraint.expected_exceptions,
|
||||
"KeystoneRegionConstraint expected exceptions error")
|
||||
|
||||
def test_constraint(self):
|
||||
constraint = client.KeystoneRegionConstraint()
|
||||
client_mock = mock.MagicMock()
|
||||
client_plugin_mock = mock.MagicMock()
|
||||
client_plugin_mock.get_region_id.return_value = self.sample_uuid
|
||||
client_mock.client_plugin.return_value = client_plugin_mock
|
||||
|
||||
self.assertIsNone(constraint.validate_with_client(client_mock,
|
||||
self.sample_uuid))
|
||||
|
||||
client_plugin_mock.get_region_id.assert_called_once_with(
|
||||
self.sample_uuid
|
||||
)
|
||||
|
||||
|
||||
class KeystoneClientPluginServiceTest(common.HeatTestCase):
|
||||
|
||||
sample_uuid = '477e8273-60a7-4c41-b683-fdb0bc7cd152'
|
||||
|
|
|
@ -102,6 +102,7 @@ heat.constraints =
|
|||
keystone.group = heat.engine.clients.os.keystone:KeystoneGroupConstraint
|
||||
keystone.service = heat.engine.clients.os.keystone:KeystoneServiceConstraint
|
||||
keystone.user = heat.engine.clients.os.keystone:KeystoneUserConstraint
|
||||
keystone.region = heat.engine.clients.os.keystone:KeystoneRegionConstraint
|
||||
magnum.baymodel = heat.engine.clients.os.magnum:BaymodelConstraint
|
||||
manila.share_snapshot = heat.engine.clients.os.manila:ManilaShareSnapshotConstraint
|
||||
manila.share_network = heat.engine.clients.os.manila:ManilaShareNetworkConstraint
|
||||
|
|
Loading…
Reference in New Issue