Merge "Validate type parameter for empty string"

This commit is contained in:
Zuul 2018-06-28 12:24:09 +00:00 committed by Gerrit Code Review
commit 5d142c08da
3 changed files with 13 additions and 1 deletions

View File

@ -294,7 +294,7 @@ RESOURCE_ATTRIBUTE_MAP = {
'type': {
'allow_post': True,
'allow_put': False,
'validate': {'type:string': None},
'validate': {'type:not_empty_string': None},
'is_visible': True
},
'auth_url': {

View File

@ -126,3 +126,14 @@ class VIMCreateTestCase(base.TestCase):
self.controller.create,
request, vim_dict)
self.assertEqual(msg, six.text_type(exp))
@ddt.data("", " ", None, 123)
def test_create_vim_with_invalid_type(self, value):
vim_dict = get_vim_config()
vim_dict['vim']['type'] = value
request = wsgi.Request.blank("/vims.json", method='POST',
headers={'Content-Type': "application/json"})
request.environ['tacker.context'] = self.fake_admin_context()
self.assertRaises(exc.HTTPBadRequest,
self.controller.create,
request, vim_dict)

View File

@ -302,6 +302,7 @@ class TestNfvoPlugin(db_base.SqlTestCase):
self.assertIn('created_at', res)
self.assertIn('updated_at', res)
self.assertEqual(False, res['is_default'])
self.assertEqual('openstack', res['type'])
def test_delete_vim(self):
self._insert_dummy_vim()