CnpOnline 8.31.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +139 -0
  3. data/CONTRIBUTORS +2 -0
  4. data/DESCRIPTION +5 -0
  5. data/LICENSE +22 -0
  6. data/README.md +72 -0
  7. data/Rakefile +89 -0
  8. data/Rakefile~ +89 -0
  9. data/SETUP.md +46 -0
  10. data/bin/Setup.rb +124 -0
  11. data/bin/sample_batch_driver.rb +123 -0
  12. data/bin/sample_driver.rb +49 -0
  13. data/lib/Communications.rb +85 -0
  14. data/lib/Configuration.rb +67 -0
  15. data/lib/EnvironmentVariables.rb +22 -0
  16. data/lib/LitleBatchRequest.rb +562 -0
  17. data/lib/LitleListeners.rb +142 -0
  18. data/lib/LitleOnline.rb +62 -0
  19. data/lib/LitleOnlineRequest.rb +297 -0
  20. data/lib/LitleRequest.rb +494 -0
  21. data/lib/LitleTransaction.rb +463 -0
  22. data/lib/LitleXmlMapper.rb +64 -0
  23. data/lib/XMLFields.rb +1869 -0
  24. data/lib/cacert.pem +3331 -0
  25. data/samples/Auth/LitleAuthReversalTransaction.rb +15 -0
  26. data/samples/Auth/LitleAuthorizationTransaction.rb +31 -0
  27. data/samples/Auth/LitlePaymentFullLifeCycle.rb +47 -0
  28. data/samples/Batch/AccountUpdate.rb +64 -0
  29. data/samples/Batch/SampleBatchDriver.rb +94 -0
  30. data/samples/Capture/LitleCaptureGivenAuthTransaction.rb +30 -0
  31. data/samples/Capture/LitleCaptureTransaction.rb +14 -0
  32. data/samples/Capture/LitleForceCaptureTransaction.rb +26 -0
  33. data/samples/Capture/LitlePartialCapture.rb +16 -0
  34. data/samples/Credit/LitleCreditTransaction.rb +16 -0
  35. data/samples/Credit/LitleRefundTransaction.rb +29 -0
  36. data/samples/Other/LitleAvsTransaction.rb +34 -0
  37. data/samples/Other/LitleVoidTransaction.rb +18 -0
  38. data/samples/Paypage/FullPaypageLifeCycle.rb +74 -0
  39. data/samples/Run_all.rb +17 -0
  40. data/samples/Sale/LitleSaleTransaction.rb +29 -0
  41. data/samples/Sale/SampleSaleTransaction.rb +24 -0
  42. data/test/certification/certTest1_base.rb +945 -0
  43. data/test/certification/certTest2_authenhanced.rb +573 -0
  44. data/test/certification/certTest3_authreversal.rb +185 -0
  45. data/test/certification/certTest4_echeck.rb +278 -0
  46. data/test/certification/certTest5_token.rb +204 -0
  47. data/test/certification/certTest_batchAll.rb +337 -0
  48. data/test/certification/ts_all.rb +33 -0
  49. data/test/functional/test_activate.rb +100 -0
  50. data/test/functional/test_activateReversal.rb +56 -0
  51. data/test/functional/test_auth.rb +298 -0
  52. data/test/functional/test_authReversal.rb +69 -0
  53. data/test/functional/test_balanceInquiry.rb +80 -0
  54. data/test/functional/test_batch.rb +164 -0
  55. data/test/functional/test_batchStream.rb +145 -0
  56. data/test/functional/test_cancelSubscription.rb +55 -0
  57. data/test/functional/test_capture.rb +84 -0
  58. data/test/functional/test_captureGivenAuth.rb +235 -0
  59. data/test/functional/test_configuration.rb +89 -0
  60. data/test/functional/test_createPlan.rb +85 -0
  61. data/test/functional/test_credit.rb +174 -0
  62. data/test/functional/test_deactivate.rb +80 -0
  63. data/test/functional/test_deactivateReversal.rb +56 -0
  64. data/test/functional/test_depositReversal.rb +56 -0
  65. data/test/functional/test_echeckCredit.rb +134 -0
  66. data/test/functional/test_echeckRedeposit.rb +88 -0
  67. data/test/functional/test_echeckSale.rb +177 -0
  68. data/test/functional/test_echeckVerification.rb +127 -0
  69. data/test/functional/test_echeckVoid.rb +41 -0
  70. data/test/functional/test_forceCapture.rb +183 -0
  71. data/test/functional/test_litle_requests.rb +356 -0
  72. data/test/functional/test_load.rb +82 -0
  73. data/test/functional/test_loadReversal.rb +56 -0
  74. data/test/functional/test_override.rb +64 -0
  75. data/test/functional/test_refundReversal.rb +56 -0
  76. data/test/functional/test_sale.rb +259 -0
  77. data/test/functional/test_token.rb +115 -0
  78. data/test/functional/test_unload.rb +82 -0
  79. data/test/functional/test_unloadReversal.rb +56 -0
  80. data/test/functional/test_updateCardValidationNumOnToken.rb +43 -0
  81. data/test/functional/test_updatePlan.rb +58 -0
  82. data/test/functional/test_updateSubscription.rb +76 -0
  83. data/test/functional/test_xmlfields.rb +427 -0
  84. data/test/functional/ts_all.rb +66 -0
  85. data/test/unit/test_LitleAUBatch.rb +216 -0
  86. data/test/unit/test_LitleBatchRequest.rb +643 -0
  87. data/test/unit/test_LitleOnlineRequest.rb +295 -0
  88. data/test/unit/test_LitleRequest.rb +316 -0
  89. data/test/unit/test_LitleTransaction.rb +397 -0
  90. data/test/unit/test_activate.rb +92 -0
  91. data/test/unit/test_activateReversal.rb +44 -0
  92. data/test/unit/test_auth.rb +421 -0
  93. data/test/unit/test_authReversal.rb +82 -0
  94. data/test/unit/test_balanceInquiry.rb +52 -0
  95. data/test/unit/test_cancelSubscription.rb +43 -0
  96. data/test/unit/test_capture.rb +73 -0
  97. data/test/unit/test_captureGivenAuth.rb +188 -0
  98. data/test/unit/test_createPlan.rb +52 -0
  99. data/test/unit/test_credit.rb +342 -0
  100. data/test/unit/test_deactivate.rb +52 -0
  101. data/test/unit/test_deactivateReversal.rb +44 -0
  102. data/test/unit/test_depositReversal.rb +44 -0
  103. data/test/unit/test_echeckCredit.rb +71 -0
  104. data/test/unit/test_echeckRedeposit.rb +94 -0
  105. data/test/unit/test_echeckSale.rb +71 -0
  106. data/test/unit/test_echeckVerification.rb +71 -0
  107. data/test/unit/test_echeckVoid.rb +54 -0
  108. data/test/unit/test_forceCapture.rb +145 -0
  109. data/test/unit/test_load.rb +53 -0
  110. data/test/unit/test_loadReversal.rb +44 -0
  111. data/test/unit/test_refundReversal.rb +44 -0
  112. data/test/unit/test_sale.rb +465 -0
  113. data/test/unit/test_token.rb +144 -0
  114. data/test/unit/test_unload.rb +53 -0
  115. data/test/unit/test_unloadReversal.rb +44 -0
  116. data/test/unit/test_updateCardValidationNumOnToken.rb +80 -0
  117. data/test/unit/test_updatePlan.rb +45 -0
  118. data/test/unit/test_updateSubscription.rb +172 -0
  119. data/test/unit/test_xmlfields.rb +2930 -0
  120. data/test/unit/ts_unit.rb +65 -0
  121. metadata +255 -0
