Improve naming of get_allowed_params() argument
This used to be just a list of allowed names, but now it's a dict mapping names to types. Use variable names that reflect the current meaning, fix the docs, and use named constants where available. Change-Id: I3aadca4e1e9db5da5d07d521c2313162062639b7
This commit is contained in:
parent
24bae944dc
commit
73d05c0cdc
@ -109,21 +109,21 @@ class EventController(object):
|
|||||||
@util.registered_identified_stack
|
@util.registered_identified_stack
|
||||||
def index(self, req, identity, resource_name=None):
|
def index(self, req, identity, resource_name=None):
|
||||||
"""Lists summary information for all events."""
|
"""Lists summary information for all events."""
|
||||||
whitelist = {
|
param_types = {
|
||||||
'limit': util.PARAM_TYPE_SINGLE,
|
'limit': util.PARAM_TYPE_SINGLE,
|
||||||
'marker': util.PARAM_TYPE_SINGLE,
|
'marker': util.PARAM_TYPE_SINGLE,
|
||||||
'sort_dir': util.PARAM_TYPE_SINGLE,
|
'sort_dir': util.PARAM_TYPE_SINGLE,
|
||||||
'sort_keys': util.PARAM_TYPE_MULTI,
|
'sort_keys': util.PARAM_TYPE_MULTI,
|
||||||
'nested_depth': util.PARAM_TYPE_SINGLE,
|
'nested_depth': util.PARAM_TYPE_SINGLE,
|
||||||
}
|
}
|
||||||
filter_whitelist = {
|
filter_param_types = {
|
||||||
'resource_status': util.PARAM_TYPE_MIXED,
|
'resource_status': util.PARAM_TYPE_MIXED,
|
||||||
'resource_action': util.PARAM_TYPE_MIXED,
|
'resource_action': util.PARAM_TYPE_MIXED,
|
||||||
'resource_name': util.PARAM_TYPE_MIXED,
|
'resource_name': util.PARAM_TYPE_MIXED,
|
||||||
'resource_type': util.PARAM_TYPE_MIXED,
|
'resource_type': util.PARAM_TYPE_MIXED,
|
||||||
}
|
}
|
||||||
params = util.get_allowed_params(req.params, whitelist)
|
params = util.get_allowed_params(req.params, param_types)
|
||||||
filter_params = util.get_allowed_params(req.params, filter_whitelist)
|
filter_params = util.get_allowed_params(req.params, filter_param_types)
|
||||||
|
|
||||||
int_params = (rpc_api.PARAM_LIMIT, rpc_api.PARAM_NESTED_DEPTH)
|
int_params = (rpc_api.PARAM_LIMIT, rpc_api.PARAM_NESTED_DEPTH)
|
||||||
try:
|
try:
|
||||||
|
@ -96,18 +96,18 @@ class ResourceController(object):
|
|||||||
def index(self, req, identity):
|
def index(self, req, identity):
|
||||||
"""Lists information for all resources."""
|
"""Lists information for all resources."""
|
||||||
|
|
||||||
whitelist = {
|
param_types = {
|
||||||
'type': 'mixed',
|
'type': util.PARAM_TYPE_MIXED,
|
||||||
'status': 'mixed',
|
'status': util.PARAM_TYPE_MIXED,
|
||||||
'name': 'mixed',
|
'name': util.PARAM_TYPE_MIXED,
|
||||||
'action': 'mixed',
|
'action': util.PARAM_TYPE_MIXED,
|
||||||
'id': 'mixed',
|
'id': util.PARAM_TYPE_MIXED,
|
||||||
'physical_resource_id': 'mixed'
|
'physical_resource_id': util.PARAM_TYPE_MIXED,
|
||||||
}
|
}
|
||||||
|
|
||||||
invalid_keys = (set(req.params.keys()) -
|
invalid_keys = (set(req.params.keys()) -
|
||||||
set(list(whitelist) + [rpc_api.PARAM_NESTED_DEPTH,
|
set(list(param_types) + [rpc_api.PARAM_NESTED_DEPTH,
|
||||||
rpc_api.PARAM_WITH_DETAIL]))
|
rpc_api.PARAM_WITH_DETAIL]))
|
||||||
if invalid_keys:
|
if invalid_keys:
|
||||||
raise exc.HTTPBadRequest(_('Invalid filter parameters %s') %
|
raise exc.HTTPBadRequest(_('Invalid filter parameters %s') %
|
||||||
str(list(invalid_keys)))
|
str(list(invalid_keys)))
|
||||||
@ -121,7 +121,7 @@ class ResourceController(object):
|
|||||||
param_utils.extract_bool,
|
param_utils.extract_bool,
|
||||||
default=False)
|
default=False)
|
||||||
|
|
||||||
params = util.get_allowed_params(req.params, whitelist)
|
params = util.get_allowed_params(req.params, param_types)
|
||||||
|
|
||||||
res_list = self.rpc_client.list_stack_resources(req.context,
|
res_list = self.rpc_client.list_stack_resources(req.context,
|
||||||
identity,
|
identity,
|
||||||
@ -135,8 +135,8 @@ class ResourceController(object):
|
|||||||
def show(self, req, identity, resource_name):
|
def show(self, req, identity, resource_name):
|
||||||
"""Gets detailed information for a resource."""
|
"""Gets detailed information for a resource."""
|
||||||
|
|
||||||
whitelist = {'with_attr': util.PARAM_TYPE_MULTI}
|
param_types = {'with_attr': util.PARAM_TYPE_MULTI}
|
||||||
params = util.get_allowed_params(req.params, whitelist)
|
params = util.get_allowed_params(req.params, param_types)
|
||||||
if 'with_attr' not in params:
|
if 'with_attr' not in params:
|
||||||
params['with_attr'] = None
|
params['with_attr'] = None
|
||||||
res = self.rpc_client.describe_stack_resource(req.context,
|
res = self.rpc_client.describe_stack_resource(req.context,
|
||||||
|
@ -44,11 +44,11 @@ class SoftwareConfigController(object):
|
|||||||
raise exc.HTTPBadRequest(str(e))
|
raise exc.HTTPBadRequest(str(e))
|
||||||
|
|
||||||
def _index(self, req, use_admin_cnxt=False):
|
def _index(self, req, use_admin_cnxt=False):
|
||||||
whitelist = {
|
param_types = {
|
||||||
'limit': util.PARAM_TYPE_SINGLE,
|
'limit': util.PARAM_TYPE_SINGLE,
|
||||||
'marker': util.PARAM_TYPE_SINGLE
|
'marker': util.PARAM_TYPE_SINGLE
|
||||||
}
|
}
|
||||||
params = util.get_allowed_params(req.params, whitelist)
|
params = util.get_allowed_params(req.params, param_types)
|
||||||
|
|
||||||
if use_admin_cnxt:
|
if use_admin_cnxt:
|
||||||
cnxt = context.get_admin_context()
|
cnxt = context.get_admin_context()
|
||||||
|
@ -37,10 +37,10 @@ class SoftwareDeploymentController(object):
|
|||||||
@util.registered_policy_enforce
|
@util.registered_policy_enforce
|
||||||
def index(self, req):
|
def index(self, req):
|
||||||
"""List software deployments."""
|
"""List software deployments."""
|
||||||
whitelist = {
|
param_types = {
|
||||||
'server_id': util.PARAM_TYPE_SINGLE,
|
'server_id': util.PARAM_TYPE_SINGLE,
|
||||||
}
|
}
|
||||||
params = util.get_allowed_params(req.params, whitelist)
|
params = util.get_allowed_params(req.params, param_types)
|
||||||
sds = self.rpc_client.list_software_deployments(req.context, **params)
|
sds = self.rpc_client.list_software_deployments(req.context, **params)
|
||||||
return {'software_deployments': sds}
|
return {'software_deployments': sds}
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ class StackController(object):
|
|||||||
raise exc.HTTPBadRequest(str(e))
|
raise exc.HTTPBadRequest(str(e))
|
||||||
|
|
||||||
def _index(self, req, use_admin_cnxt=False):
|
def _index(self, req, use_admin_cnxt=False):
|
||||||
filter_whitelist = {
|
filter_param_types = {
|
||||||
# usage of keys in this list are not encouraged, please use
|
# usage of keys in this list are not encouraged, please use
|
||||||
# rpc_api.STACK_KEYS instead
|
# rpc_api.STACK_KEYS instead
|
||||||
'id': util.PARAM_TYPE_MIXED,
|
'id': util.PARAM_TYPE_MIXED,
|
||||||
@ -215,7 +215,7 @@ class StackController(object):
|
|||||||
'username': util.PARAM_TYPE_MIXED,
|
'username': util.PARAM_TYPE_MIXED,
|
||||||
'owner_id': util.PARAM_TYPE_MIXED,
|
'owner_id': util.PARAM_TYPE_MIXED,
|
||||||
}
|
}
|
||||||
whitelist = {
|
param_types = {
|
||||||
'limit': util.PARAM_TYPE_SINGLE,
|
'limit': util.PARAM_TYPE_SINGLE,
|
||||||
'marker': util.PARAM_TYPE_SINGLE,
|
'marker': util.PARAM_TYPE_SINGLE,
|
||||||
'sort_dir': util.PARAM_TYPE_SINGLE,
|
'sort_dir': util.PARAM_TYPE_SINGLE,
|
||||||
@ -228,7 +228,7 @@ class StackController(object):
|
|||||||
'not_tags': util.PARAM_TYPE_SINGLE,
|
'not_tags': util.PARAM_TYPE_SINGLE,
|
||||||
'not_tags_any': util.PARAM_TYPE_SINGLE,
|
'not_tags_any': util.PARAM_TYPE_SINGLE,
|
||||||
}
|
}
|
||||||
params = util.get_allowed_params(req.params, whitelist)
|
params = util.get_allowed_params(req.params, param_types)
|
||||||
stack_keys = dict.fromkeys(rpc_api.STACK_KEYS, util.PARAM_TYPE_MIXED)
|
stack_keys = dict.fromkeys(rpc_api.STACK_KEYS, util.PARAM_TYPE_MIXED)
|
||||||
unsupported = (
|
unsupported = (
|
||||||
rpc_api.STACK_ID, # not user visible
|
rpc_api.STACK_ID, # not user visible
|
||||||
@ -246,7 +246,7 @@ class StackController(object):
|
|||||||
for key in unsupported:
|
for key in unsupported:
|
||||||
stack_keys.pop(key)
|
stack_keys.pop(key)
|
||||||
# downward compatibility
|
# downward compatibility
|
||||||
stack_keys.update(filter_whitelist)
|
stack_keys.update(filter_param_types)
|
||||||
filter_params = util.get_allowed_params(req.params, stack_keys)
|
filter_params = util.get_allowed_params(req.params, stack_keys)
|
||||||
|
|
||||||
show_deleted = False
|
show_deleted = False
|
||||||
@ -519,8 +519,8 @@ class StackController(object):
|
|||||||
raise exc.HTTPAccepted()
|
raise exc.HTTPAccepted()
|
||||||
|
|
||||||
def _param_show_nested(self, req):
|
def _param_show_nested(self, req):
|
||||||
whitelist = {'show_nested': 'single'}
|
param_types = {'show_nested': util.PARAM_TYPE_SINGLE}
|
||||||
params = util.get_allowed_params(req.params, whitelist)
|
params = util.get_allowed_params(req.params, param_types)
|
||||||
|
|
||||||
p_name = 'show_nested'
|
p_name = 'show_nested'
|
||||||
if p_name in params:
|
if p_name in params:
|
||||||
@ -604,9 +604,9 @@ class StackController(object):
|
|||||||
|
|
||||||
data = InstantiationData(body)
|
data = InstantiationData(body)
|
||||||
|
|
||||||
whitelist = {'show_nested': util.PARAM_TYPE_SINGLE,
|
param_types = {'show_nested': util.PARAM_TYPE_SINGLE,
|
||||||
'ignore_errors': util.PARAM_TYPE_SINGLE}
|
'ignore_errors': util.PARAM_TYPE_SINGLE}
|
||||||
params = util.get_allowed_params(req.params, whitelist)
|
params = util.get_allowed_params(req.params, param_types)
|
||||||
|
|
||||||
show_nested = False
|
show_nested = False
|
||||||
p_name = rpc_api.PARAM_SHOW_NESTED
|
p_name = rpc_api.PARAM_SHOW_NESTED
|
||||||
|
@ -86,22 +86,22 @@ PARAM_TYPES = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_allowed_params(params, whitelist):
|
def get_allowed_params(params, param_types):
|
||||||
"""Extract from ``params`` all entries listed in ``whitelist``.
|
"""Extract from ``params`` all entries listed in ``param_types``.
|
||||||
|
|
||||||
The returning dict will contain an entry for a key if, and only if,
|
The returning dict will contain an entry for a key if, and only if,
|
||||||
there's an entry in ``whitelist`` for that key and at least one entry in
|
there's an entry in ``param_types`` for that key and at least one entry in
|
||||||
``params``. If ``params`` contains multiple entries for the same key, it
|
``params``. If ``params`` contains multiple entries for the same key, it
|
||||||
will yield an array of values: ``{key: [v1, v2,...]}``
|
will yield an array of values: ``{key: [v1, v2,...]}``
|
||||||
|
|
||||||
:param params: a NestedMultiDict from webob.Request.params
|
:param params: a NestedMultiDict from webob.Request.params
|
||||||
:param whitelist: an array of strings to whitelist
|
:param param_types: an dict of allowed parameters and their types
|
||||||
|
|
||||||
:returns: a dict with {key: value} pairs
|
:returns: a dict with {key: value} pairs
|
||||||
"""
|
"""
|
||||||
allowed_params = {}
|
allowed_params = {}
|
||||||
|
|
||||||
for key, get_type in whitelist.items():
|
for key, get_type in param_types.items():
|
||||||
assert get_type in PARAM_TYPES
|
assert get_type in PARAM_TYPES
|
||||||
|
|
||||||
value = None
|
value = None
|
||||||
|
@ -374,7 +374,7 @@ class EventControllerTest(tools.ControllerTest, common.HeatTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@mock.patch.object(rpc_client.EngineClient, 'call')
|
@mock.patch.object(rpc_client.EngineClient, 'call')
|
||||||
def test_index_whitelists_pagination_params(self, mock_call, mock_enforce):
|
def test_index_bogus_pagination_param(self, mock_call, mock_enforce):
|
||||||
self._mock_enforce_setup(mock_enforce, 'index', True)
|
self._mock_enforce_setup(mock_enforce, 'index', True)
|
||||||
params = {
|
params = {
|
||||||
'limit': 10,
|
'limit': 10,
|
||||||
@ -428,7 +428,7 @@ class EventControllerTest(tools.ControllerTest, common.HeatTestCase):
|
|||||||
self.assertFalse(mock_call.called)
|
self.assertFalse(mock_call.called)
|
||||||
|
|
||||||
@mock.patch.object(rpc_client.EngineClient, 'call')
|
@mock.patch.object(rpc_client.EngineClient, 'call')
|
||||||
def test_index_whitelist_filter_params(self, mock_call, mock_enforce):
|
def test_index_bogus_filter_param(self, mock_call, mock_enforce):
|
||||||
self._mock_enforce_setup(mock_enforce, 'index', True)
|
self._mock_enforce_setup(mock_enforce, 'index', True)
|
||||||
params = {
|
params = {
|
||||||
'resource_status': 'COMPLETE',
|
'resource_status': 'COMPLETE',
|
||||||
|
@ -48,8 +48,8 @@ class SoftwareDeploymentControllerTest(tools.ControllerTest,
|
|||||||
resp = self.controller.index(req, tenant_id=self.tenant)
|
resp = self.controller.index(req, tenant_id=self.tenant)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
{'software_deployments': []}, resp)
|
{'software_deployments': []}, resp)
|
||||||
whitelist = mock_call.call_args[1]
|
params = mock_call.call_args[1]
|
||||||
self.assertEqual({}, whitelist)
|
self.assertEqual({}, params)
|
||||||
server_id = 'fb322564-7927-473d-8aad-68ae7fbf2abf'
|
server_id = 'fb322564-7927-473d-8aad-68ae7fbf2abf'
|
||||||
req = self._get('/software_deployments', {'server_id': server_id})
|
req = self._get('/software_deployments', {'server_id': server_id})
|
||||||
with mock.patch.object(
|
with mock.patch.object(
|
||||||
@ -59,8 +59,8 @@ class SoftwareDeploymentControllerTest(tools.ControllerTest,
|
|||||||
resp = self.controller.index(req, tenant_id=self.tenant)
|
resp = self.controller.index(req, tenant_id=self.tenant)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
{'software_deployments': []}, resp)
|
{'software_deployments': []}, resp)
|
||||||
whitelist = mock_call.call_args[1]
|
params = mock_call.call_args[1]
|
||||||
self.assertEqual({'server_id': server_id}, whitelist)
|
self.assertEqual({'server_id': server_id}, params)
|
||||||
|
|
||||||
@mock.patch.object(policy.Enforcer, 'enforce')
|
@mock.patch.object(policy.Enforcer, 'enforce')
|
||||||
def test_show(self, mock_enforce):
|
def test_show(self, mock_enforce):
|
||||||
|
@ -313,7 +313,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
|
|||||||
req.context, ('list_stacks', default_args), version='1.33')
|
req.context, ('list_stacks', default_args), version='1.33')
|
||||||
|
|
||||||
@mock.patch.object(rpc_client.EngineClient, 'call')
|
@mock.patch.object(rpc_client.EngineClient, 'call')
|
||||||
def test_index_whitelists_pagination_params(self, mock_call, mock_enforce):
|
def test_index_bogus_pagination_param(self, mock_call, mock_enforce):
|
||||||
self._mock_enforce_setup(mock_enforce, 'index', True)
|
self._mock_enforce_setup(mock_enforce, 'index', True)
|
||||||
params = {
|
params = {
|
||||||
'limit': 10,
|
'limit': 10,
|
||||||
@ -351,7 +351,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
|
|||||||
self.assertFalse(mock_call.called)
|
self.assertFalse(mock_call.called)
|
||||||
|
|
||||||
@mock.patch.object(rpc_client.EngineClient, 'call')
|
@mock.patch.object(rpc_client.EngineClient, 'call')
|
||||||
def test_index_whitelist_filter_params(self, mock_call, mock_enforce):
|
def test_index_bogus_filter_param(self, mock_call, mock_enforce):
|
||||||
self._mock_enforce_setup(mock_enforce, 'index', True)
|
self._mock_enforce_setup(mock_enforce, 'index', True)
|
||||||
params = {
|
params = {
|
||||||
'id': 'fake id',
|
'id': 'fake id',
|
||||||
@ -381,7 +381,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
|
|||||||
'parent': 'fake parent',
|
'parent': 'fake parent',
|
||||||
'stack_user_project_id': 'fake project id',
|
'stack_user_project_id': 'fake project id',
|
||||||
'tags': 'fake tags',
|
'tags': 'fake tags',
|
||||||
'barlog': 'you shall not pass!'
|
'balrog': 'you shall not pass!'
|
||||||
}
|
}
|
||||||
req = self._get('/stacks', params=params)
|
req = self._get('/stacks', params=params)
|
||||||
mock_call.return_value = []
|
mock_call.return_value = []
|
||||||
@ -403,7 +403,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
|
|||||||
for key in ('stack_identity', 'creation_time', 'updated_time',
|
for key in ('stack_identity', 'creation_time', 'updated_time',
|
||||||
'deletion_time', 'notification_topics', 'description',
|
'deletion_time', 'notification_topics', 'description',
|
||||||
'template_description', 'parameters', 'outputs',
|
'template_description', 'parameters', 'outputs',
|
||||||
'capabilities', 'tags', 'barlog'):
|
'capabilities', 'tags', 'balrog'):
|
||||||
self.assertNotIn(key, filters)
|
self.assertNotIn(key, filters)
|
||||||
|
|
||||||
def test_index_returns_stack_count_if_with_count_is_true(
|
def test_index_returns_stack_count_if_with_count_is_true(
|
||||||
|
@ -28,60 +28,60 @@ class TestGetAllowedParams(common.HeatTestCase):
|
|||||||
req = wsgi.Request({})
|
req = wsgi.Request({})
|
||||||
self.params = req.params.copy()
|
self.params = req.params.copy()
|
||||||
self.params.add('foo', 'foo value')
|
self.params.add('foo', 'foo value')
|
||||||
self.whitelist = {'foo': util.PARAM_TYPE_SINGLE}
|
self.param_types = {'foo': util.PARAM_TYPE_SINGLE}
|
||||||
|
|
||||||
def test_returns_empty_dict(self):
|
def test_returns_empty_dict(self):
|
||||||
self.whitelist = {}
|
self.param_types = {}
|
||||||
|
|
||||||
result = util.get_allowed_params(self.params, self.whitelist)
|
result = util.get_allowed_params(self.params, self.param_types)
|
||||||
self.assertEqual({}, result)
|
self.assertEqual({}, result)
|
||||||
|
|
||||||
def test_only_adds_whitelisted_params_if_param_exists(self):
|
def test_only_adds_allowed_param_if_param_exists(self):
|
||||||
self.whitelist = {'foo': util.PARAM_TYPE_SINGLE}
|
self.param_types = {'foo': util.PARAM_TYPE_SINGLE}
|
||||||
self.params.clear()
|
self.params.clear()
|
||||||
|
|
||||||
result = util.get_allowed_params(self.params, self.whitelist)
|
result = util.get_allowed_params(self.params, self.param_types)
|
||||||
self.assertNotIn('foo', result)
|
self.assertNotIn('foo', result)
|
||||||
|
|
||||||
def test_returns_only_whitelisted_params(self):
|
def test_returns_only_allowed_params(self):
|
||||||
self.params.add('bar', 'bar value')
|
self.params.add('bar', 'bar value')
|
||||||
|
|
||||||
result = util.get_allowed_params(self.params, self.whitelist)
|
result = util.get_allowed_params(self.params, self.param_types)
|
||||||
self.assertIn('foo', result)
|
self.assertIn('foo', result)
|
||||||
self.assertNotIn('bar', result)
|
self.assertNotIn('bar', result)
|
||||||
|
|
||||||
def test_handles_single_value_params(self):
|
def test_handles_single_value_params(self):
|
||||||
result = util.get_allowed_params(self.params, self.whitelist)
|
result = util.get_allowed_params(self.params, self.param_types)
|
||||||
self.assertEqual('foo value', result['foo'])
|
self.assertEqual('foo value', result['foo'])
|
||||||
|
|
||||||
def test_handles_multiple_value_params(self):
|
def test_handles_multiple_value_params(self):
|
||||||
self.whitelist = {'foo': util.PARAM_TYPE_MULTI}
|
self.param_types = {'foo': util.PARAM_TYPE_MULTI}
|
||||||
self.params.add('foo', 'foo value 2')
|
self.params.add('foo', 'foo value 2')
|
||||||
|
|
||||||
result = util.get_allowed_params(self.params, self.whitelist)
|
result = util.get_allowed_params(self.params, self.param_types)
|
||||||
self.assertEqual(2, len(result['foo']))
|
self.assertEqual(2, len(result['foo']))
|
||||||
self.assertIn('foo value', result['foo'])
|
self.assertIn('foo value', result['foo'])
|
||||||
self.assertIn('foo value 2', result['foo'])
|
self.assertIn('foo value 2', result['foo'])
|
||||||
|
|
||||||
def test_handles_mixed_value_param_with_multiple_entries(self):
|
def test_handles_mixed_value_param_with_multiple_entries(self):
|
||||||
self.whitelist = {'foo': util.PARAM_TYPE_MIXED}
|
self.param_types = {'foo': util.PARAM_TYPE_MIXED}
|
||||||
self.params.add('foo', 'foo value 2')
|
self.params.add('foo', 'foo value 2')
|
||||||
|
|
||||||
result = util.get_allowed_params(self.params, self.whitelist)
|
result = util.get_allowed_params(self.params, self.param_types)
|
||||||
self.assertEqual(2, len(result['foo']))
|
self.assertEqual(2, len(result['foo']))
|
||||||
self.assertIn('foo value', result['foo'])
|
self.assertIn('foo value', result['foo'])
|
||||||
self.assertIn('foo value 2', result['foo'])
|
self.assertIn('foo value 2', result['foo'])
|
||||||
|
|
||||||
def test_handles_mixed_value_param_with_single_entry(self):
|
def test_handles_mixed_value_param_with_single_entry(self):
|
||||||
self.whitelist = {'foo': util.PARAM_TYPE_MIXED}
|
self.param_types = {'foo': util.PARAM_TYPE_MIXED}
|
||||||
|
|
||||||
result = util.get_allowed_params(self.params, self.whitelist)
|
result = util.get_allowed_params(self.params, self.param_types)
|
||||||
self.assertEqual('foo value', result['foo'])
|
self.assertEqual('foo value', result['foo'])
|
||||||
|
|
||||||
def test_bogus_whitelist_items(self):
|
def test_bogus_param_type(self):
|
||||||
self.whitelist = {'foo': 'blah'}
|
self.param_types = {'foo': 'blah'}
|
||||||
self.assertRaises(AssertionError, util.get_allowed_params,
|
self.assertRaises(AssertionError, util.get_allowed_params,
|
||||||
self.params, self.whitelist)
|
self.params, self.param_types)
|
||||||
|
|
||||||
|
|
||||||
class TestPolicyEnforce(common.HeatTestCase):
|
class TestPolicyEnforce(common.HeatTestCase):
|
||||||
|
Loading…
Reference in New Issue
Block a user