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
3
23
from keystoneclient.v3 import users
4
24
from tests.v3 import utils
21
41
kwargs.setdefault('name', uuid.uuid4().hex)
22
42
kwargs.setdefault('project_id', uuid.uuid4().hex)
45
def test_add_user_to_group(self):
46
group_id = uuid.uuid4().hex
48
resp = utils.TestResponse({
54
kwargs = copy.copy(self.TEST_REQUEST_BASE)
55
kwargs['headers'] = self.headers[method]
60
'v3/groups/%s/%s/%s' % (
61
group_id, self.collection_key, ref['id'])),
62
**kwargs).AndReturn((resp))
65
self.manager.add_to_group(user=ref['id'], group=group_id)
67
def test_list_users_in_group(self):
68
group_id = uuid.uuid4().hex
69
ref_list = [self.new_ref(), self.new_ref()]
70
resp = utils.TestResponse({
72
"text": self.serialize(ref_list),
76
kwargs = copy.copy(self.TEST_REQUEST_BASE)
77
kwargs['headers'] = self.headers[method]
83
group_id, self.collection_key)),
84
**kwargs).AndReturn((resp))
87
returned_list = self.manager.list(group=group_id)
88
self.assertTrue(len(returned_list))
89
[self.assertTrue(isinstance(r, self.model)) for r in returned_list]
91
def test_check_user_in_group(self):
92
group_id = uuid.uuid4().hex
94
resp = utils.TestResponse({
100
kwargs = copy.copy(self.TEST_REQUEST_BASE)
101
kwargs['headers'] = self.headers[method]
106
'v3/groups/%s/%s/%s' % (
107
group_id, self.collection_key, ref['id'])),
108
**kwargs).AndReturn((resp))
111
self.manager.check_in_group(user=ref['id'], group=group_id)
113
def test_remove_user_from_group(self):
114
group_id = uuid.uuid4().hex
116
resp = utils.TestResponse({
122
kwargs = copy.copy(self.TEST_REQUEST_BASE)
123
kwargs['headers'] = self.headers[method]
128
'v3/groups/%s/%s/%s' % (
129
group_id, self.collection_key, ref['id'])),
130
**kwargs).AndReturn((resp))
133
self.manager.remove_from_group(user=ref['id'], group=group_id)