Merge "Validate uuid-ness in v2 image entity"

This commit is contained in:
Jenkins 2012-08-17 14:14:44 +00:00 committed by Gerrit Code Review
commit 5eb7ac1d2e
2 changed files with 8 additions and 1 deletions

View File

@ -378,7 +378,8 @@ _BASE_PROPERTIES = {
'id': { 'id': {
'type': 'string', 'type': 'string',
'description': 'An identifier for the image', 'description': 'An identifier for the image',
'maxLength': 36, 'pattern': ('^([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}'
'-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}$'),
}, },
'name': { 'name': {
'type': 'string', 'type': 'string',

View File

@ -445,6 +445,12 @@ class TestImagesDeserializer(test_utils.BaseTestCase):
expected = {'image': {'properties': {}}} expected = {'image': {'properties': {}}}
self.assertEqual(expected, output) self.assertEqual(expected, output)
def test_create_invalid_id(self):
request = unit_test_utils.get_fake_request()
request.body = json.dumps({'id': 'gabe'})
self.assertRaises(webob.exc.HTTPBadRequest, self.deserializer.create,
request)
def test_create_no_body(self): def test_create_no_body(self):
request = unit_test_utils.get_fake_request() request = unit_test_utils.get_fake_request()
self.assertRaises(webob.exc.HTTPBadRequest, self.deserializer.create, self.assertRaises(webob.exc.HTTPBadRequest, self.deserializer.create,