Merge "Handling filters in Generalized Filtering API"

This commit is contained in:
Zuul 2019-03-26 16:27:05 +00:00 committed by Gerrit Code Review
commit 7a14b019a5
3 changed files with 8 additions and 7 deletions

View File

@ -427,8 +427,9 @@ def reject_invalid_filters(context, filters, resource,
"%s~" % key in configured_filters):
invalid_filters.append(key)
if invalid_filters:
if (resource == 'volume_type' and len(invalid_filters) == 1
and invalid_filters[0] == 'is_public'):
if 'all_tenants' in invalid_filters:
invalid_filters.remove('all_tenants')
if len(invalid_filters) == 0:
return
raise webob.exc.HTTPBadRequest(
explanation=_('Invalid filters %s are found in query '

View File

@ -415,7 +415,7 @@ class GeneralFiltersTest(test.TestCase):
'resource': 'fake_resource'},
{'filters': {'is_public': True},
'is_admin': False,
'result': {'volume_type': []},
'result': {'volume_type': ["is_public"]},
'expected': {'is_public': True},
'resource': 'volume_type'})
@ddt.unpack
@ -485,7 +485,7 @@ class GeneralFiltersTest(test.TestCase):
'expected': ["name", "status", "volume_id", "metadata",
"availability_zone"]},
{'resource': 'group_snapshot',
'expected': ["status", "group_id"]},
'expected': ["name", "status", "group_id"]},
{'resource': 'attachment',
'expected': ["volume_id", "status", "instance_id",
"attach_status"]},

View File

@ -5,11 +5,11 @@
"backup": ["name", "status", "volume_id"],
"snapshot": ["name", "status", "volume_id", "metadata",
"availability_zone"],
"group": [],
"group_snapshot": ["status", "group_id"],
"group": ["name"],
"group_snapshot": ["name", "status", "group_id"],
"attachment": ["volume_id", "status", "instance_id", "attach_status"],
"message": ["resource_uuid", "resource_type", "event_id",
"request_id", "message_level"],
"pool": ["name", "volume_type"],
"volume_type": []
"volume_type": ["is_public"]
}