Merge "Validate tag name when filtering for images"
This commit is contained in:
@@ -132,8 +132,10 @@ class Controller(object):
|
|||||||
tags_url_params = []
|
tags_url_params = []
|
||||||
|
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
if isinstance(tag, six.string_types):
|
if not isinstance(tag, six.string_types):
|
||||||
tags_url_params.append({'tag': encodeutils.safe_encode(tag)})
|
raise exc.HTTPBadRequest("Invalid tag value %s" % tag)
|
||||||
|
|
||||||
|
tags_url_params.append({'tag': encodeutils.safe_encode(tag)})
|
||||||
|
|
||||||
for param, value in six.iteritems(filters):
|
for param, value in six.iteritems(filters):
|
||||||
if isinstance(value, six.string_types):
|
if isinstance(value, six.string_types):
|
||||||
|
@@ -631,7 +631,6 @@ class TestController(testtools.TestCase):
|
|||||||
images = list(self.controller.list(**filters))
|
images = list(self.controller.list(**filters))
|
||||||
self.assertEqual(1, len(images))
|
self.assertEqual(1, len(images))
|
||||||
self.assertEqual('%s' % img_id, images[0].id)
|
self.assertEqual('%s' % img_id, images[0].id)
|
||||||
pass
|
|
||||||
|
|
||||||
def test_list_images_for_tag_multiple_images(self):
|
def test_list_images_for_tag_multiple_images(self):
|
||||||
img_id1 = '2a4560b2-e585-443e-9b39-553b46ec92d1'
|
img_id1 = '2a4560b2-e585-443e-9b39-553b46ec92d1'
|
||||||
@@ -654,6 +653,13 @@ class TestController(testtools.TestCase):
|
|||||||
images = list(self.controller.list(**filters))
|
images = list(self.controller.list(**filters))
|
||||||
self.assertEqual(0, len(images))
|
self.assertEqual(0, len(images))
|
||||||
|
|
||||||
|
def test_list_images_for_invalid_tag(self):
|
||||||
|
filters = {'filters': {'tag': [[]]}}
|
||||||
|
|
||||||
|
self.assertRaises(exc.HTTPBadRequest,
|
||||||
|
list,
|
||||||
|
self.controller.list(**filters))
|
||||||
|
|
||||||
def test_list_images_with_single_sort_key(self):
|
def test_list_images_with_single_sort_key(self):
|
||||||
img_id1 = '2a4560b2-e585-443e-9b39-553b46ec92d1'
|
img_id1 = '2a4560b2-e585-443e-9b39-553b46ec92d1'
|
||||||
sort_key = 'name'
|
sort_key = 'name'
|
||||||
|
Reference in New Issue
Block a user