]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Allow 0 length name
authorJohn Griffith <john.griffith8@gmail.com>
Mon, 17 Aug 2015 14:08:14 +0000 (08:08 -0600)
committerJohn Griffith <john.griffith8@gmail.com>
Mon, 17 Aug 2015 14:36:20 +0000 (08:36 -0600)
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

cinder/api/openstack/wsgi.py
cinder/tests/unit/api/contrib/test_consistencygroups.py
cinder/tests/unit/api/openstack/test_wsgi.py

index 0c9b59b6340d636b9923945dd86dbddc159837b6..7fb76813c5108d5d4779371df9ffc1e5bc4d615c 100644 (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)
 
index 4fd83a22f47b05ed11b8493cccecf53fa122f584..84f4cce45faa8b89c0309280992f8f65bf7456a4 100644 (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)
 
index 42b18cd56f86594c48b5ea8d5f8a3fd1fb2df321..e462bbf03b106e1afc269c0ae74f48ae817ad3e9 100644 (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': ""}