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