mxhero-api 1.2.4 → 1.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/communication.rb +7 -5
- data/lib/directories.rb +1 -1
- data/lib/groups.rb +25 -14
- data/lib/mxhero-api.rb +7 -7
- data/lib/urls.rb +3 -3
- data/mxhero-api.gemspec +5 -5
- 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/fixtures/api/validate_user_credential.yml +192 -109
- data/test/test_groups.rb +16 -0
- data/test/test_mxhero_api.rb +61 -50
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 778d526d0854e4c50736d0cd53130bc22740f432
|
4
|
+
data.tar.gz: b1c6fc56151b095b0dc65fad92fef36abebf92f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c18ab9158b5d6128f31822d9dc288c9d7e64c677cb336f2bf858931639fa64be148638a9396fef63fdf371edbdc37197446627bb44732c25ca817e1db2da626
|
7
|
+
data.tar.gz: 9ed2618db43e48c59fa36f67cc844534a2a19d55db6bcea96935c287ec528b61dc4089cbc3f97ddaa9dc64fba0d13a1abdb03f779dc6cecefa924e5342aceddf
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.9
|
data/lib/communication.rb
CHANGED
@@ -19,7 +19,7 @@ module MxHero
|
|
19
19
|
@client ||= HTTPClient.new(:force_basic_auth => true)
|
20
20
|
end
|
21
21
|
@client.set_auth(url, @username, @password)
|
22
|
-
response = @client.request(method, url, nil, body, headers)
|
22
|
+
response = @client.request(method, url, nil, body, headers(more_options))
|
23
23
|
raise "Unauthorized" if response.status == 401
|
24
24
|
unless more_options[:throw_exception] == false
|
25
25
|
raise "An error ocurred when try to communicate with the API\nError: #{response.inspect}" if (500..600).include?(response.status)
|
@@ -28,10 +28,12 @@ module MxHero
|
|
28
28
|
end
|
29
29
|
|
30
30
|
# Default headers
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
def headers(options = {})
|
32
|
+
accept = options.fetch(:accept, 'application/json')
|
33
|
+
content_type = options.fetch(:content_type, 'application/json')
|
34
|
+
return {
|
35
|
+
'Accept' => accept,
|
36
|
+
'Content-Type' => content_type,
|
35
37
|
"Authorization" => "Basic " + ::Base64.encode64(@username + ':' + @password).gsub("\n",''),
|
36
38
|
}.merge(@as_user ? { "X-MxHero-As-User" => @as_user } : {})
|
37
39
|
end
|
data/lib/directories.rb
CHANGED
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
|
@@ -37,7 +37,7 @@ module MxHero::API
|
|
37
37
|
# @params pagination info. Ex.: page: 2, per_page: 10 or simple page: 2
|
38
38
|
#
|
39
39
|
# @return [PaginatedElement] that contains an array of Group elements
|
40
|
-
# 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
|
41
41
|
#
|
42
42
|
def all(pagination = { page: nil, per_page: nil })
|
43
43
|
response = call(:get, groups_url(pagination))
|
@@ -46,6 +46,12 @@ module MxHero::API
|
|
46
46
|
end
|
47
47
|
end
|
48
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
|
+
|
49
55
|
# Save a new group
|
50
56
|
#
|
51
57
|
# @param group [MxHero::API::Group]
|
@@ -60,8 +66,8 @@ module MxHero::API
|
|
60
66
|
#
|
61
67
|
# @param group_name [String]
|
62
68
|
#
|
63
|
-
# @return [MxHero::API::Response] with content empty.
|
64
|
-
# 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:
|
65
71
|
# + domain.group.not.found : Inexistent group
|
66
72
|
def delete(group_name)
|
67
73
|
response = call(:delete, group_url(group_name), nil, throw_exception: false)
|
@@ -87,8 +93,8 @@ module MxHero::API
|
|
87
93
|
# @param group_name [String]
|
88
94
|
# @param account_name [String]
|
89
95
|
#
|
90
|
-
# @return [MxHero::API::Response] with content empty.
|
91
|
-
# 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:
|
92
98
|
# + domain.account.not.found : Inexistent account
|
93
99
|
# + domain.group.account.already.has.group : Try to add an account to a group when already is in that
|
94
100
|
def add_account(group_name, account_name)
|
@@ -99,17 +105,17 @@ module MxHero::API
|
|
99
105
|
# @param group_name [String]
|
100
106
|
# @param account_name [String]
|
101
107
|
#
|
102
|
-
# @return [MxHero::API::Response] with content empty.
|
103
|
-
# 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:
|
104
110
|
# + domain.account.not.found : Inexistent account
|
105
111
|
# + domain.group.account.not.in.group : Try to remove an account that is not in the group
|
106
|
-
#
|
112
|
+
#
|
107
113
|
def remove_account(group_name, account_name)
|
108
114
|
response = call(:delete, group_remove_accounts_url(group_name, account_name), nil, throw_exception: false)
|
109
115
|
wrap_response_from response
|
110
116
|
end
|
111
117
|
|
112
|
-
private
|
118
|
+
private
|
113
119
|
|
114
120
|
def paginate_wrap(response, &block)
|
115
121
|
raise 'an error ocurred when try to communicate with the API' if response.status != 200
|
@@ -119,7 +125,7 @@ module MxHero::API
|
|
119
125
|
|
120
126
|
def wrap_response_from(response)
|
121
127
|
content = (200..299).include?(response.code) ? group_from(response) : json_parse(response.content)
|
122
|
-
Response.new(response.status, content)
|
128
|
+
Response.new(response.status, content)
|
123
129
|
end
|
124
130
|
|
125
131
|
def group_from(response)
|
@@ -133,7 +139,7 @@ module MxHero::API
|
|
133
139
|
end
|
134
140
|
|
135
141
|
def groups_url(pagination = {})
|
136
|
-
domain_by_id_url(domain) + 'groups' + pagination_query(pagination)
|
142
|
+
domain_by_id_url(domain) + '/groups' + pagination_query(pagination)
|
137
143
|
end
|
138
144
|
|
139
145
|
def pagination_query(params = { page: nil, per_page: nil })
|
@@ -143,7 +149,7 @@ module MxHero::API
|
|
143
149
|
section << "offset=#{params[:page]}" if params[:page]
|
144
150
|
end.join('&')
|
145
151
|
end
|
146
|
-
|
152
|
+
|
147
153
|
def group_url(group_name)
|
148
154
|
groups_url + "/#{URI::encode(group_name)}"
|
149
155
|
end
|
@@ -155,10 +161,15 @@ module MxHero::API
|
|
155
161
|
def group_add_accounts_url(group_name, account_name)
|
156
162
|
group_accounts_url(group_name) + "/#{account_name}/add"
|
157
163
|
end
|
158
|
-
|
164
|
+
|
159
165
|
def group_remove_accounts_url(group_name, account_name)
|
160
166
|
group_accounts_url(group_name) + "/#{account_name}/remove"
|
161
167
|
end
|
168
|
+
|
169
|
+
def search_accounts_url(term)
|
170
|
+
"#{groups_url}/accounts/available?account=#{term}"
|
171
|
+
end
|
172
|
+
|
162
173
|
end
|
163
174
|
|
164
175
|
|
data/lib/mxhero-api.rb
CHANGED
@@ -44,7 +44,7 @@ module MxHero::API
|
|
44
44
|
# @return MxHero::API::Directories
|
45
45
|
def directories(domain)
|
46
46
|
@directories ||= Directories.new(domain, api_url: @service_url,
|
47
|
-
username: @username, password: @password,
|
47
|
+
username: @username, password: @password,
|
48
48
|
verbose: @verbose, as_user: @as_user)
|
49
49
|
end
|
50
50
|
|
@@ -505,8 +505,8 @@ module MxHero::API
|
|
505
505
|
# Validate if the an user and password match
|
506
506
|
#
|
507
507
|
def valid_user_credentials?(user, password)
|
508
|
-
validate_user_credential_url = user_url(user) + "password
|
509
|
-
response = call(:
|
508
|
+
validate_user_credential_url = user_url(user) + "/password/check"
|
509
|
+
response = call(:post, validate_user_credential_url, password, { content_type: 'text/plain' })
|
510
510
|
response.status == 204
|
511
511
|
end
|
512
512
|
|
@@ -563,11 +563,11 @@ module MxHero::API
|
|
563
563
|
end
|
564
564
|
|
565
565
|
def user_url(user)
|
566
|
-
users_url + "/#{user}
|
566
|
+
users_url + "/#{user}"
|
567
567
|
end
|
568
568
|
|
569
569
|
def user_domains_url(user)
|
570
|
-
user_url(user) + "domains"
|
570
|
+
user_url(user) + "/domains"
|
571
571
|
end
|
572
572
|
|
573
573
|
def users_for_domain_url(domain)
|
@@ -575,7 +575,7 @@ module MxHero::API
|
|
575
575
|
end
|
576
576
|
|
577
577
|
def user_with_domain_url(user,domain)
|
578
|
-
user_url(user) + "domains/#{domain}/"
|
578
|
+
user_url(user) + "/domains/#{domain}/"
|
579
579
|
end
|
580
580
|
|
581
581
|
def user_url_set_password(user,new_password)
|
@@ -651,7 +651,7 @@ module MxHero::API
|
|
651
651
|
|
652
652
|
def accounts_by_domain_url(domain, filter_account = nil)
|
653
653
|
filter = filter_account ? "?account=#{filter_account}" : ''
|
654
|
-
domain_by_id_url(domain) + 'accounts' + filter
|
654
|
+
domain_by_id_url(domain) + '/accounts' + filter
|
655
655
|
end
|
656
656
|
|
657
657
|
def domain_rule_url(domain, id)
|
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.9 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.9"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib"]
|
10
10
|
s.authors = ["Maximiliano Dello Russo", "Juan Pablo Royo", "mxHero"]
|
11
|
-
s.date = "
|
11
|
+
s.date = "2020-06-09"
|
12
12
|
s.description = "A gem to provide easy access to the API of MxHero platform (http://www.mxhero.com/)"
|
13
13
|
s.email = ["maxidr@mxhero.com", "juanpablo.royo@gmail.com", "mxhero@mxhero.com"]
|
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/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"]
|
15
15
|
s.homepage = "http://github.com/mxhero/mxhero-api"
|
16
16
|
s.licenses = ["GPL-3"]
|
17
17
|
s.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
18
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
|
@@ -1,111 +1,194 @@
|
|
1
1
|
---
|
2
2
|
http_interactions:
|
3
|
-
- request:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://admin:password@test.mxhero.com/webapi/api/v1/users/test@mxhero.com/password/check
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: xxx1234
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- HTTPClient/1.0 (2.7.1, ruby 2.3.0 (2015-12-25))
|
12
|
+
Accept:
|
13
|
+
- application/json
|
14
|
+
Date:
|
15
|
+
- Tue, 09 Jun 2020 18:10:59 GMT
|
16
|
+
Content-Type:
|
17
|
+
- text/plain
|
18
|
+
X-Mxhero-As-User:
|
19
|
+
- tester@mxhero.com
|
20
|
+
Authorization:
|
21
|
+
- Basic YWRtaW46cGFzc3dvcmQ=
|
22
|
+
response:
|
23
|
+
status:
|
24
|
+
code: 204
|
25
|
+
message:
|
26
|
+
headers:
|
27
|
+
Server:
|
28
|
+
- nginx/1.17.10
|
29
|
+
Date:
|
30
|
+
- Tue, 09 Jun 2020 18:10:59 GMT
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
Set-Cookie:
|
34
|
+
- JSESSIONID=A45FB13F6416E2F7704C5F5839F8BF0F; Path=/webapi; HttpOnly
|
35
|
+
X-Application-Context:
|
36
|
+
- application:dev
|
37
|
+
X-Content-Type-Options:
|
38
|
+
- nosniff
|
39
|
+
X-Xss-Protection:
|
40
|
+
- 1; mode=block
|
41
|
+
Cache-Control:
|
42
|
+
- no-cache, no-store, max-age=0, must-revalidate
|
43
|
+
Pragma:
|
44
|
+
- no-cache
|
45
|
+
Expires:
|
46
|
+
- "0"
|
47
|
+
X-Frame-Options:
|
48
|
+
- DENY
|
49
|
+
Access-Control-Allow-Origin:
|
50
|
+
- "*"
|
51
|
+
Access-Control-Allow-Credentials:
|
52
|
+
- "true"
|
53
|
+
Access-Control-Allow-Methods:
|
54
|
+
- GET, PUT, POST, DELETE, PATCH, OPTIONS
|
55
|
+
Access-Control-Allow-Headers:
|
56
|
+
- DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,x-authorization-storage
|
57
|
+
body:
|
58
|
+
encoding: UTF-8
|
59
|
+
string: ""
|
60
|
+
http_version:
|
61
|
+
recorded_at: Tue, 09 Jun 2020 18:10:59 GMT
|
62
|
+
- request:
|
63
|
+
method: post
|
64
|
+
uri: http://admin:password@test.mxhero.com/webapi/api/v1/users/admin/password/check
|
65
|
+
body:
|
66
|
+
encoding: UTF-8
|
67
|
+
string: wrong
|
68
|
+
headers:
|
69
|
+
User-Agent:
|
70
|
+
- HTTPClient/1.0 (2.7.1, ruby 2.3.0 (2015-12-25))
|
71
|
+
Accept:
|
72
|
+
- application/json
|
73
|
+
Date:
|
74
|
+
- Tue, 09 Jun 2020 18:10:59 GMT
|
75
|
+
Content-Type:
|
76
|
+
- text/plain
|
77
|
+
X-Mxhero-As-User:
|
78
|
+
- tester@mxhero.com
|
79
|
+
Cookie:
|
80
|
+
- JSESSIONID=A45FB13F6416E2F7704C5F5839F8BF0F
|
81
|
+
Authorization:
|
82
|
+
- Basic YWRtaW46cGFzc3dvcmQ=
|
83
|
+
response:
|
84
|
+
status:
|
85
|
+
code: 404
|
86
|
+
message:
|
87
|
+
headers:
|
88
|
+
Server:
|
89
|
+
- nginx/1.17.10
|
90
|
+
Date:
|
91
|
+
- Tue, 09 Jun 2020 18:11:00 GMT
|
92
|
+
Content-Type:
|
93
|
+
- application/json;charset=UTF-8
|
94
|
+
Transfer-Encoding:
|
95
|
+
- chunked
|
96
|
+
Connection:
|
97
|
+
- keep-alive
|
98
|
+
Vary:
|
99
|
+
- Accept-Encoding
|
100
|
+
Set-Cookie:
|
101
|
+
- JSESSIONID=1210F2BCAA52EEE46A2E99A296CE1410; Path=/webapi; HttpOnly
|
102
|
+
X-Application-Context:
|
103
|
+
- application:dev
|
104
|
+
X-Content-Type-Options:
|
105
|
+
- nosniff
|
106
|
+
X-Xss-Protection:
|
107
|
+
- 1; mode=block
|
108
|
+
Cache-Control:
|
109
|
+
- no-cache, no-store, max-age=0, must-revalidate
|
110
|
+
Pragma:
|
111
|
+
- no-cache
|
112
|
+
Expires:
|
113
|
+
- "0"
|
114
|
+
X-Frame-Options:
|
115
|
+
- DENY
|
116
|
+
Access-Control-Allow-Origin:
|
117
|
+
- "*"
|
118
|
+
Access-Control-Allow-Credentials:
|
119
|
+
- "true"
|
120
|
+
Access-Control-Allow-Methods:
|
121
|
+
- GET, PUT, POST, DELETE, PATCH, OPTIONS
|
122
|
+
Access-Control-Allow-Headers:
|
123
|
+
- DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,x-authorization-storage
|
124
|
+
body:
|
125
|
+
encoding: UTF-8
|
126
|
+
string: '{"timestamp":1591726260165,"status":404,"error":"user.not.found.or.invalid.password","message":"user.not.found.or.invalid.password","path":"/webapi/api/v1/users/admin/password/check"}'
|
127
|
+
http_version:
|
128
|
+
recorded_at: Tue, 09 Jun 2020 18:11:00 GMT
|
129
|
+
- request:
|
130
|
+
method: post
|
131
|
+
uri: http://admin:password@test.mxhero.com/webapi/api/v1/users/inexistent.user/password/check
|
132
|
+
body:
|
133
|
+
encoding: UTF-8
|
134
|
+
string: xxx
|
135
|
+
headers:
|
136
|
+
User-Agent:
|
137
|
+
- HTTPClient/1.0 (2.7.1, ruby 2.3.0 (2015-12-25))
|
138
|
+
Accept:
|
139
|
+
- application/json
|
140
|
+
Date:
|
141
|
+
- Tue, 09 Jun 2020 18:11:00 GMT
|
142
|
+
Content-Type:
|
143
|
+
- text/plain
|
144
|
+
X-Mxhero-As-User:
|
145
|
+
- tester@mxhero.com
|
146
|
+
Cookie:
|
147
|
+
- JSESSIONID=1210F2BCAA52EEE46A2E99A296CE1410
|
148
|
+
Authorization:
|
149
|
+
- Basic YWRtaW46cGFzc3dvcmQ=
|
150
|
+
response:
|
151
|
+
status:
|
152
|
+
code: 404
|
153
|
+
message:
|
154
|
+
headers:
|
155
|
+
Server:
|
156
|
+
- nginx/1.17.10
|
157
|
+
Date:
|
158
|
+
- Tue, 09 Jun 2020 18:11:00 GMT
|
159
|
+
Content-Type:
|
160
|
+
- application/json;charset=UTF-8
|
161
|
+
Transfer-Encoding:
|
162
|
+
- chunked
|
163
|
+
Connection:
|
164
|
+
- keep-alive
|
165
|
+
Vary:
|
166
|
+
- Accept-Encoding
|
167
|
+
X-Application-Context:
|
168
|
+
- application:dev
|
169
|
+
X-Content-Type-Options:
|
170
|
+
- nosniff
|
171
|
+
X-Xss-Protection:
|
172
|
+
- 1; mode=block
|
173
|
+
Cache-Control:
|
174
|
+
- no-cache, no-store, max-age=0, must-revalidate
|
175
|
+
Pragma:
|
176
|
+
- no-cache
|
177
|
+
Expires:
|
178
|
+
- "0"
|
179
|
+
X-Frame-Options:
|
180
|
+
- DENY
|
181
|
+
Access-Control-Allow-Origin:
|
182
|
+
- "*"
|
183
|
+
Access-Control-Allow-Credentials:
|
184
|
+
- "true"
|
185
|
+
Access-Control-Allow-Methods:
|
186
|
+
- GET, PUT, POST, DELETE, PATCH, OPTIONS
|
187
|
+
Access-Control-Allow-Headers:
|
188
|
+
- DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,x-authorization-storage
|
189
|
+
body:
|
190
|
+
encoding: UTF-8
|
191
|
+
string: '{"timestamp":1591726260540,"status":404,"error":"user.not.found.or.invalid.password","message":"user.not.found.or.invalid.password","path":"/webapi/api/v1/users/inexistent.user/password/check"}'
|
192
|
+
http_version:
|
193
|
+
recorded_at: Tue, 09 Jun 2020 18:11:00 GMT
|
194
|
+
recorded_with: VCR 3.0.1
|
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
@@ -24,7 +24,7 @@ class MxHeroAPITest < Minitest::Test
|
|
24
24
|
rules = obtain_rules(domain)
|
25
25
|
existing_rule = rules.first
|
26
26
|
updated_rule = existing_rule.clone
|
27
|
-
|
27
|
+
|
28
28
|
property = updated_rule[:properties].find { |property| property[:propertyKey] == 'return.message' }
|
29
29
|
property[:propertyValue] = 'another content'
|
30
30
|
updated_rule[:name] = updated_rule[:name] + ' more name'
|
@@ -36,6 +36,7 @@ class MxHeroAPITest < Minitest::Test
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
+
|
39
40
|
=begin
|
40
41
|
def test_rule_status
|
41
42
|
VCR.use_cassette('rule_status') do
|
@@ -43,9 +44,9 @@ class MxHeroAPITest < Minitest::Test
|
|
43
44
|
rules = obtain_rules(mx_domain)
|
44
45
|
existing_rule = rules.find { |r| r[:enabled] }
|
45
46
|
updated_rule = existing_rule.clone
|
46
|
-
|
47
|
+
|
47
48
|
assert_equal @api.rule_status(mx_domain, updated_rule[:id], false).code, 200
|
48
|
-
|
49
|
+
|
49
50
|
rule = @api.domain_rule(updated_rule[:domain], updated_rule[:id])
|
50
51
|
assert !rule[:enabled]
|
51
52
|
|
@@ -54,7 +55,7 @@ class MxHeroAPITest < Minitest::Test
|
|
54
55
|
rule = @api.domain_rule(updated_rule[:domain], updated_rule[:id])
|
55
56
|
assert rule[:enabled]
|
56
57
|
end
|
57
|
-
end
|
58
|
+
end
|
58
59
|
|
59
60
|
def test_domain_rule
|
60
61
|
VCR.use_cassette('domain_rule') do
|
@@ -138,7 +139,7 @@ class MxHeroAPITest < Minitest::Test
|
|
138
139
|
assert response.key? :elements
|
139
140
|
account = response[:elements].first
|
140
141
|
start_with = account[:account][0..2]
|
141
|
-
|
142
|
+
|
142
143
|
response = @api.accounts_by_domain(domain, without_group: true, account: start_with)
|
143
144
|
assert response[:totalElements] >= 1
|
144
145
|
find_account = response[:elements].first
|
@@ -148,7 +149,7 @@ class MxHeroAPITest < Minitest::Test
|
|
148
149
|
|
149
150
|
def test_accounts_by_domain_filtered
|
150
151
|
VCR.use_cassette('accounts_filtered') do
|
151
|
-
# The test environment have 4 accounts:
|
152
|
+
# The test environment have 4 accounts:
|
152
153
|
# agent.smith, john.doe, test, test1, test2
|
153
154
|
response = @api.accounts_by_domain(domain, account: 'test')
|
154
155
|
assert_equal 3, response[:elements].count
|
@@ -176,7 +177,7 @@ class MxHeroAPITest < Minitest::Test
|
|
176
177
|
assert response
|
177
178
|
end
|
178
179
|
end
|
179
|
-
|
180
|
+
|
180
181
|
#def test_try_to_create_rule_that_alredy_exist
|
181
182
|
# VCR.use_cassette('create_rule_alredy_exist') do
|
182
183
|
# response = @api.create_rule(create_rule_msg)
|
@@ -186,10 +187,10 @@ class MxHeroAPITest < Minitest::Test
|
|
186
187
|
# assert_equal "rules.already.exists.for.component", new_response.msg[:developerMessage]
|
187
188
|
# end
|
188
189
|
#end
|
189
|
-
|
190
|
+
|
190
191
|
def test_create_rule_for_domain
|
191
192
|
VCR.use_cassette('create_rule_for_domain') do
|
192
|
-
delete_all_rules
|
193
|
+
delete_all_rules
|
193
194
|
response = @api.create_rule_for_domain(domain, rule)
|
194
195
|
assert response.code == 201
|
195
196
|
new_response = @api.create_rule_for_domain(domain, rule)
|
@@ -199,20 +200,20 @@ class MxHeroAPITest < Minitest::Test
|
|
199
200
|
end
|
200
201
|
|
201
202
|
def test_account_properties
|
202
|
-
VCR.use_cassette('account_properties') do
|
203
|
+
VCR.use_cassette('account_properties') do
|
203
204
|
account = 'test'
|
204
205
|
response = @api.account_properties(domain, account)
|
205
206
|
assert_equal 200, response.code
|
206
207
|
assert response.is_a? MxHero::API::Response
|
207
208
|
properties = response.msg
|
208
|
-
%w( email fax lastname mobile name opt1 opt2 opt3 telephone ).each do |property|
|
209
|
+
%w( email fax lastname mobile name opt1 opt2 opt3 telephone ).each do |property|
|
209
210
|
assert properties.key? property
|
210
211
|
end
|
211
212
|
end
|
212
213
|
end
|
213
214
|
|
214
215
|
def test_account_propertes_not_found
|
215
|
-
VCR.use_cassette('account_properties_not_found') do
|
216
|
+
VCR.use_cassette('account_properties_not_found') do
|
216
217
|
begin
|
217
218
|
account = 'xxxxx'
|
218
219
|
response = @api.account_properties(domain, account)
|
@@ -225,12 +226,12 @@ class MxHeroAPITest < Minitest::Test
|
|
225
226
|
end
|
226
227
|
|
227
228
|
def test_update_account_properties
|
228
|
-
VCR.use_cassette('update_account_properties') do
|
229
|
+
VCR.use_cassette('update_account_properties') do
|
229
230
|
account = 'test'
|
230
231
|
response = @api.account_properties(domain, account)
|
231
232
|
properties = response.msg
|
232
|
-
properties['lastname'] = ( properties['lastname'] || '' ) + ' CHANGED'
|
233
|
-
properties['name'] = ( properties['name'] || '' ) + ' CHANGED'
|
233
|
+
properties['lastname'] = ( properties['lastname'] || '' ) + ' CHANGED'
|
234
|
+
properties['name'] = ( properties['name'] || '' ) + ' CHANGED'
|
234
235
|
properties['fax'] = nil
|
235
236
|
response = @api.update_account_properties(domain, account, properties)
|
236
237
|
assert_equal 200, response.code
|
@@ -241,7 +242,7 @@ class MxHeroAPITest < Minitest::Test
|
|
241
242
|
assert_equal properties['fax'], response.msg['fax']
|
242
243
|
end
|
243
244
|
end
|
244
|
-
|
245
|
+
|
245
246
|
def test_update_accounts_group_scope
|
246
247
|
VCR.use_cassette('update_accounts_group_scope') do
|
247
248
|
|
@@ -268,7 +269,7 @@ class MxHeroAPITest < Minitest::Test
|
|
268
269
|
end
|
269
270
|
end
|
270
271
|
|
271
|
-
|
272
|
+
|
272
273
|
|
273
274
|
def test_domain
|
274
275
|
VCR.use_cassette('test_domain') do
|
@@ -294,8 +295,8 @@ class MxHeroAPITest < Minitest::Test
|
|
294
295
|
end.new
|
295
296
|
end
|
296
297
|
|
297
|
-
err = assert_raises ::RuntimeError do
|
298
|
-
@api.domain('nop')
|
298
|
+
err = assert_raises ::RuntimeError do
|
299
|
+
@api.domain('nop')
|
299
300
|
end
|
300
301
|
|
301
302
|
assert_match /An error ocurred when try to fetch the domain nop/, err.message
|
@@ -305,8 +306,8 @@ class MxHeroAPITest < Minitest::Test
|
|
305
306
|
def test_ldap_info
|
306
307
|
VCR.use_cassette('ldap_info') do
|
307
308
|
ldap = @api.ldap_info('mxhero.com')
|
308
|
-
%w{domain directoryType addres port sslFlag user password filter
|
309
|
-
base nextUpdate lastUpdate error overrideFlag
|
309
|
+
%w{domain directoryType addres port sslFlag user password filter
|
310
|
+
base nextUpdate lastUpdate error overrideFlag
|
310
311
|
dnAuthenticate properties}.each do |field|
|
311
312
|
assert ldap.key?(field.to_sym), "must retrieve ldap hash info with key: #{field}"
|
312
313
|
end
|
@@ -342,7 +343,7 @@ class MxHeroAPITest < Minitest::Test
|
|
342
343
|
response = @api.save_system_property('test.key', 'test.value')
|
343
344
|
assert response
|
344
345
|
assert_equal 'test.value', @api.system_properties('test.key')
|
345
|
-
|
346
|
+
|
346
347
|
response = @api.save_system_property('test.key', 'test.value.change')
|
347
348
|
assert response
|
348
349
|
assert_equal 'test.value.change', @api.system_properties('test.key')
|
@@ -369,13 +370,13 @@ class MxHeroAPITest < Minitest::Test
|
|
369
370
|
assert !users.empty?
|
370
371
|
assert users.find { |user| user[:userName] == 'mxhero@mxhero.com' }
|
371
372
|
end
|
372
|
-
end
|
373
|
+
end
|
373
374
|
|
374
375
|
def test_fetch_user
|
375
376
|
VCR.use_cassette('fetch_user') do
|
376
377
|
user = @api.fetch_user('mxhero@mxhero.com')
|
377
378
|
refute user.nil?
|
378
|
-
|
379
|
+
|
379
380
|
user = @api.fetch_user('not-exist@mxhero.com')
|
380
381
|
assert user.nil?
|
381
382
|
end
|
@@ -384,7 +385,7 @@ class MxHeroAPITest < Minitest::Test
|
|
384
385
|
def test_create_user
|
385
386
|
VCR.use_cassette('create_user') do
|
386
387
|
user_info = {
|
387
|
-
name: 'test', lastName: 'test last name',
|
388
|
+
name: 'test', lastName: 'test last name',
|
388
389
|
notifyEmail: 'test@mxhero.com', userName: 'test@mxhero.com'
|
389
390
|
}
|
390
391
|
created = @api.create_user(user_info, 'mxhero.com', 'stage.mxhero.com')
|
@@ -426,18 +427,28 @@ class MxHeroAPITest < Minitest::Test
|
|
426
427
|
end
|
427
428
|
end
|
428
429
|
=end
|
430
|
+
|
431
|
+
def test_valid_user_credentials
|
432
|
+
VCR.use_cassette('validate_user_credential') do
|
433
|
+
assert @api.valid_user_credentials?('test@mxhero.com', 'xxx1234')
|
434
|
+
refute @api.valid_user_credentials?('admin', 'wrong')
|
435
|
+
refute @api.valid_user_credentials?('inexistent.user', 'xxx')
|
436
|
+
end
|
437
|
+
end
|
438
|
+
|
439
|
+
|
429
440
|
private
|
430
|
-
|
441
|
+
|
431
442
|
def delete_all_rules
|
432
443
|
response = @api.rules_for_domain(domain)
|
433
|
-
response.msg.each do |rule|
|
434
|
-
@api.delete_rule(domain, rule[:id])
|
444
|
+
response.msg.each do |rule|
|
445
|
+
@api.delete_rule(domain, rule[:id])
|
435
446
|
end
|
436
447
|
end
|
437
448
|
|
438
449
|
def obtain_rules(domain)
|
439
450
|
response = @api.rules_for_domain(domain)
|
440
|
-
if response.msg.nil? || response.msg.empty?
|
451
|
+
if response.msg.nil? || response.msg.empty?
|
441
452
|
created = @api.create_rule_for_domain(domain, rule)
|
442
453
|
return [ created.msg ]
|
443
454
|
end
|
@@ -475,29 +486,29 @@ class MxHeroAPITest < Minitest::Test
|
|
475
486
|
end
|
476
487
|
|
477
488
|
def rule
|
478
|
-
{ :domain => domain,
|
479
|
-
:twoWays => false,
|
480
|
-
:enabled => true,
|
481
|
-
:name => "The rules for sales",
|
482
|
-
:created => "1375998105095",
|
483
|
-
:fromDirection => { :id => nil,
|
484
|
-
:directionType => "domain",
|
485
|
-
:freeValue => domain,
|
486
|
-
:domain => domain,
|
487
|
-
:account => nil, :group => nil },
|
488
|
-
:toDirection => { :id => nil,
|
489
|
-
:directionType => "anyone",
|
490
|
-
:freeValue => "Anyone",
|
491
|
-
:domain => domain,
|
492
|
-
:account => nil, :group => nil},
|
489
|
+
{ :domain => domain,
|
490
|
+
:twoWays => false,
|
491
|
+
:enabled => true,
|
492
|
+
:name => "The rules for sales",
|
493
|
+
:created => "1375998105095",
|
494
|
+
:fromDirection => { :id => nil,
|
495
|
+
:directionType => "domain",
|
496
|
+
:freeValue => domain,
|
497
|
+
:domain => domain,
|
498
|
+
:account => nil, :group => nil },
|
499
|
+
:toDirection => { :id => nil,
|
500
|
+
:directionType => "anyone",
|
501
|
+
:freeValue => "Anyone",
|
502
|
+
:domain => domain,
|
503
|
+
:account => nil, :group => nil},
|
493
504
|
:properties => [
|
494
|
-
{ :propertyKey => "return.message",
|
495
|
-
:propertyValue => "<hr /><p><em><span style=\"color:green\">Think before you print and save a tree.</span></em></p>" },
|
496
|
-
{ :propertyKey => "return.message.plain",
|
497
|
-
:propertyValue => "\r\n----------------\r\nThink before you print and save a tree.r\n\r\n"},
|
498
|
-
{ :propertyKey => "interParsing",
|
505
|
+
{ :propertyKey => "return.message",
|
506
|
+
:propertyValue => "<hr /><p><em><span style=\"color:green\">Think before you print and save a tree.</span></em></p>" },
|
507
|
+
{ :propertyKey => "return.message.plain",
|
508
|
+
:propertyValue => "\r\n----------------\r\nThink before you print and save a tree.r\n\r\n"},
|
509
|
+
{ :propertyKey => "interParsing",
|
499
510
|
:propertyValue => true}
|
500
|
-
],
|
511
|
+
],
|
501
512
|
:component => "org.mxhero.feature.disclaimer" }
|
502
513
|
end
|
503
514
|
|
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.9
|
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-06-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: vcr
|
@@ -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
|
@@ -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
|