From e509cc0ddf7a92628f34cf7101a9af8c0953983c Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Mon, 17 Feb 2014 11:39:54 +0000 Subject: [PATCH] Ensure domains.list filtered results are correct Convert enabled=False to enabled=0, such that requests directed to an older keystone not containing the fix for bug #1267530 will not return the wrong data. Closes-Bug: #1281070 Change-Id: I49fd0953fc2323f2034c241c6342ced6f3412125 --- keystoneclient/tests/v3/test_domains.py | 12 ++++++++++++ keystoneclient/v3/domains.py | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/keystoneclient/tests/v3/test_domains.py b/keystoneclient/tests/v3/test_domains.py index 5482107e6..e86971ac0 100644 --- a/keystoneclient/tests/v3/test_domains.py +++ b/keystoneclient/tests/v3/test_domains.py @@ -29,3 +29,15 @@ class DomainTests(utils.TestCase, utils.CrudTests): kwargs.setdefault('enabled', True) kwargs.setdefault('name', uuid.uuid4().hex) return kwargs + + def test_list_filter_name(self): + super(DomainTests, self).test_list(name='adomain123') + + def test_list_filter_enabled(self): + super(DomainTests, self).test_list(enabled=True) + + def test_list_filter_disabled(self): + # False is converted to '0' ref bug #1267530 + expected_query = {'enabled': '0'} + super(DomainTests, self).test_list(expected_query=expected_query, + enabled=False) diff --git a/keystoneclient/v3/domains.py b/keystoneclient/v3/domains.py index 35d41a744..ebe48f942 100644 --- a/keystoneclient/v3/domains.py +++ b/keystoneclient/v3/domains.py @@ -50,6 +50,10 @@ class DomainManager(base.CrudManager): ``**kwargs`` allows filter criteria to be passed where supported by the server. """ + # Ref bug #1267530 we have to pass 0 for False to get the expected + # results on all keystone versions + if kwargs.get('enabled') is False: + kwargs['enabled'] = 0 return super(DomainManager, self).list(**kwargs) def update(self, domain, name=None,