aggcat 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,10 +26,10 @@ module Aggcat
26
26
  post("/institutions/#{institution_id}/logins", body)
27
27
  end
28
28
 
29
- def account_confirmation(institution_id, challenge_session_id, challenge_node_id, answer)
30
- validate(institution_id: institution_id, challenge_node_id: challenge_session_id, challenge_node_id: challenge_node_id, answer: answer)
29
+ def account_confirmation(institution_id, challenge_session_id, challenge_node_id, answers)
30
+ validate(institution_id: institution_id, challenge_node_id: challenge_session_id, challenge_node_id: challenge_node_id, answers: answers)
31
31
  headers = {'challengeSessionId' => challenge_session_id, 'challengeNodeId' => challenge_node_id}
32
- post("/institutions/#{institution_id}/logins", challenge_answer(answer), headers)
32
+ post("/institutions/#{institution_id}/logins", challenge_answers(answers), headers)
33
33
  end
34
34
 
35
35
  def accounts
@@ -56,10 +56,10 @@ module Aggcat
56
56
  put("/logins/#{login_id}?refresh=true", body)
57
57
  end
58
58
 
59
- def update_login_confirmation(login_id, challenge_session_id, challenge_node_id, answer)
60
- validate(login_id: login_id, challenge_node_id: challenge_session_id, challenge_node_id: challenge_node_id, answer: answer)
61
- headers = {challengeSessionId: challenge_session_id, challengeNodeId: challenge_node_id}
62
- put("/logins/#{login_id}?refresh=true", challenge_answer(answer), headers)
59
+ def update_login_confirmation(login_id, challenge_session_id, challenge_node_id, answers)
60
+ validate(login_id: login_id, challenge_node_id: challenge_session_id, challenge_node_id: challenge_node_id, answers: answers)
61
+ headers = {'challengeSessionId' => challenge_session_id, 'challengeNodeId' => challenge_node_id}
62
+ put("/logins/#{login_id}?refresh=true", challenge_answers(answers), headers)
63
63
  end
64
64
 
65
65
  def delete_account(account_id)
@@ -143,14 +143,17 @@ module Aggcat
143
143
  end
144
144
  end
145
145
 
146
- def challenge_answer(answer)
146
+ def challenge_answers(answers)
147
147
  xml = Builder::XmlMarkup.new
148
148
  xml.InstitutionLogin('xmlns' => LOGIN_NAMESPACE) do |login|
149
149
  login.challengeResponses do |challenge|
150
- challenge.response(answer, 'xmlns' => CHALLENGE_NAMESPACE)
150
+ [answers].flatten.each do |answer|
151
+ challenge.response(answer, 'xmlns' => CHALLENGE_NAMESPACE)
152
+ end
151
153
  end
152
154
  end
153
155
  end
156
+
154
157
  end
155
158
  end
156
159
 
@@ -1,3 +1,3 @@
1
1
  module Aggcat
2
- VERSION = '0.2.5'
2
+ VERSION = '0.2.6'
3
3
  end
@@ -189,6 +189,17 @@ class ClientTest < Test::Unit::TestCase
189
189
  @client.account_confirmation(institution_id, challenge_session_id, challenge_node_id, answer)
190
190
  end
191
191
 
192
+ def test_account_confirmation_multi_answer
193
+ institution_id = '100000'
194
+ challenge_session_id = '1234'
195
+ challenge_node_id = '4321'
196
+ answers = ['answer1', 'answer2']
197
+ parser = XmlHasher::Parser.new(snakecase: true, ignore_namespaces: true)
198
+ stub_get("/institutions/#{institution_id}").to_return(:body => fixture('institution.xml'), :headers => {:content_type => 'application/xml; charset=utf-8'})
199
+ stub_post("/institutions/#{institution_id}/logins").to_return(:body => lambda { |request| assert_equal(parser.parse(fixture('challenges.xml')), parser.parse(request.body)) })
200
+ @client.account_confirmation(institution_id, challenge_session_id, challenge_node_id, answers)
201
+ end
202
+
192
203
  def test_update_login_confirmation
193
204
  login_id = '1234567890'
194
205
  challenge_session_id = '1234'
@@ -204,6 +215,21 @@ class ClientTest < Test::Unit::TestCase
204
215
  @client.update_login_confirmation(login_id, challenge_session_id, challenge_node_id, answer)
205
216
  end
206
217
 
218
+ def test_update_login_confirmation_multi_answers
219
+ login_id = '1234567890'
220
+ challenge_session_id = '1234'
221
+ challenge_node_id = '4321'
222
+ answers = ['answer1', 'answer2']
223
+ validator = lambda do |request|
224
+ parser = XmlHasher::Parser.new(snakecase: true, ignore_namespaces: true)
225
+ assert_equal(parser.parse(fixture('challenges.xml')), parser.parse(request.body))
226
+ assert_equal(challenge_session_id, request.headers['Challengesessionid'])
227
+ assert_equal(challenge_node_id, request.headers['Challengenodeid'])
228
+ end
229
+ stub_put("/logins/#{login_id}?refresh=true").to_return(:body => validator)
230
+ @client.update_login_confirmation(login_id, challenge_session_id, challenge_node_id, answers)
231
+ end
232
+
207
233
  def test_retry_success
208
234
  institution_id = '100000'
209
235
  stub_get("/institutions/#{institution_id}").to_timeout.times(1).then.to_return(:body => fixture('institution.xml'), :headers => {:content_type => 'application/xml; charset=utf-8'})
@@ -0,0 +1,6 @@
1
+ <InstitutionLogin xmlns:v1="http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1">
2
+ <challengeResponses>
3
+ <response xmlns:v11="http://schema.intuit.com/platform/fdatafeed/challenge/v1">answer1</response>
4
+ <response xmlns:v11="http://schema.intuit.com/platform/fdatafeed/challenge/v1">answer2</response>
5
+ </challengeResponses>
6
+ </InstitutionLogin>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aggcat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -148,6 +148,7 @@ files:
148
148
  - test/fixtures/accounts.xml
149
149
  - test/fixtures/cert.key
150
150
  - test/fixtures/challenge.xml
151
+ - test/fixtures/challenges.xml
151
152
  - test/fixtures/institution.xml
152
153
  - test/fixtures/institutions.xml
153
154
  - test/fixtures/login.xml
@@ -186,6 +187,7 @@ test_files:
186
187
  - test/fixtures/accounts.xml
187
188
  - test/fixtures/cert.key
188
189
  - test/fixtures/challenge.xml
190
+ - test/fixtures/challenges.xml
189
191
  - test/fixtures/institution.xml
190
192
  - test/fixtures/institutions.xml
191
193
  - test/fixtures/login.xml