CnpOnline 12.3.0 → 12.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +12 -0
- data/Rakefile +1 -1
- data/lib/CnpBatchRequest.rb +17 -8
- data/lib/CnpOnline.rb +2 -0
- data/lib/CnpOnlineRequest.rb +30 -2
- data/lib/CnpRequest.rb +24 -4
- data/lib/CnpTransaction.rb +70 -7
- data/lib/CommManager.rb +185 -0
- data/lib/Communications.rb +7 -3
- data/lib/EnvironmentVariables.rb +8 -0
- data/lib/RequestTarget.rb +10 -0
- data/lib/XMLFields.rb +148 -11
- data/out/production/cnp-sdk-for-ruby/CnpBatchRequest.rb +787 -0
- data/out/production/cnp-sdk-for-ruby/CnpListeners.rb +265 -0
- data/out/production/cnp-sdk-for-ruby/CnpOnline.rb +65 -0
- data/out/production/cnp-sdk-for-ruby/CnpOnlineRequest.rb +370 -0
- data/out/production/cnp-sdk-for-ruby/CnpRequest.rb +670 -0
- data/out/production/cnp-sdk-for-ruby/CnpTransaction.rb +831 -0
- data/out/production/cnp-sdk-for-ruby/CnpXmlMapper.rb +71 -0
- data/out/production/cnp-sdk-for-ruby/CommManager.rb +185 -0
- data/out/production/cnp-sdk-for-ruby/Communications.rb +90 -0
- data/out/production/cnp-sdk-for-ruby/Configuration.rb +75 -0
- data/out/production/cnp-sdk-for-ruby/EnvironmentVariables.rb +33 -0
- data/out/production/cnp-sdk-for-ruby/RequestTarget.rb +10 -0
- data/out/production/cnp-sdk-for-ruby/Setup.rb +147 -0
- data/out/production/cnp-sdk-for-ruby/XMLFields.rb +2638 -0
- data/out/production/cnp-sdk-for-ruby/cacert.pem +3331 -0
- data/out/production/cnp-sdk-for-ruby/sample_batch_driver.rb +123 -0
- data/out/production/cnp-sdk-for-ruby/sample_driver.rb +49 -0
- data/out/test/cnp-sdk-for-ruby/certification/certTest1_base.rb +948 -0
- data/out/test/cnp-sdk-for-ruby/certification/certTest2_authenhanced.rb +577 -0
- data/out/test/cnp-sdk-for-ruby/certification/certTest3_authreversal.rb +190 -0
- data/out/test/cnp-sdk-for-ruby/certification/certTest4_echeck.rb +288 -0
- data/out/test/cnp-sdk-for-ruby/certification/certTest5_token.rb +209 -0
- data/out/test/cnp-sdk-for-ruby/certification/certTest_batchAll.rb +610 -0
- data/out/test/cnp-sdk-for-ruby/certification/ts_all.rb +33 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_activate.rb +133 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_activateReversal.rb +73 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_auth.rb +478 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_authReversal.rb +74 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_balanceInquiry.rb +107 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_batch.rb +264 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_batchStream.rb +154 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_cancelSubscription.rb +57 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_capture.rb +147 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_captureGivenAuth.rb +352 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_commManager.rb +302 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_configuration.rb +89 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_createPlan.rb +87 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_credit.rb +222 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_ctx.rb +124 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_deactivate.rb +105 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_deactivateReversal.rb +71 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_depositReversal.rb +70 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_echeckCredit.rb +179 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_echeckRedeposit.rb +117 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_echeckSale.rb +255 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_echeckVerification.rb +160 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_echeckVoid.rb +42 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_fastAccessFunding.rb +177 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_forceCapture.rb +272 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_fraudCheck.rb +76 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_giftCardAuthReversal.rb +72 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_giftCardCapture.rb +72 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_giftCardCredit.rb +69 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_litle_requests.rb +355 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_load.rb +108 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_loadReversal.rb +71 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_override.rb +68 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_pgp_cnp_requests.rb +295 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_queryTransaction.rb +154 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_refundReversal.rb +71 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_sale.rb +459 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_token.rb +137 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_translateToken.rb +203 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_unload.rb +108 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_unloadReversal.rb +71 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_updateCardValidationNumOnToken.rb +44 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_updatePlan.rb +61 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_updateSubscription.rb +80 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_wallet.rb +74 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_xmlfields.rb +429 -0
- data/out/test/cnp-sdk-for-ruby/functional/ts_all.rb +69 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_LitleAUBatch.rb +244 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_LitleBatchRequest.rb +791 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_LitleOnlineRequest.rb +253 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_LitleRequest.rb +317 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_LitleTransaction.rb +426 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_LitleXmlMapper.rb +139 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_activate.rb +92 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_activateReversal.rb +56 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_auth.rb +463 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_authReversal.rb +82 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_balanceInquiry.rb +52 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_cancelSubscription.rb +43 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_capture.rb +99 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_captureGivenAuth.rb +234 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_createPlan.rb +52 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_credit.rb +355 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_deactivate.rb +71 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_deactivateReversal.rb +56 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_depositReversal.rb +56 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_echeckCredit.rb +103 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_echeckRedeposit.rb +109 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_echeckSale.rb +107 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_echeckVerification.rb +74 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_echeckVoid.rb +54 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_forceCapture.rb +163 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_fraudCheck.rb +45 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_giftCardAuthReversal.rb +58 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_giftCardCapture.rb +57 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_giftCardCredit.rb +57 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_load.rb +53 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_loadReversal.rb +56 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_pgp_CnpRequest.rb +139 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_queryTransaction.rb +106 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_refundReversal.rb +56 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_sale.rb +551 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_token.rb +159 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_unload.rb +53 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_unloadReversal.rb +56 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_updateCardValidationNumOnToken.rb +80 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_updatePlan.rb +45 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_updateSubscription.rb +172 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_wallet.rb +262 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_xmlfields.rb +2930 -0
- data/out/test/cnp-sdk-for-ruby/unit/ts_unit.rb +67 -0
- data/test/certification/certTest2_authenhanced.rb +28 -27
- data/test/functional/test_batch.rb +106 -1
- data/test/functional/test_batchStream.rb +3 -2
- data/test/functional/test_captureGivenAuth.rb +24 -0
- data/test/functional/test_commManager.rb +302 -0
- data/test/functional/test_ctx.rb +124 -0
- data/test/functional/test_fastAccessFunding.rb +21 -0
- data/test/functional/test_forceCapture.rb +21 -0
- data/test/functional/test_xmlfields.rb +20 -1
- metadata +122 -4
@@ -0,0 +1,302 @@
|
|
1
|
+
require File.expand_path("../../../lib/CnpOnline",__FILE__)
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
module CnpOnline
|
5
|
+
class TestCommManager < Test::Unit::TestCase
|
6
|
+
|
7
|
+
@@site1Url = "https://multisite1.com"
|
8
|
+
@@site2Url = "https://multisite2.com"
|
9
|
+
@@legacyUrl = "https://legacy.com"
|
10
|
+
|
11
|
+
def test_instance_legacy
|
12
|
+
_config = Configuration.new.config
|
13
|
+
_config["url"] = @@legacyUrl
|
14
|
+
_config["multiSite"] = false
|
15
|
+
_config["printMultiSiteDebug"] = true
|
16
|
+
|
17
|
+
CommManager.reset
|
18
|
+
_cmg = CommManager.instance(_config)
|
19
|
+
|
20
|
+
assert_not_nil(_cmg)
|
21
|
+
assert_false(_cmg.multiSite)
|
22
|
+
assert_equal(@@legacyUrl, _cmg.legacyUrl)
|
23
|
+
|
24
|
+
_config2 = Configuration.new.config
|
25
|
+
_config2["url"] = "https://nowhere.com"
|
26
|
+
_config2["multiSite"] = false
|
27
|
+
_config2["printMultiSiteDebug"] = true
|
28
|
+
_cmg2 = CommManager.instance(_config2)
|
29
|
+
assert_equal(@@legacyUrl, _cmg2.legacyUrl) # should be same manager as previous
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_instance_multi_site
|
33
|
+
_config = Configuration.new.config
|
34
|
+
_config["url"] = @@legacyUrl
|
35
|
+
_config["multiSite"] = true
|
36
|
+
_config["printMultiSiteDebug"] = true
|
37
|
+
_config["multSiteUrl1"] = @@site1Url
|
38
|
+
_config["multSiteUrl2"] = @@site2Url
|
39
|
+
_config["multiSiteThreshold"] = 4
|
40
|
+
_config["maxHoursWithoutSwitch"] = 48
|
41
|
+
|
42
|
+
CommManager.reset
|
43
|
+
_cmg = CommManager.instance(_config)
|
44
|
+
|
45
|
+
assert_not_nil(_cmg)
|
46
|
+
assert_true(_cmg.multiSite)
|
47
|
+
assert_equal(4, _cmg.multiSiteThreshold)
|
48
|
+
assert_equal(2, _cmg.multiSiteUrls.length)
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_instance_multi_site_no_urls
|
53
|
+
_config = Configuration.new.config
|
54
|
+
_config["url"] = @@legacyUrl
|
55
|
+
_config["multiSite"] = true
|
56
|
+
_config["printMultiSiteDebug"] = true
|
57
|
+
|
58
|
+
CommManager.reset
|
59
|
+
_cmg = CommManager.instance(_config)
|
60
|
+
|
61
|
+
assert_not_nil(_cmg)
|
62
|
+
assert_false(_cmg.multiSite)
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_instance_multi_site_default_props
|
66
|
+
_config = Configuration.new.config
|
67
|
+
_config["url"] = @@legacyUrl
|
68
|
+
_config["multiSite"] = true
|
69
|
+
_config["printMultiSiteDebug"] = true
|
70
|
+
_config["multSiteUrl1"] = @@site1Url
|
71
|
+
_config["multSiteUrl2"] = @@site2Url
|
72
|
+
_config["multiSiteErrorThreshold"] = 102
|
73
|
+
_config["maxHoursWithoutSwitch"] = 500
|
74
|
+
|
75
|
+
CommManager.reset
|
76
|
+
_cmg = CommManager.instance(_config)
|
77
|
+
|
78
|
+
assert_not_nil(_cmg)
|
79
|
+
assert_true(_cmg.multiSite)
|
80
|
+
assert_equal(5, _cmg.multiSiteThreshold)
|
81
|
+
assert_equal(48, _cmg.maxHoursWithoutSwitch)
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_instance_multi_site_out_of_range
|
85
|
+
_config = Configuration.new.config
|
86
|
+
_config["url"] = @@legacyUrl
|
87
|
+
_config["multiSite"] = true
|
88
|
+
_config["printMultiSiteDebug"] = true
|
89
|
+
_config["multSiteUrl1"] = @@site1Url
|
90
|
+
_config["multSiteUrl2"] = @@site2Url
|
91
|
+
|
92
|
+
CommManager.reset
|
93
|
+
_cmg = CommManager.instance(_config)
|
94
|
+
|
95
|
+
assert_not_nil(_cmg)
|
96
|
+
assert_true(_cmg.multiSite)
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_find_url_legacy
|
100
|
+
_config = Configuration.new.config
|
101
|
+
_config["url"] = @@legacyUrl
|
102
|
+
_config["multiSite"] = false
|
103
|
+
_config["printMultiSiteDebug"] = false
|
104
|
+
|
105
|
+
CommManager.reset
|
106
|
+
_cmg = CommManager.instance(_config)
|
107
|
+
|
108
|
+
assert_not_nil(_cmg)
|
109
|
+
assert_false(_cmg.multiSite)
|
110
|
+
|
111
|
+
_requestTarget = _cmg.findUrl
|
112
|
+
assert_equal(@@legacyUrl, _requestTarget.targetUrl)
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_find_url_multi_site1
|
116
|
+
_config = Configuration.new.config
|
117
|
+
_config["url"] = @@legacyUrl
|
118
|
+
_config["multiSite"] = true
|
119
|
+
_config["printMultiSiteDebug"] = true
|
120
|
+
_config["multSiteUrl1"] = @@site1Url
|
121
|
+
_config["multSiteUrl2"] = @@site2Url
|
122
|
+
_config["multiSiteThreshold"] = 4
|
123
|
+
_config["maxHoursWithoutSwitch"] = 48
|
124
|
+
|
125
|
+
CommManager.reset
|
126
|
+
_cmg = CommManager.instance(_config)
|
127
|
+
|
128
|
+
assert_not_nil(_cmg)
|
129
|
+
assert_true(_cmg.multiSite)
|
130
|
+
|
131
|
+
_requestTarget = _cmg.findUrl
|
132
|
+
assert_equal(_cmg.multiSiteUrls.at(_cmg.currentMultiSiteUrlIndex), _requestTarget.targetUrl)
|
133
|
+
assert_true(_requestTarget.targetUrl == @@site1Url || _requestTarget.targetUrl == @@site2Url)
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_find_url_multi_site2
|
137
|
+
_config = Configuration.new.config
|
138
|
+
_config["url"] = @@legacyUrl
|
139
|
+
_config["multiSite"] = true
|
140
|
+
_config["printMultiSiteDebug"] = false
|
141
|
+
_config["multSiteUrl1"] = @@site1Url
|
142
|
+
_config["multSiteUrl2"] = @@site2Url
|
143
|
+
_config["multiSiteThreshold"] = 3
|
144
|
+
_config["maxHoursWithoutSwitch"] = 48
|
145
|
+
|
146
|
+
CommManager.reset
|
147
|
+
_cmg = CommManager.instance(_config)
|
148
|
+
|
149
|
+
assert_not_nil(_cmg)
|
150
|
+
assert_true(_cmg.multiSite)
|
151
|
+
assert_equal(3, _cmg.multiSiteThreshold)
|
152
|
+
|
153
|
+
_requestTarget1 = _cmg.findUrl
|
154
|
+
assert_equal(_requestTarget1.targetUrl, _cmg.multiSiteUrls.at(_cmg.currentMultiSiteUrlIndex))
|
155
|
+
_cmg.reportResult(_requestTarget1, _cmg.REQUEST_RESULT_RESPONSE_TIMEOUT, 0)
|
156
|
+
_requestTarget2 = _cmg.findUrl
|
157
|
+
assert_equal(_requestTarget1.targetUrl, _requestTarget2.targetUrl)
|
158
|
+
_cmg.reportResult(_requestTarget2, _cmg.REQUEST_RESULT_RESPONSE_TIMEOUT, 0)
|
159
|
+
_requestTarget3 = _cmg.findUrl
|
160
|
+
assert_equal(_requestTarget1.targetUrl, _requestTarget3.targetUrl)
|
161
|
+
_cmg.reportResult(_requestTarget3, _cmg.REQUEST_RESULT_RESPONSE_TIMEOUT, 0)
|
162
|
+
assert_equal(3, _cmg.errorCount)
|
163
|
+
|
164
|
+
_requestTarget4 = _cmg.findUrl
|
165
|
+
assert_false(_requestTarget4.targetUrl == _requestTarget1.targetUrl)
|
166
|
+
end
|
167
|
+
|
168
|
+
def test_find_url_multi_site3
|
169
|
+
_config = Configuration.new.config
|
170
|
+
_config["url"] = @@legacyUrl
|
171
|
+
_config["multiSite"] = true
|
172
|
+
_config["printMultiSiteDebug"] = false
|
173
|
+
_config["multSiteUrl1"] = @@site1Url
|
174
|
+
_config["multSiteUrl2"] = @@site2Url
|
175
|
+
_config["multiSiteThreshold"] = 3
|
176
|
+
_config["maxHoursWithoutSwitch"] = 48
|
177
|
+
|
178
|
+
CommManager.reset
|
179
|
+
_cmg = CommManager.instance(_config)
|
180
|
+
|
181
|
+
assert_not_nil(_cmg)
|
182
|
+
assert_true(_cmg.multiSite)
|
183
|
+
assert_equal(3, _cmg.multiSiteThreshold)
|
184
|
+
|
185
|
+
_requestTarget1 = _cmg.findUrl
|
186
|
+
assert_equal(_requestTarget1.targetUrl, _cmg.multiSiteUrls.at(_cmg.currentMultiSiteUrlIndex))
|
187
|
+
_cmg.reportResult(_requestTarget1, _cmg.REQUEST_RESULT_RESPONSE_TIMEOUT, 0)
|
188
|
+
_requestTarget2 = _cmg.findUrl
|
189
|
+
assert_equal(_requestTarget1.targetUrl, _requestTarget2.targetUrl)
|
190
|
+
_cmg.reportResult(_requestTarget2, _cmg.REQUEST_RESULT_RESPONSE_TIMEOUT, 0)
|
191
|
+
_requestTarget3 = _cmg.findUrl
|
192
|
+
assert_equal(_requestTarget1.targetUrl, _requestTarget3.targetUrl)
|
193
|
+
_cmg.reportResult(_requestTarget3, _cmg.REQUEST_RESULT_RESPONSE_TIMEOUT, 0)
|
194
|
+
assert_equal(3, _cmg.errorCount)
|
195
|
+
|
196
|
+
_requestTarget4 = _cmg.findUrl
|
197
|
+
assert_false(_requestTarget4.targetUrl == _requestTarget1.targetUrl)
|
198
|
+
|
199
|
+
_requestTarget10 = _cmg.findUrl
|
200
|
+
assert_equal(_cmg.multiSiteUrls.at(_cmg.currentMultiSiteUrlIndex), _requestTarget10.targetUrl)
|
201
|
+
_cmg.reportResult(_requestTarget10, _cmg.REQUEST_RESULT_RESPONSE_RECEIVED, 401)
|
202
|
+
_requestTarget11 = _cmg.findUrl
|
203
|
+
assert_equal(_requestTarget10.targetUrl, _requestTarget11.targetUrl)
|
204
|
+
_cmg.reportResult(_requestTarget11, _cmg.REQUEST_RESULT_CONNECTION_FAILED, 0)
|
205
|
+
_requestTarget12 = _cmg.findUrl
|
206
|
+
assert_equal(_requestTarget11.targetUrl, _requestTarget12.targetUrl)
|
207
|
+
_cmg.reportResult(_requestTarget12, _cmg.REQUEST_RESULT_RESPONSE_TIMEOUT, 0)
|
208
|
+
assert_equal(_cmg.errorCount, 3)
|
209
|
+
|
210
|
+
_requestTarget13 = _cmg.findUrl
|
211
|
+
assert_false(_requestTarget13.targetUrl == _requestTarget11.targetUrl)
|
212
|
+
assert_true(_requestTarget13.targetUrl == _requestTarget1.targetUrl)
|
213
|
+
|
214
|
+
end
|
215
|
+
|
216
|
+
def test_find_url_multi_site4
|
217
|
+
_config = Configuration.new.config
|
218
|
+
_config["url"] = @@legacyUrl
|
219
|
+
_config["multiSite"] = true
|
220
|
+
_config["printMultiSiteDebug"] = false
|
221
|
+
_config["multSiteUrl1"] = @@site1Url
|
222
|
+
_config["multSiteUrl2"] = @@site2Url
|
223
|
+
_config["multiSiteThreshold"] = 3
|
224
|
+
_config["maxHoursWithoutSwitch"] = 0
|
225
|
+
|
226
|
+
CommManager.reset
|
227
|
+
_cmg = CommManager.instance(_config)
|
228
|
+
|
229
|
+
assert_not_nil(_cmg)
|
230
|
+
assert_true(_cmg.multiSite)
|
231
|
+
assert_equal(3, _cmg.multiSiteThreshold)
|
232
|
+
|
233
|
+
_requestTarget1 = _cmg.findUrl
|
234
|
+
assert_equal(_cmg.multiSiteUrls.at(_cmg.currentMultiSiteUrlIndex), _requestTarget1.targetUrl)
|
235
|
+
_cmg.reportResult(_requestTarget1, _cmg.REQUEST_RESULT_RESPONSE_TIMEOUT, 0)
|
236
|
+
_requestTarget2 = _cmg.findUrl
|
237
|
+
assert_equal(_requestTarget1.targetUrl, _requestTarget2.targetUrl)
|
238
|
+
_cmg.reportResult(_requestTarget2, _cmg.REQUEST_RESULT_RESPONSE_RECEIVED, 200)
|
239
|
+
assert_equal(_cmg.errorCount, 0)
|
240
|
+
|
241
|
+
_requestTarget3 = _cmg.findUrl
|
242
|
+
assert_equal(_requestTarget1.targetUrl, _requestTarget3.targetUrl)
|
243
|
+
_cmg.reportResult(_requestTarget3, _cmg.REQUEST_RESULT_RESPONSE_RECEIVED, 301)
|
244
|
+
assert_equal(_cmg.errorCount, 0)
|
245
|
+
|
246
|
+
end
|
247
|
+
|
248
|
+
# test that url is switched when number of hours since last switch exceeds threshold
|
249
|
+
def test_find_url_multi_site_max_hours
|
250
|
+
_config = Configuration.new.config
|
251
|
+
_config["url"] = @@legacyUrl
|
252
|
+
_config["multiSite"] = true
|
253
|
+
_config["printMultiSiteDebug"] = true
|
254
|
+
_config["multSiteUrl1"] = @@site1Url
|
255
|
+
_config["multSiteUrl2"] = @@site2Url
|
256
|
+
_config["multiSiteThreshold"] = 3
|
257
|
+
_config["maxHoursWithoutSwitch"] = 4
|
258
|
+
|
259
|
+
CommManager.reset
|
260
|
+
_cmg = CommManager.instance(_config)
|
261
|
+
|
262
|
+
assert_not_nil(_cmg)
|
263
|
+
assert_true(_cmg.multiSite)
|
264
|
+
assert_equal(3, _cmg.multiSiteThreshold)
|
265
|
+
|
266
|
+
_requestTarget1 = _cmg.findUrl
|
267
|
+
assert_equal(_cmg.multiSiteUrls.at(_cmg.currentMultiSiteUrlIndex), _requestTarget1.targetUrl)
|
268
|
+
_cmg.reportResult(_requestTarget1, _cmg.REQUEST_RESULT_RESPONSE_RECEIVED, 200)
|
269
|
+
_requestTarget2 = _cmg.findUrl
|
270
|
+
assert_equal(_requestTarget1.targetUrl, _requestTarget2.targetUrl)
|
271
|
+
_cmg.reportResult(_requestTarget2, _cmg.REQUEST_RESULT_RESPONSE_RECEIVED, 200)
|
272
|
+
|
273
|
+
_cmg.lastSiteSwitchTime = _cmg.lastSiteSwitchTime - 2.16e+7 # hours in milliseconds
|
274
|
+
|
275
|
+
_requestTarget3 = _cmg.findUrl
|
276
|
+
assert_false(_requestTarget3.targetUrl == _requestTarget1.targetUrl)
|
277
|
+
end
|
278
|
+
|
279
|
+
def test_report_result_not_multi_site
|
280
|
+
_config = Configuration.new.config
|
281
|
+
_config["url"] = @@legacyUrl
|
282
|
+
_config["multiSite"] = false
|
283
|
+
_config["printMultiSiteDebug"] = true
|
284
|
+
|
285
|
+
CommManager.reset
|
286
|
+
_cmg = CommManager.instance(_config)
|
287
|
+
|
288
|
+
assert_not_nil(_cmg)
|
289
|
+
assert_false(_cmg.multiSite)
|
290
|
+
assert_equal(_cmg.legacyUrl, @@legacyUrl)
|
291
|
+
_requestTarget = RequestTarget.new("", 1)
|
292
|
+
_cmg.reportResult(_requestTarget, 1, 0)
|
293
|
+
|
294
|
+
end
|
295
|
+
|
296
|
+
|
297
|
+
def to_boolean(str)
|
298
|
+
str == 'true'
|
299
|
+
end
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
@@ -0,0 +1,89 @@
|
|
1
|
+
=begin
|
2
|
+
Copyright (c) 2017 Vantiv eCommerce
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
16
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
18
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
19
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
20
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
21
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
=end
|
23
|
+
require File.expand_path("../../../lib/CnpOnline",__FILE__)
|
24
|
+
require 'test/unit'
|
25
|
+
|
26
|
+
|
27
|
+
module CnpOnline
|
28
|
+
class TestConfiguration < Test::Unit::TestCase
|
29
|
+
#the flag is to judge the data in config file exist or not
|
30
|
+
@@flag=false
|
31
|
+
def test_configuration_with_file
|
32
|
+
@config_hash = Configuration.new.config
|
33
|
+
@config_hash.each {|key,value| checkAttributes(key,@config_hash)}
|
34
|
+
assert_equal(false, @@flag)
|
35
|
+
end
|
36
|
+
|
37
|
+
def checkAttributes(key,datas)
|
38
|
+
if (datas[key].nil?)
|
39
|
+
@@flag=true
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_configuration_mix_file_env
|
44
|
+
#check the env variable override
|
45
|
+
ENV['cnp_timeout']='80'
|
46
|
+
@config_hash = Configuration.new.config
|
47
|
+
assert_equal('80',@config_hash['timeout'])
|
48
|
+
ENV['cnp_timeout']=nil
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
def test_configuration_without_file
|
54
|
+
#set up Env variable
|
55
|
+
ENV['cnp_user']='isola'
|
56
|
+
ENV['cnp_password']='vinicius'
|
57
|
+
ENV['cnp_currency_merchant_map']='0180'
|
58
|
+
ENV['cnp_url']='basketball@gmail.com'
|
59
|
+
ENV['cnp_proxy_addr']='iwp1.lowell.cnp.com'
|
60
|
+
ENV['cnp_proxy_port']='8080'
|
61
|
+
ENV['cnp_sftp_username']='sdkFire'
|
62
|
+
ENV['cnp_sftp_password']='fire is comming'
|
63
|
+
ENV['cnp_fast_url']='prelive.cnp.com'
|
64
|
+
ENV['cnp_fast_port']='15000'
|
65
|
+
@config_hash = Configuration.new.config
|
66
|
+
assert_equal('isola',@config_hash['user'])
|
67
|
+
assert_equal('vinicius',@config_hash['password'])
|
68
|
+
assert_equal('0180',@config_hash['currency_merchant_map'])
|
69
|
+
assert_equal('basketball@gmail.com',@config_hash['url'])
|
70
|
+
assert_equal('iwp1.lowell.cnp.com',@config_hash['proxy_addr'])
|
71
|
+
assert_equal('8080',@config_hash['proxy_port'])
|
72
|
+
assert_equal('sdkFire',@config_hash['sftp_username'])
|
73
|
+
assert_equal('fire is comming',@config_hash['sftp_password'])
|
74
|
+
assert_equal('prelive.cnp.com',@config_hash['fast_url'])
|
75
|
+
assert_equal('15000',@config_hash['fast_port'])
|
76
|
+
ENV['cnp_user']=nil
|
77
|
+
ENV['cnp_password']=nil
|
78
|
+
ENV['cnp_currency_merchant_map']=nil
|
79
|
+
ENV['cnp_url']=nil
|
80
|
+
ENV['cnp_proxy_addr']=nil
|
81
|
+
ENV['cnp_proxy_port']=nil
|
82
|
+
ENV['cnp_sftp_username']=nil
|
83
|
+
ENV['cnp_sftp_password']=nil
|
84
|
+
ENV['cnp_fast_url']=nil
|
85
|
+
ENV['cnp_fast_port']=nil
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
=begin
|
2
|
+
Copyright (c) 2017 Vantiv eCommerce
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person
|
5
|
+
obtaining a copy of this software and associated documentation
|
6
|
+
files (the "Software"), to deal in the Software without
|
7
|
+
restriction, including without limitation the rights to use,
|
8
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the
|
10
|
+
Software is furnished to do so, subject to the following
|
11
|
+
conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
18
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
20
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
21
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
22
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
23
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
=end
|
25
|
+
require File.expand_path("../../../lib/CnpOnline",__FILE__)
|
26
|
+
require 'test/unit'
|
27
|
+
|
28
|
+
#test Activate Transaction
|
29
|
+
module CnpOnline
|
30
|
+
class TestCreatePlan < Test::Unit::TestCase
|
31
|
+
|
32
|
+
def test_simple_happy
|
33
|
+
hash ={
|
34
|
+
'merchantId' => '101',
|
35
|
+
'version'=>'8.8',
|
36
|
+
'reportGroup'=>'Planets',
|
37
|
+
'planCode'=>'planCodeString',
|
38
|
+
'name'=>'nameString',
|
39
|
+
'description'=>'descriptionString',
|
40
|
+
'intervalType'=>'ANNUAL',
|
41
|
+
'amount'=>'500',
|
42
|
+
'numberOfPayments'=>'2',
|
43
|
+
'trialNumberOfIntervals'=>'1',
|
44
|
+
'trialIntervalType'=>'MONTH',
|
45
|
+
'active'=>'true'
|
46
|
+
}
|
47
|
+
|
48
|
+
response= CnpOnlineRequest.new.create_plan(hash)
|
49
|
+
assert_equal('Valid Format', response.message)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_simple_out_of_order
|
53
|
+
hash ={
|
54
|
+
'merchantId' => '101',
|
55
|
+
'version'=>'8.8',
|
56
|
+
'reportGroup'=>'Planets',
|
57
|
+
'planCode'=>'planCodeString',
|
58
|
+
'name'=>'nameString',
|
59
|
+
'intervalType'=>'ANNUAL',
|
60
|
+
'description'=>'descriptionString',
|
61
|
+
'amount'=>'500',
|
62
|
+
'numberOfPayments'=>'2',
|
63
|
+
'trialNumberOfIntervals'=>'1',
|
64
|
+
'trialIntervalType'=>'MONTH',
|
65
|
+
'active'=>'true'
|
66
|
+
}
|
67
|
+
|
68
|
+
response= CnpOnlineRequest.new.create_plan(hash)
|
69
|
+
assert_equal('Valid Format', response.message)
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_simple_error
|
73
|
+
hash = {
|
74
|
+
'merchantId' => '101',
|
75
|
+
'version'=>'8.8',
|
76
|
+
'reportGroup'=>'Planets',
|
77
|
+
'amount' =>'500',
|
78
|
+
'intervalType'=>'ANNUAL',
|
79
|
+
}
|
80
|
+
|
81
|
+
#Get exceptions
|
82
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.create_plan(hash)}
|
83
|
+
#Test
|
84
|
+
assert(exception.message =~ /Error validating xml data against the schema/)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|