crowd-client 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,6 +19,8 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ["lib"]
20
20
 
21
21
  s.add_development_dependency "rspec"
22
+ s.add_development_dependency "vcr"
23
+ s.add_development_dependency "webmock"
22
24
 
23
25
  s.add_runtime_dependency "faraday", "~> 0.7.5"
24
26
  s.add_runtime_dependency "faraday_middleware", "~> 0.7.0"
@@ -31,7 +31,7 @@ module Crowd
31
31
 
32
32
  def valid_session?(token)
33
33
  response = connection.post("session/#{token}", {})
34
- response.status == 200 ? true : false
34
+ response.status == 200
35
35
  end
36
36
 
37
37
  def logout(token)
@@ -39,6 +39,14 @@ module Crowd
39
39
  raise Exception::UnkownError if response.status != 204
40
40
  end
41
41
 
42
+ def in_group?(username, group_name)
43
+ response = connection.get("user/group/nested") do |request|
44
+ request.params[:username] = username
45
+ request.params[:groupname] = group_name
46
+ end
47
+ response.status == 200
48
+ end
49
+
42
50
  def connection
43
51
  ::Faraday::Connection.new(
44
52
  :url => config.url,
@@ -1,5 +1,5 @@
1
1
  module Crowd
2
2
  module Client
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -0,0 +1,910 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :get
5
+ uri: http://127.0.0.1:8095/user/group/nested
6
+ body: !!null
7
+ headers:
8
+ accept:
9
+ - application/json
10
+ authorization:
11
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
12
+ username:
13
+ - user@example.com
14
+ groupname:
15
+ - MyGroup
16
+ response: !ruby/struct:VCR::Response
17
+ status: !ruby/struct:VCR::ResponseStatus
18
+ code: 404
19
+ message: Not Found
20
+ headers:
21
+ server:
22
+ - Apache-Coyote/1.1
23
+ content-type:
24
+ - text/html;charset=utf-8
25
+ content-length:
26
+ - '1006'
27
+ date:
28
+ - Mon, 24 Oct 2011 17:41:27 GMT
29
+ body: ! '<html><head><title>Apache Tomcat/6.0.32 - Error report</title><style><!--H1
30
+ {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
31
+ H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;}
32
+ H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;}
33
+ BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;}
34
+ B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;}
35
+ P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A
36
+ {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP
37
+ Status 404 - /user/group/nested</h1><HR size="1" noshade="noshade"><p><b>type</b>
38
+ Status report</p><p><b>message</b> <u>/user/group/nested</u></p><p><b>description</b>
39
+ <u>The requested resource (/user/group/nested) is not available.</u></p><HR
40
+ size="1" noshade="noshade"><h3>Apache Tomcat/6.0.32</h3></body></html>'
41
+ http_version: '1.1'
42
+ - !ruby/struct:VCR::HTTPInteraction
43
+ request: !ruby/struct:VCR::Request
44
+ method: :post
45
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/session/akoqHwkAqtQHtriHaHKfwA00
46
+ body: ! '{}'
47
+ headers:
48
+ accept:
49
+ - application/json
50
+ authorization:
51
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
52
+ content-type:
53
+ - application/json
54
+ response: !ruby/struct:VCR::Response
55
+ status: !ruby/struct:VCR::ResponseStatus
56
+ code: 200
57
+ message: OK
58
+ headers:
59
+ server:
60
+ - Apache-Coyote/1.1
61
+ x-embedded-crowd-version:
62
+ - Crowd/2.3.3
63
+ x-crowd-user-management-version:
64
+ - '1.1'
65
+ set-cookie:
66
+ - JSESSIONID=E3B16E4957759AA15D493512E36E5DDE; Path=/crowd
67
+ cache-control:
68
+ - no-cache, no-store, no-transform
69
+ content-type:
70
+ - application/json
71
+ transfer-encoding:
72
+ - chunked
73
+ date:
74
+ - Mon, 24 Oct 2011 17:41:27 GMT
75
+ body: ! '{"expand":"user","token":"akoqHwkAqtQHtriHaHKfwA00","user":{"link":{"href":"http://127.0.0.1:8095/crowd/rest/usermanagement/1/user?username=user@example.com","rel":"self"},"name":"user@example.com"},"link":{"href":"http://127.0.0.1:8095/crowd/rest/usermanagement/1/session/akoqHwkAqtQHtriHaHKfwA00","rel":"self"}}'
76
+ http_version: '1.1'
77
+ - !ruby/struct:VCR::HTTPInteraction
78
+ request: !ruby/struct:VCR::Request
79
+ method: :delete
80
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/session/akoqHwkAqtQHtriHaHKfwA00
81
+ body: !!null
82
+ headers:
83
+ accept:
84
+ - application/json
85
+ authorization:
86
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
87
+ response: !ruby/struct:VCR::Response
88
+ status: !ruby/struct:VCR::ResponseStatus
89
+ code: 204
90
+ message: No Content
91
+ headers:
92
+ server:
93
+ - Apache-Coyote/1.1
94
+ x-embedded-crowd-version:
95
+ - Crowd/2.3.3
96
+ x-crowd-user-management-version:
97
+ - '1.1'
98
+ set-cookie:
99
+ - JSESSIONID=7DB3CA4FD107004EBD7B80A3444A5DF5; Path=/crowd
100
+ date:
101
+ - Mon, 24 Oct 2011 17:41:27 GMT
102
+ body: !!null
103
+ http_version: '1.1'
104
+ - !ruby/struct:VCR::HTTPInteraction
105
+ request: !ruby/struct:VCR::Request
106
+ method: :post
107
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/session/akoqHwkAqtQHtriHaHKfwA00
108
+ body: ! '{}'
109
+ headers:
110
+ accept:
111
+ - application/json
112
+ authorization:
113
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
114
+ content-type:
115
+ - application/json
116
+ response: !ruby/struct:VCR::Response
117
+ status: !ruby/struct:VCR::ResponseStatus
118
+ code: 404
119
+ message: Not Found
120
+ headers:
121
+ server:
122
+ - Apache-Coyote/1.1
123
+ x-embedded-crowd-version:
124
+ - Crowd/2.3.3
125
+ x-crowd-user-management-version:
126
+ - '1.1'
127
+ set-cookie:
128
+ - JSESSIONID=3F4377B74E289159EB2093D7DBBA35A5; Path=/crowd
129
+ content-type:
130
+ - application/json
131
+ transfer-encoding:
132
+ - chunked
133
+ date:
134
+ - Mon, 24 Oct 2011 17:41:27 GMT
135
+ body: ! '{"reason":"INVALID_SSO_TOKEN","message":"Token does not validate."}'
136
+ http_version: '1.1'
137
+ - !ruby/struct:VCR::HTTPInteraction
138
+ request: !ruby/struct:VCR::Request
139
+ method: :post
140
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/session/cMPdTh8dEd586Z8pFpoc8g00
141
+ body: ! '{}'
142
+ headers:
143
+ accept:
144
+ - application/json
145
+ authorization:
146
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
147
+ content-type:
148
+ - application/json
149
+ response: !ruby/struct:VCR::Response
150
+ status: !ruby/struct:VCR::ResponseStatus
151
+ code: 200
152
+ message: OK
153
+ headers:
154
+ server:
155
+ - Apache-Coyote/1.1
156
+ x-embedded-crowd-version:
157
+ - Crowd/2.3.3
158
+ x-crowd-user-management-version:
159
+ - '1.1'
160
+ set-cookie:
161
+ - JSESSIONID=E190FCEDC0E0F3EC04A4110F336716DA; Path=/crowd
162
+ cache-control:
163
+ - no-cache, no-store, no-transform
164
+ content-type:
165
+ - application/json
166
+ transfer-encoding:
167
+ - chunked
168
+ date:
169
+ - Mon, 24 Oct 2011 17:42:22 GMT
170
+ body: ! '{"expand":"user","token":"cMPdTh8dEd586Z8pFpoc8g00","user":{"link":{"href":"http://127.0.0.1:8095/crowd/rest/usermanagement/1/user?username=user@example.com","rel":"self"},"name":"user@example.com"},"link":{"href":"http://127.0.0.1:8095/crowd/rest/usermanagement/1/session/cMPdTh8dEd586Z8pFpoc8g00","rel":"self"}}'
171
+ http_version: '1.1'
172
+ - !ruby/struct:VCR::HTTPInteraction
173
+ request: !ruby/struct:VCR::Request
174
+ method: :delete
175
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/session/cMPdTh8dEd586Z8pFpoc8g00
176
+ body: !!null
177
+ headers:
178
+ accept:
179
+ - application/json
180
+ authorization:
181
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
182
+ response: !ruby/struct:VCR::Response
183
+ status: !ruby/struct:VCR::ResponseStatus
184
+ code: 204
185
+ message: No Content
186
+ headers:
187
+ server:
188
+ - Apache-Coyote/1.1
189
+ x-embedded-crowd-version:
190
+ - Crowd/2.3.3
191
+ x-crowd-user-management-version:
192
+ - '1.1'
193
+ set-cookie:
194
+ - JSESSIONID=EF59322E28B415D3606CAE145B9D44A8; Path=/crowd
195
+ date:
196
+ - Mon, 24 Oct 2011 17:42:22 GMT
197
+ body: !!null
198
+ http_version: '1.1'
199
+ - !ruby/struct:VCR::HTTPInteraction
200
+ request: !ruby/struct:VCR::Request
201
+ method: :post
202
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/session/cMPdTh8dEd586Z8pFpoc8g00
203
+ body: ! '{}'
204
+ headers:
205
+ accept:
206
+ - application/json
207
+ authorization:
208
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
209
+ content-type:
210
+ - application/json
211
+ response: !ruby/struct:VCR::Response
212
+ status: !ruby/struct:VCR::ResponseStatus
213
+ code: 404
214
+ message: Not Found
215
+ headers:
216
+ server:
217
+ - Apache-Coyote/1.1
218
+ x-embedded-crowd-version:
219
+ - Crowd/2.3.3
220
+ x-crowd-user-management-version:
221
+ - '1.1'
222
+ set-cookie:
223
+ - JSESSIONID=905E33DD1C4EE45752732C847045D273; Path=/crowd
224
+ content-type:
225
+ - application/json
226
+ transfer-encoding:
227
+ - chunked
228
+ date:
229
+ - Mon, 24 Oct 2011 17:42:22 GMT
230
+ body: ! '{"reason":"INVALID_SSO_TOKEN","message":"Token does not validate."}'
231
+ http_version: '1.1'
232
+ - !ruby/struct:VCR::HTTPInteraction
233
+ request: !ruby/struct:VCR::Request
234
+ method: :post
235
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/session/PY2wAuVlJcwulTnBP5FIbQ00
236
+ body: ! '{}'
237
+ headers:
238
+ accept:
239
+ - application/json
240
+ authorization:
241
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
242
+ content-type:
243
+ - application/json
244
+ response: !ruby/struct:VCR::Response
245
+ status: !ruby/struct:VCR::ResponseStatus
246
+ code: 200
247
+ message: OK
248
+ headers:
249
+ server:
250
+ - Apache-Coyote/1.1
251
+ x-embedded-crowd-version:
252
+ - Crowd/2.3.3
253
+ x-crowd-user-management-version:
254
+ - '1.1'
255
+ set-cookie:
256
+ - JSESSIONID=79CEC57B4545DFB4CEEF4DBFA12EF484; Path=/crowd
257
+ cache-control:
258
+ - no-cache, no-store, no-transform
259
+ content-type:
260
+ - application/json
261
+ transfer-encoding:
262
+ - chunked
263
+ date:
264
+ - Mon, 24 Oct 2011 17:42:59 GMT
265
+ body: ! '{"expand":"user","token":"PY2wAuVlJcwulTnBP5FIbQ00","user":{"link":{"href":"http://127.0.0.1:8095/crowd/rest/usermanagement/1/user?username=user@example.com","rel":"self"},"name":"user@example.com"},"link":{"href":"http://127.0.0.1:8095/crowd/rest/usermanagement/1/session/PY2wAuVlJcwulTnBP5FIbQ00","rel":"self"}}'
266
+ http_version: '1.1'
267
+ - !ruby/struct:VCR::HTTPInteraction
268
+ request: !ruby/struct:VCR::Request
269
+ method: :delete
270
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/session/PY2wAuVlJcwulTnBP5FIbQ00
271
+ body: !!null
272
+ headers:
273
+ accept:
274
+ - application/json
275
+ authorization:
276
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
277
+ response: !ruby/struct:VCR::Response
278
+ status: !ruby/struct:VCR::ResponseStatus
279
+ code: 204
280
+ message: No Content
281
+ headers:
282
+ server:
283
+ - Apache-Coyote/1.1
284
+ x-embedded-crowd-version:
285
+ - Crowd/2.3.3
286
+ x-crowd-user-management-version:
287
+ - '1.1'
288
+ set-cookie:
289
+ - JSESSIONID=B1A18D07B87E284D8C336656294181AC; Path=/crowd
290
+ date:
291
+ - Mon, 24 Oct 2011 17:42:59 GMT
292
+ body: !!null
293
+ http_version: '1.1'
294
+ - !ruby/struct:VCR::HTTPInteraction
295
+ request: !ruby/struct:VCR::Request
296
+ method: :post
297
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/session/PY2wAuVlJcwulTnBP5FIbQ00
298
+ body: ! '{}'
299
+ headers:
300
+ accept:
301
+ - application/json
302
+ authorization:
303
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
304
+ content-type:
305
+ - application/json
306
+ response: !ruby/struct:VCR::Response
307
+ status: !ruby/struct:VCR::ResponseStatus
308
+ code: 404
309
+ message: Not Found
310
+ headers:
311
+ server:
312
+ - Apache-Coyote/1.1
313
+ x-embedded-crowd-version:
314
+ - Crowd/2.3.3
315
+ x-crowd-user-management-version:
316
+ - '1.1'
317
+ set-cookie:
318
+ - JSESSIONID=CF4BEA4A9616CFCBD6ED5A94909F1A1E; Path=/crowd
319
+ content-type:
320
+ - application/json
321
+ transfer-encoding:
322
+ - chunked
323
+ date:
324
+ - Mon, 24 Oct 2011 17:43:00 GMT
325
+ body: ! '{"reason":"INVALID_SSO_TOKEN","message":"Token does not validate."}'
326
+ http_version: '1.1'
327
+ - !ruby/struct:VCR::HTTPInteraction
328
+ request: !ruby/struct:VCR::Request
329
+ method: :post
330
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/session/P0dncW093f0cOMGCd0OG4A00
331
+ body: ! '{}'
332
+ headers:
333
+ accept:
334
+ - application/json
335
+ authorization:
336
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
337
+ content-type:
338
+ - application/json
339
+ response: !ruby/struct:VCR::Response
340
+ status: !ruby/struct:VCR::ResponseStatus
341
+ code: 200
342
+ message: OK
343
+ headers:
344
+ server:
345
+ - Apache-Coyote/1.1
346
+ x-embedded-crowd-version:
347
+ - Crowd/2.3.3
348
+ x-crowd-user-management-version:
349
+ - '1.1'
350
+ set-cookie:
351
+ - JSESSIONID=4E1BA767A1A41ED5E73D48E52A1EC23F; Path=/crowd
352
+ cache-control:
353
+ - no-cache, no-store, no-transform
354
+ content-type:
355
+ - application/json
356
+ transfer-encoding:
357
+ - chunked
358
+ date:
359
+ - Mon, 24 Oct 2011 17:45:16 GMT
360
+ body: ! '{"expand":"user","token":"P0dncW093f0cOMGCd0OG4A00","user":{"link":{"href":"http://127.0.0.1:8095/crowd/rest/usermanagement/1/user?username=user@example.com","rel":"self"},"name":"user@example.com"},"link":{"href":"http://127.0.0.1:8095/crowd/rest/usermanagement/1/session/P0dncW093f0cOMGCd0OG4A00","rel":"self"}}'
361
+ http_version: '1.1'
362
+ - !ruby/struct:VCR::HTTPInteraction
363
+ request: !ruby/struct:VCR::Request
364
+ method: :delete
365
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/session/P0dncW093f0cOMGCd0OG4A00
366
+ body: !!null
367
+ headers:
368
+ accept:
369
+ - application/json
370
+ authorization:
371
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
372
+ response: !ruby/struct:VCR::Response
373
+ status: !ruby/struct:VCR::ResponseStatus
374
+ code: 204
375
+ message: No Content
376
+ headers:
377
+ server:
378
+ - Apache-Coyote/1.1
379
+ x-embedded-crowd-version:
380
+ - Crowd/2.3.3
381
+ x-crowd-user-management-version:
382
+ - '1.1'
383
+ set-cookie:
384
+ - JSESSIONID=A7D101ABF814F975C9012762F223CCF2; Path=/crowd
385
+ date:
386
+ - Mon, 24 Oct 2011 17:45:16 GMT
387
+ body: !!null
388
+ http_version: '1.1'
389
+ - !ruby/struct:VCR::HTTPInteraction
390
+ request: !ruby/struct:VCR::Request
391
+ method: :post
392
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/session/P0dncW093f0cOMGCd0OG4A00
393
+ body: ! '{}'
394
+ headers:
395
+ accept:
396
+ - application/json
397
+ authorization:
398
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
399
+ content-type:
400
+ - application/json
401
+ response: !ruby/struct:VCR::Response
402
+ status: !ruby/struct:VCR::ResponseStatus
403
+ code: 404
404
+ message: Not Found
405
+ headers:
406
+ server:
407
+ - Apache-Coyote/1.1
408
+ x-embedded-crowd-version:
409
+ - Crowd/2.3.3
410
+ x-crowd-user-management-version:
411
+ - '1.1'
412
+ set-cookie:
413
+ - JSESSIONID=AC6FE680BACF3FA7A97E246C684C2F1D; Path=/crowd
414
+ content-type:
415
+ - application/json
416
+ transfer-encoding:
417
+ - chunked
418
+ date:
419
+ - Mon, 24 Oct 2011 17:45:16 GMT
420
+ body: ! '{"reason":"INVALID_SSO_TOKEN","message":"Token does not validate."}'
421
+ http_version: '1.1'
422
+ - !ruby/struct:VCR::HTTPInteraction
423
+ request: !ruby/struct:VCR::Request
424
+ method: :post
425
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/session/USsWljgK06dsd0DHDBnVMA00
426
+ body: ! '{}'
427
+ headers:
428
+ accept:
429
+ - application/json
430
+ authorization:
431
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
432
+ content-type:
433
+ - application/json
434
+ response: !ruby/struct:VCR::Response
435
+ status: !ruby/struct:VCR::ResponseStatus
436
+ code: 200
437
+ message: OK
438
+ headers:
439
+ server:
440
+ - Apache-Coyote/1.1
441
+ x-embedded-crowd-version:
442
+ - Crowd/2.3.3
443
+ x-crowd-user-management-version:
444
+ - '1.1'
445
+ set-cookie:
446
+ - JSESSIONID=74FB1546A6B6F474085E830B9D6F973D; Path=/crowd
447
+ cache-control:
448
+ - no-cache, no-store, no-transform
449
+ content-type:
450
+ - application/json
451
+ transfer-encoding:
452
+ - chunked
453
+ date:
454
+ - Mon, 24 Oct 2011 17:46:16 GMT
455
+ body: ! '{"expand":"user","token":"USsWljgK06dsd0DHDBnVMA00","user":{"link":{"href":"http://127.0.0.1:8095/crowd/rest/usermanagement/1/user?username=user@example.com","rel":"self"},"name":"user@example.com"},"link":{"href":"http://127.0.0.1:8095/crowd/rest/usermanagement/1/session/USsWljgK06dsd0DHDBnVMA00","rel":"self"}}'
456
+ http_version: '1.1'
457
+ - !ruby/struct:VCR::HTTPInteraction
458
+ request: !ruby/struct:VCR::Request
459
+ method: :delete
460
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/session/USsWljgK06dsd0DHDBnVMA00
461
+ body: !!null
462
+ headers:
463
+ accept:
464
+ - application/json
465
+ authorization:
466
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
467
+ response: !ruby/struct:VCR::Response
468
+ status: !ruby/struct:VCR::ResponseStatus
469
+ code: 204
470
+ message: No Content
471
+ headers:
472
+ server:
473
+ - Apache-Coyote/1.1
474
+ x-embedded-crowd-version:
475
+ - Crowd/2.3.3
476
+ x-crowd-user-management-version:
477
+ - '1.1'
478
+ set-cookie:
479
+ - JSESSIONID=486D79AB6412A27EAF225AA8FD0A8DAE; Path=/crowd
480
+ date:
481
+ - Mon, 24 Oct 2011 17:46:16 GMT
482
+ body: !!null
483
+ http_version: '1.1'
484
+ - !ruby/struct:VCR::HTTPInteraction
485
+ request: !ruby/struct:VCR::Request
486
+ method: :post
487
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/session/USsWljgK06dsd0DHDBnVMA00
488
+ body: ! '{}'
489
+ headers:
490
+ accept:
491
+ - application/json
492
+ authorization:
493
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
494
+ content-type:
495
+ - application/json
496
+ response: !ruby/struct:VCR::Response
497
+ status: !ruby/struct:VCR::ResponseStatus
498
+ code: 404
499
+ message: Not Found
500
+ headers:
501
+ server:
502
+ - Apache-Coyote/1.1
503
+ x-embedded-crowd-version:
504
+ - Crowd/2.3.3
505
+ x-crowd-user-management-version:
506
+ - '1.1'
507
+ set-cookie:
508
+ - JSESSIONID=A3950A88E6EE8FC4CAFEF3AABB5C86CC; Path=/crowd
509
+ content-type:
510
+ - application/json
511
+ transfer-encoding:
512
+ - chunked
513
+ date:
514
+ - Mon, 24 Oct 2011 17:46:17 GMT
515
+ body: ! '{"reason":"INVALID_SSO_TOKEN","message":"Token does not validate."}'
516
+ http_version: '1.1'
517
+ - !ruby/struct:VCR::HTTPInteraction
518
+ request: !ruby/struct:VCR::Request
519
+ method: :get
520
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/user/group/nested
521
+ body: !!null
522
+ headers:
523
+ accept:
524
+ - application/json
525
+ authorization:
526
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
527
+ username:
528
+ - user@example.com
529
+ groupname:
530
+ - MyGroup
531
+ response: !ruby/struct:VCR::Response
532
+ status: !ruby/struct:VCR::ResponseStatus
533
+ code: 400
534
+ message: Bad Request
535
+ headers:
536
+ server:
537
+ - Apache-Coyote/1.1
538
+ x-embedded-crowd-version:
539
+ - Crowd/2.3.3
540
+ x-crowd-user-management-version:
541
+ - '1.1'
542
+ set-cookie:
543
+ - JSESSIONID=504AEE176C5C63D321513207BB9E55DB; Path=/crowd
544
+ content-type:
545
+ - application/json
546
+ transfer-encoding:
547
+ - chunked
548
+ date:
549
+ - Mon, 24 Oct 2011 17:46:48 GMT
550
+ body: ! '{"reason":"ILLEGAL_ARGUMENT","message":"username query parameter must
551
+ be given"}'
552
+ http_version: '1.1'
553
+ - !ruby/struct:VCR::HTTPInteraction
554
+ request: !ruby/struct:VCR::Request
555
+ method: :post
556
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/session/XZ0sHLGWuTFoIjwNFa1eWw00
557
+ body: ! '{}'
558
+ headers:
559
+ accept:
560
+ - application/json
561
+ authorization:
562
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
563
+ content-type:
564
+ - application/json
565
+ response: !ruby/struct:VCR::Response
566
+ status: !ruby/struct:VCR::ResponseStatus
567
+ code: 200
568
+ message: OK
569
+ headers:
570
+ server:
571
+ - Apache-Coyote/1.1
572
+ x-embedded-crowd-version:
573
+ - Crowd/2.3.3
574
+ x-crowd-user-management-version:
575
+ - '1.1'
576
+ set-cookie:
577
+ - JSESSIONID=79278EC3A1B5E22593BC068AC5370043; Path=/crowd
578
+ cache-control:
579
+ - no-cache, no-store, no-transform
580
+ content-type:
581
+ - application/json
582
+ transfer-encoding:
583
+ - chunked
584
+ date:
585
+ - Mon, 24 Oct 2011 17:51:35 GMT
586
+ body: ! '{"expand":"user","token":"XZ0sHLGWuTFoIjwNFa1eWw00","user":{"link":{"href":"http://127.0.0.1:8095/crowd/rest/usermanagement/1/user?username=user@example.com","rel":"self"},"name":"user@example.com"},"link":{"href":"http://127.0.0.1:8095/crowd/rest/usermanagement/1/session/XZ0sHLGWuTFoIjwNFa1eWw00","rel":"self"}}'
587
+ http_version: '1.1'
588
+ - !ruby/struct:VCR::HTTPInteraction
589
+ request: !ruby/struct:VCR::Request
590
+ method: :delete
591
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/session/XZ0sHLGWuTFoIjwNFa1eWw00
592
+ body: !!null
593
+ headers:
594
+ accept:
595
+ - application/json
596
+ authorization:
597
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
598
+ response: !ruby/struct:VCR::Response
599
+ status: !ruby/struct:VCR::ResponseStatus
600
+ code: 204
601
+ message: No Content
602
+ headers:
603
+ server:
604
+ - Apache-Coyote/1.1
605
+ x-embedded-crowd-version:
606
+ - Crowd/2.3.3
607
+ x-crowd-user-management-version:
608
+ - '1.1'
609
+ set-cookie:
610
+ - JSESSIONID=7668AD93346DA50BC804F80498E70891; Path=/crowd
611
+ date:
612
+ - Mon, 24 Oct 2011 17:51:35 GMT
613
+ body: !!null
614
+ http_version: '1.1'
615
+ - !ruby/struct:VCR::HTTPInteraction
616
+ request: !ruby/struct:VCR::Request
617
+ method: :post
618
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/session/XZ0sHLGWuTFoIjwNFa1eWw00
619
+ body: ! '{}'
620
+ headers:
621
+ accept:
622
+ - application/json
623
+ authorization:
624
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
625
+ content-type:
626
+ - application/json
627
+ response: !ruby/struct:VCR::Response
628
+ status: !ruby/struct:VCR::ResponseStatus
629
+ code: 404
630
+ message: Not Found
631
+ headers:
632
+ server:
633
+ - Apache-Coyote/1.1
634
+ x-embedded-crowd-version:
635
+ - Crowd/2.3.3
636
+ x-crowd-user-management-version:
637
+ - '1.1'
638
+ set-cookie:
639
+ - JSESSIONID=32F4E96FE6D897D0D98BE42890CC6770; Path=/crowd
640
+ content-type:
641
+ - application/json
642
+ transfer-encoding:
643
+ - chunked
644
+ date:
645
+ - Mon, 24 Oct 2011 17:51:35 GMT
646
+ body: ! '{"reason":"INVALID_SSO_TOKEN","message":"Token does not validate."}'
647
+ http_version: '1.1'
648
+ - !ruby/struct:VCR::HTTPInteraction
649
+ request: !ruby/struct:VCR::Request
650
+ method: :post
651
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/session
652
+ body: ! '{"username":"user@example.com","password":"wrong_password"}'
653
+ headers:
654
+ accept:
655
+ - application/json
656
+ authorization:
657
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
658
+ content-type:
659
+ - application/json
660
+ response: !ruby/struct:VCR::Response
661
+ status: !ruby/struct:VCR::ResponseStatus
662
+ code: 400
663
+ message: Bad Request
664
+ headers:
665
+ server:
666
+ - Apache-Coyote/1.1
667
+ x-embedded-crowd-version:
668
+ - Crowd/2.3.3
669
+ x-crowd-user-management-version:
670
+ - '1.1'
671
+ set-cookie:
672
+ - JSESSIONID=8377CD6C163BF4054E8B7BAE067A2C54; Path=/crowd
673
+ content-type:
674
+ - application/json
675
+ transfer-encoding:
676
+ - chunked
677
+ date:
678
+ - Mon, 24 Oct 2011 17:51:58 GMT
679
+ body: ! '{"reason":"INVALID_USER_AUTHENTICATION","message":"Failed to authenticate
680
+ principal, password was invalid"}'
681
+ http_version: '1.1'
682
+ - !ruby/struct:VCR::HTTPInteraction
683
+ request: !ruby/struct:VCR::Request
684
+ method: :post
685
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/session
686
+ body: ! '{"username":"inactive_user@example.com","password":"password"}'
687
+ headers:
688
+ accept:
689
+ - application/json
690
+ authorization:
691
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
692
+ content-type:
693
+ - application/json
694
+ response: !ruby/struct:VCR::Response
695
+ status: !ruby/struct:VCR::ResponseStatus
696
+ code: 400
697
+ message: Bad Request
698
+ headers:
699
+ server:
700
+ - Apache-Coyote/1.1
701
+ x-embedded-crowd-version:
702
+ - Crowd/2.3.3
703
+ x-crowd-user-management-version:
704
+ - '1.1'
705
+ set-cookie:
706
+ - JSESSIONID=74CD3F4173D9E523E64C021D4DB2F02F; Path=/crowd
707
+ content-type:
708
+ - application/json
709
+ transfer-encoding:
710
+ - chunked
711
+ date:
712
+ - Mon, 24 Oct 2011 17:51:58 GMT
713
+ body: ! '{"reason":"INACTIVE_ACCOUNT","message":"Account with name <inactive_user@example.com>
714
+ is inactive"}'
715
+ http_version: '1.1'
716
+ - !ruby/struct:VCR::HTTPInteraction
717
+ request: !ruby/struct:VCR::Request
718
+ method: :get
719
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/user/group/nested?groupname=MyGroup&username=user@example.com
720
+ body: !!null
721
+ headers:
722
+ accept:
723
+ - application/json
724
+ authorization:
725
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
726
+ response: !ruby/struct:VCR::Response
727
+ status: !ruby/struct:VCR::ResponseStatus
728
+ code: 200
729
+ message: OK
730
+ headers:
731
+ server:
732
+ - Apache-Coyote/1.1
733
+ x-embedded-crowd-version:
734
+ - Crowd/2.3.3
735
+ x-crowd-user-management-version:
736
+ - '1.1'
737
+ set-cookie:
738
+ - JSESSIONID=58A2FA47A0D6E4CC8F2F5F10F9175E31; Path=/crowd
739
+ content-type:
740
+ - application/json
741
+ transfer-encoding:
742
+ - chunked
743
+ date:
744
+ - Mon, 24 Oct 2011 17:51:58 GMT
745
+ body: ! '{"link":{"href":"http://127.0.0.1:8095/crowd/rest/usermanagement/1/group?groupname=MyGroup","rel":"self"},"name":"MyGroup"}'
746
+ http_version: '1.1'
747
+ - !ruby/struct:VCR::HTTPInteraction
748
+ request: !ruby/struct:VCR::Request
749
+ method: :get
750
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/user/group/nested?groupname=OtherGroup&username=user@example.com
751
+ body: !!null
752
+ headers:
753
+ accept:
754
+ - application/json
755
+ authorization:
756
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
757
+ response: !ruby/struct:VCR::Response
758
+ status: !ruby/struct:VCR::ResponseStatus
759
+ code: 404
760
+ message: Not Found
761
+ headers:
762
+ server:
763
+ - Apache-Coyote/1.1
764
+ x-embedded-crowd-version:
765
+ - Crowd/2.3.3
766
+ x-crowd-user-management-version:
767
+ - '1.1'
768
+ set-cookie:
769
+ - JSESSIONID=8AEE3C12707576D28A4D88339E639054; Path=/crowd
770
+ content-type:
771
+ - application/json
772
+ transfer-encoding:
773
+ - chunked
774
+ date:
775
+ - Mon, 24 Oct 2011 17:51:58 GMT
776
+ body: ! '{"reason":"MEMBERSHIP_NOT_FOUND","message":"The child entity <user@example.com>
777
+ is not a member of the parent <OtherGroup>"}'
778
+ http_version: '1.1'
779
+ - !ruby/struct:VCR::HTTPInteraction
780
+ request: !ruby/struct:VCR::Request
781
+ method: :post
782
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/session
783
+ body: ! '{"username":"user@example.com","password":"password"}'
784
+ headers:
785
+ accept:
786
+ - application/json
787
+ authorization:
788
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
789
+ content-type:
790
+ - application/json
791
+ response: !ruby/struct:VCR::Response
792
+ status: !ruby/struct:VCR::ResponseStatus
793
+ code: 201
794
+ message: Created
795
+ headers:
796
+ server:
797
+ - Apache-Coyote/1.1
798
+ x-embedded-crowd-version:
799
+ - Crowd/2.3.3
800
+ x-crowd-user-management-version:
801
+ - '1.1'
802
+ set-cookie:
803
+ - JSESSIONID=30FA13CD6003863CB75FF12D46496901; Path=/crowd
804
+ cache-control:
805
+ - no-cache, no-store, no-transform
806
+ location:
807
+ - http://127.0.0.1:8095/crowd/rest/usermanagement/1/session/5Q4uuXK0ix464NwJOGvCbA00
808
+ content-type:
809
+ - application/json
810
+ transfer-encoding:
811
+ - chunked
812
+ date:
813
+ - Mon, 24 Oct 2011 17:51:58 GMT
814
+ body: ! '{"expand":"user","token":"5Q4uuXK0ix464NwJOGvCbA00","user":{"link":{"href":"http://127.0.0.1:8095/crowd/rest/usermanagement/1/user?username=user@example.com","rel":"self"},"name":"user@example.com"},"link":{"href":"http://127.0.0.1:8095/crowd/rest/usermanagement/1/session/5Q4uuXK0ix464NwJOGvCbA00","rel":"self"}}'
815
+ http_version: '1.1'
816
+ - !ruby/struct:VCR::HTTPInteraction
817
+ request: !ruby/struct:VCR::Request
818
+ method: :post
819
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/session/5Q4uuXK0ix464NwJOGvCbA00
820
+ body: ! '{}'
821
+ headers:
822
+ accept:
823
+ - application/json
824
+ authorization:
825
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
826
+ content-type:
827
+ - application/json
828
+ response: !ruby/struct:VCR::Response
829
+ status: !ruby/struct:VCR::ResponseStatus
830
+ code: 200
831
+ message: OK
832
+ headers:
833
+ server:
834
+ - Apache-Coyote/1.1
835
+ x-embedded-crowd-version:
836
+ - Crowd/2.3.3
837
+ x-crowd-user-management-version:
838
+ - '1.1'
839
+ set-cookie:
840
+ - JSESSIONID=0AB74E9852438A71130B8A32654D9E9C; Path=/crowd
841
+ cache-control:
842
+ - no-cache, no-store, no-transform
843
+ content-type:
844
+ - application/json
845
+ transfer-encoding:
846
+ - chunked
847
+ date:
848
+ - Mon, 24 Oct 2011 17:51:58 GMT
849
+ body: ! '{"expand":"user","token":"5Q4uuXK0ix464NwJOGvCbA00","user":{"link":{"href":"http://127.0.0.1:8095/crowd/rest/usermanagement/1/user?username=user@example.com","rel":"self"},"name":"user@example.com"},"link":{"href":"http://127.0.0.1:8095/crowd/rest/usermanagement/1/session/5Q4uuXK0ix464NwJOGvCbA00","rel":"self"}}'
850
+ http_version: '1.1'
851
+ - !ruby/struct:VCR::HTTPInteraction
852
+ request: !ruby/struct:VCR::Request
853
+ method: :delete
854
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/session/5Q4uuXK0ix464NwJOGvCbA00
855
+ body: !!null
856
+ headers:
857
+ accept:
858
+ - application/json
859
+ authorization:
860
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
861
+ response: !ruby/struct:VCR::Response
862
+ status: !ruby/struct:VCR::ResponseStatus
863
+ code: 204
864
+ message: No Content
865
+ headers:
866
+ server:
867
+ - Apache-Coyote/1.1
868
+ x-embedded-crowd-version:
869
+ - Crowd/2.3.3
870
+ x-crowd-user-management-version:
871
+ - '1.1'
872
+ set-cookie:
873
+ - JSESSIONID=7CDAA352345E3E0B63CC6A16541A0EA4; Path=/crowd
874
+ date:
875
+ - Mon, 24 Oct 2011 17:51:59 GMT
876
+ body: !!null
877
+ http_version: '1.1'
878
+ - !ruby/struct:VCR::HTTPInteraction
879
+ request: !ruby/struct:VCR::Request
880
+ method: :post
881
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/session/5Q4uuXK0ix464NwJOGvCbA00
882
+ body: ! '{}'
883
+ headers:
884
+ accept:
885
+ - application/json
886
+ authorization:
887
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
888
+ content-type:
889
+ - application/json
890
+ response: !ruby/struct:VCR::Response
891
+ status: !ruby/struct:VCR::ResponseStatus
892
+ code: 404
893
+ message: Not Found
894
+ headers:
895
+ server:
896
+ - Apache-Coyote/1.1
897
+ x-embedded-crowd-version:
898
+ - Crowd/2.3.3
899
+ x-crowd-user-management-version:
900
+ - '1.1'
901
+ set-cookie:
902
+ - JSESSIONID=5A5987F464ACACD1EAD53BA8CAC76158; Path=/crowd
903
+ content-type:
904
+ - application/json
905
+ transfer-encoding:
906
+ - chunked
907
+ date:
908
+ - Mon, 24 Oct 2011 17:51:59 GMT
909
+ body: ! '{"reason":"INVALID_SSO_TOKEN","message":"Token does not validate."}'
910
+ http_version: '1.1'
@@ -1,7 +1,10 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
2
  require File.expand_path(File.dirname(__FILE__) + '/../lib/crowd-client')
2
3
 
3
4
  describe Crowd::Client do
4
5
 
6
+ use_vcr_cassette
7
+
5
8
  describe "#config" do
6
9
  subject { Crowd::Client.config }
7
10
 
@@ -34,6 +37,14 @@ describe Crowd::Client do
34
37
  end
35
38
  end
36
39
 
40
+ describe "#in_group?" do
41
+
42
+ it "should confirm users are in groups" do
43
+ subject.in_group?('user@example.com', 'MyGroup').should be_true
44
+ subject.in_group?('user@example.com', 'OtherGroup').should be_false
45
+ end
46
+ end
47
+
37
48
  describe "#logout" do
38
49
 
39
50
  it "should logout the current session" do
@@ -0,0 +1,23 @@
1
+ # Requires supporting ruby files with custom matchers and macros, etc,
2
+ # in spec/support/ and its subdirectories.
3
+ require 'vcr'
4
+ Dir[File.join(File.dirname(__FILE__), "spec/support/**/*.rb")].each {|f| require f}
5
+
6
+ VCR.config do |c|
7
+ c.cassette_library_dir = 'spec/cassettes'
8
+ c.stub_with :webmock
9
+ c.default_cassette_options = { :record => :new_episodes, :match_requests_on => [:method, :uri, :body]}
10
+ end
11
+
12
+ RSpec.configure do |config|
13
+ # == Mock Framework
14
+ #
15
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
16
+ #
17
+ # config.mock_with :mocha
18
+ # config.mock_with :flexmock
19
+ # config.mock_with :rr
20
+ config.mock_with :rspec
21
+ config.extend VCR::RSpec::Macros
22
+
23
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crowd-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-19 00:00:00.000000000Z
12
+ date: 2011-10-24 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70357705270420 !ruby/object:Gem::Requirement
16
+ requirement: &70256891490720 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,32 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70357705270420
24
+ version_requirements: *70256891490720
25
+ - !ruby/object:Gem::Dependency
26
+ name: vcr
27
+ requirement: &70256891490160 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70256891490160
36
+ - !ruby/object:Gem::Dependency
37
+ name: webmock
38
+ requirement: &70256891489460 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70256891489460
25
47
  - !ruby/object:Gem::Dependency
26
48
  name: faraday
27
- requirement: &70357705269080 !ruby/object:Gem::Requirement
49
+ requirement: &70256891488580 !ruby/object:Gem::Requirement
28
50
  none: false
29
51
  requirements:
30
52
  - - ~>
@@ -32,10 +54,10 @@ dependencies:
32
54
  version: 0.7.5
33
55
  type: :runtime
34
56
  prerelease: false
35
- version_requirements: *70357705269080
57
+ version_requirements: *70256891488580
36
58
  - !ruby/object:Gem::Dependency
37
59
  name: faraday_middleware
38
- requirement: &70357705267980 !ruby/object:Gem::Requirement
60
+ requirement: &70256891487820 !ruby/object:Gem::Requirement
39
61
  none: false
40
62
  requirements:
41
63
  - - ~>
@@ -43,10 +65,10 @@ dependencies:
43
65
  version: 0.7.0
44
66
  type: :runtime
45
67
  prerelease: false
46
- version_requirements: *70357705267980
68
+ version_requirements: *70256891487820
47
69
  - !ruby/object:Gem::Dependency
48
70
  name: patron
49
- requirement: &70357705267320 !ruby/object:Gem::Requirement
71
+ requirement: &70256891486680 !ruby/object:Gem::Requirement
50
72
  none: false
51
73
  requirements:
52
74
  - - ~>
@@ -54,10 +76,10 @@ dependencies:
54
76
  version: 0.4.16
55
77
  type: :runtime
56
78
  prerelease: false
57
- version_requirements: *70357705267320
79
+ version_requirements: *70256891486680
58
80
  - !ruby/object:Gem::Dependency
59
81
  name: json
60
- requirement: &70357705266600 !ruby/object:Gem::Requirement
82
+ requirement: &70256891485380 !ruby/object:Gem::Requirement
61
83
  none: false
62
84
  requirements:
63
85
  - - ~>
@@ -65,7 +87,7 @@ dependencies:
65
87
  version: 1.6.1
66
88
  type: :runtime
67
89
  prerelease: false
68
- version_requirements: *70357705266600
90
+ version_requirements: *70256891485380
69
91
  description: A simple rest client for Crowd
70
92
  email:
71
93
  - paul@webpowerdesign.net
@@ -80,7 +102,9 @@ files:
80
102
  - lib/crowd-client.rb
81
103
  - lib/crowd-client/exceptions.rb
82
104
  - lib/crowd-client/version.rb
105
+ - spec/cassettes/Crowd_Client.yml
83
106
  - spec/crowd-client_spec.rb
107
+ - spec/spec_helper.rb
84
108
  homepage: ''
85
109
  licenses: []
86
110
  post_install_message:
@@ -106,4 +130,6 @@ signing_key:
106
130
  specification_version: 3
107
131
  summary: Crowd Client Library
108
132
  test_files:
133
+ - spec/cassettes/Crowd_Client.yml
109
134
  - spec/crowd-client_spec.rb
135
+ - spec/spec_helper.rb