yodlee_wrap 0.0.0 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,21 +1,20 @@
1
- require "yodleeicious"
1
+ require "yodlee_wrap"
2
+ require "byebug"
2
3
 
3
4
  describe 'the yodlee api client integration tests', integration: true do
4
- let(:config) {
5
- {
6
- base_url: ENV['YODLEE_BASE_URL'],
5
+ let(:config) {
6
+ {
7
7
  cobranded_username: ENV['YODLEE_COBRANDED_USERNAME'],
8
8
  cobranded_password: ENV['YODLEE_COBRANDED_PASSWORD'],
9
- proxy_url: ENV['YODLEEICIOUS_PROXY_URL']
10
9
  }
11
10
  }
12
11
 
13
- let(:api) { Yodleeicious::YodleeApi.new(config) }
12
+ let(:api) { YodleeWrap::YodleeApi.new(config) }
14
13
 
15
14
  let(:registered_user) {
16
15
  {
17
- email: 'testuser_with_transactions@liftforward.com',
18
- password: 'testpassword143'
16
+ username: 'sbMemstudentloangenius1',
17
+ password: 'sbMemstudentloangenius1#123'
19
18
  }
20
19
  }
21
20
 
@@ -24,47 +23,72 @@ describe 'the yodlee api client integration tests', integration: true do
24
23
  context 'When /authenticate/coblogin is called the return' do
25
24
  subject { api.cobranded_login }
26
25
 
27
- it { is_expected.to be_kind_of(Yodleeicious::Response) }
26
+ it { is_expected.to be_kind_of(YodleeWrap::Response) }
28
27
  it { is_expected.to be_success }
29
28
 
30
29
  it 'contains valid json response' do
31
- expect(subject.body['cobrandConversationCredentials']).not_to be_nil
32
- expect(subject.body['cobrandConversationCredentials']['sessionToken']).not_to be_nil
30
+ expect(subject.body['session']).not_to be_nil
31
+ expect(subject.body['session']['cobSession']).not_to be_nil
32
+ expect(subject.status).to eq 200
33
+ end
34
+
35
+ it 'sets the cobrand_auth variable' do
36
+ expect(api.cobranded_auth).to be_nil
37
+ subject
38
+ expect(api.cobranded_auth).not_to be_nil
33
39
  end
34
40
  end
35
41
  end
36
42
  end
37
43
 
38
44
  describe 'the yodlee apis user login endpoint' do
39
- context 'Given valid cobranded credentials and base_url' do
45
+ context 'Given valid cobranded credentials' do
40
46
  context 'Given a new user who does not exist within the cobranded account' do
41
- describe 'When /authenticate/coblogin is called the return' do
42
- subject {
47
+ describe 'When login_user is called the return' do
48
+ subject {
43
49
  api.cobranded_login
44
- api.user_login 'testuser', 'testpassword'
50
+ api.login_user(username: 'testuser', password: 'testpassword')
45
51
  }
46
52
 
47
- it { is_expected.to be_kind_of(Yodleeicious::Response) }
53
+ it { is_expected.to be_kind_of(YodleeWrap::Response) }
48
54
  it { is_expected.to be_fail }
49
55
 
50
56
  it 'returns an error response' do
51
- expect(subject.body).to eq({"Error"=>[{"errorDetail"=>"Invalid User Credentials"}]})
57
+ expect(subject.error_code).not_to be_empty
58
+ expect(subject.error_message).not_to be_empty
59
+ expect(subject.body['errorCode']).to eq 'Y002'
60
+ expect(subject.body['errorMessage']).to eq 'Invalid loginName/password'
61
+ expect(subject.status).to eq 401
62
+ end
63
+
64
+ it 'does not set the user auth variable' do
65
+ expect(api.user_auth).to be_nil
66
+ subject
67
+ expect(api.user_auth).to be_nil
52
68
  end
53
69
  end
54
70
  end
55
71
 
56
72
  context 'Given a user who does exist within the cobranded account' do
57
- describe 'When /authenticate/coblogin is called the return' do
58
- subject {
73
+ describe 'When login_user is called the return' do
74
+ subject {
59
75
  api.cobranded_login
60
- api.user_login 'testuser', 'testpassword'
76
+ api.login_user(registered_user)
61
77
  }
62
78
 
63
- it { is_expected.to be_kind_of(Yodleeicious::Response) }
64
- it { is_expected.to be_fail }
79
+ it { is_expected.to be_a(YodleeWrap::Response) }
80
+ it { is_expected.to be_success }
65
81
 
66
- it 'returns an error response' do
67
- expect(subject.body).to eq({"Error"=>[{"errorDetail"=>"Invalid User Credentials"}]})
82
+ it 'returns an response including user and session information' do
83
+ expect(subject.body).to have_key('user')
84
+ expect(subject.body['user']).to have_key('session')
85
+ expect(subject.status).to eq 200
86
+ end
87
+
88
+ it 'sets the user_auth variable' do
89
+ expect(api.user_auth).to be_nil
90
+ subject
91
+ expect(api.user_auth).not_to be_nil
68
92
  end
69
93
  end
70
94
  end
@@ -72,417 +96,522 @@ describe 'the yodlee api client integration tests', integration: true do
72
96
  end
73
97
 
74
98
  describe 'the yodlee apis register user endpoint' do
75
- context 'Given a valid cobranded credentials and base_url' do
99
+ context 'Given a valid cobranded credentials' do
76
100
  context 'Given a new user who does not exist within the cobranded account' do
77
- context 'When /jsonsdk/UserRegistration/register3 endpoint is called the response' do
78
- subject {
79
- api.cobranded_login
80
- api.register_user "testuser#{rand(100...200)}", 'testpassword143', 'test@test.com'
81
- }
101
+ context 'When register_user endpoint is called the response' do
102
+ context 'with invalid password' do
103
+ subject {
104
+ api.cobranded_login
105
+ test_user = "testuser#{rand(100...200)}@gmail.com"
106
+ api.register_user(username: test_user, password: 'testpassword143', email: test_user, subscribe: false)
107
+ }
82
108
 
83
- after {
84
- api.unregister_user
85
- }
109
+ after {
110
+ api.unregister_user
111
+ }
86
112
 
87
- it 'is expected to offer a valid response' do
88
- is_expected.to be_kind_of(Yodleeicious::Response)
89
- is_expected.to be_success
90
- expect(subject.body['errorOccurred']).to be_nil
91
- expect(subject.body['userContext']['conversationCredentials']['sessionToken']).to be_kind_of(String)
92
- expect(subject.body['userContext']['conversationCredentials']['sessionToken'].length).to be > 0
93
- expect(api.user_session_token).not_to be_nil
113
+ it 'is expected to have an error response' do
114
+ is_expected.to be_a(YodleeWrap::Response)
115
+ is_expected.to be_fail
116
+ expect(subject.error_message).to eq "Your password doesn't meet required criteria"
117
+ expect(subject.status).to eq 400
118
+ expect(api.user_session_token).to be_nil
119
+ end
94
120
  end
95
- end
96
- end
97
- end
98
- end
99
121
 
100
- describe '#unregister_user' do
101
- context 'Given a valid cobranded credentials and base_url' do
102
- context 'Given a user who it logged into the api' do
103
- context 'When #unregister_user is called the response' do
104
- subject {
105
- api.cobranded_login
106
- api.login_or_register_user "testuser#{rand(100...200)}", 'testpassword143', 'test@test.com'
107
- expect(api.user_session_token).not_to be_nil
108
- api.unregister_user
109
- }
122
+ # Testing user creation is limited in sandbox environment.
123
+ context 'with valid password' do
124
+ subject {
125
+ api.cobranded_login
126
+ test_user = "testuser#{rand(100...200)}"
127
+ api.register_user(username: "#{test_user}", password: 'Testpassword#143', email: "#{test_user}@example.com", subscribe: false)
128
+ }
110
129
 
130
+ after {
131
+ api.unregister_user
132
+ }
111
133
 
112
- it 'is expected to offer a valid response' do
113
- is_expected.to be_kind_of(Yodleeicious::Response)
114
- is_expected.to be_success
115
- expect(api.user_session_token).to be_nil
134
+ it 'is expected to give accessibility error because yodlee sandbox limitations' do
135
+ is_expected.to be_a(YodleeWrap::Response)
136
+ is_expected.to be_fail
137
+ expect(subject.error_message).to eq 'Accessibility denied.'
138
+ expect(subject.status).to eq 400
139
+ end
116
140
  end
117
-
118
- after { api.unregister_user }
119
-
120
141
  end
121
142
  end
122
143
  end
123
144
  end
124
145
 
125
- describe 'the yodleeicious login_or_register_user method' do
146
+ # Testing user creation/deletion is limited in sandbox environment
147
+ # describe '#unregister_user' do
148
+ # context 'Given a valid cobranded credentials and base_url' do
149
+ # context 'Given a user who it logged into the api' do
150
+ # context 'When #unregister_user is called the response' do
151
+ # subject {
152
+ # api.cobranded_login
153
+ # api.login_or_register_user "testuser#{rand(100...200)}", 'testpassword143', 'test@test.com'
154
+ # expect(api.user_session_token).not_to be_nil
155
+ # api.unregister_user
156
+ # }
157
+ #
158
+ #
159
+ # it 'is expected to offer a valid response' do
160
+ # is_expected.to be_kind_of(YodleeWrap::Response)
161
+ # is_expected.to be_success
162
+ # expect(api.user_session_token).to be_nil
163
+ # end
164
+ #
165
+ # after { api.unregister_user }
166
+ #
167
+ # end
168
+ # end
169
+ # end
170
+ # end
171
+
172
+ describe 'the yodlee_wrap login_or_register_user method' do
126
173
  before { api.cobranded_login }
127
174
 
128
175
  context 'Given a new user with valid credentials' do
129
176
  after { api.unregister_user }
130
- let (:email) { "testuser#{rand(100...200)}@test.com" }
131
- let (:password) { "password#{rand(100...200)}" }
177
+ let(:email) { "testuser#{rand(100...200)}@test.com" }
178
+ let(:password) { "Password##{rand(100...200)}" }
132
179
 
133
180
  context 'When login_or_register_user is called' do
134
- subject { api.login_or_register_user email, password, email }
181
+ subject { api.login_or_register_user(username: email, password: password, email: email) }
135
182
 
136
- it 'should register the new user and set the user_session_token' do
137
- expect(subject).to be_success
138
- expect(subject).to be_kind_of(Yodleeicious::Response)
139
- expect(api.user_session_token).not_to be_nil
183
+ it 'should give an accessibility denied error because yodlee sandbox limitations' do
184
+ expect(subject).to be_fail
185
+ expect(subject).to be_a(YodleeWrap::Response)
186
+ expect(subject.error_message).to eq('Accessibility denied.')
140
187
  end
141
188
  end
142
189
  end
143
190
 
144
191
  context 'Given an existing user with valid credentials' do
145
- before { api.register_user registered_user[:email], registered_user[:password], registered_user[:email] }
146
192
 
147
193
  context 'When login_or_register_user is called' do
148
- subject { api.login_or_register_user registered_user[:email], registered_user[:password], registered_user[:email] }
194
+ subject { api.login_or_register_user(username: registered_user[:username], email: registered_user[:username], password: registered_user[:password]) }
149
195
 
150
196
  it 'should login the user and not register them' do
151
197
  expect(subject).to be_success
152
- expect(subject).to be_kind_of(Yodleeicious::Response)
198
+ expect(subject).to be_a(YodleeWrap::Response)
153
199
  expect(api.user_session_token).not_to be_nil
154
200
  end
155
201
  end
156
202
  end
157
- end
158
-
159
- describe '#get_site_info' do
160
- context 'Given a valid cobranded credentials and base_url' do
161
- before {
162
- api.cobranded_login
163
- }
164
203
 
165
- context 'When a request for site info is performed the result' do
166
- subject { api.get_site_info 16441 }
204
+ context 'given an existing user with invalid password' do
205
+ context 'when login_or_register_user is called' do
206
+ subject { api.login_or_register_user(username: registered_user[:username], email: registered_user[:username], password: 'WRONGPASSWORD') }
167
207
 
168
- it 'is expected to contain login form details' do
169
- is_expected.not_to be_nil
170
- is_expected.to be_kind_of(Yodleeicious::Response)
171
- expect(subject.body['errorOccurred']).to be_nil
172
- expect(subject.body['loginForms']).not_to be_nil
173
- expect(subject.body['loginForms']).to be_kind_of(Array)
174
- expect(subject.body['loginForms'].length).to be > 0
208
+ it 'will attempt to create a new user' do
209
+ expect(api).to receive(:register_user).and_return(OpenStruct.new('success?': true))
210
+ subject
175
211
  end
176
212
  end
177
213
  end
178
214
  end
179
215
 
216
+ describe '#get_provider_details' do
217
+ context 'Given a valid cobranded credentials' do
218
+ before do
219
+ api.cobranded_login
220
+ api.login_user(registered_user)
221
+ end
222
+ subject { api.get_provider_details(provider_id) }
180
223
 
181
- describe '#get_content_service_info_by_routing_number' do
182
- context 'Given a valid cobranded credentials and base_url' do
183
- before { api.cobranded_login }
184
224
 
185
- context 'When #get_content_service_info_by_routing_number is called with a valid routing number the result' do
186
- subject { api.get_content_service_info_by_routing_number 999988181 }
225
+ context 'When a request for site info is performed the result' do
226
+ let(:provider_id) { 16441 }
187
227
 
188
- it 'is expected to contain valid content services info' do
228
+ it 'is expected to respond with the provider details and contain the login form' do
189
229
  is_expected.not_to be_nil
190
- is_expected.to be_kind_of(Yodleeicious::Response)
191
- is_expected.to be_success
192
- expect(subject.body['errorOccurred']).to be_nil
193
- expect(subject.body['siteId']).to eq(16441)
194
- expect(subject.body['contentServiceDisplayName']).to eq('Dag Site (US) - Bank')
230
+ is_expected.to be_kind_of(YodleeWrap::Response)
231
+ expect(subject.body['provider']).to be_a Array
232
+ expect(subject.body['provider'].length).to eq 1
233
+ expect(subject.body['provider'].first['id']).to eq provider_id
234
+ expect(subject.body['provider'].first.fetch('loginForm')).not_to be_nil
195
235
  end
196
- end
197
-
198
- context 'When #get_content_service_info_by_routing_number is called with an invalid routing number' do
199
- subject { api.get_content_service_info_by_routing_number -23423 }
200
236
 
201
- it 'is expected to contain valid error details' do
202
- is_expected.not_to be_nil
203
- is_expected.to be_kind_of(Yodleeicious::Response)
204
- is_expected.to be_fail
205
- expect(subject.body['errorOccurred']).to be_truthy
206
- expect(subject.body['exceptionType']).to eq('com.yodlee.core.routingnumberservice.InvalidRoutingNumberException')
237
+ it 'the login form' do
238
+ login_form = subject.body['provider'].first.fetch('loginForm')
239
+ expect(login_form).to be_a Hash
240
+ expect(login_form).to have_key 'forgetPasswordURL'
241
+ expect(login_form).to have_key 'formType'
242
+ expect(login_form).to have_key 'row'
243
+ expect(login_form['row']).to be_a Array
207
244
  end
208
245
  end
209
- end
210
- end
211
246
 
212
- describe '#get_mfa_response_for_site' do
213
- context 'Given a valid cobranded credentials and base_url' do
214
- context 'Given a user who it logged into the api' do
215
- context 'When #get_mfa_response_for_site is called the response' do
216
- subject {
217
- api.cobranded_login
218
- response = api.login_or_register_user "testuser#{rand(100...200)}", 'testpassword143', 'test@test.com'
219
- expect(response).to be_success
247
+ context 'no MFA' do
248
+ let(:provider_id) { 16441 }
249
+ it 'should indicate in the response that there is no mfa' do
250
+ expect(subject.mfa?).to be_falsey
251
+ expect(subject.mfa_type).to be_nil
252
+ end
253
+ end
220
254
 
221
- response = api.get_site_login_form(16445)
222
- expect(response).to be_success
255
+ context 'with MFA - CAPTCHA' do
256
+ let(:provider_id) { 18769 }
257
+ it 'should indicate in the response that there is captcha MFA' do
258
+ expect(subject.mfa?).to be_truthy
259
+ expect(subject.mfa_type).to eq 'Image based multifactor authentication'
223
260
 
224
- login_form = response.body
225
- login_form['componentList'][0]['fieldValue'] = 'yodlicious1.site16445.1'
226
- login_form['componentList'][1]['fieldValue'] = 'site16445.1'
261
+ end
262
+ end
227
263
 
228
- response = api.add_site_account_and_wait(16445, login_form)
229
- expect(response).to be_success
264
+ context 'with MFA - SecurityQA' do
265
+ let(:provider_id) { 16486 }
266
+ it 'should indicate in the response that there is security question MFA' do
267
+ expect(subject.mfa?).to be_truthy
268
+ expect(subject.mfa_type).to eq 'Question and answer type multi factor authentication.'
269
+ end
270
+ end
230
271
 
231
- expect(response.body['siteRefreshInfo']['siteRefreshMode']['refreshMode']).to eq('MFA')
232
- api.get_mfa_response_for_site response.body['siteAccountId']
233
- }
272
+ context 'with MFA - SecurityQA' do
273
+ let(:provider_id) { 16477 }
274
+ it 'should indicate that there is some MFA stuff going on.' do
275
+ expect(subject.mfa?).to be_truthy
276
+ expect(subject.mfa_type).to eq 'Question and answer type multi factor authentication.'
277
+ end
278
+ end
279
+ end
280
+ end
234
281
 
235
- it 'is expected be a valid response' do
236
- is_expected.to be_kind_of(Yodleeicious::Response)
237
- is_expected.to be_success
238
- expect(subject.body['isMessageAvailable']).not_to be_nil
239
- end
282
+ describe 'add provider account - no MFA' do
283
+ context 'Given valid cobranded credentials' do
284
+ context 'when #add_provider_account is called' do
285
+ subject do
286
+ api.cobranded_login
287
+ api.login_user(registered_user)
288
+ response = api.get_provider_details(16441)
289
+ expect(response).to be_success
290
+ login_form = response.body['provider'].first['loginForm']
291
+ login_form['row'][0]['field'][0]['value'] = 'TheUsername.site16441.2'
292
+ login_form['row'][1]['field'][0]['value'] = 'site16441.2'
293
+
294
+ api.add_provider_account(16441, response.body)
295
+ end
240
296
 
241
- after { api.unregister_user }
297
+ it 'should create a provider account' do
298
+ is_expected.to be_kind_of(YodleeWrap::Response)
299
+ is_expected.to be_success
300
+ expect(subject.body['providerAccountId']).not_to be_nil
301
+ expect(subject.mfa?).to be_falsey
302
+ expect(subject.body['refreshInfo']).not_to be_nil
303
+ expect(subject.status).to eq 201
242
304
  end
243
305
  end
244
306
  end
245
307
  end
246
308
 
247
- describe '#get_mfa_response_for_site_and_wait' do
309
+ describe '#get_provider_account_status - no MFA' do
248
310
  context 'Given a valid cobranded credentials and base_url' do
249
311
  context 'Given a user who it logged into the api' do
250
- context 'When #get_mfa_response_for_site_and_wait is called the response' do
251
- subject {
312
+ context 'When #get_mfa_response_for_site is called the response' do
313
+ subject do
252
314
  api.cobranded_login
253
- response = api.login_or_register_user "testuser#{rand(100...200)}", 'testpassword143', 'test@test.com'
254
- expect(response).to be_success
255
-
256
- response = api.get_site_login_form(16445)
315
+ api.login_user(registered_user)
316
+ response = api.get_provider_details(16441)
257
317
  expect(response).to be_success
318
+ login_form = response.body['provider'].first['loginForm']
319
+ login_form['row'][0]['field'][0]['value'] = 'TheUsername.site16441.2'
320
+ login_form['row'][1]['field'][0]['value'] = 'site16441.2'
258
321
 
259
- login_form = response.body
260
- login_form['componentList'][0]['fieldValue'] = 'yodlicious1.site16445.1'
261
- login_form['componentList'][1]['fieldValue'] = 'site16445.1'
262
-
263
- response = api.add_site_account(16445, login_form)
264
- expect(response).to be_success
265
-
266
- expect(response.body['siteRefreshInfo']['siteRefreshMode']['refreshMode']).to eq('MFA')
267
- api.get_mfa_response_for_site_and_wait response.body['siteAccountId'], 2
268
- }
322
+ response = api.add_provider_account(16441, response.body)
323
+ api.get_provider_account_status(response.body['providerAccountId'])
324
+ end
269
325
 
270
326
  it 'is expected be a valid response' do
271
- is_expected.to be_kind_of(Yodleeicious::Response)
327
+ is_expected.to be_kind_of(YodleeWrap::Response)
272
328
  is_expected.to be_success
273
- expect(subject.body['isMessageAvailable']).to be_truthy
274
- expect(subject.body['fieldInfo']).not_to be_nil
329
+ expect(subject.body['providerAccount']).not_to be_nil
330
+ expect(subject.body['providerAccount']['refreshInfo']).not_to be_nil
331
+ expect(subject.status).to eq 200
275
332
  end
276
-
277
- after { api.unregister_user }
278
333
  end
279
334
  end
280
335
  end
281
336
  end
282
337
 
283
- describe '#put_mfa_request_for_site' do
284
- context 'Given a valid cobranded credentials and base_url' do
285
- context 'Given a user who is logged into the api' do
286
- context 'Given a user attempting to add a site with Token Based MFA' do
287
- context 'When #put_mfa_request_for_site is called the response' do
288
- subject {
289
- api.cobranded_login
290
- response = api.login_or_register_user "testuser#{rand(100...200)}", 'testpassword143', 'test@test.com'
291
-
292
- response = api.get_site_login_form(16445)
293
- expect(response).to be_success
294
-
295
- login_form = response.body
296
-
297
- login_form['componentList'][0]['fieldValue'] = 'yodlicious1.site16445.1'
298
- login_form['componentList'][1]['fieldValue'] = 'site16445.1'
299
-
300
- response = api.add_site_account(16445, login_form)
301
- expect(response).to be_success
302
-
303
- expect(response.body['siteRefreshInfo']['siteRefreshMode']['refreshMode']).to eq('MFA')
304
- site_account_id = response.body['siteAccountId']
305
- response = api.get_mfa_response_for_site_and_wait site_account_id, 2
306
- expect(response.body['isMessageAvailable']).to be_truthy
307
-
308
- field_info = response.body['fieldInfo']
309
- field_info['fieldValue'] = "monkeys"
310
- api.put_mfa_request_for_site site_account_id, :MFATokenResponse, field_info
311
- }
312
-
313
- it 'is expected be a valid response' do
314
- is_expected.to be_kind_of(Yodleeicious::Response)
315
- is_expected.to be_success
316
- expect(subject.body['primitiveObj']).to be_truthy
317
- end
318
-
319
- after { api.unregister_user }
320
- end
321
- end
322
-
323
- context 'Given a user attempting to add a site with Security Question and Answer MFA' do
324
- context 'When #put_mfa_request_for_site is called the response' do
325
- subject {
326
- api.cobranded_login
327
- response = api.login_or_register_user "testuser#{rand(100...200)}", 'testpassword143', 'test@test.com'
328
-
329
- response = api.get_site_login_form(16486)
330
- expect(response).to be_success
331
-
332
- login_form = response.body
333
- login_form['componentList'][0]['fieldValue'] = 'yodlicious1.site16486.1'
334
- login_form['componentList'][1]['fieldValue'] = 'site16486.1'
335
-
336
- response = api.add_site_account(16486, login_form)
337
- expect(response).to be_success
338
-
339
- expect(response.body['siteRefreshInfo']['siteRefreshMode']['refreshMode']).to eq('MFA')
340
- site_account_id = response.body['siteAccountId']
341
- response = api.get_mfa_response_for_site_and_wait site_account_id, 2
342
- expect(response.body['isMessageAvailable']).to be_truthy
343
-
344
- field_info = response.body['fieldInfo']
345
- field_info['questionAndAnswerValues'][0]['fieldValue'] = 'Texas'
346
- field_info['questionAndAnswerValues'][1]['fieldValue'] = 'w3schools'
347
- api.put_mfa_request_for_site site_account_id, :MFAQuesAnsResponse, field_info
348
- }
349
-
350
- it 'is expected be a valid response' do
351
- is_expected.to be_kind_of(Yodleeicious::Response)
352
- is_expected.to be_success
353
- expect(subject.body['primitiveObj']).to be_truthy
354
- end
355
-
356
- after { api.unregister_user }
357
- end
358
- end
359
-
360
- context 'Given a user attempting to add a site with Captcha MFA' do
361
- context 'When #put_mfa_request_for_site is called the response' do
362
- subject {
363
- api.cobranded_login
364
- response = api.login_or_register_user "testuser#{rand(100...200)}", 'testpassword143', 'test@test.com'
365
- expect(response).to be_success
366
-
367
- response = api.get_site_login_form(18769)
368
- expect(response).to be_success
369
-
370
- login_form = response.body
371
- login_form['componentList'][0]['fieldValue'] = 'yodlicious1.site18769.1'
372
- login_form['componentList'][1]['fieldValue'] = 'site18769.1'
373
-
374
- response = api.add_site_account(18769, login_form)
375
- expect(response).to be_success
376
-
377
- expect(response.body['siteRefreshInfo']['siteRefreshMode']['refreshMode']).to eq('MFA')
378
- site_account_id = response.body['siteAccountId']
379
- response = api.get_mfa_response_for_site_and_wait site_account_id, 2
380
- expect(response.body['isMessageAvailable']).to be_truthy
381
-
382
- field_info = response.body['fieldInfo']
383
- field_info['fieldValue'] = "monkeys"
384
- api.put_mfa_request_for_site site_account_id, :MFAImageResponse, field_info
385
- }
386
-
387
- it 'is expected be a valid response' do
388
- is_expected.to be_kind_of(Yodleeicious::Response)
389
- is_expected.to be_success
390
- expect(subject.body['primitiveObj']).to be_truthy
391
- end
392
-
393
- after { api.unregister_user }
394
- end
338
+ describe 'MFA Workflow' do
339
+ context 'Given valid cobranded credentials' do
340
+ context 'when #add_provider_account is called' do
341
+ subject do
342
+ api.cobranded_login
343
+ api.login_user(registered_user)
344
+ response = api.get_provider_details(18769)
345
+ expect(response).to be_success
346
+ expect(response.mfa?).to be_truthy
347
+ login_form = response.body['provider'].first['loginForm']
348
+ login_form['row'][0]['field'][0]['value'] = 'TheUsername.site18769.1'
349
+ login_form['row'][1]['field'][0]['value'] = 'site18769.1'
350
+
351
+ api.add_provider_account(18769, response.body)
395
352
  end
396
- end
397
- end
398
- end
399
353
 
400
- describe 'the yodlee apis fetching summary data about registered site accounts endpoints' do
401
- context 'Given a registered user with registered accounts' do
402
- before {
403
- api.cobranded_login
404
- api.user_login "testuser_with_transactions@liftforward.com", 'testpassword143'
405
- # api.register_user "testuser#{rand(100..999)}", 'testpassword143', 'test@test.com'
406
- # dag_login_form[:componentList][0][:value] = 'yodlicious.site16441.1'
407
- # dag_login_form[:componentList][1][:value] = 'site16441.1'
408
- # api.add_site_account_and_wait(16441, dag_login_form)
409
- }
410
-
411
- context 'when getAllSiteAccounts is called the return' do
412
- subject { api.get_all_site_accounts }
413
-
414
- it 'is expected to return an array containing 1 siteAccount' do
415
- # puts JSON.pretty_generate(subject)
354
+ it 'should create a provider account' do
355
+ is_expected.to be_kind_of(YodleeWrap::Response)
416
356
  is_expected.to be_success
417
- expect(subject.body).to be_kind_of(Array)
418
- expect(subject.body.length).to be > 0
419
- expect(subject.body[0]['siteAccountId']).not_to be_nil
420
- expect(subject.body[0]['siteRefreshInfo']['siteRefreshStatus']['siteRefreshStatus']).to eq('REFRESH_COMPLETED')
421
-
357
+ expect(subject.body['providerAccountId']).not_to be_nil
358
+ expect(subject.body['refreshInfo']).not_to be_nil
359
+ expect(subject.status).to eq 201
422
360
  end
423
- end
424
361
 
425
- context 'when getItemSummariesForSite is called the return' do
426
- subject {
427
- site_accounts = api.get_all_site_accounts
428
- # puts site_accounts[0]['siteAccountId']
429
- # puts JSON.pretty_generate(site_accounts)
430
- api.get_item_summaries_for_site(site_accounts.body[0]['siteAccountId'])
431
- }
432
-
433
- it 'is expected to return an array site summaries' do
434
- # puts JSON.pretty_generate(subject)
435
-
436
- is_expected.to be_kind_of(Yodleeicious::Response)
437
- is_expected.to be_success
438
- expect(subject.body[0]['itemId']).not_to be_nil
439
- end
362
+ # context 'with incorrect login credentials' do
363
+ # subject do
364
+ # api.cobranded_login
365
+ # api.login_user(registered_user)
366
+ # response = api.get_provider_details(18769)
367
+ # expect(response).to be_success
368
+ # expect(response.mfa?).to be_truthy
369
+ # login_form = response.body['provider'].first['loginForm']
370
+ # login_form['row'][0]['field'][0]['value'] = 'TheUsername.site18769.1'
371
+ # login_form['row'][1]['field'][0]['value'] = 'WrongPassword.site18769.1'
372
+ # response = api.add_provider_account(18769, response.body)
373
+ # expect(response).to be_a(YodleeWrap::Response)
374
+ # expect(response).to be_truthy
375
+ # sleep(5)
376
+ # api.get_provider_account_status(response.body['providerAccountId'])
377
+ # end
378
+ #
379
+ # it 'should create a provider account, but with errors when you check on the status' do
380
+ # is_expected.to be_a(YodleeWrap::Response)
381
+ # is_expected.to be_success
382
+ # byebug
383
+ # expect(subject.body['providerAccount']['refreshInfo']['statusMessage']).to eq 'LOGIN_FAILED'
384
+ # end
385
+ # end
440
386
  end
441
387
 
442
- context 'when getItemSummaries is called the return' do
443
- subject { api.get_item_summaries }
444
-
445
- it 'is expected to return an array of site summaries' do
446
- # puts JSON.pretty_generate(subject)
447
-
448
- is_expected.to be_kind_of(Yodleeicious::Response)
449
- is_expected.to be_success
450
- expect(subject.body.length).to be > 0
451
- expect(subject.body[0]['itemId']).not_to be_nil
452
- end
453
- end
454
388
  end
455
389
  end
456
390
 
457
- describe 'the yodlee apis fetching user/s transactions' do
458
- context 'Given a registered user with registered accounts' do
459
- before {
460
- api.cobranded_login
461
- api.login_or_register_user 'testuser_with_transactions@liftforward.com', 'testpassword143', 'testuser_with_transactions@liftforward.com'
462
- dag_login_form['componentList'][0]['fieldValue'] = 'yodlicious.site16441.1'
463
- dag_login_form['componentList'][1]['fieldValue'] = 'site16441.1'
464
- api.add_site_account(16441, dag_login_form)
465
- }
466
-
467
- context 'When a transaction search for all transactions is performed the result' do
468
- subject { api.execute_user_search_request }
469
-
470
- it 'is expected to return a valid search result' do
471
- # puts JSON.pretty_generate(subject.body)
472
-
473
- is_expected.not_to be_nil
474
- is_expected.to be_kind_of(Yodleeicious::Response)
475
- is_expected.to be_success
476
- expect(subject.body['errorOccurred']).to be_nil
477
- expect(subject.body['searchIdentifier']).not_to be_nil
478
- expect(subject.body['searchResult']['transactions']).to be_kind_of(Array)
479
- expect(subject.body['searchResult']['transactions'].length).to be > 0
391
+ describe '#get_all_provider_accounts' do
392
+ context 'given valid cobrand credentials' do
393
+ context 'and a user who is logged in to the api' do
394
+ context 'when #get_all_provider_accounts is called' do
395
+ subject do
396
+ api.cobranded_login
397
+ api.login_user(registered_user)
398
+ api.get_all_provider_accounts
399
+ end
400
+ it 'should return all provider accounts for the currently logged in user' do
401
+ is_expected.to be_kind_of(YodleeWrap::Response)
402
+ is_expected.to be_success
403
+ expect(subject.body).to be_a Hash
404
+ expect(subject.body).to have_key 'providerAccount'
405
+ expect(subject.body['providerAccount']).to be_a Array
406
+ end
480
407
  end
481
408
  end
482
409
  end
483
410
  end
484
411
 
485
- pending 'downloading transaction history'
412
+ # describe '#put_mfa_request_for_site' do
413
+ # context 'Given a valid cobranded credentials and base_url' do
414
+ # context 'Given a user who is logged into the api' do
415
+ # context 'Given a user attempting to add a site with Token Based MFA' do
416
+ # context 'When #put_mfa_request_for_site is called the response' do
417
+ # subject {
418
+ # api.cobranded_login
419
+ # response = api.login_or_register_user "testuser#{rand(100...200)}", 'testpassword143', 'test@test.com'
420
+ #
421
+ # response = api.get_site_login_form(16445)
422
+ # expect(response).to be_success
423
+ #
424
+ # login_form = response.body
425
+ #
426
+ # login_form['componentList'][0]['fieldValue'] = 'yodlicious1.site16445.1'
427
+ # login_form['componentList'][1]['fieldValue'] = 'site16445.1'
428
+ #
429
+ # response = api.add_site_account(16445, login_form)
430
+ # expect(response).to be_success
431
+ #
432
+ # expect(response.body['siteRefreshInfo']['siteRefreshMode']['refreshMode']).to eq('MFA')
433
+ # site_account_id = response.body['siteAccountId']
434
+ # response = api.get_mfa_response_for_site_and_wait site_account_id, 2
435
+ # expect(response.body['isMessageAvailable']).to be_truthy
436
+ #
437
+ # field_info = response.body['fieldInfo']
438
+ # field_info['fieldValue'] = "monkeys"
439
+ # api.put_mfa_request_for_site site_account_id, :MFATokenResponse, field_info
440
+ # }
441
+ #
442
+ # it 'is expected be a valid response' do
443
+ # is_expected.to be_kind_of(YodleeWrap::Response)
444
+ # is_expected.to be_success
445
+ # expect(subject.body['primitiveObj']).to be_truthy
446
+ # end
447
+ #
448
+ # after { api.unregister_user }
449
+ # end
450
+ # end
451
+ #
452
+ # context 'Given a user attempting to add a site with Security Question and Answer MFA' do
453
+ # context 'When #put_mfa_request_for_site is called the response' do
454
+ # subject {
455
+ # api.cobranded_login
456
+ # response = api.login_or_register_user "testuser#{rand(100...200)}", 'testpassword143', 'test@test.com'
457
+ #
458
+ # response = api.get_site_login_form(16486)
459
+ # expect(response).to be_success
460
+ #
461
+ # login_form = response.body
462
+ # login_form['componentList'][0]['fieldValue'] = 'yodlicious1.site16486.1'
463
+ # login_form['componentList'][1]['fieldValue'] = 'site16486.1'
464
+ #
465
+ # response = api.add_site_account(16486, login_form)
466
+ # expect(response).to be_success
467
+ #
468
+ # expect(response.body['siteRefreshInfo']['siteRefreshMode']['refreshMode']).to eq('MFA')
469
+ # site_account_id = response.body['siteAccountId']
470
+ # response = api.get_mfa_response_for_site_and_wait site_account_id, 2
471
+ # expect(response.body['isMessageAvailable']).to be_truthy
472
+ #
473
+ # field_info = response.body['fieldInfo']
474
+ # field_info['questionAndAnswerValues'][0]['fieldValue'] = 'Texas'
475
+ # field_info['questionAndAnswerValues'][1]['fieldValue'] = 'w3schools'
476
+ # api.put_mfa_request_for_site site_account_id, :MFAQuesAnsResponse, field_info
477
+ # }
478
+ #
479
+ # it 'is expected be a valid response' do
480
+ # is_expected.to be_kind_of(YodleeWrap::Response)
481
+ # is_expected.to be_success
482
+ # expect(subject.body['primitiveObj']).to be_truthy
483
+ # end
484
+ #
485
+ # after { api.unregister_user }
486
+ # end
487
+ # end
488
+ #
489
+ # context 'Given a user attempting to add a site with Captcha MFA' do
490
+ # context 'When #put_mfa_request_for_site is called the response' do
491
+ # subject do
492
+ # api.cobranded_login
493
+ # response = api.login_or_register_user "testuser#{rand(100...200)}", 'testpassword143', 'test@test.com'
494
+ # expect(response).to be_success
495
+ #
496
+ # response = api.get_site_login_form(18769)
497
+ # expect(response).to be_success
498
+ #
499
+ # login_form = response.body
500
+ # login_form['componentList'][0]['fieldValue'] = 'yodlicious1.site18769.1'
501
+ # login_form['componentList'][1]['fieldValue'] = 'site18769.1'
502
+ #
503
+ # response = api.add_site_account(18769, login_form)
504
+ # expect(response).to be_success
505
+ #
506
+ # expect(response.body['siteRefreshInfo']['siteRefreshMode']['refreshMode']).to eq('MFA')
507
+ # site_account_id = response.body['siteAccountId']
508
+ # response = api.get_mfa_response_for_site_and_wait site_account_id, 2
509
+ # expect(response.body['isMessageAvailable']).to be_truthy
510
+ #
511
+ # field_info = response.body['fieldInfo']
512
+ # field_info['fieldValue'] = "monkeys"
513
+ # api.put_mfa_request_for_site site_account_id, :MFAImageResponse, field_info
514
+ # end
515
+ #
516
+ # it 'is expected be a valid response' do
517
+ # is_expected.to be_kind_of(YodleeWrap::Response)
518
+ # is_expected.to be_success
519
+ # expect(subject.body['primitiveObj']).to be_truthy
520
+ # end
521
+ #
522
+ # after { api.unregister_user }
523
+ # end
524
+ # end
525
+ # end
526
+ # end
527
+ # end
528
+
529
+ # describe 'the yodlee apis fetching summary data about registered site accounts endpoints' do
530
+ # context 'Given a registered user with registered accounts' do
531
+ # before {
532
+ # api.cobranded_login
533
+ # api.login_user "testuser_with_transactions@liftforward.com", 'testpassword143'
534
+ # # api.register_user "testuser#{rand(100..999)}", 'testpassword143', 'test@test.com'
535
+ # # dag_login_form[:componentList][0][:value] = 'yodlicious.site16441.1'
536
+ # # dag_login_form[:componentList][1][:value] = 'site16441.1'
537
+ # # api.add_site_account_and_wait(16441, dag_login_form)
538
+ # }
539
+ #
540
+ # context 'when getAllSiteAccounts is called the return' do
541
+ # subject { api.get_all_site_accounts }
542
+ #
543
+ # it 'is expected to return an array containing 1 siteAccount' do
544
+ # # puts JSON.pretty_generate(subject)
545
+ # is_expected.to be_success
546
+ # expect(subject.body).to be_kind_of(Array)
547
+ # expect(subject.body.length).to be > 0
548
+ # expect(subject.body[0]['siteAccountId']).not_to be_nil
549
+ # expect(subject.body[0]['siteRefreshInfo']['siteRefreshStatus']['siteRefreshStatus']).to eq('REFRESH_COMPLETED')
550
+ #
551
+ # end
552
+ # end
553
+ #
554
+ # context 'when getItemSummariesForSite is called the return' do
555
+ # subject {
556
+ # site_accounts = api.get_all_site_accounts
557
+ # # puts site_accounts[0]['siteAccountId']
558
+ # # puts JSON.pretty_generate(site_accounts)
559
+ # api.get_item_summaries_for_site(site_accounts.body[0]['siteAccountId'])
560
+ # }
561
+ #
562
+ # it 'is expected to return an array site summaries' do
563
+ # # puts JSON.pretty_generate(subject)
564
+ #
565
+ # is_expected.to be_kind_of(YodleeWrap::Response)
566
+ # is_expected.to be_success
567
+ # expect(subject.body[0]['itemId']).not_to be_nil
568
+ # end
569
+ # end
570
+ #
571
+ # context 'when getItemSummaries is called the return' do
572
+ # subject { api.get_item_summaries }
573
+ #
574
+ # it 'is expected to return an array of site summaries' do
575
+ # # puts JSON.pretty_generate(subject)
576
+ #
577
+ # is_expected.to be_kind_of(YodleeWrap::Response)
578
+ # is_expected.to be_success
579
+ # expect(subject.body.length).to be > 0
580
+ # expect(subject.body[0]['itemId']).not_to be_nil
581
+ # end
582
+ # end
583
+ # end
584
+ # end
585
+
586
+ # describe 'the yodlee apis fetching user/s transactions' do
587
+ # context 'Given a registered user with registered accounts' do
588
+ # before {
589
+ # api.cobranded_login
590
+ # api.login_or_register_user 'testuser_with_transactions@liftforward.com', 'testpassword143', 'testuser_with_transactions@liftforward.com'
591
+ # dag_login_form['componentList'][0]['fieldValue'] = 'yodlicious.site16441.1'
592
+ # dag_login_form['componentList'][1]['fieldValue'] = 'site16441.1'
593
+ # api.add_site_account(16441, dag_login_form)
594
+ # }
595
+ #
596
+ # context 'When a transaction search for all transactions is performed the result' do
597
+ # subject { api.execute_user_search_request }
598
+ #
599
+ # it 'is expected to return a valid search result' do
600
+ # # puts JSON.pretty_generate(subject.body)
601
+ #
602
+ # is_expected.not_to be_nil
603
+ # is_expected.to be_kind_of(YodleeWrap::Response)
604
+ # is_expected.to be_success
605
+ # expect(subject.body['errorOccurred']).to be_nil
606
+ # expect(subject.body['searchIdentifier']).not_to be_nil
607
+ # expect(subject.body['searchResult']['transactions']).to be_kind_of(Array)
608
+ # expect(subject.body['searchResult']['transactions'].length).to be > 0
609
+ # end
610
+ # end
611
+ # end
612
+ # end
613
+
614
+ pending 'downloading transaction history'
486
615
  pending 'fetching a list of content services'
487
616
  pending 'failing to create a new session'
488
617
  pending 'failing when running a search for a site'