Fix use of fields argument in get_rbac_policies

The 'fields' argument wasn't being passed into the _get_collection
call so the results were always coming back with all of the fields.
This adds an API test to prevent a regression.

Change-Id: Iddef9dcc7639a557a9d19dc7265f10f98e002172
Closes-Bug: #1517815
(cherry picked from commit 09c032fa4e)
This commit is contained in:
Kevin Benton 2015-11-19 20:37:05 -08:00 committed by garyk
parent d6a628e545
commit 271413fcb4
2 changed files with 14 additions and 1 deletions

View File

@ -105,7 +105,7 @@ class RbacPluginMixin(common_db_mixin.CommonDbMixin):
models.get_type_model_map(), 'object_type')
return self._get_collection(
context, model, self._make_rbac_policy_dict, filters=filters,
sorts=sorts, limit=limit, page_reverse=page_reverse)
fields=fields, sorts=sorts, limit=limit, page_reverse=page_reverse)
def _get_object_type(self, context, entry_id):
"""Scans all RBAC tables for an ID to figure out the type.

View File

@ -300,6 +300,19 @@ class RBACSharedNetworksTest(base.BaseAdminNetworkTest):
[p['id']
for p in self.client2.list_rbac_policies()['rbac_policies']])
@test.attr(type='smoke')
@test.idempotent_id('bf5052b8-b11e-407c-8e43-113447404d3e')
def test_filter_fields(self):
net = self.create_network()
self.client.create_rbac_policy(
object_type='network', object_id=net['id'],
action='access_as_shared', target_tenant=self.client2.tenant_id)
field_args = (('id',), ('id', 'action'), ('object_type', 'object_id'),
('tenant_id', 'target_tenant'))
for fields in field_args:
res = self.client.list_rbac_policies(fields=fields)
self.assertEqual(set(fields), set(res['rbac_policies'][0].keys()))
@test.attr(type='smoke')
@test.idempotent_id('86c3529b-1231-40de-803c-afffffff5fff')
def test_policy_show(self):