@@ -0,0 +1,55 @@
1
+ =begin
2
+ Copyright (c) 2012 Litle & Co.
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/LitleOnline",__FILE__)
26
+ require 'test/unit'
27
+
28
+ #test Authorization Transaction
29
+ module LitleOnline
30
+ class TestCancelSubscription < Test::Unit::TestCase
31
+ def test_simple_happy
32
+ hash = {
33
+ 'merchantId' => '101',
34
+ 'version'=>'8.8',
35
+ 'reportGroup'=>'Planets',
36
+ 'subscriptionId' =>'1001'
37
+ }
38
+
39
+ response= LitleOnlineRequest.new.cancel_subscription(hash)
40
+ assert_equal('Valid Format', response.message)
41
+ end
42
+
43
+ def test_simple_error
44
+ hash = {
45
+ 'merchantId' => '101',
46
+ 'version'=>'8.8',
47
+ 'reportGroup'=>'Planets',
48
+ }
49
+
50
+ response= LitleOnlineRequest.new.cancel_subscription(hash)
51
+ assert(response.message =~ /Error validating xml data against the schema/)
52
+ end
53
+
54
+ end
55
+ end
@@ -0,0 +1,84 @@
1
+ =begin
2
+ Copyright (c) 2012 Litle & Co.
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/LitleOnline",__FILE__)
26
+ require 'test/unit'
27
+
28
+ module LitleOnline
29
+ class Test_capture < Test::Unit::TestCase
30
+ def test_simple_capture
31
+ hash = {
32
+ 'merchantId' => '101',
33
+ 'version'=>'8.8',
34
+ 'reportGroup'=>'Planets',
35
+ 'litleTxnId'=>'123456000',
36
+ 'amount'=>'106',
37
+ }
38
+ response= LitleOnlineRequest.new.capture(hash)
39
+ assert_equal('Valid Format', response.message)
40
+ end
41
+
42
+ def test_simple_capture_with_partial
43
+ hash = {
44
+ 'merchantId' => '101',
45
+ 'version'=>'8.8',
46
+ 'reportGroup'=>'Planets',
47
+ 'partial'=>'true',
48
+ 'litleTxnId'=>'123456000',
49
+ 'amount'=>'106',
50
+ }
51
+ response= LitleOnlineRequest.new.capture(hash)
52
+ assert_equal('Valid Format', response.message)
53
+ end
54
+
55
+ def test_complex_capture
56
+ hash = {
57
+ 'merchantId' => '101',
58
+ 'version'=>'8.8',
59
+ 'reportGroup'=>'Planets',
60
+ 'litleTxnId'=>'123456000',
61
+ 'amount'=>'106',
62
+ 'enhancedData'=>{
63
+ 'customerReference'=>'Litle',
64
+ 'salesTax'=>'50',
65
+ 'deliveryType'=>'TBD'},
66
+ 'payPalOrderComplete'=>'true'
67
+ }
68
+ response= LitleOnlineRequest.new.capture(hash)
69
+ assert_equal('Valid Format', response.message)
70
+ end
71
+
72
+ def test_no_txn_id
73
+ hash = {
74
+ 'merchantId' => '101',
75
+ 'version'=>'8.8',
76
+ 'reportGroup'=>'Planets',
77
+ 'amount'=>'106',
78
+ }
79
+ response= LitleOnlineRequest.new.capture(hash)
80
+ assert(response.message =~ /Error validating xml data against the schema/)
81
+ end
82
+
83
+ end
84
+ end
@@ -0,0 +1,235 @@
1
+ =begin
2
+ Copyright (c) 2012 Litle & Co.
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/LitleOnline",__FILE__)
26
+ require 'test/unit'
27
+
28
+ module LitleOnline
29
+ class TestcaptureGivenAuth < Test::Unit::TestCase
30
+ def test_simple_capture_given_auth_with_card
31
+ hash = {
32
+ 'merchantId' => '101',
33
+ 'version'=>'8.8',
34
+ 'reportGroup'=>'Planets',
35
+ 'orderId'=>'12344',
36
+ 'amount'=>'106',
37
+ 'authInformation' => {
38
+ 'authDate'=>'2002-10-09','authCode'=>'543216',
39
+ 'authAmount'=>'12345'
40
+ },
41
+ 'orderSource'=>'ecommerce',
42
+ 'card'=>{
43
+ 'type'=>'VI',
44
+ 'number' =>'4100000000000000',
45
+ 'expDate' =>'1210'
46
+ }}
47
+ response= LitleOnlineRequest.new.capture_given_auth(hash)
48
+ assert_equal('Valid Format', response.message)
49
+ end
50
+
51
+ def test_simple_capture_given_auth_with_token
52
+ hash = {
53
+ 'merchantId' => '101',
54
+ 'version'=>'8.8',
55
+ 'reportGroup'=>'Planets',
56
+ 'orderId'=>'12344',
57
+ 'authInformation' => {
58
+ 'authDate'=>'2002-10-09','authCode'=>'543216', 'processingInstructions'=>{'bypassVelocityCheck'=>'true'},
59
+ 'authAmount'=>'12345'
60
+ },
61
+ 'amount'=>'106',
62
+ 'orderSource'=>'ecommerce',
63
+ 'token'=> {
64
+ 'litleToken'=>'123456789101112',
65
+ 'expDate'=>'1210',
66
+ 'cardValidationNum'=>'555',
67
+ 'type'=>'VI'
68
+ }}
69
+ response= LitleOnlineRequest.new.capture_given_auth(hash)
70
+ assert_equal('Valid Format', response.message)
71
+ end
72
+
73
+ def test_fields_out_of_order
74
+ hash = {
75
+ 'merchantId' => '101',
76
+ 'version'=>'8.8',
77
+ 'orderSource'=>'ecommerce',
78
+ 'authInformation' => {
79
+ 'authDate'=>'2002-10-09','authCode'=>'543216',
80
+ 'authAmount'=>'12345'
81
+ },
82
+ 'amount'=>'106',
83
+ 'card'=>{
84
+ 'type'=>'VI',
85
+ 'number' =>'4100000000000000',
86
+ 'expDate' =>'1210'
87
+ },
88
+ 'reportGroup'=>'Planets',
89
+ 'orderId'=>'12344'
90
+ }
91
+ response= LitleOnlineRequest.new.capture_given_auth(hash)
92
+ assert_equal('Valid Format', response.message)
93
+ end
94
+
95
+ def test_invalid_field
96
+ hash = {
97
+ 'merchantId' => '101',
98
+ 'version'=>'8.8',
99
+ 'reportGroup'=>'Planets',
100
+ 'authInformation' => {
101
+ 'authDate'=>'2002-10-09','authCode'=>'543216',
102
+ 'authAmount'=>'12345'
103
+ },
104
+ 'orderId'=>'12344',
105
+ 'amount'=>'106',
106
+ 'orderSource'=>'ecommerce',
107
+ 'card'=>{
108
+ 'NOexistantField' => 'ShouldNotCauseError',
109
+ 'type'=>'VI',
110
+ 'number' =>'4100000000000000',
111
+ 'expDate' =>'1210'
112
+ }}
113
+ response= LitleOnlineRequest.new.capture_given_auth(hash)
114
+ assert_equal('Valid Format', response.message)
115
+ end
116
+
117
+ def test_complex_capture_given_auth
118
+ hash = {
119
+ 'merchantId' => '101',
120
+ 'version'=>'8.8',
121
+ 'reportGroup'=>'Planets',
122
+ 'orderId'=>'12344',
123
+ 'amount'=>'106',
124
+ 'authInformation' => {
125
+ 'authDate'=>'2002-10-09','authCode'=>'543216',
126
+ 'authAmount'=>'12345'
127
+ },
128
+ 'billToAddress'=>{'name'=>'Bob','city'=>'lowell','state'=>'MA','email'=>'litle.com'},
129
+ 'processingInstructions'=>{'bypassVelocityCheck'=>'true'},
130
+ 'orderSource'=>'ecommerce',
131
+ 'card'=>{
132
+ 'type'=>'VI',
133
+ 'number' =>'4100000000000000',
134
+ 'expDate' =>'1210'
135
+ }}
136
+ response= LitleOnlineRequest.new.capture_given_auth(hash)
137
+ assert_equal('Valid Format', response.message)
138
+ end
139
+
140
+ def test_auth_info
141
+ hash = {
142
+ 'merchantId' => '101',
143
+ 'version'=>'8.8',
144
+ 'reportGroup'=>'Planets',
145
+ 'orderId'=>'12344',
146
+ 'amount'=>'106',
147
+ 'authInformation' => {
148
+ 'authDate'=>'2002-10-09','authCode'=>'543216',
149
+ 'authAmount'=>'12345','fraudResult'=>{'avsResult'=>'12','cardValidationResult'=>'123','authenticationResult'=>'1',
150
+ 'advancedAVSResult'=>'123',
151
+ 'advancedFraudResults' => {'deviceReviewStatus' => 'deviceReviewStatusString',
152
+ 'deviceReputationScore' => '100',
153
+ 'triggeredRule' => ['rule1','rule2']
154
+ }
155
+ }
156
+ },
157
+ 'orderSource'=>'ecommerce',
158
+ 'card'=>{
159
+ 'type'=>'VI',
160
+ 'number' =>'4100000000000000',
161
+ 'expDate' =>'1210'
162
+ }}
163
+ response= LitleOnlineRequest.new.capture_given_auth(hash)
164
+ assert_equal('Valid Format', response.message)
165
+ end
166
+
167
+ def test_no_amount
168
+ hash = {
169
+ 'merchantId' => '101',
170
+ 'version'=>'8.8',
171
+ 'reportGroup'=>'Planets',
172
+ 'orderId'=>'12344',
173
+ 'authInformation' => {
174
+ 'authDate'=>'2002-10-09','authCode'=>'543216',
175
+ 'authAmount'=>'12345'
176
+ },
177
+ 'orderSource'=>'ecommerce',
178
+ 'card'=>{
179
+ 'type'=>'VI',
180
+ 'number' =>'4100000000000001',
181
+ 'expDate' =>'1210'
182
+ }}
183
+ response= LitleOnlineRequest.new.capture_given_auth(hash)
184
+ assert(response.message =~ /Error validating xml data against the schema/)
185
+ end
186
+
187
+ def test_simple_captureGivenAuth_with_mpos
188
+ hash = {
189
+ 'merchantId' => '101',
190
+ 'version'=>'8.8',
191
+ 'reportGroup'=>'Planets',
192
+ 'orderId'=>'12344',
193
+ 'amount'=>'106',
194
+ 'authInformation' => {
195
+ 'authDate'=>'2002-10-09','authCode'=>'543216',
196
+ 'authAmount'=>'12345'
197
+ },
198
+ 'orderSource'=>'ecommerce',
199
+ 'mpos'=>
200
+ {
201
+ 'ksn'=>'ksnString',
202
+ 'formatId'=>'30',
203
+ 'encryptedTrack'=>'encryptedTrackString',
204
+ 'track1Status'=>'0',
205
+ 'track2Status'=>'0'
206
+ }
207
+ }
208
+ response= LitleOnlineRequest.new.capture_given_auth(hash)
209
+ assert_equal('Valid Format', response.message)
210
+ end
211
+
212
+ def test_simple_capture_given_auth_with_secondaryAmount
213
+ hash = {
214
+ 'merchantId' => '101',
215
+ 'version'=>'8.8',
216
+ 'reportGroup'=>'Planets',
217
+ 'orderId'=>'12344',
218
+ 'authInformation' => {
219
+ 'authDate'=>'2002-10-09','authCode'=>'543216', 'processingInstructions'=>{'bypassVelocityCheck'=>'true'},
220
+ 'authAmount'=>'12345'
221
+ },
222
+ 'amount'=>'106',
223
+ 'secondaryAmount'=>'50',
224
+ 'orderSource'=>'ecommerce',
225
+ 'token'=> {
226
+ 'litleToken'=>'123456789101112',
227
+ 'expDate'=>'1210',
228
+ 'cardValidationNum'=>'555',
229
+ 'type'=>'VI'
230
+ }}
231
+ response= LitleOnlineRequest.new.capture_given_auth(hash)
232
+ assert_equal('Valid Format', response.message)
233
+ end
234
+ end
235
+ end
@@ -0,0 +1,89 @@
1
+ =begin
2
+ Copyright (c) 2012 Litle & Co.
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/LitleOnline",__FILE__)
24
+ require 'test/unit'
25
+
26
+
27
+ module LitleOnline
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['litle_timeout']='80'
46
+ @config_hash = Configuration.new.config
47
+ assert_equal('80',@config_hash['timeout'])
48
+ ENV['litle_timeout']=nil
49
+ end
50
+
51
+
52
+
53
+ def test_configuration_without_file
54
+ #set up Env variable
55
+ ENV['litle_user']='isola'
56
+ ENV['litle_password']='vinicius'
57
+ ENV['litle_currency_merchant_map']='0180'
58
+ ENV['litle_url']='basketball@gmail.com'
59
+ ENV['litle_proxy_addr']='iwp1.lowell.litle.com'
60
+ ENV['litle_proxy_port']='8080'
61
+ ENV['litle_sftp_username']='sdkFire'
62
+ ENV['litle_sftp_password']='fire is comming'
63
+ ENV['litle_fast_url']='prelive.litle.com'
64
+ ENV['litle_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.litle.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.litle.com',@config_hash['fast_url'])
75
+ assert_equal('15000',@config_hash['fast_port'])
76
+ ENV['litle_user']=nil
77
+ ENV['litle_password']=nil
78
+ ENV['litle_currency_merchant_map']=nil
79
+ ENV['litle_url']=nil
80
+ ENV['litle_proxy_addr']=nil
81
+ ENV['litle_proxy_port']=nil
82
+ ENV['litle_sftp_username']=nil
83
+ ENV['litle_sftp_password']=nil
84
+ ENV['litle_fast_url']=nil
85
+ ENV['litle_fast_port']=nil
86
+ end
87
+
88
+ end
89
+ end