crowd-client 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. data/crowd-client.gemspec +3 -1
  2. data/lib/crowd-client.rb +2 -2
  3. data/lib/crowd-client/exceptions.rb +2 -1
  4. data/lib/crowd-client/group.rb +42 -0
  5. data/lib/crowd-client/user.rb +121 -0
  6. data/lib/crowd-client/version.rb +1 -1
  7. data/spec/cassettes/Crowd_Client/_in_group_/should_confirm_users_are_in_groups.yml +69 -0
  8. data/spec/cassettes/Crowd_Client/_login/should_authenticate_and_return_a_session_token.yml +42 -0
  9. data/spec/cassettes/Crowd_Client/_login/should_raise_Crowd_Client_Exception_AuthenticationFailed_if_authentication_fails.yml +40 -0
  10. data/spec/cassettes/Crowd_Client/_login/should_raise_Crowd_Client_Exception_InactiveAccount_if_an_account_is_inactive.yml +40 -0
  11. data/spec/cassettes/Crowd_Client/_logout/should_logout_the_current_session.yml +143 -0
  12. data/spec/cassettes/Crowd_Client/_user_groups_username_/should_return_the_groups_of_the_user.yml +36 -0
  13. data/spec/cassettes/Crowd_Client/_user_token_/should_return_the_expanded_user.yml +75 -0
  14. data/spec/cassettes/Crowd_Client/_valid_session_/should_validate_the_current_session.yml +79 -0
  15. data/spec/cassettes/Crowd_Client_Group/_add_user/missing_group/should_raise_Exception_NotFound_for_missing_group.yml +104 -0
  16. data/spec/cassettes/Crowd_Client_Group/_add_user/should_add_the_user.yml +139 -0
  17. data/spec/cassettes/Crowd_Client_Group/_add_user/should_raise_Exception_NotFound_for_missing_user.yml +106 -0
  18. data/spec/cassettes/Crowd_Client_Group/_remove_user/should_remove_the_user.yml +168 -0
  19. data/spec/cassettes/Crowd_Client_Group/_users/should_return_all_of_the_users_in_the_group.yml +36 -0
  20. data/spec/cassettes/Crowd_Client_User/Creating_a_user/should_create_a_user_with_attributes.yml +102 -0
  21. data/spec/cassettes/Crowd_Client_User/Get_groups_for_user/should_be_in_the_group.yml +36 -0
  22. data/spec/cassettes/Crowd_Client_User/Update_user/should_update_user_properties.yml +133 -0
  23. data/spec/cassettes/Crowd_Client_User/_destroy/should_delete_the_user.yml +102 -0
  24. data/spec/cassettes/Crowd_Client_User/authenticate/should_return_false_if_the_password_is_invalid.yml +40 -0
  25. data/spec/cassettes/Crowd_Client_User/authenticate/should_return_true_if_the_password_is_valid.yml +38 -0
  26. data/spec/cassettes/Crowd_Client_User/change_password/should_allow_the_user_to_set_a_new_password.yml +135 -0
  27. data/spec/cassettes/Crowd_Client_User/display_name/.yml +36 -0
  28. data/spec/cassettes/Crowd_Client_User/email/.yml +36 -0
  29. data/spec/crowd-client_group_spec.rb +50 -0
  30. data/spec/crowd-client_spec.rb +0 -3
  31. data/spec/crowd-client_user_spec.rb +75 -0
  32. data/spec/spec_helper.rb +16 -2
  33. metadata +89 -19
  34. data/spec/cassettes/Crowd_Client.yml +0 -358
