Correct field filtering for member/l7rule/amphora

The exposed definition was incorrect due to a copy/paste error during
the original creation of these controllers, causing the field filter
list to be read as a single value. A side-effect of this was that the
filtering code still worked, but did an 'in' operation on one string
instead of a list.

This caused two bugs:
1) Multiple field filters were ignored, and only the first would be
returned.
2) The field matching would match inside of the field names, so
filtering for `id` would match `id`, `project_id`, etc. and return
extra fields.

Change-Id: Ibb509c1e487876b957ad02cd66cebebc178bef4d
Backport-Candidate: Queens Pike
This commit is contained in:
Adam Harwell 2018-05-04 00:42:02 -07:00
parent b4632d7fe9
commit fe92dabe33
6 changed files with 16 additions and 15 deletions

View File

@ -51,8 +51,8 @@ class AmphoraController(base.BaseController):
db_amp, amp_types.AmphoraResponse)
return amp_types.AmphoraRootResponse(amphora=result)
@wsme_pecan.wsexpose(amp_types.AmphoraeRootResponse, wtypes.text,
[wtypes.text], ignore_extra_args=True)
@wsme_pecan.wsexpose(amp_types.AmphoraeRootResponse, [wtypes.text],
ignore_extra_args=True)
def get_all(self, fields=None):
"""Gets all health monitors."""
pcontext = pecan.request.context

View File

@ -55,8 +55,8 @@ class L7RuleController(base.BaseController):
l7rule_types.L7RuleResponse)
return l7rule_types.L7RuleRootResponse(rule=result)
@wsme_pecan.wsexpose(l7rule_types.L7RulesRootResponse, wtypes.text,
[wtypes.text], ignore_extra_args=True)
@wsme_pecan.wsexpose(l7rule_types.L7RulesRootResponse, [wtypes.text],
ignore_extra_args=True)
def get_all(self, fields=None):
"""Lists all l7rules of a l7policy."""
pcontext = pecan.request.context

View File

@ -56,8 +56,8 @@ class MemberController(base.BaseController):
member_types.MemberResponse)
return member_types.MemberRootResponse(member=result)
@wsme_pecan.wsexpose(member_types.MembersRootResponse, wtypes.text,
[wtypes.text], ignore_extra_args=True)
@wsme_pecan.wsexpose(member_types.MembersRootResponse, [wtypes.text],
ignore_extra_args=True)
def get_all(self, fields=None):
"""Lists all pool members of a pool."""
pcontext = pecan.request.context

View File

@ -304,11 +304,11 @@ class TestAmphora(base.BaseAPITest):
def test_get_all_fields_filter(self):
amps = self.get(self.AMPHORAE_PATH, params={
'fields': ['id', 'compute_id']}).json
'fields': ['id', 'role']}).json
for amp in amps['amphorae']:
self.assertIn(u'id', amp.keys())
self.assertIn(u'compute_id', amp.keys())
self.assertNotIn(u'vrrp_ip', amp.keys())
self.assertIn(u'role', amp.keys())
self.assertNotIn(u'ha_port_id', amp.keys())
def test_get_all_filter(self):
self._create_additional_amp()

View File

@ -305,11 +305,11 @@ class TestL7Rule(base.BaseAPITest):
self.set_lb_status(self.lb_id)
l7rus = self.get(self.l7rules_path, params={
'fields': ['id', 'project_id']}).json
'fields': ['id', 'compare_type']}).json
for l7ru in l7rus['rules']:
self.assertIn(u'id', l7ru.keys())
self.assertIn(u'project_id', l7ru.keys())
self.assertNotIn(u'description', l7ru.keys())
self.assertIn(u'compare_type', l7ru.keys())
self.assertNotIn(u'project_id', l7ru.keys())
def test_get_all_filter(self):
ru1 = self.create_l7rule(

View File

@ -296,11 +296,12 @@ class TestMember(base.BaseAPITest):
self.set_lb_status(self.lb_id)
members = self.get(self.members_path, params={
'fields': ['id', 'project_id']}).json
'fields': ['id', 'address']}).json
for member in members['members']:
self.assertIn(u'id', member.keys())
self.assertIn(u'project_id', member.keys())
self.assertNotIn(u'description', member.keys())
self.assertIn(u'address', member.keys())
self.assertNotIn(u'name', member.keys())
self.assertNotIn(u'monitor_address', member.keys())
def test_get_all_filter(self):
mem1 = self.create_member(self.pool_id,