mxhero-api 1.2.3 → 1.2.8
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/communication.rb +7 -2
- data/lib/directories.rb +9 -1
- data/lib/email-sync.rb +10 -4
- data/lib/groups.rb +30 -18
- data/lib/mxhero-api.rb +9 -6
- data/lib/pst-converter.rb +4 -3
- data/lib/urls.rb +3 -3
- data/mxhero-api.gemspec +7 -7
- data/test/fixtures/api/search_accounts_starts_with_a.yml +34 -0
- data/test/fixtures/api/search_accounts_starts_with_ab.yml +34 -0
- data/test/test_directories.rb +1 -1
- data/test/test_groups.rb +16 -0
- data/test/test_mxhero_api.rb +5 -3
- metadata +12 -8
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
YWViNTg2OTAxMGRhYTcwOWI3NjMyMGZjMDE3YmQ3NWZmZGM3MDQ2OQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 98333e3bb84f6ffadd098d5786d3ed69f25f8da4
|
4
|
+
data.tar.gz: 57e0eefff6ee290646606bd24fd0c664932c21e4
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
MDc1OWZjNzY0N2RlN2Q3ZWYzZjE2NDZkYWIxZTAxYmIxZTJhODc4ZTA3OTIw
|
11
|
-
N2FkMGZlODEwMWMzOTk3YTViNGVjOGQxYWNlNTE1MjBiZGMxYTk=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NzdiNzA2YzQxNWIwZmQ2MTg1M2M3YjI4MzY1ZDgyMTBlY2E3MTFhNThkMWU0
|
14
|
-
NjY2ZDkzNTE5MzE2OTMwY2NhZjc3MWM4OTRhMTA5ZmM5MmU5ZWZiMzc5NGQ1
|
15
|
-
MWIxNjQyMjUzZTE1OTc0MWE1ZTJlYzJlMDU2YTI4N2ZiMWI5Yzg=
|
6
|
+
metadata.gz: d7750ef9ad95224f185224cb8545fd499548ba294c8a080b7052c179935fd9ceb6eedcc1599a92b3b5a6e5d62c01eb20661413006e6ff8176a5a09016d850604
|
7
|
+
data.tar.gz: 91197d516036befbfdddc77044184f294f58f479334b19ccb45b6d9d442d69df382f08d0fb1e34fdbf7e0ca320d1f6bc0932e9bd03e1e0b9999b58df271e0e33
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.8
|
data/lib/communication.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'httpclient'
|
2
2
|
require 'json'
|
3
3
|
require_relative 'response'
|
4
|
+
require 'base64'
|
4
5
|
|
5
6
|
module MxHero
|
6
7
|
module API
|
@@ -15,7 +16,7 @@ module MxHero
|
|
15
16
|
# @return [HTTP::Message](http://www.rubydoc.info/gems/httpclient/HTTP/Message)
|
16
17
|
def call(method, url, body = nil, more_options = {})
|
17
18
|
unless @client
|
18
|
-
@client ||= HTTPClient.new
|
19
|
+
@client ||= HTTPClient.new(:force_basic_auth => true)
|
19
20
|
end
|
20
21
|
@client.set_auth(url, @username, @password)
|
21
22
|
response = @client.request(method, url, nil, body, headers)
|
@@ -28,7 +29,11 @@ module MxHero
|
|
28
29
|
|
29
30
|
# Default headers
|
30
31
|
def headers
|
31
|
-
|
32
|
+
{
|
33
|
+
'Accept' => 'application/json',
|
34
|
+
'Content-Type' => 'application/json',
|
35
|
+
"Authorization" => "Basic " + ::Base64.encode64(@username + ':' + @password).gsub("\n",''),
|
36
|
+
}.merge(@as_user ? { "X-MxHero-As-User" => @as_user } : {})
|
32
37
|
end
|
33
38
|
|
34
39
|
# @return [Hash]
|
data/lib/directories.rb
CHANGED
@@ -98,12 +98,20 @@ module MxHero::API
|
|
98
98
|
|
99
99
|
attr_reader :domain
|
100
100
|
|
101
|
+
# @param [String] domain
|
102
|
+
# @param [Hash] config the options of configuration
|
103
|
+
# @option config [String] :api_url The URL to consume the API
|
104
|
+
# @option config [String] :username The username for access the API
|
105
|
+
# @option config [String] :password The password for the user that access the API
|
106
|
+
# @option config [Boolean] :verbose (false) If true puts information about http operations
|
107
|
+
# @option config [String] :as_user Send to the API to indentify the end user (app user email)
|
101
108
|
def initialize(domain, config = {})
|
102
109
|
@domain = domain
|
103
110
|
@service_url = config[:api_url]
|
104
111
|
@username = config[:username]
|
105
112
|
@password = config[:password]
|
106
113
|
@verbose = config[:verbose] || false
|
114
|
+
@as_user = config[:as_user]
|
107
115
|
end
|
108
116
|
|
109
117
|
|
@@ -178,7 +186,7 @@ module MxHero::API
|
|
178
186
|
end
|
179
187
|
|
180
188
|
def directories_url
|
181
|
-
domain_by_id_url(domain) + 'adldap'
|
189
|
+
domain_by_id_url(domain) + '/adldap'
|
182
190
|
end
|
183
191
|
end
|
184
192
|
|
data/lib/email-sync.rb
CHANGED
@@ -10,13 +10,19 @@ module MxHero::API
|
|
10
10
|
include Communication
|
11
11
|
include Urls
|
12
12
|
|
13
|
-
#attr_reader :domain
|
14
13
|
|
14
|
+
# @param [Hash] config the options of configuration
|
15
|
+
# @option config [String] :api_url The URL to consume the API
|
16
|
+
# @option config [String] :username The username for access the API
|
17
|
+
# @option config [String] :password The password for the user that access the API
|
18
|
+
# @option config [Boolean] :verbose (false) If true puts information about http operations
|
19
|
+
# @option config [String] :as_user Send to the API to indentify the end user (app user email)
|
15
20
|
def initialize(config = {})
|
16
21
|
@service_url = config[:api_url]
|
17
|
-
@username
|
18
|
-
@password
|
19
|
-
@verbose
|
22
|
+
@username = config[:username]
|
23
|
+
@password = config[:password]
|
24
|
+
@verbose = config[:verbose] || false
|
25
|
+
@as_user = config[:as_user]
|
20
26
|
end
|
21
27
|
|
22
28
|
def all(domain, params = {})
|
data/lib/groups.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
require_relative 'communication'
|
3
3
|
require_relative 'urls'
|
4
4
|
|
5
|
-
require 'open-uri'
|
5
|
+
require 'open-uri'
|
6
6
|
require 'delegate'
|
7
7
|
|
8
8
|
module MxHero::API
|
@@ -24,11 +24,12 @@ module MxHero::API
|
|
24
24
|
attr_reader :domain
|
25
25
|
|
26
26
|
def initialize(domain, config = {})
|
27
|
-
@domain
|
27
|
+
@domain = domain
|
28
28
|
@service_url = config[:api_url]
|
29
|
-
@username
|
30
|
-
@password
|
31
|
-
@verbose
|
29
|
+
@username = config[:username]
|
30
|
+
@password = config[:password]
|
31
|
+
@verbose = config[:verbose] || false
|
32
|
+
@as_user = config[:as_user]
|
32
33
|
end
|
33
34
|
|
34
35
|
# Retrieve all the groups
|
@@ -36,7 +37,7 @@ module MxHero::API
|
|
36
37
|
# @params pagination info. Ex.: page: 2, per_page: 10 or simple page: 2
|
37
38
|
#
|
38
39
|
# @return [PaginatedElement] that contains an array of Group elements
|
39
|
-
# Basically its an Array with instances of [MxHero::API::Group] with the methods total_elements, total_pages and actual_page
|
40
|
+
# Basically its an Array with instances of [MxHero::API::Group] with the methods total_elements, total_pages and actual_page
|
40
41
|
#
|
41
42
|
def all(pagination = { page: nil, per_page: nil })
|
42
43
|
response = call(:get, groups_url(pagination))
|
@@ -45,6 +46,12 @@ module MxHero::API
|
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
49
|
+
# Search available accounts
|
50
|
+
def search_accounts(term)
|
51
|
+
response = call(:get, search_accounts_url(term) ,nil, throw_exception: false)
|
52
|
+
Response.new(response.status, json_parse(response.content))
|
53
|
+
end
|
54
|
+
|
48
55
|
# Save a new group
|
49
56
|
#
|
50
57
|
# @param group [MxHero::API::Group]
|
@@ -59,8 +66,8 @@ module MxHero::API
|
|
59
66
|
#
|
60
67
|
# @param group_name [String]
|
61
68
|
#
|
62
|
-
# @return [MxHero::API::Response] with content empty.
|
63
|
-
# In case on error, may be one of the following:
|
69
|
+
# @return [MxHero::API::Response] with content empty.
|
70
|
+
# In case on error, may be one of the following:
|
64
71
|
# + domain.group.not.found : Inexistent group
|
65
72
|
def delete(group_name)
|
66
73
|
response = call(:delete, group_url(group_name), nil, throw_exception: false)
|
@@ -86,8 +93,8 @@ module MxHero::API
|
|
86
93
|
# @param group_name [String]
|
87
94
|
# @param account_name [String]
|
88
95
|
#
|
89
|
-
# @return [MxHero::API::Response] with content empty.
|
90
|
-
# In case on error, may be one of the following:
|
96
|
+
# @return [MxHero::API::Response] with content empty.
|
97
|
+
# In case on error, may be one of the following:
|
91
98
|
# + domain.account.not.found : Inexistent account
|
92
99
|
# + domain.group.account.already.has.group : Try to add an account to a group when already is in that
|
93
100
|
def add_account(group_name, account_name)
|
@@ -98,17 +105,17 @@ module MxHero::API
|
|
98
105
|
# @param group_name [String]
|
99
106
|
# @param account_name [String]
|
100
107
|
#
|
101
|
-
# @return [MxHero::API::Response] with content empty.
|
102
|
-
# In case on error, may be one of the following:
|
108
|
+
# @return [MxHero::API::Response] with content empty.
|
109
|
+
# In case on error, may be one of the following:
|
103
110
|
# + domain.account.not.found : Inexistent account
|
104
111
|
# + domain.group.account.not.in.group : Try to remove an account that is not in the group
|
105
|
-
#
|
112
|
+
#
|
106
113
|
def remove_account(group_name, account_name)
|
107
114
|
response = call(:delete, group_remove_accounts_url(group_name, account_name), nil, throw_exception: false)
|
108
115
|
wrap_response_from response
|
109
116
|
end
|
110
117
|
|
111
|
-
private
|
118
|
+
private
|
112
119
|
|
113
120
|
def paginate_wrap(response, &block)
|
114
121
|
raise 'an error ocurred when try to communicate with the API' if response.status != 200
|
@@ -118,7 +125,7 @@ module MxHero::API
|
|
118
125
|
|
119
126
|
def wrap_response_from(response)
|
120
127
|
content = (200..299).include?(response.code) ? group_from(response) : json_parse(response.content)
|
121
|
-
Response.new(response.status, content)
|
128
|
+
Response.new(response.status, content)
|
122
129
|
end
|
123
130
|
|
124
131
|
def group_from(response)
|
@@ -132,7 +139,7 @@ module MxHero::API
|
|
132
139
|
end
|
133
140
|
|
134
141
|
def groups_url(pagination = {})
|
135
|
-
domain_by_id_url(domain) + 'groups' + pagination_query(pagination)
|
142
|
+
domain_by_id_url(domain) + '/groups' + pagination_query(pagination)
|
136
143
|
end
|
137
144
|
|
138
145
|
def pagination_query(params = { page: nil, per_page: nil })
|
@@ -142,7 +149,7 @@ module MxHero::API
|
|
142
149
|
section << "offset=#{params[:page]}" if params[:page]
|
143
150
|
end.join('&')
|
144
151
|
end
|
145
|
-
|
152
|
+
|
146
153
|
def group_url(group_name)
|
147
154
|
groups_url + "/#{URI::encode(group_name)}"
|
148
155
|
end
|
@@ -154,10 +161,15 @@ module MxHero::API
|
|
154
161
|
def group_add_accounts_url(group_name, account_name)
|
155
162
|
group_accounts_url(group_name) + "/#{account_name}/add"
|
156
163
|
end
|
157
|
-
|
164
|
+
|
158
165
|
def group_remove_accounts_url(group_name, account_name)
|
159
166
|
group_accounts_url(group_name) + "/#{account_name}/remove"
|
160
167
|
end
|
168
|
+
|
169
|
+
def search_accounts_url(term)
|
170
|
+
"#{groups_url}/accounts/available?account=#{term}"
|
171
|
+
end
|
172
|
+
|
161
173
|
end
|
162
174
|
|
163
175
|
|
data/lib/mxhero-api.rb
CHANGED
@@ -30,11 +30,13 @@ module MxHero::API
|
|
30
30
|
# @option config [String] :username The username for access the API
|
31
31
|
# @option config [String] :password The password for the user that access the API
|
32
32
|
# @option config [Boolean] :verbose (false) If true puts information about http operations
|
33
|
+
# @option config [String] :as_user Send to the API to indentify the end user (app user email)
|
33
34
|
def initialize(config = {})
|
34
35
|
@service_url = config[:api_url]
|
35
36
|
@username = config[:username]
|
36
37
|
@password = config[:password]
|
37
38
|
@verbose = config[:verbose] || false
|
39
|
+
@as_user = config[:as_user]
|
38
40
|
end
|
39
41
|
|
40
42
|
# Expose directories api
|
@@ -42,7 +44,8 @@ module MxHero::API
|
|
42
44
|
# @return MxHero::API::Directories
|
43
45
|
def directories(domain)
|
44
46
|
@directories ||= Directories.new(domain, api_url: @service_url,
|
45
|
-
username: @username, password: @password,
|
47
|
+
username: @username, password: @password,
|
48
|
+
verbose: @verbose, as_user: @as_user)
|
46
49
|
end
|
47
50
|
|
48
51
|
# Find a rule by domain and ID
|
@@ -502,7 +505,7 @@ module MxHero::API
|
|
502
505
|
# Validate if the an user and password match
|
503
506
|
#
|
504
507
|
def valid_user_credentials?(user, password)
|
505
|
-
validate_user_credential_url = user_url(user) + "password/#{password}"
|
508
|
+
validate_user_credential_url = user_url(user) + "/password/#{CGI::escape(password)}"
|
506
509
|
response = call(:get, validate_user_credential_url)
|
507
510
|
response.status == 204
|
508
511
|
end
|
@@ -560,11 +563,11 @@ module MxHero::API
|
|
560
563
|
end
|
561
564
|
|
562
565
|
def user_url(user)
|
563
|
-
users_url + "/#{user}
|
566
|
+
users_url + "/#{user}"
|
564
567
|
end
|
565
568
|
|
566
569
|
def user_domains_url(user)
|
567
|
-
user_url(user) + "domains"
|
570
|
+
user_url(user) + "/domains"
|
568
571
|
end
|
569
572
|
|
570
573
|
def users_for_domain_url(domain)
|
@@ -572,7 +575,7 @@ module MxHero::API
|
|
572
575
|
end
|
573
576
|
|
574
577
|
def user_with_domain_url(user,domain)
|
575
|
-
user_url(user) + "domains/#{domain}/"
|
578
|
+
user_url(user) + "/domains/#{domain}/"
|
576
579
|
end
|
577
580
|
|
578
581
|
def user_url_set_password(user,new_password)
|
@@ -648,7 +651,7 @@ module MxHero::API
|
|
648
651
|
|
649
652
|
def accounts_by_domain_url(domain, filter_account = nil)
|
650
653
|
filter = filter_account ? "?account=#{filter_account}" : ''
|
651
|
-
domain_by_id_url(domain) + 'accounts' + filter
|
654
|
+
domain_by_id_url(domain) + '/accounts' + filter
|
652
655
|
end
|
653
656
|
|
654
657
|
def domain_rule_url(domain, id)
|
data/lib/pst-converter.rb
CHANGED
@@ -14,9 +14,10 @@ module MxHero::API
|
|
14
14
|
|
15
15
|
def initialize(config = {})
|
16
16
|
@service_url = config[:api_url]
|
17
|
-
@username
|
18
|
-
@password
|
19
|
-
@verbose
|
17
|
+
@username = config[:username]
|
18
|
+
@password = config[:password]
|
19
|
+
@verbose = config[:verbose] || false
|
20
|
+
@as_user = config[:as_user]
|
20
21
|
end
|
21
22
|
|
22
23
|
# Retrieve all tasks for {account} in status {status}
|
data/lib/urls.rb
CHANGED
@@ -5,15 +5,15 @@ module MxHero
|
|
5
5
|
def service_url
|
6
6
|
@service_url
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
def domains_url
|
10
10
|
service_url + '/domains'
|
11
11
|
end
|
12
12
|
|
13
13
|
def domain_by_id_url(domain)
|
14
|
-
domains_url + "/#{domain}
|
14
|
+
domains_url + "/#{domain}"
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
data/mxhero-api.gemspec
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: mxhero-api 1.2.
|
2
|
+
# stub: mxhero-api 1.2.8 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "mxhero-api"
|
6
|
-
s.version = "1.2.
|
6
|
+
s.version = "1.2.8"
|
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 = "
|
11
|
+
s.date = "2020-05-27"
|
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
|
-
s.files = [".gitignore", ".ruby-gemset", ".ruby-version", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "VERSION", "lib/communication.rb", "lib/directories.rb", "lib/dto.rb", "lib/email-sync.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/response.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/emailsync_delete.yml", "test/fixtures/api/emailsync_fetch_all.yml", "test/fixtures/api/emailsync_task_by_id.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/pst_inactive_tasks.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_emailsync.rb", "test/test_feature.rb", "test/test_groups.rb", "test/test_mxhero_api.rb", "test/test_mxhero_api_response.rb", "test/test_pst-converter.rb", "test/test_resource.rb"]
|
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/email-sync.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/response.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/emailsync_delete.yml", "test/fixtures/api/emailsync_fetch_all.yml", "test/fixtures/api/emailsync_task_by_id.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/pst_inactive_tasks.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/search_accounts_starts_with_a.yml", "test/fixtures/api/search_accounts_starts_with_ab.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_emailsync.rb", "test/test_feature.rb", "test/test_groups.rb", "test/test_mxhero_api.rb", "test/test_mxhero_api_response.rb", "test/test_pst-converter.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
|
-
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/emailsync_delete.yml", "test/fixtures/api/emailsync_fetch_all.yml", "test/fixtures/api/emailsync_task_by_id.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/pst_inactive_tasks.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_emailsync.rb", "test/test_feature.rb", "test/test_groups.rb", "test/test_mxhero_api.rb", "test/test_mxhero_api_response.rb", "test/test_pst-converter.rb", "test/test_resource.rb"]
|
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/emailsync_delete.yml", "test/fixtures/api/emailsync_fetch_all.yml", "test/fixtures/api/emailsync_task_by_id.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/pst_inactive_tasks.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/search_accounts_starts_with_a.yml", "test/fixtures/api/search_accounts_starts_with_ab.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_emailsync.rb", "test/test_feature.rb", "test/test_groups.rb", "test/test_mxhero_api.rb", "test/test_mxhero_api_response.rb", "test/test_pst-converter.rb", "test/test_resource.rb"]
|
21
21
|
|
22
22
|
if s.respond_to? :specification_version then
|
23
23
|
s.specification_version = 4
|
@@ -0,0 +1,34 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://admin:password@test.mxhero.com/webapi/api/v1/domains/tesla.com/groups/accounts/available?account=a
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/json
|
12
|
+
Content-Type:
|
13
|
+
- application/json
|
14
|
+
Authorization:
|
15
|
+
- Basic YWRtaW46cGFzc3dvcmQ=
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Server:
|
22
|
+
- Apache-Coyote/1.1
|
23
|
+
Content-Type:
|
24
|
+
- application/json
|
25
|
+
Transfer-Encoding:
|
26
|
+
- chunked
|
27
|
+
Date:
|
28
|
+
- Tue, 06 Jun 2017 15:17:42 GMT
|
29
|
+
body:
|
30
|
+
encoding: UTF-8
|
31
|
+
string: '{"totalElements":3,"totalPages":1,"actualPage":1,"elements":[{"account":"abuse","domain":"mxhero.com","createdDate":1395439948000,"updatedDate":1465322769000,"group":null,"dataSource":"manual","isEmailList":true,"aliases":[{"name":"abuse","domain":"mail2box.io","dataSource":"manual"},{"name":"abuse","domain":"mail2cloud.io","dataSource":"manual"},{"name":"abuse","domain":"mxhero.com","dataSource":"manual"},{"name":"abuse","domain":"mxhero.net","dataSource":"manual"},{"name":"abuse","domain":"mxheromail.com","dataSource":"manual"}],"properties":null},{"account":"antonio","domain":"mxhero.com","createdDate":1465308356000,"updatedDate":1465322769000,"group":null,"dataSource":"manual","isEmailList":false,"aliases":[{"name":"antonio","domain":"mail2box.io","dataSource":"manual"},{"name":"antonio","domain":"mail2cloud.io","dataSource":"manual"},{"name":"antonio","domain":"mxhero.com","dataSource":"manual"},{"name":"antonio","domain":"mxhero.net","dataSource":"manual"},{"name":"antonio","domain":"mxheromail.com","dataSource":"manual"},{"name":"antoniodelaheria","domain":"mail2box.io","dataSource":"manual"},{"name":"antoniodelaheria","domain":"mail2cloud.io","dataSource":"manual"},{"name":"antoniodelaheria","domain":"mxhero.com","dataSource":"manual"},{"name":"antoniodelaheria","domain":"mxhero.net","dataSource":"manual"},{"name":"antoniodelaheria","domain":"mxheromail.com","dataSource":"manual"}],"properties":null},{"account":"archive","domain":"mxhero.com","createdDate":1395439948000,"updatedDate":1465322769000,"group":null,"dataSource":"manual","isEmailList":true,"aliases":[{"name":"archive","domain":"mail2box.io","dataSource":"manual"},{"name":"archive","domain":"mail2cloud.io","dataSource":"manual"},{"name":"archive","domain":"mxhero.com","dataSource":"manual"},{"name":"archive","domain":"mxhero.net","dataSource":"manual"},{"name":"archive","domain":"mxheromail.com","dataSource":"manual"}],"properties":null}]}'
|
32
|
+
http_version:
|
33
|
+
recorded_at: Tue, 06 Jun 2017 15:17:42 GMT
|
34
|
+
recorded_with: VCR 3.0.1
|
@@ -0,0 +1,34 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://admin:password@test.mxhero.com/webapi/api/v1/domains/tesla.com/groups/accounts/available?account=ab
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/json
|
12
|
+
Content-Type:
|
13
|
+
- application/json
|
14
|
+
Authorization:
|
15
|
+
- Basic YWRtaW46cGFzc3dvcmQ=
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Server:
|
22
|
+
- Apache-Coyote/1.1
|
23
|
+
Content-Type:
|
24
|
+
- application/json
|
25
|
+
Transfer-Encoding:
|
26
|
+
- chunked
|
27
|
+
Date:
|
28
|
+
- Tue, 06 Jun 2017 15:20:32 GMT
|
29
|
+
body:
|
30
|
+
encoding: UTF-8
|
31
|
+
string: '{"totalElements":1,"totalPages":1,"actualPage":1,"elements":[{"account":"abuse","domain":"mxhero.com","createdDate":1395439948000,"updatedDate":1465322769000,"group":null,"dataSource":"manual","isEmailList":true,"aliases":[{"name":"abuse","domain":"mail2box.io","dataSource":"manual"},{"name":"abuse","domain":"mail2cloud.io","dataSource":"manual"},{"name":"abuse","domain":"mxhero.com","dataSource":"manual"},{"name":"abuse","domain":"mxhero.net","dataSource":"manual"},{"name":"abuse","domain":"mxheromail.com","dataSource":"manual"}],"properties":null}]}'
|
32
|
+
http_version:
|
33
|
+
recorded_at: Tue, 06 Jun 2017 15:20:32 GMT
|
34
|
+
recorded_with: VCR 3.0.1
|
data/test/test_directories.rb
CHANGED
@@ -116,7 +116,7 @@ class DirectoriesTest < MiniTest::Test
|
|
116
116
|
override: true, dn_authenticate: 'dn_autheticate message'
|
117
117
|
}
|
118
118
|
directory.update_properties changes
|
119
|
-
changes.keys.each { |prop| assert_equal
|
119
|
+
changes.keys.each { |prop| assert_equal(changes[prop], directory.send(prop)) }
|
120
120
|
end
|
121
121
|
|
122
122
|
def test_initialize_properties
|
data/test/test_groups.rb
CHANGED
@@ -120,5 +120,21 @@ class GroupsTest < Minitest::Test
|
|
120
120
|
assert_equal '?limit=10&offset=2', @groups.send(:pagination_query, per_page: 10, page: 2)
|
121
121
|
end
|
122
122
|
|
123
|
+
def test_search_accounts
|
124
|
+
VCR.use_cassette('search_accounts_starts_with_a') do
|
125
|
+
response = @groups.search_accounts('a')
|
126
|
+
assert response.success?
|
127
|
+
assert_equal 3, response.msg[:totalElements]
|
128
|
+
assert_equal [ 'abuse', 'antonio', 'archive' ], response.msg[:elements].map { |e| e[:account] }
|
129
|
+
end
|
130
|
+
|
131
|
+
VCR.use_cassette('search_accounts_starts_with_ab') do
|
132
|
+
response = @groups.search_accounts('ab')
|
133
|
+
assert response.success?
|
134
|
+
assert_equal 1, response.msg[:totalElements]
|
135
|
+
assert_equal [ 'abuse' ], response.msg[:elements].map { |e| e[:account] }
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
123
139
|
end
|
124
140
|
|
data/test/test_mxhero_api.rb
CHANGED
@@ -3,7 +3,7 @@ require_relative 'helper'
|
|
3
3
|
class MxHeroAPITest < Minitest::Test
|
4
4
|
|
5
5
|
def setup
|
6
|
-
@api = MxHero::API::Client.new(username: TEST_API_USER, password: TEST_API_PASSWORD, verbose: false, api_url: TEST_API_URL)
|
6
|
+
@api = MxHero::API::Client.new(username: TEST_API_USER, password: TEST_API_PASSWORD, verbose: false, api_url: TEST_API_URL, as_user: 'tester@mxhero.com')
|
7
7
|
end
|
8
8
|
|
9
9
|
def domain
|
@@ -18,6 +18,7 @@ class MxHeroAPITest < Minitest::Test
|
|
18
18
|
assert api.verbose?, 'Verbose state must be changed'
|
19
19
|
end
|
20
20
|
|
21
|
+
|
21
22
|
def test_update_rule
|
22
23
|
VCR.use_cassette('update_rule') do
|
23
24
|
rules = obtain_rules(domain)
|
@@ -35,6 +36,7 @@ class MxHeroAPITest < Minitest::Test
|
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
39
|
+
=begin
|
38
40
|
def test_rule_status
|
39
41
|
VCR.use_cassette('rule_status') do
|
40
42
|
mx_domain = 'mxhero.com'
|
@@ -169,7 +171,7 @@ class MxHeroAPITest < Minitest::Test
|
|
169
171
|
def test_delete_rule
|
170
172
|
VCR.use_cassette('delete_rule') do
|
171
173
|
rules = obtain_rules(domain)
|
172
|
-
one_rule = rules.first
|
174
|
+
one_rule = rules.first
|
173
175
|
response = @api.delete_rule(domain, one_rule[:id])
|
174
176
|
assert response
|
175
177
|
end
|
@@ -423,7 +425,7 @@ class MxHeroAPITest < Minitest::Test
|
|
423
425
|
refute @api.valid_user_credentials?('inexistent.user', 'xxx')
|
424
426
|
end
|
425
427
|
end
|
426
|
-
|
428
|
+
=end
|
427
429
|
private
|
428
430
|
|
429
431
|
def delete_all_rules
|
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.2.
|
4
|
+
version: 1.2.8
|
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:
|
13
|
+
date: 2020-05-27 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
|
@@ -123,6 +123,8 @@ files:
|
|
123
123
|
- test/fixtures/api/rules_for_domain.yml
|
124
124
|
- test/fixtures/api/rules_for_domain_by_component.yml
|
125
125
|
- test/fixtures/api/save_group.yml
|
126
|
+
- test/fixtures/api/search_accounts_starts_with_a.yml
|
127
|
+
- test/fixtures/api/search_accounts_starts_with_ab.yml
|
126
128
|
- test/fixtures/api/system_properties.yml
|
127
129
|
- test/fixtures/api/system_properties_create.yml
|
128
130
|
- test/fixtures/api/system_properties_element.yml
|
@@ -158,17 +160,17 @@ require_paths:
|
|
158
160
|
- lib
|
159
161
|
required_ruby_version: !ruby/object:Gem::Requirement
|
160
162
|
requirements:
|
161
|
-
- -
|
163
|
+
- - ">="
|
162
164
|
- !ruby/object:Gem::Version
|
163
165
|
version: 2.3.0
|
164
166
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
167
|
requirements:
|
166
|
-
- -
|
168
|
+
- - ">="
|
167
169
|
- !ruby/object:Gem::Version
|
168
170
|
version: '0'
|
169
171
|
requirements: []
|
170
172
|
rubyforge_project:
|
171
|
-
rubygems_version: 2.1
|
173
|
+
rubygems_version: 2.5.1
|
172
174
|
signing_key:
|
173
175
|
specification_version: 4
|
174
176
|
summary: A MxHero API client for ruby
|
@@ -211,6 +213,8 @@ test_files:
|
|
211
213
|
- test/fixtures/api/rules_for_domain.yml
|
212
214
|
- test/fixtures/api/rules_for_domain_by_component.yml
|
213
215
|
- test/fixtures/api/save_group.yml
|
216
|
+
- test/fixtures/api/search_accounts_starts_with_a.yml
|
217
|
+
- test/fixtures/api/search_accounts_starts_with_ab.yml
|
214
218
|
- test/fixtures/api/system_properties.yml
|
215
219
|
- test/fixtures/api/system_properties_create.yml
|
216
220
|
- test/fixtures/api/system_properties_element.yml
|