aggcat 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e76c9be70762e7631e51a4d2a8d9d5f7929e7b35
4
- data.tar.gz: 5b028818231cb8023a7b77a8763e54f584e3a947
3
+ metadata.gz: 2babc95ea6a1ae18b2eb38d885ca8c0b6df490f7
4
+ data.tar.gz: e6d99493341928d4597b9183ef7aeda407297830
5
5
  SHA512:
6
- metadata.gz: e66e62910a2b0054439010754af5bb91f956644a8ed1049d7d05e05014d6ff0db182907ab49f1178976593d8068e3fb914a9e34ff779a02a7c0f1b17f6796cc2
7
- data.tar.gz: fea8cdc454ecfd3f2647c8a88668c0c7a40d2199f2d5c83a44627952b2483b8d04a14558c1bbb72a0d3da2af2e45ca2b7be043a0234f8f7801ed0a5d69a8a6c9
6
+ metadata.gz: 200d081f1aa7f64b5e06a749e0575203025ce7a9347018b4f81484482e35fe7e80d3808a091e71996c3561145460545cc671f9871549ec21a512d00fa44142eb
7
+ data.tar.gz: 5bf7761fafd1073abee8445050c54073980d318f765d523c7ef28ff7ad0fc32813704862765eccd8a4d2597107e39ee687d9231a8a3446229cdbed1f44ce09bc
@@ -136,16 +136,12 @@ module Aggcat
136
136
  def credentials(institution_id, login_credentials)
137
137
  institution = institution(institution_id)
138
138
  raise ArgumentError.new("institution_id #{institution_id} is invalid") if institution.nil? || institution[:result][:institution_detail].nil?
139
- institution_login_keys = institution[:result][:institution_detail][:keys][:key].sort { |a, b| a[:display_order].to_i <=> b[:display_order].to_i }
140
-
141
- if institution_login_keys.length != login_credentials.length
142
- raise ArgumentError.new("institution_id #{institution_id} requires #{institution_login_keys.length} credential fields but was only given #{login_credentials.length} to authenticate with.")
139
+ login_keys = institution[:result][:institution_detail][:keys][:key].select { |key| key[:display_flag] == 'true' }.sort { |a, b| a[:display_order].to_i <=> b[:display_order].to_i }
140
+ if login_keys.length != login_credentials.length
141
+ raise ArgumentError.new("institution_id #{institution_id} requires #{login_keys.length} credential fields but was given #{login_credentials.length} to authenticate with.")
143
142
  end
144
143
 
145
- hash = {}
146
- institution_login_keys.each_with_index do |institution_login_key, index|
147
- hash[institution_login_key[:name]] = login_credentials[index].to_s
148
- end
144
+ hash = login_keys.each_with_index.inject({}) { |h, (key, index)| h[key[:name]] = login_credentials[index].to_s; h }
149
145
 
150
146
  xml = Builder::XmlMarkup.new
151
147
  xml.InstitutionLogin('xmlns' => LOGIN_NAMESPACE) do |login|
@@ -1,3 +1,3 @@
1
1
  module Aggcat
2
- VERSION = '0.3.4'
2
+ VERSION = '0.3.5'
3
3
  end
@@ -52,6 +52,15 @@ class ClientTest < Test::Unit::TestCase
52
52
  assert_equal '000000000001', response[:result][:account_list][:banking_account][:account_id]
53
53
  end
54
54
 
55
+ def test_discover_and_add_accounts_inactive_fields
56
+ institution_id = '100000'
57
+ stub_get("/institutions/#{institution_id}").to_return(:body => fixture('institution_hidden_fields.xml'), :headers => {:content_type => 'application/xml; charset=utf-8'})
58
+ stub_post("/institutions/#{institution_id}/logins").to_return(:body => fixture('account.xml'), :headers => {:content_type => 'application/xml; charset=utf-8'})
59
+ response = @client.discover_and_add_accounts(institution_id, 'username', 'password')
60
+ assert_equal institution_id, response[:result][:account_list][:banking_account][:institution_id]
61
+ assert_equal '000000000001', response[:result][:account_list][:banking_account][:account_id]
62
+ end
63
+
55
64
  def test_discover_and_add_accounts_with_challenge
56
65
  institution_id = '100000'
57
66
  stub_get("/institutions/#{institution_id}").to_return(:body => fixture('institution.xml'), :headers => {:content_type => 'application/xml; charset=utf-8'})
@@ -61,6 +70,22 @@ class ClientTest < Test::Unit::TestCase
61
70
  assert_equal '000000000001', response[:result][:account_list][:banking_account][:account_id]
62
71
  end
63
72
 
