code42 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -0
- data/README.md +1 -1
- data/code42.gemspec +2 -1
- data/lib/code42.rb +5 -0
- data/lib/code42/api/password_reset.rb +15 -0
- data/lib/code42/api/user.rb +10 -0
- data/lib/code42/client.rb +11 -0
- data/lib/code42/org.rb +2 -2
- data/lib/code42/user.rb +4 -0
- data/lib/code42/version.rb +1 -1
- data/spec/cassettes/Code42_Client/_deactivate_org/puts_to_the_correct_route.yml +40 -0
- data/spec/cassettes/Code42_Client/_reset_password/when_sending_a_user_id/as_a_string/behaves_like_reset_password/is_successful.yml +39 -0
- data/spec/cassettes/Code42_Client/_reset_password/when_sending_a_user_id/as_an_integer/behaves_like_reset_password/is_successful.yml +39 -0
- data/spec/cassettes/Code42_Client/_reset_password/when_sending_a_username/behaves_like_reset_password/is_successful.yml +39 -0
- data/spec/cassettes/Code42_Client/_reset_password/when_sending_a_view_url/behaves_like_reset_password/is_successful.yml +39 -0
- data/spec/cassettes/Code42_Client/_update_user/returns_the_updated_user.yml +77 -0
- data/spec/cassettes/Code42_Client/_update_user/when_sending_an_invalid_email/raises_an_exception.yml +77 -0
- data/spec/code42/client_spec.rb +76 -0
- data/spec/code42/extension_spec.rb +26 -0
- metadata +36 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5016c27492e6c35df7c2e929aad4c1decd716043
|
4
|
+
data.tar.gz: 3b45794691537a0af54e0d497349be891cd9d5e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6831500eefe3bc2050162469ebe54aef89089b5bc77d25177458ce755e75f78913aba2444d800bc4d2c47a87462a27c978a30bd241af15b3a9a08ad8c2502dd
|
7
|
+
data.tar.gz: 1b0bf029724e99e6ea571092c7d9e24799a1c05149bb4760f7be62923bd59f5b885afcf141c9668d90e069eb7507f7a695430f73a46b94c02ff04d91761387d2
|
data/.travis.yml
ADDED
data/README.md
CHANGED
data/code42.gemspec
CHANGED
@@ -12,9 +12,10 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.summary = %q{...}
|
13
13
|
gem.homepage = "http://www.crashplan.com/apidocviewer/"
|
14
14
|
|
15
|
-
gem.add_development_dependency 'rspec', '~> 2.
|
15
|
+
gem.add_development_dependency 'rspec', '~> 2.14.0'
|
16
16
|
gem.add_development_dependency 'webmock', '~> 1.11.0'
|
17
17
|
gem.add_development_dependency 'vcr', '~> 2.5.0'
|
18
|
+
gem.add_development_dependency 'rake'
|
18
19
|
gem.add_dependency 'faraday', '~> 0.8.7'
|
19
20
|
gem.add_dependency 'activesupport', '>= 3.2.0'
|
20
21
|
gem.add_dependency 'faraday_middleware', '~> 0.8.7'
|
data/lib/code42.rb
CHANGED
@@ -28,6 +28,11 @@ module Code42
|
|
28
28
|
@client ||= Code42::Client.new
|
29
29
|
end
|
30
30
|
|
31
|
+
def use_extension(module_name)
|
32
|
+
Client.send(:include, module_name::ClientMethods) if defined?(module_name::ClientMethods)
|
33
|
+
self.send(:include, module_name::Resources) if defined?(module_name::Resources)
|
34
|
+
end
|
35
|
+
|
31
36
|
def configure
|
32
37
|
yield self.settings
|
33
38
|
self
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Code42
|
2
|
+
module API
|
3
|
+
module PasswordReset
|
4
|
+
# Send a password reset email to the user identified by +username_or_id+
|
5
|
+
# @param username_or_id [String, Integer] The username or user_id of the user to whom the email should be sent.
|
6
|
+
# @param view_url [String] the path of the password-reset form. Defaults to /console/password-reset.html
|
7
|
+
def reset_password(username_or_id, view_url = nil)
|
8
|
+
key = username_or_id.to_i > 0 ? :userId : :username
|
9
|
+
params = { key => username_or_id }
|
10
|
+
params.merge!(viewUrl: view_url) if view_url
|
11
|
+
post("UserPasswordReset", params)['data']['success']
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/code42/api/user.rb
CHANGED
@@ -12,6 +12,16 @@ module Code42
|
|
12
12
|
object_from_response(Code42::User, :post, "user", attrs)
|
13
13
|
end
|
14
14
|
|
15
|
+
# Updates a user
|
16
|
+
# @returns [Code42::User] The updated user
|
17
|
+
# @param id [integer] The user id to be updated
|
18
|
+
# @param attrs [Hash] A hash of attributes to update
|
19
|
+
# @example
|
20
|
+
# client.update_user(2, email_promo: true, first_name: 'John')
|
21
|
+
def update_user(id, attrs = {})
|
22
|
+
object_from_response(Code42::User, :put, "user/#{id}", attrs)
|
23
|
+
end
|
24
|
+
|
15
25
|
# Returns information for a given user
|
16
26
|
# @return [Code42::User] The requested user
|
17
27
|
# @param id_or_username [String, Integer] A code42 user ID or username
|
data/lib/code42/client.rb
CHANGED
@@ -8,6 +8,7 @@ module Code42
|
|
8
8
|
include Code42::API::Org
|
9
9
|
include Code42::API::Computer
|
10
10
|
include Code42::API::Token
|
11
|
+
include Code42::API::PasswordReset
|
11
12
|
|
12
13
|
attr_accessor :settings
|
13
14
|
|
@@ -55,6 +56,10 @@ module Code42
|
|
55
56
|
delete("computerblock/#{id}")
|
56
57
|
end
|
57
58
|
|
59
|
+
def deactivate_org(id)
|
60
|
+
put("OrgDeactivation/#{id}")
|
61
|
+
end
|
62
|
+
|
58
63
|
def connection
|
59
64
|
@connection = Connection.new(
|
60
65
|
host: settings.host,
|
@@ -79,6 +84,7 @@ module Code42
|
|
79
84
|
private
|
80
85
|
|
81
86
|
def object_from_response(klass, request_method, path, options = {})
|
87
|
+
klass = fetch_class(klass)
|
82
88
|
options = klass.serialize(options)
|
83
89
|
response = send(request_method.to_sym, path, options)
|
84
90
|
return nil unless response_has_data?(response['data'])
|
@@ -87,6 +93,7 @@ module Code42
|
|
87
93
|
|
88
94
|
def objects_from_response(klass, request_method, path, options = {})
|
89
95
|
key = options.delete(:key)
|
96
|
+
klass = fetch_class(klass)
|
90
97
|
options = klass.serialize(options)
|
91
98
|
response = send(request_method.to_sym, path, options)
|
92
99
|
return nil unless response_has_data?(response)
|
@@ -95,6 +102,10 @@ module Code42
|
|
95
102
|
objects_from_array(klass, response)
|
96
103
|
end
|
97
104
|
|
105
|
+
def fetch_class(klass)
|
106
|
+
klass.is_a?(Module) ? klass : Code42.const_get(klass)
|
107
|
+
end
|
108
|
+
|
98
109
|
def response_has_data?(response)
|
99
110
|
!response.nil?
|
100
111
|
end
|
data/lib/code42/org.rb
CHANGED
data/lib/code42/user.rb
CHANGED
data/lib/code42/version.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: put
|
5
|
+
uri: http://admin:admin@localhost:7280/api/OrgDeactivation/88
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{}'
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.8.9
|
12
|
+
Content-Type:
|
13
|
+
- application/json
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
|
+
Accept:
|
17
|
+
- '*/*'
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 201
|
21
|
+
message: Created
|
22
|
+
headers:
|
23
|
+
Cache-Control:
|
24
|
+
- no-store
|
25
|
+
Pragma:
|
26
|
+
- no-cache
|
27
|
+
Content-Location:
|
28
|
+
- http://localhost:4280/api/v1/OrgDeactivation/88
|
29
|
+
Content-Type:
|
30
|
+
- application/json
|
31
|
+
Content-Length:
|
32
|
+
- '0'
|
33
|
+
Server:
|
34
|
+
- Jetty(7.6.3.v20120416)
|
35
|
+
body:
|
36
|
+
encoding: UTF-8
|
37
|
+
string: ''
|
38
|
+
http_version:
|
39
|
+
recorded_at: Mon, 28 Apr 2014 21:18:38 GMT
|
40
|
+
recorded_with: VCR 2.5.0
|
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://admin:admin@localhost:7280/api/UserPasswordReset
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"userId":"42"}'
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.8.9
|
12
|
+
Content-Type:
|
13
|
+
- application/json
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
|
+
Accept:
|
17
|
+
- '*/*'
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Cache-Control:
|
24
|
+
- no-store
|
25
|
+
Pragma:
|
26
|
+
- no-cache
|
27
|
+
Content-Location:
|
28
|
+
- http://localhost:7280/api/v1/UserPasswordReset
|
29
|
+
Content-Type:
|
30
|
+
- application/json; charset=utf-8
|
31
|
+
Transfer-Encoding:
|
32
|
+
- chunked
|
33
|
+
Server:
|
34
|
+
- Jetty(7.6.3.v20120416)
|
35
|
+
body:
|
36
|
+
encoding: UTF-8
|
37
|
+
string: '{"metadata":{"timestamp":"2014-04-02T12:33:37.965-05:00","params":{}},"data":{"success":true}}'
|
38
|
+
http_version:
|
39
|
+
recorded_at: Wed, 02 Apr 2014 17:33:37 GMT
|
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://admin:admin@localhost:7280/api/UserPasswordReset
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"userId":42}'
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.8.9
|
12
|
+
Content-Type:
|
13
|
+
- application/json
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
|
+
Accept:
|
17
|
+
- '*/*'
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Cache-Control:
|
24
|
+
- no-store
|
25
|
+
Pragma:
|
26
|
+
- no-cache
|
27
|
+
Content-Location:
|
28
|
+
- http://localhost:7280/api/v1/UserPasswordReset
|
29
|
+
Content-Type:
|
30
|
+
- application/json; charset=utf-8
|
31
|
+
Transfer-Encoding:
|
32
|
+
- chunked
|
33
|
+
Server:
|
34
|
+
- Jetty(7.6.3.v20120416)
|
35
|
+
body:
|
36
|
+
encoding: UTF-8
|
37
|
+
string: '{"metadata":{"timestamp":"2014-04-02T12:33:37.925-05:00","params":{}},"data":{"success":true}}'
|
38
|
+
http_version:
|
39
|
+
recorded_at: Wed, 02 Apr 2014 17:33:37 GMT
|
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://admin:admin@localhost:7280/api/UserPasswordReset
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"username":"admin"}'
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.8.9
|
12
|
+
Content-Type:
|
13
|
+
- application/json
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
|
+
Accept:
|
17
|
+
- '*/*'
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Cache-Control:
|
24
|
+
- no-store
|
25
|
+
Pragma:
|
26
|
+
- no-cache
|
27
|
+
Content-Location:
|
28
|
+
- http://localhost:7280/api/v1/UserPasswordReset
|
29
|
+
Content-Type:
|
30
|
+
- application/json; charset=utf-8
|
31
|
+
Transfer-Encoding:
|
32
|
+
- chunked
|
33
|
+
Server:
|
34
|
+
- Jetty(7.6.3.v20120416)
|
35
|
+
body:
|
36
|
+
encoding: UTF-8
|
37
|
+
string: '{"metadata":{"timestamp":"2014-04-02T12:33:37.888-05:00","params":{}},"data":{"success":true}}'
|
38
|
+
http_version:
|
39
|
+
recorded_at: Wed, 02 Apr 2014 17:33:37 GMT
|
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://admin:admin@localhost:7280/api/UserPasswordReset
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"username":"admin"}'
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.8.9
|
12
|
+
Content-Type:
|
13
|
+
- application/json
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
|
+
Accept:
|
17
|
+
- '*/*'
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Cache-Control:
|
24
|
+
- no-store
|
25
|
+
Pragma:
|
26
|
+
- no-cache
|
27
|
+
Content-Location:
|
28
|
+
- http://localhost:7280/api/v1/UserPasswordReset
|
29
|
+
Content-Type:
|
30
|
+
- application/json; charset=utf-8
|
31
|
+
Transfer-Encoding:
|
32
|
+
- chunked
|
33
|
+
Server:
|
34
|
+
- Jetty(7.6.3.v20120416)
|
35
|
+
body:
|
36
|
+
encoding: UTF-8
|
37
|
+
string: '{"metadata":{"timestamp":"2014-04-02T12:33:37.844-05:00","params":{}},"data":{"success":true}}'
|
38
|
+
http_version:
|
39
|
+
recorded_at: Wed, 02 Apr 2014 17:33:37 GMT
|
@@ -0,0 +1,77 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://admin:admin@localhost:7280/api/user
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"orgId":2,"username":"testuser"}'
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.8.8
|
12
|
+
Content-Type:
|
13
|
+
- application/json
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
|
+
Accept:
|
17
|
+
- '*/*'
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Cache-Control:
|
24
|
+
- no-store
|
25
|
+
Pragma:
|
26
|
+
- no-cache
|
27
|
+
Content-Location:
|
28
|
+
- http://localhost:7280/api/v1/user
|
29
|
+
Content-Type:
|
30
|
+
- application/json; charset=utf-8
|
31
|
+
Transfer-Encoding:
|
32
|
+
- chunked
|
33
|
+
Server:
|
34
|
+
- Jetty(7.6.3.v20120416)
|
35
|
+
body:
|
36
|
+
encoding: UTF-8
|
37
|
+
string: '{"metadata":{"timestamp":"2014-03-19T17:11:52.798-05:00","params":{}},"data":{"userId":2,"userUid":"3b1d82e0fd88818b","status":"Active","username":"testuser","email":null,"firstName":null,"lastName":"Jenkins","quotaInBytes":-1,"orgId":2,"orgUid":"DEFAULT_CUSTOMER_ORG_ID","orgName":"Default","active":true,"blocked":false,"emailPromo":true,"invited":true,"orgType":"ENTERPRISE","usernameIsAnEmail":null,"creationDate":"2014-03-19T17:04:14.449-05:00","modificationDate":"2014-03-19T17:11:52.781-05:00","passwordReset":false}}'
|
38
|
+
http_version:
|
39
|
+
recorded_at: Wed, 19 Mar 2014 22:11:52 GMT
|
40
|
+
- request:
|
41
|
+
method: put
|
42
|
+
uri: http://admin:admin@localhost:7280/api/user/2
|
43
|
+
body:
|
44
|
+
encoding: UTF-8
|
45
|
+
string: '{"lastName":"Jenkins"}'
|
46
|
+
headers:
|
47
|
+
User-Agent:
|
48
|
+
- Faraday v0.8.8
|
49
|
+
Content-Type:
|
50
|
+
- application/json
|
51
|
+
Accept-Encoding:
|
52
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
53
|
+
Accept:
|
54
|
+
- '*/*'
|
55
|
+
response:
|
56
|
+
status:
|
57
|
+
code: 200
|
58
|
+
message: OK
|
59
|
+
headers:
|
60
|
+
Cache-Control:
|
61
|
+
- no-store
|
62
|
+
Pragma:
|
63
|
+
- no-cache
|
64
|
+
Content-Location:
|
65
|
+
- http://localhost:7280/api/v1/user/2
|
66
|
+
Content-Type:
|
67
|
+
- application/json; charset=utf-8
|
68
|
+
Transfer-Encoding:
|
69
|
+
- chunked
|
70
|
+
Server:
|
71
|
+
- Jetty(7.6.3.v20120416)
|
72
|
+
body:
|
73
|
+
encoding: UTF-8
|
74
|
+
string: '{"metadata":{"timestamp":"2014-03-19T17:11:52.838-05:00","params":{}},"data":{"userId":2,"userUid":"3b1d82e0fd88818b","status":"Active","username":"testuser","email":null,"firstName":null,"lastName":"Jenkins","quotaInBytes":-1,"orgId":2,"orgUid":"DEFAULT_CUSTOMER_ORG_ID","orgName":"Default","active":true,"blocked":false,"emailPromo":true,"invited":true,"orgType":"ENTERPRISE","usernameIsAnEmail":null,"creationDate":"2014-03-19T17:04:14.449-05:00","modificationDate":"2014-03-19T17:11:52.826-05:00","passwordReset":false}}'
|
75
|
+
http_version:
|
76
|
+
recorded_at: Wed, 19 Mar 2014 22:11:52 GMT
|
77
|
+
recorded_with: VCR 2.5.0
|
data/spec/cassettes/Code42_Client/_update_user/when_sending_an_invalid_email/raises_an_exception.yml
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://admin:admin@localhost:7280/api/user
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"orgId":2,"username":"testuser"}'
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.8.8
|
12
|
+
Content-Type:
|
13
|
+
- application/json
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
|
+
Accept:
|
17
|
+
- '*/*'
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Cache-Control:
|
24
|
+
- no-store
|
25
|
+
Pragma:
|
26
|
+
- no-cache
|
27
|
+
Content-Location:
|
28
|
+
- http://localhost:7280/api/v1/user
|
29
|
+
Content-Type:
|
30
|
+
- application/json; charset=utf-8
|
31
|
+
Transfer-Encoding:
|
32
|
+
- chunked
|
33
|
+
Server:
|
34
|
+
- Jetty(7.6.3.v20120416)
|
35
|
+
body:
|
36
|
+
encoding: UTF-8
|
37
|
+
string: '{"metadata":{"timestamp":"2014-03-19T17:11:52.875-05:00","params":{}},"data":{"userId":2,"userUid":"3b1d82e0fd88818b","status":"Active","username":"testuser","email":null,"firstName":null,"lastName":"Jenkins","quotaInBytes":-1,"orgId":2,"orgUid":"DEFAULT_CUSTOMER_ORG_ID","orgName":"Default","active":true,"blocked":false,"emailPromo":true,"invited":true,"orgType":"ENTERPRISE","usernameIsAnEmail":null,"creationDate":"2014-03-19T17:04:14.449-05:00","modificationDate":"2014-03-19T17:11:52.865-05:00","passwordReset":false}}'
|
38
|
+
http_version:
|
39
|
+
recorded_at: Wed, 19 Mar 2014 22:11:52 GMT
|
40
|
+
- request:
|
41
|
+
method: put
|
42
|
+
uri: http://admin:admin@localhost:7280/api/user/2
|
43
|
+
body:
|
44
|
+
encoding: UTF-8
|
45
|
+
string: '{"email":"Jenkins"}'
|
46
|
+
headers:
|
47
|
+
User-Agent:
|
48
|
+
- Faraday v0.8.8
|
49
|
+
Content-Type:
|
50
|
+
- application/json
|
51
|
+
Accept-Encoding:
|
52
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
53
|
+
Accept:
|
54
|
+
- '*/*'
|
55
|
+
response:
|
56
|
+
status:
|
57
|
+
code: 500
|
58
|
+
message: '[{"name":"EMAIL_INVALID","description":"com.code42.core.BuilderException","objects":[]}]'
|
59
|
+
headers:
|
60
|
+
Pragma:
|
61
|
+
- no-cache
|
62
|
+
Content-Location:
|
63
|
+
- http://localhost:7280/api/v1/user/2
|
64
|
+
Content-Type:
|
65
|
+
- text/html;charset=ISO-8859-1
|
66
|
+
Cache-Control:
|
67
|
+
- must-revalidate,no-cache,no-store
|
68
|
+
Content-Length:
|
69
|
+
- '88'
|
70
|
+
Server:
|
71
|
+
- Jetty(7.6.3.v20120416)
|
72
|
+
body:
|
73
|
+
encoding: UTF-8
|
74
|
+
string: '[{"name":"EMAIL_INVALID","description":"com.code42.core.BuilderException","objects":[]}]'
|
75
|
+
http_version:
|
76
|
+
recorded_at: Wed, 19 Mar 2014 22:11:52 GMT
|
77
|
+
recorded_with: VCR 2.5.0
|
data/spec/code42/client_spec.rb
CHANGED
@@ -42,6 +42,14 @@ describe Code42::Client, :vcr do
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
+
describe '#deactivate_org' do
|
46
|
+
it 'puts to the correct route' do
|
47
|
+
expect(client).to receive(:deactivate_org).with(88).and_call_original
|
48
|
+
expect(client).to receive(:put).with("OrgDeactivation/88").and_call_original
|
49
|
+
client.deactivate_org(88)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
45
53
|
describe "#create_org" do
|
46
54
|
let(:org_attributes) do
|
47
55
|
{
|
@@ -77,6 +85,32 @@ describe Code42::Client, :vcr do
|
|
77
85
|
end
|
78
86
|
end
|
79
87
|
|
88
|
+
describe "#update_user" do
|
89
|
+
let(:user_attributes) do
|
90
|
+
{
|
91
|
+
:orgId => 2,
|
92
|
+
:username => 'testuser'
|
93
|
+
}
|
94
|
+
end
|
95
|
+
|
96
|
+
let(:user) { @user }
|
97
|
+
|
98
|
+
before :each do
|
99
|
+
@user = client.create_user(user_attributes)
|
100
|
+
end
|
101
|
+
|
102
|
+
it "returns the updated user" do
|
103
|
+
updated_user = client.update_user(user.id, last_name: 'Jenkins')
|
104
|
+
expect(updated_user.last_name).to eq 'Jenkins'
|
105
|
+
end
|
106
|
+
|
107
|
+
context "when sending an invalid email" do
|
108
|
+
it "raises an exception" do
|
109
|
+
expect{ client.update_user(user.id, email: 'Jenkins') }.to raise_error(Code42::Error::EmailInvalid)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
80
114
|
describe "#user" do
|
81
115
|
let(:user_id) { 2 }
|
82
116
|
|
@@ -153,4 +187,46 @@ describe Code42::Client, :vcr do
|
|
153
187
|
client.ping.should be_true
|
154
188
|
end
|
155
189
|
end
|
190
|
+
|
191
|
+
describe "#reset_password" do
|
192
|
+
shared_examples 'reset_password' do
|
193
|
+
it 'is successful' do
|
194
|
+
expect(client.reset_password(*arguments)).to be_true
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
context 'when sending a username' do
|
199
|
+
let(:arguments){ ['admin'] }
|
200
|
+
|
201
|
+
it_behaves_like 'reset_password'
|
202
|
+
end
|
203
|
+
|
204
|
+
context 'when sending a view_url' do
|
205
|
+
let(:arguments){ %w(admin /new-pw-reset.html) }
|
206
|
+
|
207
|
+
before do
|
208
|
+
params = {
|
209
|
+
username: 'admin',
|
210
|
+
viewUrl: '/new-pw-reset.html'
|
211
|
+
}
|
212
|
+
client.should_receive(:post).with('UserPasswordReset', params).and_call_original
|
213
|
+
end
|
214
|
+
|
215
|
+
it_behaves_like 'reset_password'
|
216
|
+
end
|
217
|
+
|
218
|
+
context 'when sending a user_id' do
|
219
|
+
context 'as an integer' do
|
220
|
+
let(:arguments){ [42] }
|
221
|
+
|
222
|
+
it_behaves_like 'reset_password'
|
223
|
+
end
|
224
|
+
|
225
|
+
context 'as a string' do
|
226
|
+
let(:arguments){ ['42'] }
|
227
|
+
|
228
|
+
it_behaves_like 'reset_password'
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
156
232
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Code42Extension
|
4
|
+
module ClientMethods
|
5
|
+
def some_method
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
module Resources
|
10
|
+
class A < Code42::Resource; end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'use_extension' do
|
15
|
+
before do
|
16
|
+
Code42.use_extension Code42Extension
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'includes client methods' do
|
20
|
+
Code42::Client.new.should respond_to(:some_method)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'includes resources' do
|
24
|
+
Code42::A.should == Code42Extension::Resources::A
|
25
|
+
end
|
26
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: code42
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code 42
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: 2.14.0
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: 2.14.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: webmock
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 2.5.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: faraday
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -103,6 +117,7 @@ extra_rdoc_files: []
|
|
103
117
|
files:
|
104
118
|
- .gitignore
|
105
119
|
- .rspec
|
120
|
+
- .travis.yml
|
106
121
|
- Gemfile
|
107
122
|
- LICENSE
|
108
123
|
- README.md
|
@@ -118,6 +133,7 @@ files:
|
|
118
133
|
- lib/code42.rb
|
119
134
|
- lib/code42/api/computer.rb
|
120
135
|
- lib/code42/api/org.rb
|
136
|
+
- lib/code42/api/password_reset.rb
|
121
137
|
- lib/code42/api/role.rb
|
122
138
|
- lib/code42/api/token.rb
|
123
139
|
- lib/code42/api/user.rb
|
@@ -141,12 +157,19 @@ files:
|
|
141
157
|
- spec/cassettes/Code42_Client/_create_org/returns_created_org.yml
|
142
158
|
- spec/cassettes/Code42_Client/_create_user/returns_created_user.yml
|
143
159
|
- spec/cassettes/Code42_Client/_create_user/when_sending_an_invalid_email/raises_an_exception.yml
|
160
|
+
- spec/cassettes/Code42_Client/_deactivate_org/puts_to_the_correct_route.yml
|
144
161
|
- spec/cassettes/Code42_Client/_find_org_by_name/returns_the_org_with_the_specified_name.yml
|
145
162
|
- spec/cassettes/Code42_Client/_get_token/returns_valid_tokens.yml
|
146
163
|
- spec/cassettes/Code42_Client/_get_token/when_providing_invalid_credentials/should_raise_an_exception.yml
|
147
164
|
- spec/cassettes/Code42_Client/_org/when_ID_is_not_passed/returns_my_org.yml
|
148
165
|
- spec/cassettes/Code42_Client/_org/when_ID_is_passed_in/returns_a_specific_org.yml
|
149
166
|
- spec/cassettes/Code42_Client/_ping/returns_a_ping.yml
|
167
|
+
- spec/cassettes/Code42_Client/_reset_password/when_sending_a_user_id/as_a_string/behaves_like_reset_password/is_successful.yml
|
168
|
+
- spec/cassettes/Code42_Client/_reset_password/when_sending_a_user_id/as_an_integer/behaves_like_reset_password/is_successful.yml
|
169
|
+
- spec/cassettes/Code42_Client/_reset_password/when_sending_a_username/behaves_like_reset_password/is_successful.yml
|
170
|
+
- spec/cassettes/Code42_Client/_reset_password/when_sending_a_view_url/behaves_like_reset_password/is_successful.yml
|
171
|
+
- spec/cassettes/Code42_Client/_update_user/returns_the_updated_user.yml
|
172
|
+
- spec/cassettes/Code42_Client/_update_user/when_sending_an_invalid_email/raises_an_exception.yml
|
150
173
|
- spec/cassettes/Code42_Client/_user/when_ID_is_not_passed/returns_my_user.yml
|
151
174
|
- spec/cassettes/Code42_Client/_user/when_ID_is_passed_in/returns_a_specific_user.yml
|
152
175
|
- spec/cassettes/Code42_Client/_user/when_blocked/returns_the_blocked_status.yml
|
@@ -155,6 +178,7 @@ files:
|
|
155
178
|
- spec/cassettes/Code42_Client/_validate_token/returns_a_valid_response.yml
|
156
179
|
- spec/code42/client_spec.rb
|
157
180
|
- spec/code42/connection_spec.rb
|
181
|
+
- spec/code42/extension_spec.rb
|
158
182
|
- spec/code42/org_spec.rb
|
159
183
|
- spec/code42/ping_spec.rb
|
160
184
|
- spec/code42/resource_spec.rb
|
@@ -201,12 +225,19 @@ test_files:
|
|
201
225
|
- spec/cassettes/Code42_Client/_create_org/returns_created_org.yml
|
202
226
|
- spec/cassettes/Code42_Client/_create_user/returns_created_user.yml
|
203
227
|
- spec/cassettes/Code42_Client/_create_user/when_sending_an_invalid_email/raises_an_exception.yml
|
228
|
+
- spec/cassettes/Code42_Client/_deactivate_org/puts_to_the_correct_route.yml
|
204
229
|
- spec/cassettes/Code42_Client/_find_org_by_name/returns_the_org_with_the_specified_name.yml
|
205
230
|
- spec/cassettes/Code42_Client/_get_token/returns_valid_tokens.yml
|
206
231
|
- spec/cassettes/Code42_Client/_get_token/when_providing_invalid_credentials/should_raise_an_exception.yml
|
207
232
|
- spec/cassettes/Code42_Client/_org/when_ID_is_not_passed/returns_my_org.yml
|
208
233
|
- spec/cassettes/Code42_Client/_org/when_ID_is_passed_in/returns_a_specific_org.yml
|
209
234
|
- spec/cassettes/Code42_Client/_ping/returns_a_ping.yml
|
235
|
+
- spec/cassettes/Code42_Client/_reset_password/when_sending_a_user_id/as_a_string/behaves_like_reset_password/is_successful.yml
|
236
|
+
- spec/cassettes/Code42_Client/_reset_password/when_sending_a_user_id/as_an_integer/behaves_like_reset_password/is_successful.yml
|
237
|
+
- spec/cassettes/Code42_Client/_reset_password/when_sending_a_username/behaves_like_reset_password/is_successful.yml
|
238
|
+
- spec/cassettes/Code42_Client/_reset_password/when_sending_a_view_url/behaves_like_reset_password/is_successful.yml
|
239
|
+
- spec/cassettes/Code42_Client/_update_user/returns_the_updated_user.yml
|
240
|
+
- spec/cassettes/Code42_Client/_update_user/when_sending_an_invalid_email/raises_an_exception.yml
|
210
241
|
- spec/cassettes/Code42_Client/_user/when_ID_is_not_passed/returns_my_user.yml
|
211
242
|
- spec/cassettes/Code42_Client/_user/when_ID_is_passed_in/returns_a_specific_user.yml
|
212
243
|
- spec/cassettes/Code42_Client/_user/when_blocked/returns_the_blocked_status.yml
|
@@ -215,6 +246,7 @@ test_files:
|
|
215
246
|
- spec/cassettes/Code42_Client/_validate_token/returns_a_valid_response.yml
|
216
247
|
- spec/code42/client_spec.rb
|
217
248
|
- spec/code42/connection_spec.rb
|
249
|
+
- spec/code42/extension_spec.rb
|
218
250
|
- spec/code42/org_spec.rb
|
219
251
|
- spec/code42/ping_spec.rb
|
220
252
|
- spec/code42/resource_spec.rb
|