@@ -0,0 +1,168 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/user
6
+ body: "{\"name\":\"group_removal@example.com\",\"active\":true,\"password\":{\"value\":\"test\"},\"first-name\":\"Group\",\"last-name\":\"Removal\",\"email\":\"group_removal@example.com\"}"
7
+ headers:
8
+ Accept:
9
+ - application/json
10
+ Authorization:
11
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
12
+ Content-Type:
13
+ - application/json
14
+ Expect:
15
+ - ""
16
+ response:
17
+ status:
18
+ code: 201
19
+ message: Created
20
+ headers:
21
+ Server:
22
+ - Apache-Coyote/1.1
23
+ X-Embedded-Crowd-Version:
24
+ - Crowd/2.3.3
25
+ X-Crowd-User-Management-Version:
26
+ - "1.1"
27
+ Set-Cookie:
28
+ - JSESSIONID=F2A86EF86DD480237A83E1950BA203CF; Path=/crowd
29
+ Location:
30
+ - http://127.0.0.1:8095/crowd/rest/usermanagement/1/user?username=group_removal@example.com
31
+ Content-Type:
32
+ - application/json
33
+ Content-Length:
34
+ - "0"
35
+ Date:
36
+ - Wed, 21 Dec 2011 20:56:59 GMT
37
+ body: ""
38
+ http_version:
39
+ recorded_at: Wed, 21 Dec 2011 20:57:00 GMT
40
+ - request:
41
+ method: post
42
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/group/user/direct?groupname=MyGroup
43
+ body: "{\"name\":\"group_removal@example.com\"}"
44
+ headers:
45
+ Accept:
46
+ - application/json
47
+ Authorization:
48
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
49
+ Content-Type:
50
+ - application/json
51
+ Expect:
52
+ - ""
53
+ response:
54
+ status:
55
+ code: 201
56
+ message: Created
57
+ headers:
58
+ Server:
59
+ - Apache-Coyote/1.1
60
+ X-Embedded-Crowd-Version:
61
+ - Crowd/2.3.3
62
+ X-Crowd-User-Management-Version:
63
+ - "1.1"
64
+ Set-Cookie:
65
+ - JSESSIONID=7AAFB570E2326FDE5BCA9648E25F1D26; Path=/crowd
66
+ Location:
67
+ - http://127.0.0.1:8095/crowd/rest/usermanagement/1/group/user/direct?groupname=MyGroup&username=group_removal@example.com
68
+ Content-Type:
69
+ - application/json
70
+ Content-Length:
71
+ - "0"
72
+ Date:
73
+ - Wed, 21 Dec 2011 20:56:59 GMT
74
+ body: ""
75
+ http_version:
76
+ recorded_at: Wed, 21 Dec 2011 20:57:00 GMT
77
+ - request:
78
+ method: delete
79
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/group/user/direct?groupname=MyGroup&username=group_removal@example.com
80
+ body: ""
81
+ headers:
82
+ Accept:
83
+ - application/json
84
+ Authorization:
85
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
86
+ Expect:
87
+ - ""
88
+ response:
89
+ status:
90
+ code: 204
91
+ message: No Content
92
+ headers:
93
+ Server:
94
+ - Apache-Coyote/1.1
95
+ X-Embedded-Crowd-Version:
96
+ - Crowd/2.3.3
97
+ X-Crowd-User-Management-Version:
98
+ - "1.1"
99
+ Set-Cookie:
100
+ - JSESSIONID=5BD726BC203970B40786154AB0A1BB23; Path=/crowd
101
+ Date:
102
+ - Wed, 21 Dec 2011 20:56:59 GMT
103
+ body: ""
104
+ http_version:
105
+ recorded_at: Wed, 21 Dec 2011 20:57:00 GMT
106
+ - request:
107
+ method: get
108
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/group/user/nested?groupname=MyGroup
109
+ body: ""
110
+ headers:
111
+ Accept:
112
+ - application/json
113
+ Authorization:
114
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
115
+ Expect:
116
+ - ""
117
+ response:
118
+ status:
119
+ code: 200
120
+ message: OK
121
+ headers:
122
+ Server:
123
+ - Apache-Coyote/1.1
124
+ X-Embedded-Crowd-Version:
125
+ - Crowd/2.3.3
126
+ X-Crowd-User-Management-Version:
127
+ - "1.1"
128
+ Set-Cookie:
129
+ - JSESSIONID=A6ED43666233EC38D44426C6A2F39DBE; Path=/crowd
130
+ Content-Type:
131
+ - application/json
132
+ Transfer-Encoding:
133
+ - chunked
134
+ Date:
135
+ - Wed, 21 Dec 2011 20:56:59 GMT
136
+ body: "{\"expand\":\"user\",\"users\":[{\"link\":{\"href\":\"http://127.0.0.1:8095/crowd/rest/usermanagement/1/user?username=user@example.com\",\"rel\":\"self\"},\"name\":\"user@example.com\"}]}"
137
+ http_version:
138
+ recorded_at: Wed, 21 Dec 2011 20:57:00 GMT
139
+ - request:
140
+ method: delete
141
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/user?username=group_removal@example.com
142
+ body: ""
143
+ headers:
144
+ Accept:
145
+ - application/json
146
+ Authorization:
147
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
148
+ Expect:
149
+ - ""
150
+ response:
151
+ status:
152
+ code: 204
153
+ message: No Content
154
+ headers:
155
+ Server:
156
+ - Apache-Coyote/1.1
157
+ X-Embedded-Crowd-Version:
158
+ - Crowd/2.3.3
159
+ X-Crowd-User-Management-Version:
160
+ - "1.1"
161
+ Set-Cookie:
162
+ - JSESSIONID=686EFA16C0C550586F18CC09D153BB9C; Path=/crowd
163
+ Date:
164
+ - Wed, 21 Dec 2011 20:56:59 GMT
165
+ body: ""
166
+ http_version:
167
+ recorded_at: Wed, 21 Dec 2011 20:57:00 GMT
168
+ recorded_with: VCR 2.0.0.rc1
@@ -0,0 +1,36 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/group/user/nested?groupname=MyGroup
6
+ body: ""
7
+ headers:
8
+ Accept:
9
+ - application/json
10
+ Authorization:
11
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
12
+ Expect:
13
+ - ""
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ Server:
20
+ - Apache-Coyote/1.1
21
+ X-Embedded-Crowd-Version:
22
+ - Crowd/2.3.3
23
+ X-Crowd-User-Management-Version:
24
+ - "1.1"
25
+ Set-Cookie:
26
+ - JSESSIONID=792FE6F27F3D97B9254EDE56700F643D; Path=/crowd
27
+ Content-Type:
28
+ - application/json
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Date:
32
+ - Wed, 21 Dec 2011 20:57:00 GMT
33
+ body: "{\"expand\":\"user\",\"users\":[{\"link\":{\"href\":\"http://127.0.0.1:8095/crowd/rest/usermanagement/1/user?username=user@example.com\",\"rel\":\"self\"},\"name\":\"user@example.com\"}]}"
34
+ http_version:
35
+ recorded_at: Wed, 21 Dec 2011 20:57:00 GMT
36
+ recorded_with: VCR 2.0.0.rc1
@@ -0,0 +1,102 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/user
6
+ body: "{\"name\":\"new_user@example.com\",\"active\":true,\"password\":{\"value\":\"test\"},\"first-name\":\"New\",\"last-name\":\"User\",\"email\":\"new_user@example.com\"}"
7
+ headers:
8
+ Accept:
9
+ - application/json
10
+ Authorization:
11
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
12
+ Content-Type:
13
+ - application/json
14
+ Expect:
15
+ - ""
16
+ response:
17
+ status:
18
+ code: 201
19
+ message: Created
20
+ headers:
21
+ Server:
22
+ - Apache-Coyote/1.1
23
+ X-Embedded-Crowd-Version:
24
+ - Crowd/2.3.3
25
+ X-Crowd-User-Management-Version:
26
+ - "1.1"
27
+ Set-Cookie:
28
+ - JSESSIONID=D4E5EB5FBBC1EF13477BB76BD9E161AF; Path=/crowd
29
+ Location:
30
+ - http://127.0.0.1:8095/crowd/rest/usermanagement/1/user?username=new_user@example.com
31
+ Content-Type:
32
+ - application/json
33
+ Content-Length:
34
+ - "0"
35
+ Date:
36
+ - Wed, 21 Dec 2011 20:57:01 GMT
37
+ body: ""
38
+ http_version:
39
+ recorded_at: Wed, 21 Dec 2011 20:57:01 GMT
40
+ - request:
41
+ method: get
42
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/user?username=new_user@example.com
43
+ body: ""
44
+ headers:
45
+ Accept:
46
+ - application/json
47
+ Authorization:
48
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
49
+ Expect:
50
+ - ""
51
+ response:
52
+ status:
53
+ code: 200
54
+ message: OK
55
+ headers:
56
+ Server:
57
+ - Apache-Coyote/1.1
58
+ X-Embedded-Crowd-Version:
59
+ - Crowd/2.3.3
60
+ X-Crowd-User-Management-Version:
61
+ - "1.1"
62
+ Set-Cookie:
63
+ - JSESSIONID=665A2500762B9F23D8A65F94B5C9B03D; Path=/crowd
64
+ Content-Type:
65
+ - application/json
66
+ Transfer-Encoding:
67
+ - chunked
68
+ Date:
69
+ - Wed, 21 Dec 2011 20:57:01 GMT
70
+ body: "{\"expand\":\"attributes\",\"link\":{\"href\":\"http://127.0.0.1:8095/crowd/rest/usermanagement/1/user?username=new_user@example.com\",\"rel\":\"self\"},\"name\":\"new_user@example.com\",\"first-name\":\"New\",\"last-name\":\"User\",\"display-name\":\"New User\",\"email\":\"new_user@example.com\",\"password\":{\"link\":{\"href\":\"http://127.0.0.1:8095/crowd/rest/usermanagement/1/user/password?username=new_user@example.com\",\"rel\":\"edit\"}},\"active\":true,\"attributes\":{\"attributes\":[],\"link\":{\"href\":\"http://127.0.0.1:8095/crowd/rest/usermanagement/1/user/attribute?username=new_user@example.com\",\"rel\":\"self\"}}}"
71
+ http_version:
72
+ recorded_at: Wed, 21 Dec 2011 20:57:01 GMT
73
+ - request:
74
+ method: delete
75
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/user?username=new_user@example.com
76
+ body: ""
77
+ headers:
78
+ Accept:
79
+ - application/json
80
+ Authorization:
81
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
82
+ Expect:
83
+ - ""
84
+ response:
85
+ status:
86
+ code: 204
87
+ message: No Content
88
+ headers:
89
+ Server:
90
+ - Apache-Coyote/1.1
91
+ X-Embedded-Crowd-Version:
92
+ - Crowd/2.3.3
93
+ X-Crowd-User-Management-Version:
94
+ - "1.1"
95
+ Set-Cookie:
96
+ - JSESSIONID=27F10DCB721F02A779B7AD8704AEBD04; Path=/crowd
97
+ Date:
98
+ - Wed, 21 Dec 2011 20:57:01 GMT
99
+ body: ""
100
+ http_version:
101
+ recorded_at: Wed, 21 Dec 2011 20:57:01 GMT
102
+ recorded_with: VCR 2.0.0.rc1
@@ -0,0 +1,36 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/user/group/nested?username=user@example.com
6
+ body: ""
7
+ headers:
8
+ Accept:
9
+ - application/json
10
+ Authorization:
11
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
12
+ Expect:
13
+ - ""
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ Server:
20
+ - Apache-Coyote/1.1
21
+ X-Embedded-Crowd-Version:
22
+ - Crowd/2.3.3
23
+ X-Crowd-User-Management-Version:
24
+ - "1.1"
25
+ Set-Cookie:
26
+ - JSESSIONID=7C57BB844992BB042AD508D5852F72BB; Path=/crowd
27
+ Content-Type:
28
+ - application/json
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Date:
32
+ - Wed, 21 Dec 2011 20:57:01 GMT
33
+ body: "{\"expand\":\"group\",\"groups\":[{\"link\":{\"href\":\"http://127.0.0.1:8095/crowd/rest/usermanagement/1/group?groupname=MyGroup\",\"rel\":\"self\"},\"name\":\"MyGroup\"},{\"link\":{\"href\":\"http://127.0.0.1:8095/crowd/rest/usermanagement/1/group?groupname=users\",\"rel\":\"self\"},\"name\":\"users\"}]}"
34
+ http_version:
35
+ recorded_at: Wed, 21 Dec 2011 20:57:01 GMT
36
+ recorded_with: VCR 2.0.0.rc1
@@ -0,0 +1,133 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/user
6
+ body: "{\"name\":\"change_user@example.com\",\"active\":true,\"password\":{\"value\":\"test\"},\"first-name\":\"Change\",\"last-name\":\"User\",\"email\":\"change_user@example.com\"}"
7
+ headers:
8
+ Accept:
9
+ - application/json
10
+ Authorization:
11
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
12
+ Content-Type:
13
+ - application/json
14
+ Expect:
15
+ - ""
16
+ response:
17
+ status:
18
+ code: 201
19
+ message: Created
20
+ headers:
21
+ Server:
22
+ - Apache-Coyote/1.1
23
+ X-Embedded-Crowd-Version:
24
+ - Crowd/2.3.3
25
+ X-Crowd-User-Management-Version:
26
+ - "1.1"
27
+ Set-Cookie:
28
+ - JSESSIONID=6E2CA4931A19506C1FC090C59D01FF91; Path=/crowd
29
+ Location:
30
+ - http://127.0.0.1:8095/crowd/rest/usermanagement/1/user?username=change_user@example.com
31
+ Content-Type:
32
+ - application/json
33
+ Content-Length:
34
+ - "0"
35
+ Date:
36
+ - Wed, 21 Dec 2011 20:57:01 GMT
37
+ body: ""
38
+ http_version:
39
+ recorded_at: Wed, 21 Dec 2011 20:57:02 GMT
40
+ - request:
41
+ method: put
42
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/user?username=change_user@example.com
43
+ body: "{\"name\":\"change_user@example.com\",\"password\":{\"value\":\"test\"},\"first-name\":\"New First\",\"last-name\":\"And Last Name\",\"email\":\"change_user@example.com\"}"
44
+ headers:
45
+ Accept:
46
+ - application/json
47
+ Authorization:
48
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
49
+ Content-Type:
50
+ - application/json
51
+ Expect:
52
+ - ""
53
+ response:
54
+ status:
55
+ code: 204
56
+ message: No Content
57
+ headers:
58
+ Server:
59
+ - Apache-Coyote/1.1
60
+ X-Embedded-Crowd-Version:
61
+ - Crowd/2.3.3
62
+ X-Crowd-User-Management-Version:
63
+ - "1.1"
64
+ Set-Cookie:
65
+ - JSESSIONID=B91BB20D5DAB4970119A3B5F7FBA9F92; Path=/crowd
66
+ Date:
67
+ - Wed, 21 Dec 2011 20:57:01 GMT
68
+ body: ""
69
+ http_version:
70
+ recorded_at: Wed, 21 Dec 2011 20:57:02 GMT
71
+ - request:
72
+ method: get
73
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/user?username=change_user@example.com
74
+ body: ""
75
+ headers:
76
+ Accept:
77
+ - application/json
78
+ Authorization:
79
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
80
+ Expect:
81
+ - ""
82
+ response:
83
+ status:
84
+ code: 200
85
+ message: OK
86
+ headers:
87
+ Server:
88
+ - Apache-Coyote/1.1
89
+ X-Embedded-Crowd-Version:
90
+ - Crowd/2.3.3
91
+ X-Crowd-User-Management-Version:
92
+ - "1.1"
93
+ Set-Cookie:
94
+ - JSESSIONID=3ADB9EE6A7164D0822F3D734567458E0; Path=/crowd
95
+ Content-Type:
96
+ - application/json
97
+ Transfer-Encoding:
98
+ - chunked
99
+ Date:
100
+ - Wed, 21 Dec 2011 20:57:01 GMT
101
+ body: "{\"expand\":\"attributes\",\"link\":{\"href\":\"http://127.0.0.1:8095/crowd/rest/usermanagement/1/user?username=change_user@example.com\",\"rel\":\"self\"},\"name\":\"change_user@example.com\",\"first-name\":\"New First\",\"last-name\":\"And Last Name\",\"display-name\":\"New First And Last Name\",\"email\":\"change_user@example.com\",\"password\":{\"link\":{\"href\":\"http://127.0.0.1:8095/crowd/rest/usermanagement/1/user/password?username=change_user@example.com\",\"rel\":\"edit\"}},\"active\":false,\"attributes\":{\"attributes\":[],\"link\":{\"href\":\"http://127.0.0.1:8095/crowd/rest/usermanagement/1/user/attribute?username=change_user@example.com\",\"rel\":\"self\"}}}"
102
+ http_version:
103
+ recorded_at: Wed, 21 Dec 2011 20:57:02 GMT
104
+ - request:
105
+ method: delete
106
+ uri: http://127.0.0.1:8095/crowd/rest/usermanagement/1/user?username=change_user@example.com
107
+ body: ""
108
+ headers:
109
+ Accept:
110
+ - application/json
111
+ Authorization:
112
+ - Basic YXBwbGljYXRpb246cGFzc3dvcmQ=
113
+ Expect:
114
+ - ""
115
+ response:
116
+ status:
117
+ code: 204
118
+ message: No Content
119
+ headers:
120
+ Server:
121
+ - Apache-Coyote/1.1
122
+ X-Embedded-Crowd-Version:
123
+ - Crowd/2.3.3
124
+ X-Crowd-User-Management-Version:
125
+ - "1.1"
126
+ Set-Cookie:
127
+ - JSESSIONID=A6E563D48859DDEAA9B59B8A42EDCA88; Path=/crowd
128
+ Date:
129
+ - Wed, 21 Dec 2011 20:57:01 GMT
130
+ body: ""
131
+ http_version:
132
+ recorded_at: Wed, 21 Dec 2011 20:57:02 GMT
133
+ recorded_with: VCR 2.0.0.rc1