73
+ def test_discover_and_add_accounts_multiple_credential_args
74
+ institution_id = '100000'
75
+ stub_get("/institutions/#{institution_id}").to_return(:body => fixture('institution_three_credentials.xml'), :headers => {:content_type => 'application/xml; charset=utf-8'})
76
+ stub_post("/institutions/#{institution_id}/logins").to_return(:body => fixture('account.xml'), :headers => {:content_type => 'application/xml; charset=utf-8'})
77
+ response = @client.discover_and_add_accounts(institution_id, 'username', 'password', 'account pin')
78
+ assert_equal institution_id, response[:result][:account_list][:banking_account][:institution_id]
79
+ assert_equal '000000000001', response[:result][:account_list][:banking_account][:account_id]
80
+ end
81
+
82
+ def test_discover_and_add_accounts_not_enough_credentials
83
+ institution_id = '100000'
84
+ stub_get("/institutions/#{institution_id}").to_return(:body => fixture('institution_three_credentials.xml'), :headers => {:content_type => 'application/xml; charset=utf-8'})
85
+ exception = assert_raise(ArgumentError) { @client.discover_and_add_accounts(institution_id, 'username', 'password') }
86
+ assert_equal('institution_id 100000 requires 3 credential fields but was given 2 to authenticate with.', exception.message)
87
+ end
88
+
64
89
  def test_discover_and_add_accounts_bad_args
65
90
  [nil, ''].each do |arg|
66
91
  exception = assert_raise(ArgumentError) { @client.discover_and_add_accounts(arg, 'username', 'password') }
@@ -191,6 +216,23 @@ class ClientTest < Test::Unit::TestCase
191
216
  assert_equal '200', response[:status_code]
192
217
  end
193
218
 
219
+ def test_update_login_multiple_credential_args
220
+ institution_id = '100000'
221
+ login_id = '12345'
222
+ stub_get("/institutions/#{institution_id}").to_return(:body => fixture('institution_three_credentials.xml'), :headers => {:content_type => 'application/xml; charset=utf-8'})
223
+ stub_put("/logins/#{login_id}?refresh=true").to_return(:status => 200)
224
+ response = @client.update_login(institution_id, login_id, 'usename', 'password', 'account pin')
225
+ assert_equal '200', response[:status_code]
226
+ end
227
+
228
+ def test_update_login_not_enough_credentials
229
+ institution_id = '100000'
230
+ login_id = '12345'
231
+ stub_get("/institutions/#{institution_id}").to_return(:body => fixture('institution_three_credentials.xml'), :headers => {:content_type => 'application/xml; charset=utf-8'})
232
+ exception = assert_raise(ArgumentError) { @client.update_login(institution_id, login_id, 'username', 'password') }
233
+ assert_equal('institution_id 100000 requires 3 credential fields but was given 2 to authenticate with.', exception.message)
234
+ end
235
+
194
236
  def test_update_login_bad_args
195
237
  [nil, ''].each do |arg|
196
238
  exception = assert_raise(ArgumentError) { @client.update_login(arg, 1, 'username', 'password') }
@@ -30,7 +30,7 @@
30
30
  <status>Active</status>
31
31
  <valueLengthMin>1</valueLengthMin>
32
32
  <valueLengthMax>100</valueLengthMax>
33
- <displayFlag>false</displayFlag>
33
+ <displayFlag>true</displayFlag>
34
34
  <displayOrder>2</displayOrder>
35
35
  <mask>true</mask>
36
36
  <instructions>2</instructions>
