mxhero-api 1.2.8 → 1.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/communication.rb +7 -5
- data/lib/mxhero-api.rb +2 -2
- data/mxhero-api.gemspec +3 -3
- data/test/fixtures/api/validate_user_credential.yml +192 -109
- data/test/test_mxhero_api.rb +61 -50
- metadata +2 -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/mxhero-api.rb
CHANGED
@@ -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
|
|
data/mxhero-api.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
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 = "2020-
|
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
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"]
|
@@ -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_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: 2020-
|
13
|
+
date: 2020-06-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: vcr
|