1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
3
# Copyright 2012 OpenStack LLC
5
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
# not use this file except in compliance with the License. You may obtain
7
# a copy of the License at
9
# http://www.apache.org/licenses/LICENSE-2.0
11
# Unless required by applicable law or agreed to in writing, software
12
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
# License for the specific language governing permissions and limitations
23
from keystoneclient.v3 import groups
24
from tests.v3 import utils
27
class GroupTests(utils.TestCase, utils.CrudTests):
29
super(GroupTests, self).setUp()
30
self.additionalSetUp()
32
self.collection_key = 'groups'
33
self.model = groups.Group
34
self.manager = self.client.groups
36
def new_ref(self, **kwargs):
37
kwargs = super(GroupTests, self).new_ref(**kwargs)
38
kwargs.setdefault('name', uuid.uuid4().hex)
41
def test_list_groups_for_user(self):
42
user_id = uuid.uuid4().hex
43
ref_list = [self.new_ref(), self.new_ref()]
44
resp = utils.TestResponse({
46
"text": self.serialize(ref_list),
50
kwargs = copy.copy(self.TEST_REQUEST_BASE)
51
kwargs['headers'] = self.headers[method]
57
user_id, self.collection_key)),
58
**kwargs).AndReturn((resp))
61
returned_list = self.manager.list(user=user_id)
62
self.assertTrue(len(returned_list))
63
[self.assertTrue(isinstance(r, self.model)) for r in returned_list]
65
def test_list_groups_for_domain(self):
66
ref_list = [self.new_ref(), self.new_ref()]
68
domain_id = uuid.uuid4().hex
69
resp = utils.TestResponse({
71
"text": self.serialize(ref_list),
75
kwargs = copy.copy(self.TEST_REQUEST_BASE)
76
kwargs['headers'] = self.headers[method]
81
'v3/%s?domain_id=%s' % (self.collection_key, domain_id)),
82
**kwargs).AndReturn((resp))
85
returned_list = self.manager.list(domain=domain_id)
86
self.assertTrue(len(returned_list))
87
[self.assertTrue(isinstance(r, self.model)) for r in returned_list]