mxhero-api 0.1.5 → 0.1.6
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.
- data/VERSION +1 -1
- data/lib/mxhero-api.rb +8 -0
- data/mxhero-api.gemspec +4 -4
- data/test/fixtures/api/accounts_from_domain.yml +10 -10
- data/test/fixtures/api/create_rule_alredy_exist.yml +13 -23
- data/test/fixtures/api/create_rule_for_domain.yml +5 -5
- data/test/fixtures/api/create_rule_success.yml +8 -17
- data/test/fixtures/api/delete_rule.yml +118 -0
- data/test/fixtures/api/domain_by_id.yml +8 -5
- data/test/fixtures/api/domain_by_id_not_found.yml +6 -3
- data/test/fixtures/api/domain_rule.yml +100 -20
- data/test/fixtures/api/domains.yml +2 -2
- data/test/fixtures/api/rules_for_domain.yml +52 -19
- data/test/fixtures/api/update_rule.yml +101 -26
- data/test/test_mxhero_api.rb +76 -48
- metadata +5 -7
- data/test/fixtures/api/service_create_footer.yml +0 -44
- data/test/fixtures/api/service_footer_for_domain.yml +0 -73
@@ -30,10 +30,10 @@ http_interactions:
|
|
30
30
|
Y2h1bmtlZA==
|
31
31
|
!binary "RGF0ZQ==":
|
32
32
|
- !binary |-
|
33
|
-
|
33
|
+
RnJpLCAwOSBBdWcgMjAxMyAwNjozNDowNCBHTVQ=
|
34
34
|
body:
|
35
35
|
encoding: US-ASCII
|
36
36
|
string: ! '{"elements":[{"domain":"tesla.com","server":"tesla.com","creationDate":1369837819000,"updatedDate":1369837819000,"aliases":null,"ldap":null}],"totalElements":1,"totalPages":1,"actualPage":1}'
|
37
37
|
http_version:
|
38
|
-
recorded_at:
|
38
|
+
recorded_at: Tue, 13 Aug 2013 16:33:59 GMT
|
39
39
|
recorded_with: VCR 2.5.0
|
@@ -11,6 +11,8 @@ http_interactions:
|
|
11
11
|
- application/json
|
12
12
|
Content-Type:
|
13
13
|
- application/json
|
14
|
+
Authorization:
|
15
|
+
- Basic YWRtaW46cGFzc3dvcmQ=
|
14
16
|
response:
|
15
17
|
status:
|
16
18
|
code: 200
|
@@ -28,25 +30,56 @@ http_interactions:
|
|
28
30
|
Y2h1bmtlZA==
|
29
31
|
!binary "RGF0ZQ==":
|
30
32
|
- !binary |-
|
31
|
-
|
33
|
+
RnJpLCAwOSBBdWcgMjAxMyAwNjozNDowNCBHTVQ=
|
32
34
|
body:
|
33
|
-
encoding: ASCII
|
34
|
-
string: !
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
35
|
+
encoding: US-ASCII
|
36
|
+
string: ! '[{"id":114,"domain":"tesla.com","name":"blah","created":1376029845000,"updated":1376029845000,"enabled":true,"twoWays":false,"adminOrder":null,"component":"org.mxhero.feature.disclaimer","fromDirection":{"id":213,"directionType":"domain","freeValue":"tesla.com","domain":null,"account":null,"group":null},"toDirection":{"id":214,"directionType":"anyone","freeValue":"anyone","domain":null,"account":null,"group":null},"properties":[{"propertyKey":"return.message","propertyValue":"<BODY>\n <P
|
37
|
+
STYLE=\"text-align:left;\">\n <SPAN STYLE=\"letter-spacing:0px;color:#000000;font-size:12px;font-family:''Arial'';\">This
|
38
|
+
message is intended only for ${mxrecipient}. If you are not the intended recipient
|
39
|
+
you are notified that disclosing, copying, distributing or taking any action
|
40
|
+
in reliance on the contents of this information is strictly prohibited.</SPAN>\n </P>\n</BODY>"},{"propertyKey":"return.message.plain","propertyValue":"This
|
41
|
+
message is intended only for ${mxrecipient}. If you are not the intended recipient
|
42
|
+
you are notified that disclosing, copying, distributing or taking any action
|
43
|
+
in reliance on the contents of this information is strictly prohibited."},{"propertyKey":"return.message.rte","propertyValue":"<TextFlow
|
44
|
+
whiteSpaceCollapse=\"preserve\" version=\"2.0.0\" xmlns=\"http://ns.adobe.com/textLayout/2008\"><p><span>This
|
45
|
+
message is intended only for ${mxrecipient}. If you are not the intended recipient
|
46
|
+
you are notified that disclosing, copying, distributing or taking any action
|
47
|
+
in reliance on the contents of this information is strictly prohibited.</span></p></TextFlow>"}]},{"id":115,"domain":"tesla.com","name":"another
|
48
|
+
rule ","created":1376029963000,"updated":1376029963000,"enabled":true,"twoWays":false,"adminOrder":null,"component":"org.mxhero.feature.disclaimer","fromDirection":{"id":215,"directionType":"group","freeValue":"development","domain":"tesla.com","account":null,"group":"development"},"toDirection":{"id":216,"directionType":"anyone","freeValue":"anyone","domain":null,"account":null,"group":null},"properties":[{"propertyKey":"return.message","propertyValue":"<BODY>\n <P
|
49
|
+
STYLE=\"text-align:left;\">\n <SPAN STYLE=\"letter-spacing:0px;color:#000000;font-size:12px;font-family:''Arial'';\">This
|
50
|
+
message is intended only for ${mxrecipient}. If you are not the intended recipient
|
51
|
+
you are notified that disclosing, copying, distributing or taking any action
|
52
|
+
in reliance on the contents of this information is strictly prohibited.</SPAN>\n </P>\n</BODY>"},{"propertyKey":"return.message.plain","propertyValue":"This
|
53
|
+
message is intended only for ${mxrecipient}. If you are not the intended recipient
|
54
|
+
you are notified that disclosing, copying, distributing or taking any action
|
55
|
+
in reliance on the contents of this information is strictly prohibited."},{"propertyKey":"return.message.rte","propertyValue":"<TextFlow
|
56
|
+
whiteSpaceCollapse=\"preserve\" version=\"2.0.0\" xmlns=\"http://ns.adobe.com/textLayout/2008\"><p><span>This
|
57
|
+
message is intended only for ${mxrecipient}. If you are not the intended recipient
|
58
|
+
you are notified that disclosing, copying, distributing or taking any action
|
59
|
+
in reliance on the contents of this information is strictly prohibited.</span></p></TextFlow>"}]},{"id":116,"domain":"tesla.com","name":"marketing
|
60
|
+
rule","created":1376029996000,"updated":1376029996000,"enabled":true,"twoWays":false,"adminOrder":null,"component":"org.mxhero.feature.disclaimer","fromDirection":{"id":217,"directionType":"domain","freeValue":"tesla.com","domain":"tesla.com","account":null,"group":null},"toDirection":{"id":218,"directionType":"group","freeValue":"marketing","domain":"tesla.com","account":null,"group":"marketing"},"properties":[{"propertyKey":"return.message","propertyValue":"<BODY>\n <P
|
61
|
+
STYLE=\"text-align:left;\">\n <SPAN STYLE=\"letter-spacing:0px;color:#000000;font-size:12px;font-family:''Arial'';\">This
|
62
|
+
message is intended only for ${mxrecipient}. If you are not the intended recipient
|
63
|
+
you are notified that disclosing, copying, distributing or taking any action
|
64
|
+
in reliance on the contents of this information is strictly prohibited.</SPAN>\n </P>\n</BODY>"},{"propertyKey":"return.message.plain","propertyValue":"This
|
65
|
+
message is intended only for ${mxrecipient}. If you are not the intended recipient
|
66
|
+
you are notified that disclosing, copying, distributing or taking any action
|
67
|
+
in reliance on the contents of this information is strictly prohibited."},{"propertyKey":"return.message.rte","propertyValue":"<TextFlow
|
68
|
+
whiteSpaceCollapse=\"preserve\" version=\"2.0.0\" xmlns=\"http://ns.adobe.com/textLayout/2008\"><p><span>This
|
69
|
+
message is intended only for ${mxrecipient}. If you are not the intended recipient
|
70
|
+
you are notified that disclosing, copying, distributing or taking any action
|
71
|
+
in reliance on the contents of this information is strictly prohibited.</span></p></TextFlow>"}]},{"id":117,"domain":"tesla.com","name":"marketing","created":1376030034000,"updated":1376030034000,"enabled":true,"twoWays":false,"adminOrder":null,"component":"org.mxhero.feature.disclaimer","fromDirection":{"id":219,"directionType":"group","freeValue":"marketing","domain":"tesla.com","account":null,"group":"marketing"},"toDirection":{"id":220,"directionType":"anyoneelse","freeValue":"anyoneelse","domain":null,"account":null,"group":null},"properties":[{"propertyKey":"return.message","propertyValue":"<BODY>\n <P
|
72
|
+
STYLE=\"text-align:left;\">\n <SPAN STYLE=\"letter-spacing:0px;color:#000000;font-size:12px;font-family:''Arial'';\">This
|
73
|
+
message is intended only for ${mxrecipient}. If you are not the intended recipient
|
74
|
+
you are notified that disclosing, copying, distributing or taking any action
|
75
|
+
in reliance on the contents of this information is strictly prohibited.</SPAN>\n </P>\n</BODY>"},{"propertyKey":"return.message.plain","propertyValue":"This
|
76
|
+
message is intended only for ${mxrecipient}. If you are not the intended recipient
|
77
|
+
you are notified that disclosing, copying, distributing or taking any action
|
78
|
+
in reliance on the contents of this information is strictly prohibited."},{"propertyKey":"return.message.rte","propertyValue":"<TextFlow
|
79
|
+
whiteSpaceCollapse=\"preserve\" version=\"2.0.0\" xmlns=\"http://ns.adobe.com/textLayout/2008\"><p><span>This
|
80
|
+
message is intended only for ${mxrecipient}. If you are not the intended recipient
|
81
|
+
you are notified that disclosing, copying, distributing or taking any action
|
82
|
+
in reliance on the contents of this information is strictly prohibited.</span></p></TextFlow>"}]}]'
|
50
83
|
http_version:
|
51
|
-
recorded_at:
|
84
|
+
recorded_at: Tue, 13 Aug 2013 16:33:59 GMT
|
52
85
|
recorded_with: VCR 2.5.0
|
@@ -1,19 +1,96 @@
|
|
1
1
|
---
|
2
2
|
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://admin:password@localhost:8080/webapi/api/v1/domains/tesla.com/rules
|
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: !binary |-
|
20
|
+
T0s=
|
21
|
+
headers:
|
22
|
+
!binary "U2VydmVy":
|
23
|
+
- !binary |-
|
24
|
+
QXBhY2hlLUNveW90ZS8xLjE=
|
25
|
+
!binary "Q29udGVudC1UeXBl":
|
26
|
+
- !binary |-
|
27
|
+
YXBwbGljYXRpb24vanNvbg==
|
28
|
+
!binary "VHJhbnNmZXItRW5jb2Rpbmc=":
|
29
|
+
- !binary |-
|
30
|
+
Y2h1bmtlZA==
|
31
|
+
!binary "RGF0ZQ==":
|
32
|
+
- !binary |-
|
33
|
+
RnJpLCAwOSBBdWcgMjAxMyAwNjozNDowNCBHTVQ=
|
34
|
+
body:
|
35
|
+
encoding: US-ASCII
|
36
|
+
string: ! '[{"id":115,"domain":"tesla.com","name":"another rule ","created":1376029963000,"updated":1376029963000,"enabled":true,"twoWays":false,"adminOrder":null,"component":"org.mxhero.feature.disclaimer","fromDirection":{"id":215,"directionType":"group","freeValue":"development","domain":"tesla.com","account":null,"group":"development"},"toDirection":{"id":216,"directionType":"anyone","freeValue":"anyone","domain":null,"account":null,"group":null},"properties":[{"propertyKey":"return.message","propertyValue":"<BODY>\n <P
|
37
|
+
STYLE=\"text-align:left;\">\n <SPAN STYLE=\"letter-spacing:0px;color:#000000;font-size:12px;font-family:''Arial'';\">This
|
38
|
+
message is intended only for ${mxrecipient}. If you are not the intended recipient
|
39
|
+
you are notified that disclosing, copying, distributing or taking any action
|
40
|
+
in reliance on the contents of this information is strictly prohibited.</SPAN>\n </P>\n</BODY>"},{"propertyKey":"return.message.plain","propertyValue":"This
|
41
|
+
message is intended only for ${mxrecipient}. If you are not the intended recipient
|
42
|
+
you are notified that disclosing, copying, distributing or taking any action
|
43
|
+
in reliance on the contents of this information is strictly prohibited."},{"propertyKey":"return.message.rte","propertyValue":"<TextFlow
|
44
|
+
whiteSpaceCollapse=\"preserve\" version=\"2.0.0\" xmlns=\"http://ns.adobe.com/textLayout/2008\"><p><span>This
|
45
|
+
message is intended only for ${mxrecipient}. If you are not the intended recipient
|
46
|
+
you are notified that disclosing, copying, distributing or taking any action
|
47
|
+
in reliance on the contents of this information is strictly prohibited.</span></p></TextFlow>"}]},{"id":116,"domain":"tesla.com","name":"marketing
|
48
|
+
rule","created":1376029996000,"updated":1376029996000,"enabled":true,"twoWays":false,"adminOrder":null,"component":"org.mxhero.feature.disclaimer","fromDirection":{"id":217,"directionType":"domain","freeValue":"tesla.com","domain":"tesla.com","account":null,"group":null},"toDirection":{"id":218,"directionType":"group","freeValue":"marketing","domain":"tesla.com","account":null,"group":"marketing"},"properties":[{"propertyKey":"return.message","propertyValue":"<BODY>\n <P
|
49
|
+
STYLE=\"text-align:left;\">\n <SPAN STYLE=\"letter-spacing:0px;color:#000000;font-size:12px;font-family:''Arial'';\">This
|
50
|
+
message is intended only for ${mxrecipient}. If you are not the intended recipient
|
51
|
+
you are notified that disclosing, copying, distributing or taking any action
|
52
|
+
in reliance on the contents of this information is strictly prohibited.</SPAN>\n </P>\n</BODY>"},{"propertyKey":"return.message.plain","propertyValue":"This
|
53
|
+
message is intended only for ${mxrecipient}. If you are not the intended recipient
|
54
|
+
you are notified that disclosing, copying, distributing or taking any action
|
55
|
+
in reliance on the contents of this information is strictly prohibited."},{"propertyKey":"return.message.rte","propertyValue":"<TextFlow
|
56
|
+
whiteSpaceCollapse=\"preserve\" version=\"2.0.0\" xmlns=\"http://ns.adobe.com/textLayout/2008\"><p><span>This
|
57
|
+
message is intended only for ${mxrecipient}. If you are not the intended recipient
|
58
|
+
you are notified that disclosing, copying, distributing or taking any action
|
59
|
+
in reliance on the contents of this information is strictly prohibited.</span></p></TextFlow>"}]},{"id":117,"domain":"tesla.com","name":"marketing","created":1376030034000,"updated":1376030034000,"enabled":true,"twoWays":false,"adminOrder":null,"component":"org.mxhero.feature.disclaimer","fromDirection":{"id":219,"directionType":"group","freeValue":"marketing","domain":"tesla.com","account":null,"group":"marketing"},"toDirection":{"id":220,"directionType":"anyoneelse","freeValue":"anyoneelse","domain":null,"account":null,"group":null},"properties":[{"propertyKey":"return.message","propertyValue":"<BODY>\n <P
|
60
|
+
STYLE=\"text-align:left;\">\n <SPAN STYLE=\"letter-spacing:0px;color:#000000;font-size:12px;font-family:''Arial'';\">This
|
61
|
+
message is intended only for ${mxrecipient}. If you are not the intended recipient
|
62
|
+
you are notified that disclosing, copying, distributing or taking any action
|
63
|
+
in reliance on the contents of this information is strictly prohibited.</SPAN>\n </P>\n</BODY>"},{"propertyKey":"return.message.plain","propertyValue":"This
|
64
|
+
message is intended only for ${mxrecipient}. If you are not the intended recipient
|
65
|
+
you are notified that disclosing, copying, distributing or taking any action
|
66
|
+
in reliance on the contents of this information is strictly prohibited."},{"propertyKey":"return.message.rte","propertyValue":"<TextFlow
|
67
|
+
whiteSpaceCollapse=\"preserve\" version=\"2.0.0\" xmlns=\"http://ns.adobe.com/textLayout/2008\"><p><span>This
|
68
|
+
message is intended only for ${mxrecipient}. If you are not the intended recipient
|
69
|
+
you are notified that disclosing, copying, distributing or taking any action
|
70
|
+
in reliance on the contents of this information is strictly prohibited.</span></p></TextFlow>"}]}]'
|
71
|
+
http_version:
|
72
|
+
recorded_at: Tue, 13 Aug 2013 16:33:59 GMT
|
3
73
|
- request:
|
4
74
|
method: put
|
5
|
-
uri: http://admin:password@localhost:8080/webapi/api/v1/domains/tesla.com/rules/
|
75
|
+
uri: http://admin:password@localhost:8080/webapi/api/v1/domains/tesla.com/rules/115
|
6
76
|
body:
|
7
77
|
encoding: UTF-8
|
8
|
-
string: ! '{"
|
9
|
-
content"}
|
78
|
+
string: ! '{"id":115,"domain":"tesla.com","name":"another rule more name","created":1376029963000,"updated":1376029963000,"enabled":true,"twoWays":false,"adminOrder":null,"component":"org.mxhero.feature.disclaimer","fromDirection":{"id":215,"directionType":"group","freeValue":"development","domain":"tesla.com","account":null,"group":"development"},"toDirection":{"id":216,"directionType":"anyone","freeValue":"anyone","domain":null,"account":null,"group":null},"properties":[{"propertyKey":"return.message","propertyValue":"another
|
79
|
+
content"},{"propertyKey":"return.message.plain","propertyValue":"This message
|
80
|
+
is intended only for ${mxrecipient}. If you are not the intended recipient
|
81
|
+
you are notified that disclosing, copying, distributing or taking any action
|
82
|
+
in reliance on the contents of this information is strictly prohibited."},{"propertyKey":"return.message.rte","propertyValue":"<TextFlow
|
83
|
+
whiteSpaceCollapse=\"preserve\" version=\"2.0.0\" xmlns=\"http://ns.adobe.com/textLayout/2008\"><p><span>This
|
84
|
+
message is intended only for ${mxrecipient}. If you are not the intended recipient
|
85
|
+
you are notified that disclosing, copying, distributing or taking any action
|
86
|
+
in reliance on the contents of this information is strictly prohibited.</span></p></TextFlow>"}]}'
|
10
87
|
headers:
|
11
88
|
Accept:
|
12
89
|
- application/json
|
13
90
|
Content-Type:
|
14
91
|
- application/json
|
15
|
-
|
16
|
-
-
|
92
|
+
Authorization:
|
93
|
+
- Basic YWRtaW46cGFzc3dvcmQ=
|
17
94
|
response:
|
18
95
|
status:
|
19
96
|
code: 200
|
@@ -28,15 +105,15 @@ http_interactions:
|
|
28
105
|
MA==
|
29
106
|
!binary "RGF0ZQ==":
|
30
107
|
- !binary |-
|
31
|
-
|
108
|
+
RnJpLCAwOSBBdWcgMjAxMyAwNjozNDowNCBHTVQ=
|
32
109
|
body:
|
33
|
-
encoding: ASCII
|
34
|
-
string:
|
110
|
+
encoding: US-ASCII
|
111
|
+
string: ''
|
35
112
|
http_version:
|
36
|
-
recorded_at:
|
113
|
+
recorded_at: Tue, 13 Aug 2013 16:33:59 GMT
|
37
114
|
- request:
|
38
115
|
method: get
|
39
|
-
uri: http://admin:password@localhost:8080/webapi/api/v1/domains/tesla.com/rules/
|
116
|
+
uri: http://admin:password@localhost:8080/webapi/api/v1/domains/tesla.com/rules/115
|
40
117
|
body:
|
41
118
|
encoding: US-ASCII
|
42
119
|
string: ''
|
@@ -45,6 +122,8 @@ http_interactions:
|
|
45
122
|
- application/json
|
46
123
|
Content-Type:
|
47
124
|
- application/json
|
125
|
+
Authorization:
|
126
|
+
- Basic YWRtaW46cGFzc3dvcmQ=
|
48
127
|
response:
|
49
128
|
status:
|
50
129
|
code: 200
|
@@ -62,22 +141,18 @@ http_interactions:
|
|
62
141
|
Y2h1bmtlZA==
|
63
142
|
!binary "RGF0ZQ==":
|
64
143
|
- !binary |-
|
65
|
-
|
144
|
+
RnJpLCAwOSBBdWcgMjAxMyAwNjozNDowNCBHTVQ=
|
66
145
|
body:
|
67
|
-
encoding: ASCII
|
68
|
-
string: !
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
b21haW4iLCJmcmVlVmFsdWUiOiJ0ZXNsYS5jb20iLCJkb21haW4iOiJ0ZXNs
|
78
|
-
YS5jb20iLCJhY2NvdW50IjpudWxsLCJncm91cCI6bnVsbH0sInByb3BlcnRp
|
79
|
-
ZXMiOlt7InByb3BlcnR5S2V5IjoicmV0dXJuLm1lc3NhZ2UiLCJwcm9wZXJ0
|
80
|
-
eVZhbHVlIjoiYW5vdGhlciBjb250ZW50In1dfQ==
|
146
|
+
encoding: US-ASCII
|
147
|
+
string: ! '{"id":115,"domain":"tesla.com","name":"another rule more name","created":1376029963000,"updated":1376030045000,"enabled":true,"twoWays":false,"adminOrder":null,"component":"org.mxhero.feature.disclaimer","fromDirection":{"id":215,"directionType":"group","freeValue":"development","domain":"tesla.com","account":null,"group":"development"},"toDirection":{"id":216,"directionType":"anyone","freeValue":"anyone","domain":null,"account":null,"group":null},"properties":[{"propertyKey":"return.message","propertyValue":"another
|
148
|
+
content"},{"propertyKey":"return.message.plain","propertyValue":"This message
|
149
|
+
is intended only for ${mxrecipient}. If you are not the intended recipient
|
150
|
+
you are notified that disclosing, copying, distributing or taking any action
|
151
|
+
in reliance on the contents of this information is strictly prohibited."},{"propertyKey":"return.message.rte","propertyValue":"<TextFlow
|
152
|
+
whiteSpaceCollapse=\"preserve\" version=\"2.0.0\" xmlns=\"http://ns.adobe.com/textLayout/2008\"><p><span>This
|
153
|
+
message is intended only for ${mxrecipient}. If you are not the intended recipient
|
154
|
+
you are notified that disclosing, copying, distributing or taking any action
|
155
|
+
in reliance on the contents of this information is strictly prohibited.</span></p></TextFlow>"}]}'
|
81
156
|
http_version:
|
82
|
-
recorded_at:
|
157
|
+
recorded_at: Tue, 13 Aug 2013 16:33:59 GMT
|
83
158
|
recorded_with: VCR 2.5.0
|
data/test/test_mxhero_api.rb
CHANGED
@@ -6,33 +6,44 @@ class MxHeroAPITest < MiniTest::Unit::TestCase
|
|
6
6
|
@api = MxHero::API::Client.new(username: TEST_API_USER, password: TEST_API_PASSWORD, verbose: false, api_url: TEST_API_URL)
|
7
7
|
end
|
8
8
|
|
9
|
+
def domain
|
10
|
+
TEST_API_DOMAIN
|
11
|
+
end
|
12
|
+
|
9
13
|
def test_update_rule
|
10
14
|
VCR.use_cassette('update_rule') do
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
rules = obtain_rules(domain)
|
16
|
+
existing_rule = rules.first
|
17
|
+
updated_rule = existing_rule.clone
|
18
|
+
|
19
|
+
property = updated_rule[:properties].find { |property| property[:propertyKey] == 'return.message' }
|
20
|
+
property[:propertyValue] = 'another content'
|
21
|
+
updated_rule[:name] = updated_rule[:name] + ' more name'
|
22
|
+
|
23
|
+
assert @api.update_rule(updated_rule)
|
24
|
+
|
25
|
+
rule = @api.domain_rule(updated_rule[:domain], updated_rule[:id])
|
26
|
+
assert updated_rule, rule
|
19
27
|
end
|
20
28
|
end
|
21
29
|
|
22
30
|
def test_domain_rule
|
23
31
|
VCR.use_cassette('domain_rule') do
|
24
|
-
|
25
|
-
|
26
|
-
|
32
|
+
rules = obtain_rules(domain)
|
33
|
+
one_rule = rules.first
|
34
|
+
rule = @api.domain_rule(domain, one_rule[:id])
|
35
|
+
assert one_rule[:id], rule[:id]
|
36
|
+
assert one_rule, rule
|
37
|
+
assert domain, rule[:domain]
|
27
38
|
end
|
28
39
|
end
|
29
40
|
|
30
41
|
def test_rules_for_domain
|
31
42
|
VCR.use_cassette('rules_for_domain') do
|
32
|
-
response = @api.rules_for_domain(
|
43
|
+
response = @api.rules_for_domain(domain)
|
33
44
|
assert response.code == 200
|
34
45
|
rules = response.msg
|
35
|
-
assert_equal
|
46
|
+
assert_equal domain, rules.first[:domain]
|
36
47
|
end
|
37
48
|
end
|
38
49
|
|
@@ -48,7 +59,7 @@ class MxHeroAPITest < MiniTest::Unit::TestCase
|
|
48
59
|
|
49
60
|
def test_domain_by_id
|
50
61
|
VCR.use_cassette('domain_by_id') do
|
51
|
-
id =
|
62
|
+
id = domain
|
52
63
|
tesla_domain = @api.domain_by_id(id)
|
53
64
|
assert tesla_domain.key?(:domain)
|
54
65
|
assert tesla_domain.key?(:server)
|
@@ -72,7 +83,6 @@ class MxHeroAPITest < MiniTest::Unit::TestCase
|
|
72
83
|
|
73
84
|
def test_accounts_by_domain
|
74
85
|
VCR.use_cassette('accounts_from_domain') do
|
75
|
-
domain = 'mxhero.com'
|
76
86
|
response = @api.accounts_by_domain(domain)
|
77
87
|
must_have_the_keys(response, %w( elements totalElements totalPages actualPage ))
|
78
88
|
response[:elements].each do |account|
|
@@ -82,6 +92,50 @@ class MxHeroAPITest < MiniTest::Unit::TestCase
|
|
82
92
|
end
|
83
93
|
end
|
84
94
|
|
95
|
+
def test_delete_rule
|
96
|
+
VCR.use_cassette('delete_rule') do
|
97
|
+
rules = obtain_rules(domain)
|
98
|
+
one_rule = rules.first
|
99
|
+
response = @api.delete_rule(domain, one_rule[:id])
|
100
|
+
assert response
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
def test_create_rule
|
106
|
+
VCR.use_cassette('create_rule_success') do
|
107
|
+
response = @api.create_rule(create_rule_msg)
|
108
|
+
assert response.code == 201
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_try_to_create_rule_that_alredy_exist
|
113
|
+
VCR.use_cassette('create_rule_alredy_exist') do
|
114
|
+
response = @api.create_rule(create_rule_msg)
|
115
|
+
assert_equal 201, response.code
|
116
|
+
new_response = @api.create_rule(create_rule_msg)
|
117
|
+
assert_equal 500, new_response.code
|
118
|
+
assert_equal "rules.already.exists.for.component", new_response.msg[:developerMessage]
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_create_rule_for_domain
|
123
|
+
VCR.use_cassette('create_rule_for_domain') do
|
124
|
+
response = @api.create_rule_for_domain(domain, rule)
|
125
|
+
assert response.code == 201
|
126
|
+
new_response = @api.create_rule_for_domain(domain, rule)
|
127
|
+
assert new_response.code == 500
|
128
|
+
assert_equal "rules.already.exists.for.component", new_response.msg[:developerMessage]
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
private
|
133
|
+
|
134
|
+
def obtain_rules(domain)
|
135
|
+
response = @api.rules_for_domain(domain)
|
136
|
+
response.msg
|
137
|
+
end
|
138
|
+
|
85
139
|
def must_have_the_keys(hash, keys)
|
86
140
|
keys.each do |key|
|
87
141
|
assert hash.key?(key.to_sym), "must have the key #{key}"
|
@@ -101,45 +155,28 @@ class MxHeroAPITest < MiniTest::Unit::TestCase
|
|
101
155
|
enabled: true,
|
102
156
|
name: "Email footer",
|
103
157
|
created: 1369682598000,
|
104
|
-
fromDirection: { directionType: "domain", domain:
|
105
|
-
toDirection: { directionType: "domain", domain:
|
158
|
+
fromDirection: { directionType: "domain", domain: domain, freeValue: domain },
|
159
|
+
toDirection: { directionType: "domain", domain: domain, freeValue: domain },
|
106
160
|
properties: [{ propertyKey: "return.message", propertyValue: "footer content" }],
|
107
161
|
component: "org.mxhero.feature.disclaimer"
|
108
162
|
}
|
109
163
|
end
|
110
164
|
|
111
|
-
def test_create_rule
|
112
|
-
VCR.use_cassette('create_rule_success') do
|
113
|
-
response = @api.create_rule(create_rule_msg)
|
114
|
-
assert response.code == 201
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
def test_try_to_create_rule_that_alredy_exist
|
119
|
-
VCR.use_cassette('create_rule_alredy_exist') do
|
120
|
-
response = @api.create_rule(create_rule_msg)
|
121
|
-
assert response.code == 201
|
122
|
-
new_response = @api.create_rule(create_rule_msg)
|
123
|
-
assert new_response.code == 500
|
124
|
-
assert_equal "rules.already.exists.for.component", new_response.msg[:developerMessage]
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
165
|
def rule
|
129
|
-
{ :domain =>
|
166
|
+
{ :domain => domain,
|
130
167
|
:twoWays => false,
|
131
168
|
:enabled => true,
|
132
169
|
:name => "The rules for sales",
|
133
170
|
:created => "1375998105095",
|
134
171
|
:fromDirection => { :id => nil,
|
135
172
|
:directionType => "domain",
|
136
|
-
:freeValue =>
|
137
|
-
:domain =>
|
173
|
+
:freeValue => domain,
|
174
|
+
:domain => domain,
|
138
175
|
:account => nil, :group => nil },
|
139
176
|
:toDirection => { :id => nil,
|
140
177
|
:directionType => "anyone",
|
141
178
|
:freeValue => "Anyone",
|
142
|
-
:domain =>
|
179
|
+
:domain => domain,
|
143
180
|
:account => nil, :group => nil},
|
144
181
|
:properties => [
|
145
182
|
{ :propertyKey => "return.message",
|
@@ -152,13 +189,4 @@ class MxHeroAPITest < MiniTest::Unit::TestCase
|
|
152
189
|
:component => "org.mxhero.feature.disclaimer" }
|
153
190
|
end
|
154
191
|
|
155
|
-
|
156
|
-
VCR.use_cassette('create_rule_for_domain') do
|
157
|
-
response = @api.create_rule_for_domain('tesla.com', rule)
|
158
|
-
assert response.code == 201
|
159
|
-
new_response = @api.create_rule_for_domain('tesla.com', rule)
|
160
|
-
assert new_response.code == 500
|
161
|
-
assert_equal "rules.already.exists.for.component", new_response.msg[:developerMessage]
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
192
|
+
end
|