Allow 0 length name

There are currently cases where nova for example
creates volumes with a name of zero length.  We
can't just change that and break compatability.

This patch just modifes the wsgi module to allow
min length of zero again.

Change-Id: I829a8b4d6773d1c646d07cccb36994370e1dbce9
Closes-Bug: #1485198
This commit is contained in:
John Griffith 2015-08-17 08:08:14 -06:00
parent 31cb1f2377
commit 480b8737e3
3 changed files with 5 additions and 6 deletions

View File

@ -1228,7 +1228,7 @@ class Controller(object):
body['name'] = name.strip()
try:
utils.check_string_length(body['name'], 'Name',
min_length=1, max_length=255)
min_length=0, max_length=255)
except exception.InvalidInput as error:
raise webob.exc.HTTPBadRequest(explanation=error.msg)

View File

@ -622,8 +622,6 @@ class ConsistencyGroupsAPITestCase(test.TestCase):
self.assertEqual(400, res.status_int)
self.assertEqual(400, res_dict['badRequest']['code'])
self.assertEqual('Name has a minimum character requirement of 1.',
res_dict['badRequest']['message'])
db.consistencygroup_destroy(ctxt.elevated(), consistencygroup_id)

View File

@ -1022,10 +1022,11 @@ class ValidBodyTest(test.TestCase):
body)
def test_validate_name_and_description_with_name_zero_length(self):
# NOTE(jdg): We allow zero length names currently, particularly
# from Nova, changes to this require an API version bump
body = {'name': ""}
self.assertRaises(webob.exc.HTTPBadRequest,
self.controller.validate_name_and_description,
body)
self.controller.validate_name_and_description(body)
self.assertEqual('', body['name'])
def test_validate_name_and_description_with_desc_zero_length(self):
body = {'description': ""}