code42 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/code42.rb +1 -0
- data/lib/code42/api/role.rb +30 -0
- data/lib/code42/api/user.rb +7 -0
- data/lib/code42/attribute_serializer.rb +1 -1
- data/lib/code42/client.rb +1 -1
- data/lib/code42/permission.rb +13 -0
- data/lib/code42/resource.rb +3 -2
- data/lib/code42/role.rb +8 -1
- data/lib/code42/role_collection.rb +4 -0
- data/lib/code42/user.rb +10 -0
- data/lib/code42/version.rb +1 -1
- data/spec/cassettes/Code42_Client/_create_org/returns_created_org.yml +7 -41
- data/spec/cassettes/Code42_Client/_create_role/creates_a_role.yml +42 -0
- data/spec/cassettes/Code42_Client/_create_user/returns_created_user.yml +8 -32
- data/spec/cassettes/Code42_Client/_create_user/when_sending_an_invalid_email/raises_an_exception.yml +8 -7
- data/spec/cassettes/Code42_Client/_deactivate_org/puts_to_the_correct_route.yml +6 -8
- data/spec/cassettes/Code42_Client/_delete_role/deletes_a_role.yml +67 -0
- data/spec/cassettes/Code42_Client/_find_org_by_name/returns_the_org_with_the_specified_name.yml +9 -44
- data/spec/cassettes/Code42_Client/_get_token/returns_valid_tokens.yml +9 -17
- data/spec/cassettes/Code42_Client/_get_token/when_providing_invalid_credentials/should_raise_an_exception.yml +6 -5
- data/spec/cassettes/Code42_Client/_org/when_ID_is_not_passed/returns_my_org.yml +7 -41
- data/spec/cassettes/Code42_Client/_org/when_ID_is_passed_in/returns_a_specific_org.yml +7 -41
- data/spec/cassettes/Code42_Client/_permissions/returns_an_enumerable_of_permissions.yml +120 -0
- data/spec/cassettes/Code42_Client/_ping/returns_a_ping.yml +9 -14
- data/spec/cassettes/Code42_Client/_reset_password/when_sending_a_user_id/as_a_string/behaves_like_reset_password/is_successful.yml +41 -3
- data/spec/cassettes/Code42_Client/_reset_password/when_sending_a_user_id/as_an_integer/behaves_like_reset_password/is_successful.yml +41 -3
- data/spec/cassettes/Code42_Client/_reset_password/when_sending_a_username/behaves_like_reset_password/is_successful.yml +41 -3
- data/spec/cassettes/Code42_Client/_reset_password/when_sending_a_view_url/behaves_like_reset_password/is_successful.yml +41 -3
- data/spec/cassettes/Code42_Client/_roles/returns_an_enumerable.yml +243 -0
- data/spec/cassettes/Code42_Client/_unassign_role/removes_the_role.yml +107 -0
- data/spec/cassettes/Code42_Client/_update_role/updates_a_role.yml +155 -0
- data/spec/cassettes/Code42_Client/_update_user/returns_the_updated_user.yml +14 -12
- data/spec/cassettes/Code42_Client/_update_user/when_sending_an_invalid_email/raises_an_exception.yml +11 -10
- data/spec/cassettes/Code42_Client/_user/when_ID_is_not_passed/returns_my_user.yml +7 -32
- data/spec/cassettes/Code42_Client/_user/when_ID_is_passed_in/returns_a_specific_user.yml +8 -32
- data/spec/cassettes/Code42_Client/_user/when_blocked/returns_the_blocked_status.yml +15 -39
- data/spec/cassettes/Code42_Client/_user/when_unblocked/returns_the_blocked_status.yml +17 -38
- data/spec/cassettes/Code42_Client/_user_roles/returns_an_enumerable.yml +7 -19
- data/spec/cassettes/Code42_Client/_validate_token/returns_a_valid_response.yml +18 -34
- data/spec/code42/client_spec.rb +57 -2
- metadata +15 -2
@@ -2,13 +2,13 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: http://admin:admin@localhost:
|
5
|
+
uri: http://admin:admin@localhost:4280/api/user/2
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
9
9
|
headers:
|
10
10
|
User-Agent:
|
11
|
-
- Faraday v0.
|
11
|
+
- Faraday v0.9.0
|
12
12
|
Accept-Encoding:
|
13
13
|
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
14
14
|
Accept:
|
@@ -22,42 +22,18 @@ http_interactions:
|
|
22
22
|
- no-store
|
23
23
|
Pragma:
|
24
24
|
- no-cache
|
25
|
+
Content-Location:
|
26
|
+
- http://localhost:4280/api/v1/user/2
|
25
27
|
Content-Type:
|
26
|
-
- application/json;
|
28
|
+
- application/json;charset=UTF-8
|
27
29
|
Transfer-Encoding:
|
28
30
|
- chunked
|
29
31
|
Server:
|
30
32
|
- Jetty(7.6.3.v20120416)
|
31
33
|
body:
|
32
34
|
encoding: UTF-8
|
33
|
-
string:
|
34
|
-
|
35
|
-
"metadata": {
|
36
|
-
"timestamp": "2013-06-13T15:16:30.098-05:00",
|
37
|
-
"params": {}
|
38
|
-
},
|
39
|
-
"data": {
|
40
|
-
"userId": 2,
|
41
|
-
"userUid": "thwlhuOyiq2svbdcqfmm2demnda",
|
42
|
-
"status": "Active, Blocked",
|
43
|
-
"username": "account_australia",
|
44
|
-
"email": "account_australia",
|
45
|
-
"firstName": "account_australia",
|
46
|
-
"lastName": "account_australia",
|
47
|
-
"quotaInBytes": -1,
|
48
|
-
"orgId": 1,
|
49
|
-
"orgUid": "ADMIN",
|
50
|
-
"orgName": "ADMIN",
|
51
|
-
"active": true,
|
52
|
-
"blocked": true,
|
53
|
-
"emailPromo": false,
|
54
|
-
"invited": false,
|
55
|
-
"orgType": "ENTERPRISE",
|
56
|
-
"usernameIsAnEmail": false,
|
57
|
-
"creationDate": "2006-04-17T12:30:00.990-05:00",
|
58
|
-
"modificationDate": "2013-06-13T15:14:39.525-05:00"
|
59
|
-
}
|
60
|
-
}
|
35
|
+
string: '{"metadata":{"timestamp":"2014-07-09T10:34:44.057-05:00","params":{}},"data":{"userId":2,"userUid":"thwlhuOyiq2svbdcqfmm2demnda","status":"Active,
|
36
|
+
Blocked","username":"account_australia","email":"account_australia","firstName":"account_australia","lastName":"account_australia","quotaInBytes":-1,"orgId":1,"orgUid":"ADMIN","orgName":"ADMIN","active":true,"blocked":true,"emailPromo":false,"invited":false,"orgType":"ENTERPRISE","usernameIsAnEmail":false,"creationDate":"2006-04-17T12:30:00.990-05:00","modificationDate":"2014-07-09T10:27:55.771-05:00","passwordReset":false}}'
|
61
37
|
http_version:
|
62
|
-
recorded_at:
|
38
|
+
recorded_at: Wed, 09 Jul 2014 15:34:44 GMT
|
63
39
|
recorded_with: VCR 2.5.0
|
@@ -2,13 +2,13 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: put
|
5
|
-
uri: http://admin:admin@localhost:
|
5
|
+
uri: http://admin:admin@localhost:4280/api/UserBlock/2
|
6
6
|
body:
|
7
7
|
encoding: UTF-8
|
8
8
|
string: '{}'
|
9
9
|
headers:
|
10
10
|
User-Agent:
|
11
|
-
- Faraday v0.
|
11
|
+
- Faraday v0.9.0
|
12
12
|
Content-Type:
|
13
13
|
- application/json
|
14
14
|
Accept-Encoding:
|
@@ -17,33 +17,33 @@ http_interactions:
|
|
17
17
|
- '*/*'
|
18
18
|
response:
|
19
19
|
status:
|
20
|
-
code:
|
21
|
-
message:
|
20
|
+
code: 204
|
21
|
+
message: No Content
|
22
22
|
headers:
|
23
23
|
Cache-Control:
|
24
24
|
- no-store
|
25
25
|
Pragma:
|
26
26
|
- no-cache
|
27
|
+
Content-Location:
|
28
|
+
- http://localhost:4280/api/v1/UserBlock/2
|
27
29
|
Content-Type:
|
28
30
|
- application/json
|
29
|
-
Content-Length:
|
30
|
-
- '0'
|
31
31
|
Server:
|
32
32
|
- Jetty(7.6.3.v20120416)
|
33
33
|
body:
|
34
34
|
encoding: UTF-8
|
35
35
|
string: ''
|
36
36
|
http_version:
|
37
|
-
recorded_at:
|
37
|
+
recorded_at: Wed, 09 Jul 2014 15:34:44 GMT
|
38
38
|
- request:
|
39
39
|
method: get
|
40
|
-
uri: http://admin:admin@localhost:
|
40
|
+
uri: http://admin:admin@localhost:4280/api/user/2
|
41
41
|
body:
|
42
42
|
encoding: US-ASCII
|
43
43
|
string: ''
|
44
44
|
headers:
|
45
45
|
User-Agent:
|
46
|
-
- Faraday v0.
|
46
|
+
- Faraday v0.9.0
|
47
47
|
Accept-Encoding:
|
48
48
|
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
49
49
|
Accept:
|
@@ -57,42 +57,18 @@ http_interactions:
|
|
57
57
|
- no-store
|
58
58
|
Pragma:
|
59
59
|
- no-cache
|
60
|
+
Content-Location:
|
61
|
+
- http://localhost:4280/api/v1/user/2
|
60
62
|
Content-Type:
|
61
|
-
- application/json;
|
63
|
+
- application/json;charset=UTF-8
|
62
64
|
Transfer-Encoding:
|
63
65
|
- chunked
|
64
66
|
Server:
|
65
67
|
- Jetty(7.6.3.v20120416)
|
66
68
|
body:
|
67
69
|
encoding: UTF-8
|
68
|
-
string:
|
69
|
-
|
70
|
-
"metadata": {
|
71
|
-
"timestamp": "2013-06-13T15:16:30.243-05:00",
|
72
|
-
"params": {}
|
73
|
-
},
|
74
|
-
"data": {
|
75
|
-
"userId": 2,
|
76
|
-
"userUid": "thwlhuOyiq2svbdcqfmm2demnda",
|
77
|
-
"status": "Active, Blocked",
|
78
|
-
"username": "account_australia",
|
79
|
-
"email": "account_australia",
|
80
|
-
"firstName": "account_australia",
|
81
|
-
"lastName": "account_australia",
|
82
|
-
"quotaInBytes": -1,
|
83
|
-
"orgId": 1,
|
84
|
-
"orgUid": "ADMIN",
|
85
|
-
"orgName": "ADMIN",
|
86
|
-
"active": true,
|
87
|
-
"blocked": true,
|
88
|
-
"emailPromo": false,
|
89
|
-
"invited": false,
|
90
|
-
"orgType": "ENTERPRISE",
|
91
|
-
"usernameIsAnEmail": false,
|
92
|
-
"creationDate": "2006-04-17T12:30:00.990-05:00",
|
93
|
-
"modificationDate": "2013-06-13T15:16:30.212-05:00"
|
94
|
-
}
|
95
|
-
}
|
70
|
+
string: '{"metadata":{"timestamp":"2014-07-09T10:34:44.124-05:00","params":{}},"data":{"userId":2,"userUid":"thwlhuOyiq2svbdcqfmm2demnda","status":"Active,
|
71
|
+
Blocked","username":"account_australia","email":"account_australia","firstName":"account_australia","lastName":"account_australia","quotaInBytes":-1,"orgId":1,"orgUid":"ADMIN","orgName":"ADMIN","active":true,"blocked":true,"emailPromo":false,"invited":false,"orgType":"ENTERPRISE","usernameIsAnEmail":false,"creationDate":"2006-04-17T12:30:00.990-05:00","modificationDate":"2014-07-09T10:27:55.771-05:00","passwordReset":false}}'
|
96
72
|
http_version:
|
97
|
-
recorded_at:
|
73
|
+
recorded_at: Wed, 09 Jul 2014 15:34:44 GMT
|
98
74
|
recorded_with: VCR 2.5.0
|
@@ -2,13 +2,13 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: put
|
5
|
-
uri: http://admin:admin@localhost:
|
5
|
+
uri: http://admin:admin@localhost:4280/api/UserBlock/2
|
6
6
|
body:
|
7
7
|
encoding: UTF-8
|
8
8
|
string: '{}'
|
9
9
|
headers:
|
10
10
|
User-Agent:
|
11
|
-
- Faraday v0.
|
11
|
+
- Faraday v0.9.0
|
12
12
|
Content-Type:
|
13
13
|
- application/json
|
14
14
|
Accept-Encoding:
|
@@ -24,6 +24,8 @@ http_interactions:
|
|
24
24
|
- no-store
|
25
25
|
Pragma:
|
26
26
|
- no-cache
|
27
|
+
Content-Location:
|
28
|
+
- http://localhost:4280/api/v1/UserBlock/2
|
27
29
|
Content-Type:
|
28
30
|
- application/json
|
29
31
|
Server:
|
@@ -32,16 +34,16 @@ http_interactions:
|
|
32
34
|
encoding: UTF-8
|
33
35
|
string: ''
|
34
36
|
http_version:
|
35
|
-
recorded_at:
|
37
|
+
recorded_at: Wed, 09 Jul 2014 15:34:44 GMT
|
36
38
|
- request:
|
37
39
|
method: delete
|
38
|
-
uri: http://admin:admin@localhost:
|
40
|
+
uri: http://admin:admin@localhost:4280/api/UserBlock/2
|
39
41
|
body:
|
40
42
|
encoding: US-ASCII
|
41
43
|
string: ''
|
42
44
|
headers:
|
43
45
|
User-Agent:
|
44
|
-
- Faraday v0.
|
46
|
+
- Faraday v0.9.0
|
45
47
|
Accept-Encoding:
|
46
48
|
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
47
49
|
Accept:
|
@@ -55,6 +57,8 @@ http_interactions:
|
|
55
57
|
- no-store
|
56
58
|
Pragma:
|
57
59
|
- no-cache
|
60
|
+
Content-Location:
|
61
|
+
- http://localhost:4280/api/v1/UserBlock/2
|
58
62
|
Content-Type:
|
59
63
|
- application/json
|
60
64
|
Server:
|
@@ -63,16 +67,16 @@ http_interactions:
|
|
63
67
|
encoding: UTF-8
|
64
68
|
string: ''
|
65
69
|
http_version:
|
66
|
-
recorded_at:
|
70
|
+
recorded_at: Wed, 09 Jul 2014 15:34:44 GMT
|
67
71
|
- request:
|
68
72
|
method: get
|
69
|
-
uri: http://admin:admin@localhost:
|
73
|
+
uri: http://admin:admin@localhost:4280/api/user/2
|
70
74
|
body:
|
71
75
|
encoding: US-ASCII
|
72
76
|
string: ''
|
73
77
|
headers:
|
74
78
|
User-Agent:
|
75
|
-
- Faraday v0.
|
79
|
+
- Faraday v0.9.0
|
76
80
|
Accept-Encoding:
|
77
81
|
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
78
82
|
Accept:
|
@@ -86,42 +90,17 @@ http_interactions:
|
|
86
90
|
- no-store
|
87
91
|
Pragma:
|
88
92
|
- no-cache
|
93
|
+
Content-Location:
|
94
|
+
- http://localhost:4280/api/v1/user/2
|
89
95
|
Content-Type:
|
90
|
-
- application/json;
|
96
|
+
- application/json;charset=UTF-8
|
91
97
|
Transfer-Encoding:
|
92
98
|
- chunked
|
93
99
|
Server:
|
94
100
|
- Jetty(7.6.3.v20120416)
|
95
101
|
body:
|
96
102
|
encoding: UTF-8
|
97
|
-
string:
|
98
|
-
{
|
99
|
-
"metadata": {
|
100
|
-
"timestamp": "2013-06-13T15:16:30.180-05:00",
|
101
|
-
"params": {}
|
102
|
-
},
|
103
|
-
"data": {
|
104
|
-
"userId": 2,
|
105
|
-
"userUid": "thwlhuOyiq2svbdcqfmm2demnda",
|
106
|
-
"status": "Active",
|
107
|
-
"username": "account_australia",
|
108
|
-
"email": "account_australia",
|
109
|
-
"firstName": "account_australia",
|
110
|
-
"lastName": "account_australia",
|
111
|
-
"quotaInBytes": -1,
|
112
|
-
"orgId": 1,
|
113
|
-
"orgUid": "ADMIN",
|
114
|
-
"orgName": "ADMIN",
|
115
|
-
"active": true,
|
116
|
-
"blocked": false,
|
117
|
-
"emailPromo": false,
|
118
|
-
"invited": false,
|
119
|
-
"orgType": "ENTERPRISE",
|
120
|
-
"usernameIsAnEmail": false,
|
121
|
-
"creationDate": "2006-04-17T12:30:00.990-05:00",
|
122
|
-
"modificationDate": "2013-06-13T15:16:30.146-05:00"
|
123
|
-
}
|
124
|
-
}
|
103
|
+
string: '{"metadata":{"timestamp":"2014-07-09T10:34:44.244-05:00","params":{}},"data":{"userId":2,"userUid":"thwlhuOyiq2svbdcqfmm2demnda","status":"Active","username":"account_australia","email":"account_australia","firstName":"account_australia","lastName":"account_australia","quotaInBytes":-1,"orgId":1,"orgUid":"ADMIN","orgName":"ADMIN","active":true,"blocked":false,"emailPromo":false,"invited":false,"orgType":"ENTERPRISE","usernameIsAnEmail":false,"creationDate":"2006-04-17T12:30:00.990-05:00","modificationDate":"2014-07-09T10:34:44.196-05:00","passwordReset":false}}'
|
125
104
|
http_version:
|
126
|
-
recorded_at:
|
105
|
+
recorded_at: Wed, 09 Jul 2014 15:34:44 GMT
|
127
106
|
recorded_with: VCR 2.5.0
|
@@ -2,13 +2,13 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: http://admin:admin@localhost:
|
5
|
+
uri: http://admin:admin@localhost:4280/api/userRole/my
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
9
9
|
headers:
|
10
10
|
User-Agent:
|
11
|
-
- Faraday v0.
|
11
|
+
- Faraday v0.9.0
|
12
12
|
Accept-Encoding:
|
13
13
|
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
14
14
|
Accept:
|
@@ -22,29 +22,17 @@ http_interactions:
|
|
22
22
|
- no-store
|
23
23
|
Pragma:
|
24
24
|
- no-cache
|
25
|
+
Content-Location:
|
26
|
+
- http://localhost:4280/api/v1/userRole/my
|
25
27
|
Content-Type:
|
26
|
-
- application/json;
|
28
|
+
- application/json;charset=UTF-8
|
27
29
|
Transfer-Encoding:
|
28
30
|
- chunked
|
29
31
|
Server:
|
30
32
|
- Jetty(7.6.3.v20120416)
|
31
33
|
body:
|
32
34
|
encoding: UTF-8
|
33
|
-
string:
|
34
|
-
{
|
35
|
-
"metadata": {
|
36
|
-
"timestamp": "2013-06-13T15:16:30.345-05:00",
|
37
|
-
"params": {}
|
38
|
-
},
|
39
|
-
"data": [ {
|
40
|
-
"roleId": 1,
|
41
|
-
"roleName": "SYSADMIN",
|
42
|
-
"locked": true,
|
43
|
-
"creationDate": "2006-04-17T12:30:00.987-05:00",
|
44
|
-
"modificationDate": "2013-06-13T15:13:53.293-05:00",
|
45
|
-
"permissions": [{"permission": "admin"}]
|
46
|
-
}]
|
47
|
-
}
|
35
|
+
string: '{"metadata":{"timestamp":"2014-07-09T10:34:44.647-05:00","params":{}},"data":[{"roleId":1,"roleName":"SYSADMIN","locked":true,"creationDate":"2006-04-17T12:30:00.987-05:00","modificationDate":"2014-07-08T10:58:40.634-05:00","permissions":[{"permission":"admin"}]}]}'
|
48
36
|
http_version:
|
49
|
-
recorded_at:
|
37
|
+
recorded_at: Wed, 09 Jul 2014 15:34:44 GMT
|
50
38
|
recorded_with: VCR 2.5.0
|
@@ -2,13 +2,13 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: post
|
5
|
-
uri: http://admin:admin@localhost:
|
5
|
+
uri: http://admin:admin@localhost:4280/api/authToken
|
6
6
|
body:
|
7
7
|
encoding: UTF-8
|
8
8
|
string: '{}'
|
9
9
|
headers:
|
10
10
|
User-Agent:
|
11
|
-
- Faraday v0.
|
11
|
+
- Faraday v0.9.0
|
12
12
|
Content-Type:
|
13
13
|
- application/json
|
14
14
|
Accept-Encoding:
|
@@ -24,36 +24,28 @@ http_interactions:
|
|
24
24
|
- no-store
|
25
25
|
Pragma:
|
26
26
|
- no-cache
|
27
|
+
Content-Location:
|
28
|
+
- http://localhost:4280/api/v1/authToken
|
27
29
|
Content-Type:
|
28
|
-
- application/json;
|
29
|
-
|
30
|
-
-
|
30
|
+
- application/json;charset=UTF-8
|
31
|
+
Content-Length:
|
32
|
+
- '137'
|
31
33
|
Server:
|
32
34
|
- Jetty(7.6.3.v20120416)
|
33
35
|
body:
|
34
36
|
encoding: UTF-8
|
35
|
-
string:
|
36
|
-
{
|
37
|
-
"metadata": {
|
38
|
-
"timestamp": "2013-06-13T15:16:29.726-05:00",
|
39
|
-
"params": {}
|
40
|
-
},
|
41
|
-
"data": [
|
42
|
-
"134jrkicsh5pv05bhldt7otnjn",
|
43
|
-
"1lmn47hi5a0wt065xjlz15cabl"
|
44
|
-
]
|
45
|
-
}
|
37
|
+
string: '{"metadata":{"timestamp":"2014-07-09T10:34:44.894-05:00","params":{}},"data":["1f2qhb8wgaesg1ksavy8ozrz6y","19sno55kj34kn159pxfatjbhku"]}'
|
46
38
|
http_version:
|
47
|
-
recorded_at:
|
39
|
+
recorded_at: Wed, 09 Jul 2014 15:34:44 GMT
|
48
40
|
- request:
|
49
41
|
method: get
|
50
|
-
uri: http://admin:admin@localhost:
|
42
|
+
uri: http://admin:admin@localhost:4280/api/authToken/1f2qhb8wgaesg1ksavy8ozrz6y-19sno55kj34kn159pxfatjbhku
|
51
43
|
body:
|
52
44
|
encoding: US-ASCII
|
53
45
|
string: ''
|
54
46
|
headers:
|
55
47
|
User-Agent:
|
56
|
-
- Faraday v0.
|
48
|
+
- Faraday v0.9.0
|
57
49
|
Accept-Encoding:
|
58
50
|
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
59
51
|
Accept:
|
@@ -67,25 +59,17 @@ http_interactions:
|
|
67
59
|
- no-store
|
68
60
|
Pragma:
|
69
61
|
- no-cache
|
62
|
+
Content-Location:
|
63
|
+
- http://localhost:4280/api/v1/authToken/1f2qhb8wgaesg1ksavy8ozrz6y-19sno55kj34kn159pxfatjbhku
|
70
64
|
Content-Type:
|
71
|
-
- application/json;
|
72
|
-
|
73
|
-
-
|
65
|
+
- application/json;charset=UTF-8
|
66
|
+
Content-Length:
|
67
|
+
- '111'
|
74
68
|
Server:
|
75
69
|
- Jetty(7.6.3.v20120416)
|
76
70
|
body:
|
77
71
|
encoding: UTF-8
|
78
|
-
string:
|
79
|
-
{
|
80
|
-
"metadata": {
|
81
|
-
"timestamp": "2013-06-13T15:16:29.741-05:00",
|
82
|
-
"params": {}
|
83
|
-
},
|
84
|
-
"data": {
|
85
|
-
"valid": true,
|
86
|
-
"username": "admin"
|
87
|
-
}
|
88
|
-
}
|
72
|
+
string: '{"metadata":{"timestamp":"2014-07-09T10:34:44.908-05:00","params":{}},"data":{"valid":true,"username":"admin"}}'
|
89
73
|
http_version:
|
90
|
-
recorded_at:
|
74
|
+
recorded_at: Wed, 09 Jul 2014 15:34:44 GMT
|
91
75
|
recorded_with: VCR 2.5.0
|
data/spec/code42/client_spec.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Code42::Client, :vcr do
|
4
|
+
|
4
5
|
subject(:client) do
|
5
6
|
Code42::Client.new(
|
6
7
|
host: 'localhost',
|
7
|
-
port:
|
8
|
+
port: 4280,
|
8
9
|
https: false,
|
9
10
|
api_root: '/api',
|
10
11
|
username: 'admin',
|
@@ -27,6 +28,60 @@ describe Code42::Client, :vcr do
|
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
31
|
+
describe "#unassign_role" do
|
32
|
+
|
33
|
+
let(:user_id) { 4 }
|
34
|
+
let(:role_name) { 'PROe User' }
|
35
|
+
|
36
|
+
it "removes the role" do
|
37
|
+
current_roles = client.user_roles user_id
|
38
|
+
current_role_names = current_roles.map(&:name)
|
39
|
+
|
40
|
+
expect(current_role_names.include? role_name).to be_true
|
41
|
+
|
42
|
+
client.unassign_role(user_id, role_name)
|
43
|
+
expect(client.last_response.status).to eq 204
|
44
|
+
|
45
|
+
actual_roles = client.user_roles user_id
|
46
|
+
expect(actual_roles).to be_empty
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "#permissions" do
|
51
|
+
it "returns an enumerable of permissions" do
|
52
|
+
permissions = client.permissions
|
53
|
+
permissions.should respond_to(:each)
|
54
|
+
expect(permissions.first).to be_a Code42::Permission
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "#roles" do
|
59
|
+
it "returns an enumerable" do
|
60
|
+
roles = client.roles
|
61
|
+
roles.should respond_to(:each)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "#create_role" do
|
66
|
+
it 'creates a role' do
|
67
|
+
role = client.create_role('My Role', ['admin.user.read'])
|
68
|
+
role.name.should == 'My Role'
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "#delete_role" do
|
73
|
+
it "deletes a role" do
|
74
|
+
client.delete_role(62)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "#update_role" do
|
79
|
+
it "updates a role" do
|
80
|
+
role = client.update_role(63, name: 'New name')
|
81
|
+
role.name.should == 'New name'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
30
85
|
describe "#get_token" do
|
31
86
|
it "returns valid tokens" do
|
32
87
|
auth = client.get_token
|
@@ -74,7 +129,7 @@ describe Code42::Client, :vcr do
|
|
74
129
|
it "returns created user" do
|
75
130
|
user = client.create_user(user_attributes)
|
76
131
|
user.username.should eq 'testuser'
|
77
|
-
user.id.should eq
|
132
|
+
user.id.should eq 38
|
78
133
|
end
|
79
134
|
|
80
135
|
context "when sending an invalid email" do
|