ofx_for_ruby 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.externalToolBuilders/Rebuild parsers.launch +10 -0
- data/.gitignore +9 -0
- data/.loadpath +5 -0
- data/.project +27 -0
- data/COPYING +674 -0
- data/Gemfile +2 -0
- data/README +47 -0
- data/RELEASE_NOTES +45 -0
- data/Rakefile +63 -0
- data/lib/ofx.rb +60 -0
- data/lib/ofx/1.0.2/banking_message_set.rb +261 -0
- data/lib/ofx/1.0.2/credit_card_statement_message_set.rb +269 -0
- data/lib/ofx/1.0.2/document.rb +34 -0
- data/lib/ofx/1.0.2/email_message_set.rb +34 -0
- data/lib/ofx/1.0.2/financial_institution_profile_message_set.rb +155 -0
- data/lib/ofx/1.0.2/header.rb +48 -0
- data/lib/ofx/1.0.2/interbank_funds_transfer_message_set.rb +30 -0
- data/lib/ofx/1.0.2/investment_security_list_message_set.rb +30 -0
- data/lib/ofx/1.0.2/investment_statement_message_set.rb +30 -0
- data/lib/ofx/1.0.2/lexer.rb +135 -0
- data/lib/ofx/1.0.2/message_set.rb +165 -0
- data/lib/ofx/1.0.2/ofx_102.racc +90 -0
- data/lib/ofx/1.0.2/ofx_102.rex +65 -0
- data/lib/ofx/1.0.2/parser.rb +215 -0
- data/lib/ofx/1.0.2/payment_message_set.rb +30 -0
- data/lib/ofx/1.0.2/serializer.rb +114 -0
- data/lib/ofx/1.0.2/signon_message_set.rb +121 -0
- data/lib/ofx/1.0.2/signup_message_set.rb +186 -0
- data/lib/ofx/1.0.2/statements.rb +54 -0
- data/lib/ofx/1.0.2/status.rb +30 -0
- data/lib/ofx/1.0.2/wire_funds_transfer_message_set.rb +30 -0
- data/lib/ofx/banking_message_set.rb +125 -0
- data/lib/ofx/credit_card_statement_message_set.rb +104 -0
- data/lib/ofx/document.rb +30 -0
- data/lib/ofx/email_message_set.rb +42 -0
- data/lib/ofx/file_unique_identifier.rb +28 -0
- data/lib/ofx/financial_client.rb +76 -0
- data/lib/ofx/financial_institution.rb +83 -0
- data/lib/ofx/financial_institution_profile_message_set.rb +67 -0
- data/lib/ofx/header.rb +115 -0
- data/lib/ofx/http/cacert.pem +3509 -0
- data/lib/ofx/http/ofx_http_client.rb +84 -0
- data/lib/ofx/interbank_funds_transfer_message_set.rb +33 -0
- data/lib/ofx/investment_security_list_message_set.rb +33 -0
- data/lib/ofx/investment_statement_message_set.rb +33 -0
- data/lib/ofx/message_set.rb +78 -0
- data/lib/ofx/payment_message_set.rb +33 -0
- data/lib/ofx/serializer.rb +39 -0
- data/lib/ofx/signon_message_set.rb +141 -0
- data/lib/ofx/signup_message_set.rb +84 -0
- data/lib/ofx/statements.rb +49 -0
- data/lib/ofx/status.rb +100 -0
- data/lib/ofx/transaction_unique_identifier.rb +28 -0
- data/lib/ofx/version.rb +82 -0
- data/lib/ofx/wire_funds_transfer_message_set.rb +33 -0
- data/ofx_for_ruby.gemspec +25 -0
- data/planning/OFX Specification completion.ods +0 -0
- data/test/capital_one/capital_one_helper.rb +77 -0
- data/test/capital_one/fixtures/README +10 -0
- data/test/capital_one/fixtures/fipid-5599.xml +98 -0
- data/test/capital_one/test_banking_statement.rb +108 -0
- data/test/capital_one/test_financial_institution_profile.rb +295 -0
- data/test/capital_one/test_ofx_http_client.rb +72 -0
- data/test/capital_one/test_signup_account_information.rb +100 -0
- data/test/citi/citi_helper.rb +77 -0
- data/test/citi/fixtures/README +9 -0
- data/test/citi/fixtures/fipid-6642.xml +98 -0
- data/test/citi/test_credit_card_statement.rb +159 -0
- data/test/citi/test_financial_institution_profile.rb +231 -0
- data/test/citi/test_ofx_http_client.rb +71 -0
- data/test/citi/test_signup_account_information.rb +85 -0
- data/test/test_helper.rb +4 -0
- data/test/test_ofx_version.rb +141 -0
- metadata +210 -0
@@ -0,0 +1,231 @@
|
|
1
|
+
# Copyright © 2007 Chris Guidry <chrisguidry@gmail.com>
|
2
|
+
#
|
3
|
+
# This file is part of OFX for Ruby.
|
4
|
+
#
|
5
|
+
# OFX for Ruby is free software; you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation; either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# OFX for Ruby is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
|
18
|
+
require File.dirname(__FILE__) + '/citi_helper'
|
19
|
+
|
20
|
+
class CitiFinancialInstitutionProfileTest < Test::Unit::TestCase
|
21
|
+
|
22
|
+
include CitiHelper
|
23
|
+
|
24
|
+
def setup
|
25
|
+
setup_citi_credentials
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_requesting_fresh_fi_profile_from_citi
|
29
|
+
financial_institution = OFX::FinancialInstitution.get_institution('Citi')
|
30
|
+
requestDocument = financial_institution.create_request_document
|
31
|
+
|
32
|
+
client = OFX::FinancialClient.new([[OFX::FinancialInstitutionIdentification.new('Citigroup', '24909'),
|
33
|
+
OFX::UserCredentials.new(@user_name, @password)]])
|
34
|
+
requestDocument.message_sets << client.create_signon_request_message('24909')
|
35
|
+
|
36
|
+
client.date_of_last_profile_update = DateTime.new(2001, 1, 1)
|
37
|
+
requestDocument.message_sets << client.create_profile_update_request_message()
|
38
|
+
|
39
|
+
response_document = financial_institution.send(requestDocument)
|
40
|
+
assert response_document != nil
|
41
|
+
|
42
|
+
verify_citi_header response_document
|
43
|
+
|
44
|
+
assert_not_equal nil, response_document.message_sets
|
45
|
+
assert_equal 2, response_document.message_sets.length
|
46
|
+
|
47
|
+
verify_citi_signon_response response_document
|
48
|
+
|
49
|
+
profile_message = response_document.message_sets[1]
|
50
|
+
assert profile_message.kind_of?(OFX::FinancialInstitutionProfileMessageSet)
|
51
|
+
assert_equal 1, profile_message.responses.length
|
52
|
+
profile_response = profile_message.responses[0]
|
53
|
+
assert profile_response.kind_of?(OFX::FinancialInstitutionProfileResponse)
|
54
|
+
assert_not_equal nil, profile_response.transaction_identifier
|
55
|
+
assert_not_equal nil, profile_response.status
|
56
|
+
assert profile_response.status.kind_of?(OFX::Information)
|
57
|
+
assert profile_response.status.kind_of?(OFX::Success)
|
58
|
+
assert_equal 0, profile_response.status.code
|
59
|
+
assert_equal :information, profile_response.status.severity
|
60
|
+
assert_equal nil, profile_response.status.message
|
61
|
+
|
62
|
+
assert_not_equal nil, profile_response.date_of_last_profile_update
|
63
|
+
assert_equal "Citigroup", profile_response.financial_institution_name
|
64
|
+
assert_equal "8787 Baypine Road", profile_response.address
|
65
|
+
assert_equal "Jacksonville", profile_response.city
|
66
|
+
assert_equal "FL", profile_response.state
|
67
|
+
assert_equal "32256", profile_response.postal_code
|
68
|
+
assert_equal "USA", profile_response.country
|
69
|
+
assert_equal "1-800-950-5114", profile_response.customer_service_telephone
|
70
|
+
assert_equal "1-800-347-4934", profile_response.technical_support_telephone
|
71
|
+
assert_equal nil, profile_response.facsimile_telephone
|
72
|
+
assert_equal URI.parse("http://www.citicards.com"), profile_response.url
|
73
|
+
assert_equal nil, profile_response.email_address
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
assert_not_equal nil, profile_response.message_sets
|
78
|
+
assert_equal 4, profile_response.message_sets.length
|
79
|
+
|
80
|
+
# unsupported message sets
|
81
|
+
assert_equal nil, profile_response.message_sets[OFX::BankingMessageSet]
|
82
|
+
assert_equal nil, profile_response.message_sets[OFX::InvestmentStatementMessageSet]
|
83
|
+
assert_equal nil, profile_response.message_sets[OFX::InterbankFundsTransferMessageSet]
|
84
|
+
assert_equal nil, profile_response.message_sets[OFX::WireFundsTransferMessageSet]
|
85
|
+
assert_equal nil, profile_response.message_sets[OFX::InvestmentSecurityListMessageSet]
|
86
|
+
assert_equal nil, profile_response.message_sets[OFX::PaymentMessageSet]
|
87
|
+
assert_equal nil, profile_response.message_sets[OFX::EmailMessageSet]
|
88
|
+
|
89
|
+
# signon
|
90
|
+
assert_not_equal nil, profile_response.message_sets[OFX::SignonMessageSet]
|
91
|
+
assert_equal 1, profile_response.message_sets[OFX::SignonMessageSet].length
|
92
|
+
profile = profile_response.message_sets[OFX::SignonMessageSet][OFX::Version.new(1)]
|
93
|
+
assert_not_equal nil, profile
|
94
|
+
assert profile.kind_of?(OFX::SignonMessageSetProfile)
|
95
|
+
assert_equal OFX::SignonMessageSet, profile.message_set_class
|
96
|
+
assert_equal OFX::Version.new(1), profile.version
|
97
|
+
assert_equal 'Intelidata', profile.service_provider_name
|
98
|
+
assert_equal URI.parse('https://secureofx2.bankhost.com/citi/cgi-forte/ofx_rt?servicename=ofx_rt&pagename=ofx'), profile.message_url
|
99
|
+
assert_equal 'NONE', profile.required_ofx_security
|
100
|
+
assert_equal true, profile.requires_transport_security?
|
101
|
+
assert_equal 'CITI-REALM', profile.signon_realm
|
102
|
+
assert_equal 'ENG', profile.language
|
103
|
+
assert_equal 'LITE', profile.synchronization_mode
|
104
|
+
assert_equal true, profile.supports_response_file_error_recovery?
|
105
|
+
|
106
|
+
# signup
|
107
|
+
assert_not_equal nil, profile_response.message_sets[OFX::SignupMessageSet]
|
108
|
+
assert_equal 1, profile_response.message_sets[OFX::SignupMessageSet].length
|
109
|
+
profile = profile_response.message_sets[OFX::SignupMessageSet][OFX::Version.new(1)]
|
110
|
+
assert_not_equal nil, profile
|
111
|
+
assert profile.kind_of?(OFX::SignupMessageSetProfile)
|
112
|
+
assert_equal OFX::SignupMessageSet, profile.message_set_class
|
113
|
+
assert_equal OFX::Version.new(1), profile.version
|
114
|
+
assert_equal 'Intelidata', profile.service_provider_name
|
115
|
+
assert_equal URI.parse('https://secureofx2.bankhost.com/citi/cgi-forte/ofx_rt?servicename=ofx_rt&pagename=ofx'), profile.message_url
|
116
|
+
assert_equal 'NONE', profile.required_ofx_security
|
117
|
+
assert_equal true, profile.requires_transport_security?
|
118
|
+
assert_equal 'CITI-REALM', profile.signon_realm
|
119
|
+
assert_equal 'ENG', profile.language
|
120
|
+
assert_equal 'LITE', profile.synchronization_mode
|
121
|
+
assert_equal true, profile.supports_response_file_error_recovery
|
122
|
+
assert_not_equal nil, profile.enrollment
|
123
|
+
assert profile.enrollment.kind_of?(OFX::Enrollment)
|
124
|
+
assert profile.enrollment.kind_of?(OFX::ClientEnrollment)
|
125
|
+
assert_equal false, profile.enrollment.account_number_required
|
126
|
+
assert_equal false, profile.user_information_changes_allowed?
|
127
|
+
assert_equal true, profile.available_account_requests_allowed?
|
128
|
+
assert_equal false, profile.service_activation_requests_allowed?
|
129
|
+
|
130
|
+
# credit cards
|
131
|
+
assert_not_equal nil, profile_response.message_sets[OFX::CreditCardStatementMessageSet]
|
132
|
+
assert_equal 1, profile_response.message_sets[OFX::CreditCardStatementMessageSet].length
|
133
|
+
profile = profile_response.message_sets[OFX::CreditCardStatementMessageSet][OFX::Version.new(1)]
|
134
|
+
assert_not_equal nil, profile
|
135
|
+
assert profile.kind_of?(OFX::CreditCardStatementMessageSetProfile)
|
136
|
+
assert_equal OFX::CreditCardStatementMessageSet, profile.message_set_class
|
137
|
+
assert_equal OFX::Version.new(1), profile.version
|
138
|
+
assert_equal 'Intelidata', profile.service_provider_name
|
139
|
+
assert_equal URI.parse('https://secureofx2.bankhost.com/citi/cgi-forte/ofx_rt?servicename=ofx_rt&pagename=ofx'), profile.message_url
|
140
|
+
assert_equal 'NONE', profile.required_ofx_security
|
141
|
+
assert_equal true, profile.requires_transport_security?
|
142
|
+
assert_equal 'CITI-REALM', profile.signon_realm
|
143
|
+
assert_equal 'ENG', profile.language
|
144
|
+
assert_equal 'LITE', profile.synchronization_mode
|
145
|
+
assert_equal true, profile.supports_response_file_error_recovery?
|
146
|
+
assert_equal true, profile.closing_statement_available
|
147
|
+
|
148
|
+
# profile
|
149
|
+
assert_not_equal nil, profile_response.message_sets[OFX::FinancialInstitutionProfileMessageSet]
|
150
|
+
assert_equal 1, profile_response.message_sets[OFX::FinancialInstitutionProfileMessageSet].length
|
151
|
+
profile = profile_response.message_sets[OFX::FinancialInstitutionProfileMessageSet][OFX::Version.new(1)]
|
152
|
+
assert_not_equal nil, profile
|
153
|
+
assert profile.kind_of?(OFX::FinancialInstitutionProfileMessageSetProfile)
|
154
|
+
assert_equal OFX::FinancialInstitutionProfileMessageSet, profile.message_set_class
|
155
|
+
assert_equal OFX::Version.new(1), profile.version
|
156
|
+
assert_equal 'Intelidata', profile.service_provider_name
|
157
|
+
assert_equal URI.parse('https://secureofx2.bankhost.com/citi/cgi-forte/ofx_rt?servicename=ofx_rt&pagename=ofx'), profile.message_url
|
158
|
+
assert_equal 'NONE', profile.required_ofx_security
|
159
|
+
assert_equal true, profile.requires_transport_security?
|
160
|
+
assert_equal 'CITI-REALM', profile.signon_realm
|
161
|
+
assert_equal 'ENG', profile.language
|
162
|
+
assert_equal 'LITE', profile.synchronization_mode
|
163
|
+
assert_equal true, profile.supports_response_file_error_recovery?
|
164
|
+
|
165
|
+
assert_not_equal nil, profile_response.signon_realms
|
166
|
+
assert_equal 1, profile_response.signon_realms.length
|
167
|
+
signon_realm = profile_response.signon_realms[0]
|
168
|
+
assert_equal 'CITI-REALM', signon_realm.name
|
169
|
+
assert_equal 6..32, signon_realm.password_length_constraint
|
170
|
+
assert_equal :alphabetic_or_numeric, signon_realm.password_characters_constraint
|
171
|
+
assert_equal false, signon_realm.case_sensitive
|
172
|
+
assert_equal true, signon_realm.allows_special_characters
|
173
|
+
assert_equal true, signon_realm.allows_spaces
|
174
|
+
assert_equal false, signon_realm.supports_pin_changes
|
175
|
+
assert_equal false, signon_realm.requires_initial_pin_change
|
176
|
+
end
|
177
|
+
|
178
|
+
# def test_requesting_up_to_date_fi_profile_from_citi
|
179
|
+
# financial_institution = OFX::FinancialInstitution.get_institution('Capital One')
|
180
|
+
# requestDocument = financial_institution.create_request_document
|
181
|
+
#
|
182
|
+
# client = OFX::FinancialClient.new([[OFX::FinancialInstitutionIdentification.new('Hibernia', '1001'),
|
183
|
+
# OFX::UserCredentials.new(@capitalOneUserName, @capitalOnePassword)]])
|
184
|
+
# requestDocument.message_sets << client.create_signon_request_message('1001')
|
185
|
+
#
|
186
|
+
# client.date_of_last_profile_update = DateTime.now
|
187
|
+
# requestDocument.message_sets << client.create_profile_update_request_message()
|
188
|
+
#
|
189
|
+
# response_document = financial_institution.send(requestDocument)
|
190
|
+
# assert response_document != nil
|
191
|
+
#
|
192
|
+
# verify_citi_header response_document
|
193
|
+
#
|
194
|
+
# assert_not_equal nil, response_document.message_sets
|
195
|
+
# assert_equal 2, response_document.message_sets.length
|
196
|
+
#
|
197
|
+
# verify_citi_signon_response response_document
|
198
|
+
#
|
199
|
+
# profile_message = response_document.message_sets[1]
|
200
|
+
# assert profile_message.kind_of?(OFX::FinancialInstitutionProfileMessageSet)
|
201
|
+
# assert_equal 1, profile_message.responses.length
|
202
|
+
# profile_response = profile_message.responses[0]
|
203
|
+
# assert profile_response.kind_of?(OFX::FinancialInstitutionProfileResponse)
|
204
|
+
# assert_not_equal nil, profile_response.transaction_identifier
|
205
|
+
# assert_not_equal nil, profile_response.status
|
206
|
+
# assert profile_response.status.kind_of?(OFX::Information)
|
207
|
+
# assert profile_response.status.kind_of?(OFX::ClientUpToDate)
|
208
|
+
# assert_equal 1, profile_response.status.code
|
209
|
+
# assert_equal :information, profile_response.status.severity
|
210
|
+
# assert_not_equal nil, profile_response.status.message
|
211
|
+
#
|
212
|
+
# assert_equal nil, profile_response.date_of_last_profile_update
|
213
|
+
# assert_equal nil, profile_response.financial_institution_name
|
214
|
+
# assert_equal nil, profile_response.address
|
215
|
+
# assert_equal nil, profile_response.city
|
216
|
+
# assert_equal nil, profile_response.state
|
217
|
+
# assert_equal nil, profile_response.postal_code
|
218
|
+
# assert_equal nil, profile_response.country
|
219
|
+
# assert_equal nil, profile_response.customer_service_telephone
|
220
|
+
# assert_equal nil, profile_response.technical_support_telephone
|
221
|
+
# assert_equal nil, profile_response.facsimile_telephone
|
222
|
+
# assert_equal nil, profile_response.url
|
223
|
+
# assert_equal nil, profile_response.email_address
|
224
|
+
#
|
225
|
+
# assert_not_equal nil, profile_response.message_sets
|
226
|
+
# assert_equal 0, profile_response.message_sets.length
|
227
|
+
#
|
228
|
+
# assert_not_equal nil, profile_response.signon_realms
|
229
|
+
# assert_equal 0, profile_response.signon_realms.length
|
230
|
+
# end
|
231
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# Copyright © 2007 Chris Guidry <chrisguidry@gmail.com>
|
2
|
+
#
|
3
|
+
# This file is part of OFX for Ruby.
|
4
|
+
#
|
5
|
+
# OFX for Ruby is free software; you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation; either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# OFX for Ruby is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
|
18
|
+
require File.dirname(__FILE__) + '/citi_helper'
|
19
|
+
|
20
|
+
class CitiOFXHTTPClientTest < Test::Unit::TestCase
|
21
|
+
|
22
|
+
include CitiHelper
|
23
|
+
|
24
|
+
def setup
|
25
|
+
setup_citi_credentials
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_account_info_request_to_citi
|
29
|
+
account_info_request =
|
30
|
+
"OFXHEADER:100
|
31
|
+
DATA:OFXSGML
|
32
|
+
VERSION:102
|
33
|
+
SECURITY:NONE
|
34
|
+
ENCODING:USASCII
|
35
|
+
CHARSET:1252
|
36
|
+
COMPRESSION:NONE
|
37
|
+
OLDFILEUID:NONE
|
38
|
+
NEWFILEUID:20070624162951.735621
|
39
|
+
|
40
|
+
<OFX>
|
41
|
+
<SIGNONMSGSRQV1>
|
42
|
+
<SONRQ>
|
43
|
+
<DTCLIENT>20070624162951.736219[0:Z]
|
44
|
+
<USERID>#{@user_name}
|
45
|
+
<USERPASS>#{@password}
|
46
|
+
<LANGUAGE>ENG
|
47
|
+
<FI>
|
48
|
+
<ORG>Citigroup
|
49
|
+
<FID>24909
|
50
|
+
</FI>
|
51
|
+
<APPID>OFX
|
52
|
+
<APPVER>0010
|
53
|
+
</SONRQ>
|
54
|
+
</SIGNONMSGSRQV1>
|
55
|
+
<PROFMSGSRQV1>
|
56
|
+
<PROFTRNRQ>
|
57
|
+
<TRNUID>20070624162951.737132
|
58
|
+
<PROFRQ>
|
59
|
+
<CLIENTROUTING>MSGSET
|
60
|
+
<DTPROFUP>20010101000000.0[0:Z]
|
61
|
+
</PROFRQ>
|
62
|
+
</PROFTRNRQ>
|
63
|
+
</PROFMSGSRQV1>
|
64
|
+
</OFX>"
|
65
|
+
|
66
|
+
client = OFX::HTTPClient.new(URI.parse('https://secureofx2.bankhost.com/citi/cgi-forte/ofx_rt?servicename=ofx_rt&pagename=ofx'))
|
67
|
+
account_info_response = client.send(account_info_request)
|
68
|
+
assert account_info_response != nil
|
69
|
+
assert account_info_response[0..12] == 'OFXHEADER:100'
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# Copyright © 2007 Chris Guidry <chrisguidry@gmail.com>
|
2
|
+
#
|
3
|
+
# This file is part of OFX for Ruby.
|
4
|
+
#
|
5
|
+
# OFX for Ruby is free software; you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation; either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# OFX for Ruby is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
|
18
|
+
require File.dirname(__FILE__) + '/citi_helper'
|
19
|
+
|
20
|
+
class CitiSignupAccountInformationTest < Test::Unit::TestCase
|
21
|
+
|
22
|
+
include CitiHelper
|
23
|
+
|
24
|
+
def setup
|
25
|
+
setup_citi_credentials
|
26
|
+
setup_citi_accounts
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_requesting_fresh_fi_profile_from_capital_one
|
30
|
+
financial_institution = OFX::FinancialInstitution.get_institution('Citi')
|
31
|
+
requestDocument = financial_institution.create_request_document
|
32
|
+
|
33
|
+
client = OFX::FinancialClient.new([[OFX::FinancialInstitutionIdentification.new('Citigroup', '24909'),
|
34
|
+
OFX::UserCredentials.new(@user_name, @password)]])
|
35
|
+
requestDocument.message_sets << client.create_signon_request_message('24909')
|
36
|
+
|
37
|
+
|
38
|
+
signup_message_set = OFX::SignupMessageSet.new
|
39
|
+
account_info_request = OFX::AccountInformationRequest.new
|
40
|
+
account_info_request.transaction_identifier = OFX::TransactionUniqueIdentifier.new
|
41
|
+
account_info_request.date_of_last_account_update = DateTime.new(2001, 1, 1)
|
42
|
+
signup_message_set.requests << account_info_request
|
43
|
+
requestDocument.message_sets << signup_message_set
|
44
|
+
|
45
|
+
|
46
|
+
response_document = financial_institution.send(requestDocument)
|
47
|
+
assert response_document != nil
|
48
|
+
|
49
|
+
verify_citi_header response_document
|
50
|
+
|
51
|
+
assert_not_equal nil, response_document.message_sets
|
52
|
+
assert_equal 2, response_document.message_sets.length
|
53
|
+
|
54
|
+
verify_citi_signon_response response_document
|
55
|
+
|
56
|
+
signup_message = response_document.message_sets[1]
|
57
|
+
assert signup_message.kind_of?(OFX::SignupMessageSet)
|
58
|
+
assert_equal 1, signup_message.responses.length
|
59
|
+
account_info_response = signup_message.responses[0]
|
60
|
+
assert account_info_response.kind_of?(OFX::AccountInformationResponse)
|
61
|
+
assert_not_equal nil, account_info_response.transaction_identifier
|
62
|
+
assert_not_equal nil, account_info_response.status
|
63
|
+
assert account_info_response.status.kind_of?(OFX::Information)
|
64
|
+
assert account_info_response.status.kind_of?(OFX::Success)
|
65
|
+
assert_equal 0, account_info_response.status.code
|
66
|
+
assert_equal :information, account_info_response.status.severity
|
67
|
+
assert_equal nil, account_info_response.status.message
|
68
|
+
|
69
|
+
assert_not_equal nil, account_info_response.date_of_last_account_update
|
70
|
+
|
71
|
+
assert_not_equal nil, account_info_response.accounts
|
72
|
+
assert_equal 1, account_info_response.accounts.length
|
73
|
+
|
74
|
+
credit_card = account_info_response.accounts[0]
|
75
|
+
assert_equal 'CREDIT CARD ************5398', credit_card.description
|
76
|
+
assert_equal nil, credit_card.phone_number
|
77
|
+
assert_not_equal nil, credit_card.account_information
|
78
|
+
assert_not_equal nil, credit_card.account_information.account
|
79
|
+
assert_equal @accounts[:credit_card], credit_card.account_information.account.account_identifier
|
80
|
+
assert_equal true, credit_card.account_information.supports_transaction_detail_downloads
|
81
|
+
assert_equal false, credit_card.account_information.transfer_source
|
82
|
+
assert_equal false, credit_card.account_information.transfer_destination
|
83
|
+
assert_equal :active, credit_card.account_information.status
|
84
|
+
end
|
85
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
# Copyright © 2007 Chris Guidry <chrisguidry@gmail.com>
|
2
|
+
#
|
3
|
+
# This file is part of OFX for Ruby.
|
4
|
+
#
|
5
|
+
# OFX for Ruby is free software; you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation; either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# OFX for Ruby is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
|
18
|
+
require File.dirname(__FILE__) + '/test_helper'
|
19
|
+
|
20
|
+
class OFXVersionTest < Test::Unit::TestCase
|
21
|
+
|
22
|
+
def test_creating_from_array
|
23
|
+
version = OFX::Version.new([1, 2, 3])
|
24
|
+
|
25
|
+
assert_equal OFX::Version.new('1.2.3'), version
|
26
|
+
|
27
|
+
assert_equal 1, version.major
|
28
|
+
assert_equal 2, version.minor
|
29
|
+
assert_equal 3, version.revision
|
30
|
+
|
31
|
+
assert_equal [1, 2, 3], version.to_a
|
32
|
+
assert_equal '1.2.3', version.to_dotted_s
|
33
|
+
assert_equal '123', version.to_compact_s
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_creating_from_compact_string
|
37
|
+
version = OFX::Version.new('123')
|
38
|
+
|
39
|
+
assert_equal OFX::Version.new('1.2.3'), version
|
40
|
+
|
41
|
+
assert_equal 1, version.major
|
42
|
+
assert_equal 2, version.minor
|
43
|
+
assert_equal 3, version.revision
|
44
|
+
|
45
|
+
assert_equal [1, 2, 3], version.to_a
|
46
|
+
assert_equal '1.2.3', version.to_dotted_s
|
47
|
+
assert_equal '123', version.to_compact_s
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_creating_from_dotted_string
|
51
|
+
version = OFX::Version.new('1.2.3')
|
52
|
+
|
53
|
+
assert_equal OFX::Version.new([1, 2, 3]), version
|
54
|
+
|
55
|
+
assert_equal 1, version.major
|
56
|
+
assert_equal 2, version.minor
|
57
|
+
assert_equal 3, version.revision
|
58
|
+
|
59
|
+
assert_equal [1, 2, 3], version.to_a
|
60
|
+
assert_equal '1.2.3', version.to_dotted_s
|
61
|
+
assert_equal '123', version.to_compact_s
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_creating_from_number
|
65
|
+
version = OFX::Version.new(1)
|
66
|
+
|
67
|
+
assert_equal OFX::Version.new([1, 0, 0]), version
|
68
|
+
|
69
|
+
assert_equal 1, version.major
|
70
|
+
assert_equal 0, version.minor
|
71
|
+
assert_equal 0, version.revision
|
72
|
+
|
73
|
+
assert_equal [1, 0, 0], version.to_a
|
74
|
+
assert_equal '1.0.0', version.to_dotted_s
|
75
|
+
assert_equal '100', version.to_compact_s
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_creating_from_single_character
|
79
|
+
version = OFX::Version.new('1')
|
80
|
+
|
81
|
+
assert_equal OFX::Version.new([1, 0, 0]), version
|
82
|
+
|
83
|
+
assert_equal 1, version.major
|
84
|
+
assert_equal 0, version.minor
|
85
|
+
assert_equal 0, version.revision
|
86
|
+
|
87
|
+
assert_equal [1, 0, 0], version.to_a
|
88
|
+
assert_equal '1.0.0', version.to_dotted_s
|
89
|
+
assert_equal '100', version.to_compact_s
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_version_comparisons
|
93
|
+
low_version = OFX::Version.new('1.0.0')
|
94
|
+
low_revision = OFX::Version.new('1.0.1')
|
95
|
+
low_upgrade = OFX::Version.new('1.2.0')
|
96
|
+
low_upgrade_patch = OFX::Version.new('1.2.1')
|
97
|
+
next_version = OFX::Version.new('2.0.1')
|
98
|
+
next_version_patch = OFX::Version.new('2.0.2')
|
99
|
+
next_version_revision = OFX::Version.new('2.2.0')
|
100
|
+
|
101
|
+
assert_equal low_version, OFX::Version.new('1.0.0')
|
102
|
+
assert_equal low_revision, OFX::Version.new('1.0.1')
|
103
|
+
assert_equal low_upgrade, OFX::Version.new('1.2.0')
|
104
|
+
assert_equal low_upgrade_patch, OFX::Version.new('1.2.1')
|
105
|
+
assert_equal next_version, OFX::Version.new('2.0.1')
|
106
|
+
assert_equal next_version_patch, OFX::Version.new('2.0.2')
|
107
|
+
assert_equal next_version_revision, OFX::Version.new('2.2.0')
|
108
|
+
|
109
|
+
assert low_version < low_revision
|
110
|
+
assert low_revision < low_upgrade
|
111
|
+
assert low_upgrade < low_upgrade_patch
|
112
|
+
assert low_upgrade_patch < next_version
|
113
|
+
assert next_version < next_version_patch
|
114
|
+
assert next_version_patch < next_version_revision
|
115
|
+
|
116
|
+
assert low_revision > low_version
|
117
|
+
assert low_upgrade > low_revision
|
118
|
+
assert low_upgrade_patch > low_upgrade
|
119
|
+
assert next_version > low_upgrade_patch
|
120
|
+
assert next_version_patch > next_version
|
121
|
+
assert next_version_revision > next_version_patch
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_version_empty
|
125
|
+
assert OFX::Version.new(nil).empty?
|
126
|
+
assert OFX::Version.new('').empty?
|
127
|
+
assert OFX::Version.new([0, 0, 0]).empty?
|
128
|
+
assert OFX::Version.new('000').empty?
|
129
|
+
assert OFX::Version.new('0.0.0').empty?
|
130
|
+
end
|
131
|
+
|
132
|
+
def test_as_hash_key
|
133
|
+
hash =
|
134
|
+
{ OFX::Version.new(1) => 1,
|
135
|
+
OFX::Version.new(2) => 2}
|
136
|
+
|
137
|
+
assert_equal 1, hash[OFX::Version.new('1')]
|
138
|
+
assert_equal 2, hash[OFX::Version.new('2')]
|
139
|
+
assert_equal nil, hash[OFX::Version.new('3')]
|
140
|
+
end
|
141
|
+
end
|