@@ -0,0 +1,51 @@
1
+ <InstitutionDetail xmlns="http://schema.intuit.com/platform/fdatafeed/account/v1"
2
+ xmlns:ns2="http://schema.intuit.com/platform/fdatafeed/common/v1">
3
+ <institutionId>100000</institutionId>
4
+ <institutionName>CCBank</institutionName>
5
+ <homeUrl>http://www.example.com</homeUrl>
6
+ <phoneNumber>123-456-7890</phoneNumber>
7
+ <address>
8
+ <ns2:address1>100 Main Street</ns2:address1>
9
+ <ns2:city>Anytown</ns2:city>
10
+ <ns2:state>CA</ns2:state>
11
+ <ns2:postalCode>94043</ns2:postalCode>
12
+ <ns2:country>USA</ns2:country>
13
+ </address>
14
+ <emailAddress>CustomerCentralBank@intuit.com</emailAddress>
15
+ <currencyCode>ANG</currencyCode>
16
+ <keys>
17
+ <key>
18
+ <name>Banking Userid</name>
19
+ <status>Active</status>
20
+ <valueLengthMin>1</valueLengthMin>
21
+ <valueLengthMax>100</valueLengthMax>
22
+ <displayFlag>true</displayFlag>
23
+ <displayOrder>1</displayOrder>
24
+ <mask>false</mask>
25
+ <instructions>2</instructions>
26
+ <description>2</description>
27
+ </key>
28
+ <key>
29
+ <name>Banking Password</name>
30
+ <status>Active</status>
31
+ <valueLengthMin>1</valueLengthMin>
32
+ <valueLengthMax>100</valueLengthMax>
33
+ <displayFlag>true</displayFlag>
34
+ <displayOrder>2</displayOrder>
35
+ <mask>true</mask>
36
+ <instructions>2</instructions>
37
+ <description>2</description>
38
+ </key>
39
+ <key>
40
+ <name>Banking Password Old</name>
41
+ <status>Active</status>
42
+ <valueLengthMin>1</valueLengthMin>
43
+ <valueLengthMax>100</valueLengthMax>
44
+ <displayFlag>false</displayFlag>
45
+ <displayOrder>2</displayOrder>
46
+ <mask>true</mask>
47
+ <instructions>2</instructions>
48
+ <description>2</description>
49
+ </key>
50
+ </keys>
51
+ </InstitutionDetail>
@@ -0,0 +1,51 @@
1
+ <InstitutionDetail xmlns="http://schema.intuit.com/platform/fdatafeed/account/v1"
2
+ xmlns:ns2="http://schema.intuit.com/platform/fdatafeed/common/v1">
3
+ <institutionId>100000</institutionId>
4
+ <institutionName>CCBank</institutionName>
5
+ <homeUrl>http://www.example.com</homeUrl>
6
+ <phoneNumber>123-456-7890</phoneNumber>
7
+ <address>
8
+ <ns2:address1>100 Main Street</ns2:address1>
9
+ <ns2:city>Anytown</ns2:city>
10
+ <ns2:state>CA</ns2:state>
11
+ <ns2:postalCode>94043</ns2:postalCode>
12
+ <ns2:country>USA</ns2:country>
13
+ </address>
14
+ <emailAddress>CustomerCentralBank@intuit.com</emailAddress>
15
+ <currencyCode>ANG</currencyCode>
16
+ <keys>
17
+ <key>
18
+ <name>Banking Userid</name>
19
+ <status>Active</status>
20
+ <valueLengthMin>1</valueLengthMin>
21
+ <valueLengthMax>100</valueLengthMax>
22
+ <displayFlag>true</displayFlag>
23
+ <displayOrder>1</displayOrder>
24
+ <mask>false</mask>
25
+ <instructions>2</instructions>
26
+ <description>2</description>
27
+ </key>
28
+ <key>
29
+ <name>Banking Password</name>
30
+ <status>Active</status>
31
+ <valueLengthMin>1</valueLengthMin>
32
+ <valueLengthMax>100</valueLengthMax>
33
+ <displayFlag>true</displayFlag>
34
+ <displayOrder>2</displayOrder>
35
+ <mask>true</mask>
36
+ <instructions>2</instructions>
37
+ <description>2</description>
38
+ </key>
39
+ <key>
40
+ <name>Account pin</name>
41
+ <status>Active</status>
42
+ <valueLengthMin>1</valueLengthMin>
43
+ <valueLengthMax>100</valueLengthMax>
44
+ <displayFlag>true</displayFlag>
45
+ <displayOrder>3</displayOrder>
46
+ <mask>true</mask>
47
+ <instructions>2</instructions>
48
+ <description>2</description>
49
+ </key>
50
+ </keys>
51
+ </InstitutionDetail>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aggcat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gene Drabkin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-26 00:00:00.000000000 Z
11
+ date: 2014-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth
@@ -123,6 +123,8 @@ files:
123
123
  - test/fixtures/challenge.xml
124
124
  - test/fixtures/challenges.xml
125
125
  - test/fixtures/institution.xml
126
+ - test/fixtures/institution_hidden_fields.xml
127
+ - test/fixtures/institution_three_credentials.xml
126
128
  - test/fixtures/institutions.xml
127
129
  - test/fixtures/login.xml
128
130
  - test/fixtures/oauth_token.txt
@@ -148,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
150
  version: 1.3.6
149
151
  requirements: []
150
152
  rubyforge_project:
151
- rubygems_version: 2.2.2
153
+ rubygems_version: 2.1.11
152
154
  signing_key:
153
155
  specification_version: 4
154
156
  summary: Ruby client for Intuit Customer Account Data APIs
@@ -161,6 +163,8 @@ test_files:
161
163
  - test/fixtures/challenge.xml
162
164
  - test/fixtures/challenges.xml
163
165
  - test/fixtures/institution.xml
166
+ - test/fixtures/institution_hidden_fields.xml
167
+ - test/fixtures/institution_three_credentials.xml
164
168
  - test/fixtures/institutions.xml
165
169
  - test/fixtures/login.xml
166
170
  - test/fixtures/oauth_token.txt