mxhero-api 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/VERSION +1 -1
- data/lib/directories.rb +29 -27
- data/mxhero-api.gemspec +5 -5
- data/test/fixtures/api/create_directory.yml +4 -4
- data/test/fixtures/api/fetch_directory.yml +2 -2
- data/test/fixtures/api/update_directory.yml +6 -6
- data/test/test_directories.rb +32 -30
- data/test/test_domain.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MDBiYzFlMDViMDg0YmNjOTIwNGI1MjU4YWQwZjcxNDdkZDhkYjlkNA==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ba456138682906b1ca14227f6bffe9f3749903c9
|
4
|
+
data.tar.gz: 04c6819cfdd14bf406c63f150ab07545d423f362
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
MDBmMTg4YmFmMWM4M2Q0ZTM0ZTUzODcxNTExMDNiOGNhYTQwMTg1NWE0OWE5
|
11
|
-
MTRjNzBiNmM1MTQ1NzUxMTIzOTgwNjNjYjEyY2YyZGEyN2Q5OGQ=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
Y2QyOWU0Y2MyZWEwMzc5ZjA5MDVmOTRiNTBkNzUyNzQxMzkxYTk4ZmZlNjYz
|
14
|
-
N2Q4ZTFlMzEzNTA0M2E3NmQ2ZDcyNTAwMDBkNzkzZTJmMTY0ZjBhMDdkOGQ5
|
15
|
-
ZDY3NTliYjdlM2UzZmM1NWU5ZmE4NjE5NzRhZjcyYTMwNzk0Njk=
|
6
|
+
metadata.gz: 655fa6ab58d501a060245c64c0423109f2e48bc5039807c9f1e0bebf422e382f31fcba3092ac82ca5ffcda713a423caacbb98211257ebfc177a4b58944924ad9
|
7
|
+
data.tar.gz: 244eaaa1fa896c4ad175a97484cf8357f16a874b42c9db9f34e1341ee8ed09481cb63b25063cd24cb7c5145102f0b6f9ab6ae440a7e1ef53fd40019ae2e4939d
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.1
|
data/lib/directories.rb
CHANGED
@@ -1,20 +1,21 @@
|
|
1
1
|
module MxHero::API
|
2
2
|
|
3
|
-
class Directory
|
4
|
-
attr_accessor :domain, :type, :address, :port, :ssl,
|
5
|
-
:user, :password, :filter, :base, :next_update,
|
6
|
-
:last_update, :error, :override, :dn_authenticate,
|
7
|
-
:properties
|
3
|
+
class Directory
|
4
|
+
attr_accessor :domain, :type, :address, :port, :ssl,
|
5
|
+
:user, :password, :filter, :base, :next_update,
|
6
|
+
:last_update, :error, :override, :dn_authenticate,
|
7
|
+
:properties, :useMailAsMain
|
8
8
|
|
9
9
|
def initialize(data = {})
|
10
10
|
return if data.empty?
|
11
11
|
[
|
12
|
-
:domain, [:type, :directoryType], [:address, :addres], :port,
|
13
|
-
[:ssl, :sslFlag], :user, :password, :filter, :base,
|
12
|
+
:domain, [:type, :directoryType], [:address, :addres], :port,
|
13
|
+
[:ssl, :sslFlag], :user, :password, :filter, :base,
|
14
14
|
[:next_update, :nextUpdate],
|
15
15
|
[:last_update, :lastUpdate],
|
16
|
-
:error, [:override, :overrideFlag],
|
17
|
-
[:dn_authenticate, :dnAuthenticate]
|
16
|
+
:error, [:override, :overrideFlag],
|
17
|
+
[:dn_authenticate, :dnAuthenticate],
|
18
|
+
:useMailAsMain
|
18
19
|
].each do |property|
|
19
20
|
case property
|
20
21
|
when Symbol
|
@@ -26,9 +27,9 @@ module MxHero::API
|
|
26
27
|
load_properties(data)
|
27
28
|
end
|
28
29
|
|
29
|
-
|
30
|
+
|
30
31
|
def last_update=(date)
|
31
|
-
parse_update_dates(:last_update, date)
|
32
|
+
parse_update_dates(:last_update, date)
|
32
33
|
end
|
33
34
|
|
34
35
|
def next_update=(date)
|
@@ -44,15 +45,16 @@ module MxHero::API
|
|
44
45
|
domain: domain,
|
45
46
|
directoryType: type,
|
46
47
|
addres: address,
|
47
|
-
port: port,
|
48
|
+
port: port,
|
48
49
|
sslFlag: ssl, # || false,
|
49
|
-
user: user, password: password,
|
50
|
+
user: user, password: password,
|
50
51
|
filter: filter, base: base,
|
51
52
|
nextUpdate: next_update, # || DateTime.now.strftime('%Q'),
|
52
53
|
lastUpdate: last_update, # || DateTime.now.strftime('%Q'),
|
53
54
|
error: error,
|
54
55
|
overrideFlag: override, #override.nil? ? true : override,
|
55
56
|
dnAuthenticate: dn_authenticate,
|
57
|
+
useMailAsMain: useMailAsMain,
|
56
58
|
properties: properties_field_to_hash
|
57
59
|
}
|
58
60
|
end
|
@@ -60,9 +62,9 @@ module MxHero::API
|
|
60
62
|
def to_json
|
61
63
|
to_hash.to_json
|
62
64
|
end
|
63
|
-
|
65
|
+
|
64
66
|
private
|
65
|
-
|
67
|
+
|
66
68
|
def load_properties(data)
|
67
69
|
@properties ||= {}
|
68
70
|
props = data[:properties]
|
@@ -75,11 +77,11 @@ module MxHero::API
|
|
75
77
|
def properties_field_to_hash
|
76
78
|
values = []
|
77
79
|
(properties || []).each do |name, value|
|
78
|
-
values << { name: name, key: value }
|
80
|
+
values << { name: name, key: value }
|
79
81
|
end
|
80
82
|
values
|
81
83
|
end
|
82
|
-
|
84
|
+
|
83
85
|
def parse_update_dates(property, date)
|
84
86
|
if date.is_a? Integer or date.is_a? String
|
85
87
|
instance_variable_set "@#{property}", DateTime.strptime(date.to_s, '%Q')
|
@@ -89,7 +91,7 @@ module MxHero::API
|
|
89
91
|
end
|
90
92
|
|
91
93
|
end
|
92
|
-
|
94
|
+
|
93
95
|
class Directories
|
94
96
|
include Communication
|
95
97
|
include Urls
|
@@ -116,11 +118,11 @@ module MxHero::API
|
|
116
118
|
end
|
117
119
|
nil
|
118
120
|
end
|
119
|
-
|
121
|
+
|
120
122
|
# Create a directory configuration
|
121
123
|
#
|
122
124
|
# @return [MxHero::API::Response] that Directory created
|
123
|
-
# In case on error, may be one of the following:
|
125
|
+
# In case on error, may be one of the following:
|
124
126
|
# + domain.ldap.alredy.exists
|
125
127
|
#
|
126
128
|
def create(directory)
|
@@ -132,7 +134,7 @@ module MxHero::API
|
|
132
134
|
# Update the directory configuration
|
133
135
|
#
|
134
136
|
# @return [MxHero::API::Response] that Directory updated
|
135
|
-
# In case on error, may be one of the following:
|
137
|
+
# In case on error, may be one of the following:
|
136
138
|
# + domain.ldap.not.found
|
137
139
|
#
|
138
140
|
def update(directory)
|
@@ -144,7 +146,7 @@ module MxHero::API
|
|
144
146
|
# Delete the directory configuration
|
145
147
|
#
|
146
148
|
# @return [MxHero::API::Response] with empty content.
|
147
|
-
# In case on error, may be one of the following:
|
149
|
+
# In case on error, may be one of the following:
|
148
150
|
# + domain.ldap.not.found : Inexistent group
|
149
151
|
def delete
|
150
152
|
response = call(:delete, directories_url, throw_exception: false)
|
@@ -153,8 +155,8 @@ module MxHero::API
|
|
153
155
|
|
154
156
|
# Request to refresh the accounts information
|
155
157
|
#
|
156
|
-
# @return [MxHero::API::Response] with empty content.
|
157
|
-
# In case on error, may be one of the following:
|
158
|
+
# @return [MxHero::API::Response] with empty content.
|
159
|
+
# In case on error, may be one of the following:
|
158
160
|
# + domain.ldap.not.found : Inexistent group
|
159
161
|
def refresh
|
160
162
|
response = call(:post, directories_url + '/refresh', throw_exception: false)
|
@@ -163,10 +165,10 @@ module MxHero::API
|
|
163
165
|
|
164
166
|
# -------------------------------------------------------------------------
|
165
167
|
private
|
166
|
-
|
168
|
+
|
167
169
|
def wrap_response_from(response)
|
168
170
|
content = (200..299).include?(response.code) ? directory_from(response) : json_parse(response.content)
|
169
|
-
Response.new(response.status, content)
|
171
|
+
Response.new(response.status, content)
|
170
172
|
end
|
171
173
|
|
172
174
|
def directory_from(response)
|
@@ -176,7 +178,7 @@ module MxHero::API
|
|
176
178
|
end
|
177
179
|
|
178
180
|
def directories_url
|
179
|
-
domain_by_id_url(domain) + 'adldap'
|
181
|
+
domain_by_id_url(domain) + 'adldap'
|
180
182
|
end
|
181
183
|
end
|
182
184
|
|
data/mxhero-api.gemspec
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: mxhero-api 1.1.
|
2
|
+
# stub: mxhero-api 1.1.1 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "mxhero-api"
|
6
|
-
s.version = "1.1.
|
6
|
+
s.version = "1.1.1"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
9
|
+
s.require_paths = ["lib"]
|
9
10
|
s.authors = ["Maximiliano Dello Russo", "Juan Pablo Royo", "mxHero"]
|
10
|
-
s.date = "2016-
|
11
|
+
s.date = "2016-05-13"
|
11
12
|
s.description = "A gem to provide easy access to the API of MxHero platform (http://www.mxhero.com/)"
|
12
13
|
s.email = ["maxidr@mxhero.com", "juanpablo.royo@gmail.com", "mxhero@mxhero.com"]
|
13
14
|
s.files = [".gitignore", ".ruby-gemset", ".ruby-version", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "VERSION", "lib/communication.rb", "lib/directories.rb", "lib/dto.rb", "lib/groups.rb", "lib/mxhero-api.rb", "lib/pst-converter.rb", "lib/resource.rb", "lib/resources/account.rb", "lib/resources/domain.rb", "lib/resources/group.rb", "lib/urls.rb", "mxhero-api.gemspec", "test/fixtures/api/account_properties.yml", "test/fixtures/api/account_properties_not_found.yml", "test/fixtures/api/accounts.yml", "test/fixtures/api/accounts_filtered.yml", "test/fixtures/api/accounts_from_domain.yml", "test/fixtures/api/accounts_from_domain_paginated.yml", "test/fixtures/api/accounts_without_group.yml", "test/fixtures/api/add_an_inexistent_account_to_group.yml", "test/fixtures/api/add_and_remove_account.yml", "test/fixtures/api/add_feature.yml", "test/fixtures/api/all_groups.yml", "test/fixtures/api/associate_user_domain.yml", "test/fixtures/api/create_directory.yml", "test/fixtures/api/create_domain.yml", "test/fixtures/api/create_rule_for_domain.yml", "test/fixtures/api/create_user.yml", "test/fixtures/api/delete_directory.yml", "test/fixtures/api/delete_group.yml", "test/fixtures/api/delete_rule.yml", "test/fixtures/api/domain_by_id.yml", "test/fixtures/api/domain_by_id_not_found.yml", "test/fixtures/api/domain_rule.yml", "test/fixtures/api/domains.yml", "test/fixtures/api/fetch_directory.yml", "test/fixtures/api/fetch_user.yml", "test/fixtures/api/ldap_info.yml", "test/fixtures/api/move_to_trial.yml", "test/fixtures/api/refresh_directory.yml", "test/fixtures/api/remove_account_from_group_twice.yml", "test/fixtures/api/remove_inexistente_account_from_group.yml", "test/fixtures/api/rule_status.yml", "test/fixtures/api/rules_for_domain.yml", "test/fixtures/api/rules_for_domain_by_component.yml", "test/fixtures/api/save_group.yml", "test/fixtures/api/system_properties.yml", "test/fixtures/api/system_properties_create.yml", "test/fixtures/api/system_properties_element.yml", "test/fixtures/api/test_domain.yml", "test/fixtures/api/update_account_properties.yml", "test/fixtures/api/update_accounts_group_scope.yml", "test/fixtures/api/update_accounts_properties_scope.yml", "test/fixtures/api/update_directory.yml", "test/fixtures/api/update_rule.yml", "test/fixtures/api/update_user.yml", "test/fixtures/api/user_domains.yml", "test/fixtures/api/users_for_domain.yml", "test/fixtures/api/validate_user_credential.yml", "test/fixtures/domain.rb", "test/helper.rb", "test/test_directories.rb", "test/test_domain.rb", "test/test_dto.rb", "test/test_feature.rb", "test/test_groups.rb", "test/test_mxhero_api.rb", "test/test_mxhero_api_response.rb", "test/test_resource.rb"]
|
14
15
|
s.homepage = "http://github.com/mxhero/mxhero-api"
|
15
16
|
s.licenses = ["GPL-3"]
|
16
|
-
s.require_paths = ["lib"]
|
17
17
|
s.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
18
|
-
s.rubygems_version = "2.1
|
18
|
+
s.rubygems_version = "2.5.1"
|
19
19
|
s.summary = "A MxHero API client for ruby"
|
20
20
|
s.test_files = ["test/fixtures/api/account_properties.yml", "test/fixtures/api/account_properties_not_found.yml", "test/fixtures/api/accounts.yml", "test/fixtures/api/accounts_filtered.yml", "test/fixtures/api/accounts_from_domain.yml", "test/fixtures/api/accounts_from_domain_paginated.yml", "test/fixtures/api/accounts_without_group.yml", "test/fixtures/api/add_an_inexistent_account_to_group.yml", "test/fixtures/api/add_and_remove_account.yml", "test/fixtures/api/add_feature.yml", "test/fixtures/api/all_groups.yml", "test/fixtures/api/associate_user_domain.yml", "test/fixtures/api/create_directory.yml", "test/fixtures/api/create_domain.yml", "test/fixtures/api/create_rule_for_domain.yml", "test/fixtures/api/create_user.yml", "test/fixtures/api/delete_directory.yml", "test/fixtures/api/delete_group.yml", "test/fixtures/api/delete_rule.yml", "test/fixtures/api/domain_by_id.yml", "test/fixtures/api/domain_by_id_not_found.yml", "test/fixtures/api/domain_rule.yml", "test/fixtures/api/domains.yml", "test/fixtures/api/fetch_directory.yml", "test/fixtures/api/fetch_user.yml", "test/fixtures/api/ldap_info.yml", "test/fixtures/api/move_to_trial.yml", "test/fixtures/api/refresh_directory.yml", "test/fixtures/api/remove_account_from_group_twice.yml", "test/fixtures/api/remove_inexistente_account_from_group.yml", "test/fixtures/api/rule_status.yml", "test/fixtures/api/rules_for_domain.yml", "test/fixtures/api/rules_for_domain_by_component.yml", "test/fixtures/api/save_group.yml", "test/fixtures/api/system_properties.yml", "test/fixtures/api/system_properties_create.yml", "test/fixtures/api/system_properties_element.yml", "test/fixtures/api/test_domain.yml", "test/fixtures/api/update_account_properties.yml", "test/fixtures/api/update_accounts_group_scope.yml", "test/fixtures/api/update_accounts_properties_scope.yml", "test/fixtures/api/update_directory.yml", "test/fixtures/api/update_rule.yml", "test/fixtures/api/update_user.yml", "test/fixtures/api/user_domains.yml", "test/fixtures/api/users_for_domain.yml", "test/fixtures/api/validate_user_credential.yml", "test/fixtures/domain.rb", "test/helper.rb", "test/test_directories.rb", "test/test_domain.rb", "test/test_dto.rb", "test/test_feature.rb", "test/test_groups.rb", "test/test_mxhero_api.rb", "test/test_mxhero_api_response.rb", "test/test_resource.rb"]
|
21
21
|
|
@@ -5,7 +5,7 @@ http_interactions:
|
|
5
5
|
uri: http://admin:password@test.mxhero.com/webapi/api/v1/domains/test.com/adldap
|
6
6
|
body:
|
7
7
|
encoding: UTF-8
|
8
|
-
string: ! '{"domain":"test.com","directoryType":"gapps","addres":null,"port":null,"sslFlag":null,"user":"user","password":"password","filter":null,"base":null,"nextUpdate":null,"lastUpdate":null,"error":null,"overrideFlag":null,"dnAuthenticate":null,"properties":[]}'
|
8
|
+
string: ! '{"domain":"test.com","directoryType":"gapps","addres":null,"port":null,"sslFlag":null,"user":"user","password":"password","filter":null,"base":null,"nextUpdate":null,"lastUpdate":null,"error":null,"overrideFlag":null,"dnAuthenticate":null,"useMailAsMain":true,"properties":[]}'
|
9
9
|
headers:
|
10
10
|
Accept:
|
11
11
|
- application/json
|
@@ -33,8 +33,8 @@ http_interactions:
|
|
33
33
|
YXBwbGljYXRpb24vanNvbg==
|
34
34
|
body:
|
35
35
|
encoding: US-ASCII
|
36
|
-
string: ! '{"domain":"test.com","directoryType":"gapps","addres":null,"port":null,"sslFlag":false,"user":"user","password":"password","filter":null,"base":null,"nextUpdate":1386688365000,"lastUpdate":null,"error":null,"overrideFlag":false,"dnAuthenticate":null,"properties":[],"periodInHours":0}'
|
37
|
-
http_version:
|
36
|
+
string: ! '{"domain":"test.com","directoryType":"gapps","addres":null,"port":null,"sslFlag":false,"user":"user","password":"password","filter":null,"base":null,"nextUpdate":1386688365000,"lastUpdate":null,"error":null,"overrideFlag":false,"dnAuthenticate":null,"useMailAsMain":true,"properties":[],"periodInHours":0}'
|
37
|
+
http_version:
|
38
38
|
recorded_at: Tue, 10 Dec 2013 15:12:45 GMT
|
39
39
|
- request:
|
40
40
|
method: post
|
@@ -73,6 +73,6 @@ http_interactions:
|
|
73
73
|
body:
|
74
74
|
encoding: US-ASCII
|
75
75
|
string: ! '{"status":500,"code":500,"developerMessage":"domain.ldap.already.exists","moreInfoUrl":"mailto:support@mxhero.com"}'
|
76
|
-
http_version:
|
76
|
+
http_version:
|
77
77
|
recorded_at: Tue, 10 Dec 2013 15:12:46 GMT
|
78
78
|
recorded_with: VCR 2.5.0
|
@@ -33,7 +33,7 @@ http_interactions:
|
|
33
33
|
YXBwbGljYXRpb24vanNvbg==
|
34
34
|
body:
|
35
35
|
encoding: US-ASCII
|
36
|
-
string: ! '{"domain":"test.com","directoryType":"gapps","addres":null,"port":null,"sslFlag":false,"user":"user","password":"password","filter":null,"base":null,"nextUpdate":1384810741000,"lastUpdate":null,"error":null,"overrideFlag":false,"dnAuthenticate":null,"properties":[]}'
|
37
|
-
http_version:
|
36
|
+
string: ! '{"domain":"test.com","directoryType":"gapps","addres":null,"port":null,"sslFlag":false,"user":"user","password":"password","filter":null,"base":null,"nextUpdate":1384810741000,"lastUpdate":null,"error":null,"overrideFlag":false,"dnAuthenticate":null,"useMailAsMain":false,"properties":[]}'
|
37
|
+
http_version:
|
38
38
|
recorded_at: Mon, 18 Nov 2013 21:42:00 GMT
|
39
39
|
recorded_with: VCR 2.5.0
|
@@ -33,15 +33,15 @@ http_interactions:
|
|
33
33
|
YXBwbGljYXRpb24vanNvbg==
|
34
34
|
body:
|
35
35
|
encoding: US-ASCII
|
36
|
-
string: ! '{"domain":"test.com","directoryType":"gapps","addres":null,"port":null,"sslFlag":false,"user":"user","password":"password","filter":null,"base":null,"nextUpdate":1384810990000,"lastUpdate":null,"error":null,"overrideFlag":false,"dnAuthenticate":null,"properties":[]}'
|
37
|
-
http_version:
|
36
|
+
string: ! '{"domain":"test.com","directoryType":"gapps","addres":null,"port":null,"sslFlag":false,"user":"user","password":"password","filter":null,"base":null,"nextUpdate":1384810990000,"lastUpdate":null,"error":null,"overrideFlag":false,"dnAuthenticate":null,"useMailAsMain":true,"properties":[]}'
|
37
|
+
http_version:
|
38
38
|
recorded_at: Mon, 18 Nov 2013 21:43:36 GMT
|
39
39
|
- request:
|
40
40
|
method: put
|
41
41
|
uri: http://admin:password@test.mxhero.com/webapi/api/v1/domains/test.com/adldap
|
42
42
|
body:
|
43
43
|
encoding: UTF-8
|
44
|
-
string: ! '{"domain":"test.com","directoryType":"zimbra","addres":"zertifikate.telekom.de","port":"389","sslFlag":true,"user":"user","password":"password","filter":null,"base":"cn","nextUpdate":"2013-11-18T21:43:10+00:00","lastUpdate":null,"error":null,"overrideFlag":false,"dnAuthenticate":null,"properties":[]}'
|
44
|
+
string: ! '{"domain":"test.com","directoryType":"zimbra","addres":"zertifikate.telekom.de","port":"389","sslFlag":true,"user":"user","password":"password","filter":null,"base":"cn","nextUpdate":"2013-11-18T21:43:10+00:00","lastUpdate":null,"error":null,"overrideFlag":false,"dnAuthenticate":null,"useMailAsMain":true,"properties":[]}'
|
45
45
|
headers:
|
46
46
|
Accept:
|
47
47
|
- application/json
|
@@ -70,7 +70,7 @@ http_interactions:
|
|
70
70
|
body:
|
71
71
|
encoding: US-ASCII
|
72
72
|
string: ''
|
73
|
-
http_version:
|
73
|
+
http_version:
|
74
74
|
recorded_at: Mon, 18 Nov 2013 21:43:36 GMT
|
75
75
|
- request:
|
76
76
|
method: get
|
@@ -105,7 +105,7 @@ http_interactions:
|
|
105
105
|
YXBwbGljYXRpb24vanNvbg==
|
106
106
|
body:
|
107
107
|
encoding: US-ASCII
|
108
|
-
string: ! '{"domain":"test.com","directoryType":"zimbra","addres":"zertifikate.telekom.de","port":"389","sslFlag":true,"user":"user","password":"password","filter":null,"base":"cn","nextUpdate":1384810990000,"lastUpdate":null,"error":null,"overrideFlag":false,"dnAuthenticate":null,"properties":[]}'
|
109
|
-
http_version:
|
108
|
+
string: ! '{"domain":"test.com","directoryType":"zimbra","addres":"zertifikate.telekom.de","port":"389","sslFlag":true,"user":"user","password":"password","filter":null,"base":"cn","nextUpdate":1384810990000,"lastUpdate":null,"error":null,"overrideFlag":false,"dnAuthenticate":null,"useMailAsMain":true,"properties":[]}'
|
109
|
+
http_version:
|
110
110
|
recorded_at: Mon, 18 Nov 2013 21:43:36 GMT
|
111
111
|
recorded_with: VCR 2.5.0
|
data/test/test_directories.rb
CHANGED
@@ -2,9 +2,9 @@ require_relative 'helper'
|
|
2
2
|
|
3
3
|
class DirectoriesTest < MiniTest::Test
|
4
4
|
def setup
|
5
|
-
@dirs = MxHero::API::Directories.new(domain,
|
6
|
-
username: TEST_API_USER,
|
7
|
-
password: TEST_API_PASSWORD,
|
5
|
+
@dirs = MxHero::API::Directories.new(domain,
|
6
|
+
username: TEST_API_USER,
|
7
|
+
password: TEST_API_PASSWORD,
|
8
8
|
verbose: false, api_url: TEST_API_URL)
|
9
9
|
end
|
10
10
|
|
@@ -13,7 +13,7 @@ class DirectoriesTest < MiniTest::Test
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_directories_from_api
|
16
|
-
directories = MxHero::API::Client.new(api_url: TEST_API_URL, username: TEST_API_USER,
|
16
|
+
directories = MxHero::API::Client.new(api_url: TEST_API_URL, username: TEST_API_USER,
|
17
17
|
password: TEST_API_PASSWORD).directories(domain)
|
18
18
|
assert directories.is_a? MxHero::API::Directories
|
19
19
|
assert_equal domain, directories.instance_variable_get(:@domain)
|
@@ -26,28 +26,29 @@ class DirectoriesTest < MiniTest::Test
|
|
26
26
|
def test_fetch
|
27
27
|
VCR.use_cassette('fetch_directory') do
|
28
28
|
directory = @dirs.fetch
|
29
|
-
assert_equal domain, directory.domain
|
29
|
+
assert_equal domain, directory.domain
|
30
30
|
assert_equal 'gapps', directory.type
|
31
|
+
assert_equal false, directory.useMailAsMain
|
31
32
|
end
|
32
33
|
end
|
33
|
-
|
34
|
+
|
34
35
|
def test_create
|
35
36
|
directory = MxHero::API::Directory.new(domain: 'test.com', type: 'gapps',
|
36
37
|
user: 'user', password: 'password')
|
37
|
-
|
38
|
-
VCR.use_cassette('create_directory') do
|
38
|
+
|
39
|
+
VCR.use_cassette('create_directory') do
|
39
40
|
response = @dirs.create directory
|
40
41
|
assert response.success?
|
41
|
-
|
42
|
+
|
42
43
|
# try to create again
|
43
44
|
response = @dirs.create directory
|
44
|
-
assert ! response.success?
|
45
|
+
assert ! response.success?
|
45
46
|
assert_equal 'domain.ldap.already.exists', response.error
|
46
47
|
end
|
47
48
|
end
|
48
49
|
|
49
50
|
def test_update
|
50
|
-
VCR.use_cassette('update_directory') do
|
51
|
+
VCR.use_cassette('update_directory') do
|
51
52
|
directory = @dirs.fetch
|
52
53
|
directory.ssl = true
|
53
54
|
directory.base = 'cn'
|
@@ -56,9 +57,10 @@ class DirectoriesTest < MiniTest::Test
|
|
56
57
|
directory.port = '389'
|
57
58
|
directory.user = 'user'
|
58
59
|
directory.password = 'password'
|
59
|
-
|
60
|
+
directory.useMailAsMain = true
|
61
|
+
|
60
62
|
assert @dirs.update(directory).success?
|
61
|
-
|
63
|
+
|
62
64
|
updated = @dirs.fetch
|
63
65
|
|
64
66
|
assert_equal directory.ssl, updated.ssl
|
@@ -68,11 +70,12 @@ class DirectoriesTest < MiniTest::Test
|
|
68
70
|
assert_equal directory.port, updated.port
|
69
71
|
assert_equal directory.user, updated.user
|
70
72
|
assert_equal directory.password, updated.password
|
73
|
+
assert_equal directory.useMailAsMain, updated.useMailAsMain
|
71
74
|
end
|
72
75
|
end
|
73
76
|
|
74
77
|
def test_delete
|
75
|
-
VCR.use_cassette('delete_directory') do
|
78
|
+
VCR.use_cassette('delete_directory') do
|
76
79
|
deleted = @dirs.delete
|
77
80
|
assert deleted.success?
|
78
81
|
assert_nil @dirs.fetch
|
@@ -96,52 +99,52 @@ class DirectoriesTest < MiniTest::Test
|
|
96
99
|
directory.next_update = 1379949740000
|
97
100
|
directory.last_update = '1379949740000'
|
98
101
|
expected = "2013-09-23T15:22:20+00:00"
|
99
|
-
assert_equal expected, directory.next_update.to_s #23-09-2013 12:22
|
100
|
-
assert_equal expected, directory.last_update.to_s #23-09-2013 12:22
|
102
|
+
assert_equal expected, directory.next_update.to_s #23-09-2013 12:22
|
103
|
+
assert_equal expected, directory.last_update.to_s #23-09-2013 12:22
|
101
104
|
end
|
102
105
|
|
103
106
|
def test_update_properties
|
104
|
-
directory = MxHero::API::Directory.new domain: domain,
|
105
|
-
type: 'gapps', address: nil, port: nil, ssl: false,
|
107
|
+
directory = MxHero::API::Directory.new domain: domain,
|
108
|
+
type: 'gapps', address: nil, port: nil, ssl: false,
|
106
109
|
user: 'test_user', password: 'password', filter: nil,
|
107
110
|
base: nil, next_update: 1379949740000, last_update: 1379949740000,
|
108
111
|
override: false, dn_authenticate: nil
|
109
112
|
changes = {
|
110
113
|
type: 'ldap', address: 'ldap.mxhero.com', port: 1234, ssl: true,
|
111
114
|
user: 'mxhero_user', password: 'xxx', filter: 'filter',
|
112
|
-
base: 'base', next_update: Date.new, last_update: nil,
|
115
|
+
base: 'base', next_update: Date.new, last_update: nil,
|
113
116
|
override: true, dn_authenticate: 'dn_autheticate message'
|
114
117
|
}
|
115
|
-
directory.update_properties changes
|
118
|
+
directory.update_properties changes
|
116
119
|
changes.keys.each { |prop| assert_equal changes[prop], directory.send(prop) }
|
117
120
|
end
|
118
121
|
|
119
122
|
def test_initialize_properties
|
120
|
-
directory = MxHero::API::Directory.new domain: domain,
|
123
|
+
directory = MxHero::API::Directory.new domain: domain,
|
121
124
|
properties: [ {name: 'email', key: 'ldap.email'}, {name: 'name', key: 'user.name'} ]
|
122
125
|
|
123
126
|
assert_equal({ email: 'ldap.email', name: 'user.name' }, directory.properties)
|
124
127
|
|
125
|
-
directory = MxHero::API::Directory.new domain: domain,
|
128
|
+
directory = MxHero::API::Directory.new domain: domain,
|
126
129
|
properties: { email: 'ldap.email', name: 'user.name' }
|
127
|
-
|
130
|
+
|
128
131
|
assert_equal({ email: 'ldap.email', name: 'user.name' }, directory.properties)
|
129
132
|
end
|
130
133
|
|
131
134
|
def test_properties_to_json
|
132
|
-
directory = MxHero::API::Directory.new domain: domain,
|
135
|
+
directory = MxHero::API::Directory.new domain: domain,
|
133
136
|
properties: { email: 'ldap.email', name: 'user.name' }
|
134
|
-
|
137
|
+
|
135
138
|
expected = {
|
136
139
|
domain: directory.domain, directoryType: directory.type,
|
137
140
|
addres: directory.address, port: directory.port, sslFlag: directory.ssl,
|
138
141
|
user: directory.user, password: directory.password, filter: directory.filter,
|
139
|
-
base: directory.base, nextUpdate: directory.next_update,
|
140
|
-
lastUpdate: directory.last_update, error: directory.error,
|
141
|
-
overrideFlag: directory.override, dnAuthenticate: directory.dn_authenticate,
|
142
|
+
base: directory.base, nextUpdate: directory.next_update,
|
143
|
+
lastUpdate: directory.last_update, error: directory.error,
|
144
|
+
overrideFlag: directory.override, dnAuthenticate: directory.dn_authenticate, useMailAsMain: nil,
|
142
145
|
properties: [ { name: 'email', key:'ldap.email' }, { name: 'name', key: 'user.name' } ]
|
143
146
|
}
|
144
|
-
|
147
|
+
|
145
148
|
assert_equal expected.to_json, directory.to_json
|
146
149
|
|
147
150
|
directory = MxHero::API::Directory.new domain: domain
|
@@ -150,4 +153,3 @@ class DirectoriesTest < MiniTest::Test
|
|
150
153
|
end
|
151
154
|
|
152
155
|
end
|
153
|
-
|
data/test/test_domain.rb
CHANGED
@@ -16,7 +16,7 @@ class DomainTest < MiniTest::Test
|
|
16
16
|
|
17
17
|
def test_empty_metadata
|
18
18
|
[ '', 'null', nil ].each do |value|
|
19
|
-
data[:metadata] = value
|
19
|
+
data[:metadata] = value
|
20
20
|
domain = MxHero::API::Domain.new data
|
21
21
|
assert domain.metadata.nil?, "Is not empty in case of '#{value}'"
|
22
22
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mxhero-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maximiliano Dello Russo
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-05-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: vcr
|
@@ -63,9 +63,9 @@ executables: []
|
|
63
63
|
extensions: []
|
64
64
|
extra_rdoc_files: []
|
65
65
|
files:
|
66
|
-
- .gitignore
|
67
|
-
- .ruby-gemset
|
68
|
-
- .ruby-version
|
66
|
+
- ".gitignore"
|
67
|
+
- ".ruby-gemset"
|
68
|
+
- ".ruby-version"
|
69
69
|
- Gemfile
|
70
70
|
- LICENSE.txt
|
71
71
|
- README.md
|
@@ -150,17 +150,17 @@ require_paths:
|
|
150
150
|
- lib
|
151
151
|
required_ruby_version: !ruby/object:Gem::Requirement
|
152
152
|
requirements:
|
153
|
-
- -
|
153
|
+
- - ">="
|
154
154
|
- !ruby/object:Gem::Version
|
155
155
|
version: 2.3.0
|
156
156
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
157
|
requirements:
|
158
|
-
- -
|
158
|
+
- - ">="
|
159
159
|
- !ruby/object:Gem::Version
|
160
160
|
version: '0'
|
161
161
|
requirements: []
|
162
162
|
rubyforge_project:
|
163
|
-
rubygems_version: 2.1
|
163
|
+
rubygems_version: 2.5.1
|
164
164
|
signing_key:
|
165
165
|
specification_version: 4
|
166
166
|
summary: A MxHero API client for ruby
|