diff --git a/keystoneclient/v3/groups.py b/keystoneclient/v3/groups.py index f6e04c611..0768c448e 100644 --- a/keystoneclient/v3/groups.py +++ b/keystoneclient/v3/groups.py @@ -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): diff --git a/tests/v3/test_groups.py b/tests/v3/test_groups.py index b49f911d9..08b762e25 100644 --- a/tests/v3/test_groups.py +++ b/tests/v3/test_groups.py @@ -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]