Fix 500 error when filtering with specified invalid operator
Added catch 'InvalidFilterOperatorValue' exception. Change-Id: I200b79d4c197d96a7fdbf288161422c80eb97879 Closes-bug: #1517935
This commit is contained in:
parent
7500c520ef
commit
a9222ae488
@ -113,7 +113,8 @@ class ImagesController(object):
|
||||
result['next_marker'] = images[-1].image_id
|
||||
except (exception.NotFound, exception.InvalidSortKey,
|
||||
exception.InvalidFilterRangeValue,
|
||||
exception.InvalidParameterValue) as e:
|
||||
exception.InvalidParameterValue,
|
||||
exception.InvalidFilterOperatorValue) as e:
|
||||
raise webob.exc.HTTPBadRequest(explanation=e.msg)
|
||||
except exception.Forbidden as e:
|
||||
LOG.debug("User not permitted to retrieve images index")
|
||||
|
@ -2500,6 +2500,13 @@ class TestImages(functional.FunctionalTest):
|
||||
response = requests.get(path, headers=self._headers())
|
||||
self.assertEqual(400, response.status_code)
|
||||
|
||||
# Image list filters by updated_at and created_at with invalid operator
|
||||
url_template = '/v2/images?%s=invalid_operator:2015-11-19T12:24:02Z'
|
||||
for filter in ['updated_at', 'created_at']:
|
||||
path = self._url(url_template % filter)
|
||||
response = requests.get(path, headers=self._headers())
|
||||
self.assertEqual(400, response.status_code)
|
||||
|
||||
# Begin pagination after the first image
|
||||
template_url = ('/v2/images?limit=2&sort_dir=asc&sort_key=name'
|
||||
'&marker=%s&type=kernel&ping=pong')
|
||||
|
Loading…
Reference in New Issue
Block a user