25
43
user_id = uuid.uuid4().hex
26
44
domain_id = uuid.uuid4().hex
27
45
ref = self.new_ref()
28
resp = httplib2.Response({
46
resp = utils.TestResponse({
34
httplib2.Http.request(
52
kwargs = copy.copy(self.TEST_REQUEST_BASE)
53
kwargs['headers'] = self.headers[method]
37
58
'v3/domains/%s/users/%s/%s/%s' % (
38
59
domain_id, user_id, self.collection_key, ref['id'])),
40
headers=self.headers[method]) \
41
.AndReturn((resp, resp['body']))
60
**kwargs).AndReturn((resp))
42
61
self.mox.ReplayAll()
44
63
self.manager.grant(role=ref['id'], domain=domain_id, user=user_id)
65
def test_domain_group_role_grant(self):
66
group_id = uuid.uuid4().hex
67
domain_id = uuid.uuid4().hex
69
resp = utils.TestResponse({
75
kwargs = copy.copy(self.TEST_REQUEST_BASE)
76
kwargs['headers'] = self.headers[method]
81
'v3/domains/%s/groups/%s/%s/%s' % (
82
domain_id, group_id, self.collection_key, ref['id'])),
83
**kwargs).AndReturn((resp))
86
self.manager.grant(role=ref['id'], domain=domain_id, group=group_id)
46
88
def test_domain_role_list(self):
47
89
user_id = uuid.uuid4().hex
48
90
domain_id = uuid.uuid4().hex
49
91
ref_list = [self.new_ref(), self.new_ref()]
50
resp = httplib2.Response({
52
'body': self.serialize(ref_list),
92
resp = utils.TestResponse({
94
"text": self.serialize(ref_list),
56
httplib2.Http.request(
98
kwargs = copy.copy(self.TEST_REQUEST_BASE)
99
kwargs['headers'] = self.headers[method]
59
104
'v3/domains/%s/users/%s/%s' % (
60
105
domain_id, user_id, self.collection_key)),
62
headers=self.headers[method]) \
63
.AndReturn((resp, resp['body']))
106
**kwargs).AndReturn((resp))
64
107
self.mox.ReplayAll()
66
109
self.manager.list(domain=domain_id, user=user_id)
111
def test_domain_group_role_list(self):
112
group_id = uuid.uuid4().hex
113
domain_id = uuid.uuid4().hex
114
ref_list = [self.new_ref(), self.new_ref()]
115
resp = utils.TestResponse({
117
"text": self.serialize(ref_list),
121
kwargs = copy.copy(self.TEST_REQUEST_BASE)
122
kwargs['headers'] = self.headers[method]
127
'v3/domains/%s/groups/%s/%s' % (
128
domain_id, group_id, self.collection_key)),
129
**kwargs).AndReturn((resp))
132
self.manager.list(domain=domain_id, group=group_id)
68
134
def test_domain_role_check(self):
69
135
user_id = uuid.uuid4().hex
70
136
domain_id = uuid.uuid4().hex
71
137
ref = self.new_ref()
72
resp = httplib2.Response({
138
resp = utils.TestResponse({
78
httplib2.Http.request(
144
kwargs = copy.copy(self.TEST_REQUEST_BASE)
145
kwargs['headers'] = self.headers[method]
81
150
'v3/domains/%s/users/%s/%s/%s' % (
82
151
domain_id, user_id, self.collection_key, ref['id'])),
152
**kwargs).AndReturn((resp))
155
self.manager.check(role=ref['id'], domain=domain_id,
158
def test_domain_group_role_check(self):
160
group_id = uuid.uuid4().hex
161
domain_id = uuid.uuid4().hex
163
resp = utils.TestResponse({
169
kwargs = copy.copy(self.TEST_REQUEST_BASE)
170
kwargs['headers'] = self.headers[method]
84
headers=self.headers[method]) \
85
.AndReturn((resp, resp['body']))
175
'v3/domains/%s/groups/%s/%s/%s' % (
176
domain_id, group_id, self.collection_key, ref['id'])),
177
**kwargs).AndReturn((resp))
86
178
self.mox.ReplayAll()
88
self.manager.check(role=ref['id'], domain=domain_id, user=user_id)
180
self.manager.check(role=ref['id'], domain=domain_id, group=group_id)
90
182
def test_domain_role_revoke(self):
91
183
user_id = uuid.uuid4().hex
92
184
domain_id = uuid.uuid4().hex
93
185
ref = self.new_ref()
94
resp = httplib2.Response({
186
resp = utils.TestResponse({
100
httplib2.Http.request(
192
kwargs = copy.copy(self.TEST_REQUEST_BASE)
193
kwargs['headers'] = self.headers[method]
101
196
urlparse.urljoin(
103
198
'v3/domains/%s/users/%s/%s/%s' % (
104
199
domain_id, user_id, self.collection_key, ref['id'])),
106
headers=self.headers[method]) \
107
.AndReturn((resp, resp['body']))
200
**kwargs).AndReturn((resp))
108
201
self.mox.ReplayAll()
110
203
self.manager.revoke(role=ref['id'], domain=domain_id, user=user_id)
205
def test_domain_group_role_revoke(self):
206
group_id = uuid.uuid4().hex
207
domain_id = uuid.uuid4().hex
209
resp = utils.TestResponse({
215
kwargs = copy.copy(self.TEST_REQUEST_BASE)
216
kwargs['headers'] = self.headers[method]
221
'v3/domains/%s/groups/%s/%s/%s' % (
222
domain_id, group_id, self.collection_key, ref['id'])),
223
**kwargs).AndReturn((resp))
226
self.manager.revoke(role=ref['id'], domain=domain_id, group=group_id)
112
228
def test_project_role_grant(self):
113
229
user_id = uuid.uuid4().hex
114
230
project_id = uuid.uuid4().hex
115
231
ref = self.new_ref()
116
resp = httplib2.Response({
232
resp = utils.TestResponse({
122
httplib2.Http.request(
238
kwargs = copy.copy(self.TEST_REQUEST_BASE)
239
kwargs['headers'] = self.headers[method]
123
242
urlparse.urljoin(
125
244
'v3/projects/%s/users/%s/%s/%s' % (
126
245
project_id, user_id, self.collection_key, ref['id'])),
128
headers=self.headers[method]) \
129
.AndReturn((resp, resp['body']))
246
**kwargs).AndReturn((resp))
130
247
self.mox.ReplayAll()
132
249
self.manager.grant(role=ref['id'], project=project_id, user=user_id)
251
def test_project_group_role_grant(self):
252
group_id = uuid.uuid4().hex
253
project_id = uuid.uuid4().hex
255
resp = utils.TestResponse({
261
kwargs = copy.copy(self.TEST_REQUEST_BASE)
262
kwargs['headers'] = self.headers[method]
267
'v3/projects/%s/groups/%s/%s/%s' % (
268
project_id, group_id, self.collection_key, ref['id'])),
269
**kwargs).AndReturn((resp))
272
self.manager.grant(role=ref['id'], project=project_id, group=group_id)
134
274
def test_project_role_list(self):
135
275
user_id = uuid.uuid4().hex
136
276
project_id = uuid.uuid4().hex
137
277
ref_list = [self.new_ref(), self.new_ref()]
138
resp = httplib2.Response({
140
'body': self.serialize(ref_list),
278
resp = utils.TestResponse({
280
"text": self.serialize(ref_list),
144
httplib2.Http.request(
284
kwargs = copy.copy(self.TEST_REQUEST_BASE)
285
kwargs['headers'] = self.headers[method]
145
288
urlparse.urljoin(
147
290
'v3/projects/%s/users/%s/%s' % (
148
291
project_id, user_id, self.collection_key)),
150
headers=self.headers[method]) \
151
.AndReturn((resp, resp['body']))
292
**kwargs).AndReturn((resp))
152
293
self.mox.ReplayAll()
154
295
self.manager.list(project=project_id, user=user_id)
297
def test_project_group_role_list(self):
298
group_id = uuid.uuid4().hex
299
project_id = uuid.uuid4().hex
300
ref_list = [self.new_ref(), self.new_ref()]
301
resp = utils.TestResponse({
303
"text": self.serialize(ref_list),
307
kwargs = copy.copy(self.TEST_REQUEST_BASE)
308
kwargs['headers'] = self.headers[method]
313
'v3/projects/%s/groups/%s/%s' % (
314
project_id, group_id, self.collection_key)),
315
**kwargs).AndReturn((resp))
318
self.manager.list(project=project_id, group=group_id)
156
320
def test_project_role_check(self):
157
321
user_id = uuid.uuid4().hex
158
322
project_id = uuid.uuid4().hex
159
323
ref = self.new_ref()
160
resp = httplib2.Response({
324
resp = utils.TestResponse({
166
httplib2.Http.request(
330
kwargs = copy.copy(self.TEST_REQUEST_BASE)
331
kwargs['headers'] = self.headers[method]
167
334
urlparse.urljoin(
169
336
'v3/projects/%s/users/%s/%s/%s' % (
170
337
project_id, user_id, self.collection_key, ref['id'])),
172
headers=self.headers[method]) \
173
.AndReturn((resp, resp['body']))
338
**kwargs).AndReturn((resp))
174
339
self.mox.ReplayAll()
176
341
self.manager.check(role=ref['id'], project=project_id, user=user_id)
343
def test_project_group_role_check(self):
344
group_id = uuid.uuid4().hex
345
project_id = uuid.uuid4().hex
347
resp = utils.TestResponse({
353
kwargs = copy.copy(self.TEST_REQUEST_BASE)
354
kwargs['headers'] = self.headers[method]
359
'v3/projects/%s/groups/%s/%s/%s' % (
360
project_id, group_id, self.collection_key, ref['id'])),
361
**kwargs).AndReturn((resp))
364
self.manager.check(role=ref['id'], project=project_id, group=group_id)
178
366
def test_project_role_revoke(self):
179
367
user_id = uuid.uuid4().hex
180
368
project_id = uuid.uuid4().hex
181
369
ref = self.new_ref()
182
resp = httplib2.Response({
370
resp = utils.TestResponse({
187
375
method = 'DELETE'
188
httplib2.Http.request(
376
kwargs = copy.copy(self.TEST_REQUEST_BASE)
377
kwargs['headers'] = self.headers[method]
189
380
urlparse.urljoin(
191
382
'v3/projects/%s/users/%s/%s/%s' % (
192
383
project_id, user_id, self.collection_key, ref['id'])),
194
headers=self.headers[method]) \
195
.AndReturn((resp, resp['body']))
384
**kwargs).AndReturn((resp))
196
385
self.mox.ReplayAll()
198
387
self.manager.revoke(role=ref['id'], project=project_id, user=user_id)
389
def test_project_group_role_revoke(self):
390
group_id = uuid.uuid4().hex
391
project_id = uuid.uuid4().hex
393
resp = utils.TestResponse({
399
kwargs = copy.copy(self.TEST_REQUEST_BASE)
400
kwargs['headers'] = self.headers[method]
405
'v3/projects/%s/groups/%s/%s/%s' % (
406
project_id, group_id, self.collection_key, ref['id'])),
407
**kwargs).AndReturn((resp))
410
self.manager.revoke(role=ref['id'], project=project_id, group=group_id)
200
412
def test_domain_project_role_grant_fails(self):
201
413
user_id = uuid.uuid4().hex
202
414
project_id = uuid.uuid4().hex