List groups by domain in keystoneclient.
Currently keystone support filtering of groups by domain. This fix is to add support in keystone-client for filtering groups by domain. Fixes Bug #1180581 Change-Id: I3906e2474d968426d06d498928ce2c7094c6fbe9
This commit is contained in:

committed by
nachiappan-veerappan-nachiappan

parent
abe6781913
commit
6dfcbc0ec7
@@ -55,10 +55,10 @@ class GroupManager(base.CrudManager):
|
||||
domain_id=base.getid(domain),
|
||||
description=description)
|
||||
|
||||
def list(self, user=None, **kwargs):
|
||||
def list(self, user=None, domain=None, **kwargs):
|
||||
"""List groups.
|
||||
|
||||
If user is provided, then filter groups with
|
||||
If domain or user is provided, then filter groups with
|
||||
that attribute.
|
||||
|
||||
If ``**kwargs`` are provided, then filter groups with
|
||||
@@ -70,6 +70,7 @@ class GroupManager(base.CrudManager):
|
||||
base_url = None
|
||||
return super(GroupManager, self).list(
|
||||
base_url=base_url,
|
||||
domain_id=base.getid(domain),
|
||||
**kwargs)
|
||||
|
||||
def get(self, group):
|
||||
|
@@ -61,3 +61,27 @@ class GroupTests(utils.TestCase, utils.CrudTests):
|
||||
returned_list = self.manager.list(user=user_id)
|
||||
self.assertTrue(len(returned_list))
|
||||
[self.assertTrue(isinstance(r, self.model)) for r in returned_list]
|
||||
|
||||
def test_list_groups_for_domain(self):
|
||||
ref_list = [self.new_ref(), self.new_ref()]
|
||||
|
||||
domain_id = uuid.uuid4().hex
|
||||
resp = utils.TestResponse({
|
||||
"status_code": 200,
|
||||
"text": self.serialize(ref_list),
|
||||
})
|
||||
|
||||
method = 'GET'
|
||||
kwargs = copy.copy(self.TEST_REQUEST_BASE)
|
||||
kwargs['headers'] = self.headers[method]
|
||||
requests.request(
|
||||
method,
|
||||
urlparse.urljoin(
|
||||
self.TEST_URL,
|
||||
'v3/%s?domain_id=%s' % (self.collection_key, domain_id)),
|
||||
**kwargs).AndReturn((resp))
|
||||
self.mox.ReplayAll()
|
||||
|
||||
returned_list = self.manager.list(domain=domain_id)
|
||||
self.assertTrue(len(returned_list))
|
||||
[self.assertTrue(isinstance(r, self.model)) for r in returned_list]
|
||||
|
Reference in New Issue
Block a user