finapps 2.1.2 → 2.1.3

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: c165121be25a140bd8e679e20ff7d9b09aabc28a
4
- data.tar.gz: 7ced8cf8b1d9436b17bf2fed865f161502b8a6c6
3
+ metadata.gz: 9e4f49ad1b81bbda2b1e9173e85b6fd614e28ec8
4
+ data.tar.gz: 24c47741bbc17e16cb06f870b776b5fc2876d720
5
5
  SHA512:
6
- metadata.gz: b4326d7f86886911409df0a3c555d8dd8cbbfe687633d2ffb09374b6a067ac0469c556299ef53ee8e89b35eb2bf46d18af0cec822579fe55dc4e85030e96c130
7
- data.tar.gz: eb6a33a750ffb3190a3e308bc03fa5a01ba6805ddfa77bdde963f998e4d91f1675b4e408d7daa1862aeb6aa7afef7cd47d30a1786c04ee5a9be4b760a23b04c5
6
+ metadata.gz: 02e35aece506016bf18afc6fe57323d79b1b025f5ff7e95b5cd76691ea107b2bf2cb2a76a03375f95178ac1cc78e0fc724e9f0b4928092f11ac6f0cecfc014dd
7
+ data.tar.gz: 6fceaf4699078d7afa4716d854f6b0b559ae4b173f6a345844bb62048e9f396ccb71911bdea02f761bc006656b5dc9c445660a4ea0120139648deb152845c960
data/finapps.gemspec CHANGED
@@ -3,8 +3,6 @@
3
3
  lib = File.expand_path('../lib', __FILE__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require 'finapps/version'
6
-
7
- # rubocop:disable Metrics/BlockLength
8
6
  Gem::Specification.new do |spec|
9
7
  spec.name = 'finapps'
10
8
  spec.version = FinApps::VERSION
data/lib/finapps.rb CHANGED
@@ -35,6 +35,7 @@ require 'finapps/rest/user_institutions'
35
35
  require 'finapps/rest/user_institutions_forms'
36
36
  require 'finapps/rest/order_reports'
37
37
  require 'finapps/rest/order_statuses'
38
+ require 'finapps/rest/password_resets'
38
39
 
39
40
  require 'finapps/rest/configuration'
40
41
  require 'finapps/rest/credentials'
@@ -63,6 +63,10 @@ module FinApps
63
63
  def user_institutions_forms
64
64
  @user_institutions_forms ||= FinApps::REST::UserInstitutionsForms.new self
65
65
  end
66
+
67
+ def password_resets
68
+ @password_resets ||= FinApps::REST::PasswordResets.new self
69
+ end
66
70
  end
67
71
  end
68
72
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+ module FinApps
3
+ module REST
4
+ class PasswordResets < FinApps::REST::Resources # :nodoc:
5
+ using ObjectExtensions
6
+ using StringExtensions
7
+
8
+ def create(id)
9
+ raise MissingArgumentsError.new 'Missing argument: id.' if id.blank?
10
+
11
+ path = "tenant/#{ERB::Util.url_encode(id)}/password"
12
+ super nil, path
13
+ end
14
+
15
+ def update(id, params)
16
+ raise MissingArgumentsError.new 'Missing argument: id.' if id.blank?
17
+ raise MissingArgumentsError.new 'Missing argument: params.' if params.blank?
18
+
19
+ path = "tenant/#{ERB::Util.url_encode(id)}/password"
20
+ super params, path
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module FinApps
3
- VERSION = '2.1.2'
3
+ VERSION = '2.1.3'
4
4
  end
@@ -14,7 +14,7 @@ RSpec.describe FinApps::REST::Client do
14
14
  subject { FinApps::REST::Client.new(:company_identifier, :company_token) }
15
15
 
16
16
  %i(users sessions orders order_tokens order_reports order_statuses institutions institutions_forms
17
- user_institutions_statuses user_institutions user_institutions_forms).each do |method|
17
+ user_institutions_statuses user_institutions user_institutions_forms password_resets).each do |method|
18
18
  it "responds to #{method}" do
19
19
  expect(subject).to respond_to(method)
20
20
  end
@@ -64,11 +64,15 @@ RSpec.describe FinApps::REST::Client do
64
64
  it { expect(subject.user_institutions_forms).to be_an_instance_of(FinApps::REST::UserInstitutionsForms) }
65
65
  end
66
66
 
67
+ describe '#password_resets' do
68
+ it { expect(subject.password_resets).to be_an_instance_of(FinApps::REST::PasswordResets) }
69
+ end
70
+
67
71
  # [:users, :institutions, :user_institutions, :transactions, :categories,
68
72
  # :budget_models, :budget_calculation, :budgets, :cashflows,
69
73
  # :alert, :alert_definition, :alert_preferences, :alert_settings, :rule_sets]
70
74
  %i(users sessions orders order_tokens order_reports order_statuses institutions institutions_forms
71
- user_institutions_statuses user_institutions user_institutions_forms).each do |method|
75
+ user_institutions_statuses user_institutions user_institutions_forms password_resets).each do |method|
72
76
  it "memoizes the result of #{method}" do
73
77
  first = subject.send(method)
74
78
  second = subject.send(method)
@@ -8,7 +8,7 @@ RSpec.describe FinApps::REST::Orders do
8
8
  end
9
9
 
10
10
  context 'when valid params are provided' do
11
- subject { FinApps::REST::Orders.new(client).show(:id) }
11
+ subject { FinApps::REST::Orders.new(client).show(:valid_id) }
12
12
 
13
13
  it { expect { subject }.not_to raise_error }
14
14
  it('returns an array') { expect(subject).to be_a(Array) }
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+ RSpec.describe FinApps::REST::PasswordResets do
3
+ let(:client) { FinApps::REST::Client.new(:company_identifier, :company_token) }
4
+
5
+ describe '#create' do
6
+ context 'when missing id' do
7
+ subject { FinApps::REST::PasswordResets.new(client).create(nil) }
8
+ it { expect { subject }.to raise_error(FinApps::MissingArgumentsError) }
9
+ end
10
+
11
+ context 'when invalid id is provided' do
12
+ subject { FinApps::REST::PasswordResets.new(client).create(:invalid_user_id) }
13
+
14
+ it { expect { subject }.not_to raise_error }
15
+ it('results is nil') { expect(subject[0]).to be_nil }
16
+ it('error messages array is populated') { expect(subject[1]).not_to be_nil }
17
+ end
18
+
19
+ context 'when valid id is provided' do
20
+ subject { FinApps::REST::PasswordResets.new(client).create(:valid_user_id) }
21
+
22
+ it { expect { subject }.not_to raise_error }
23
+ it('returns an array') { expect(subject).to be_a(Array) }
24
+ it('performs a post and returns the response') { expect(subject[0]).to respond_to(:token) }
25
+ it('returns no error messages') { expect(subject[1]).to be_empty }
26
+ end
27
+ end
28
+
29
+ describe '#update' do
30
+ let(:valid_params) { {token: 'valid_token'} }
31
+ let(:invalid_params) { {token: 'invalid_token'} }
32
+
33
+ context 'when missing id' do
34
+ subject { FinApps::REST::PasswordResets.new(client).update(nil, :params) }
35
+ it { expect { subject }.to raise_error(FinApps::MissingArgumentsError) }
36
+ end
37
+
38
+ context 'when missing params' do
39
+ subject { FinApps::REST::PasswordResets.new(client).update(:valid_user_id, nil) }
40
+ it { expect { subject }.to raise_error(FinApps::MissingArgumentsError) }
41
+ end
42
+
43
+ context 'when invalid id is provided' do
44
+ subject { FinApps::REST::PasswordResets.new(client).update(:invalid_user_id, valid_params) }
45
+
46
+ it { expect { subject }.not_to raise_error }
47
+ it('results is nil') { expect(subject[0]).to be_nil }
48
+ it('error messages array is populated') { expect(subject[1]).not_to be_nil }
49
+ end
50
+
51
+ context 'when invalid params are provided' do
52
+ subject { FinApps::REST::PasswordResets.new(client).update(:valid_user_id, invalid_params) }
53
+
54
+ it { expect { subject }.not_to raise_error }
55
+ it('results is nil') { expect(subject[0]).to be_nil }
56
+ it('error messages array is populated') { expect(subject[1]).not_to be_nil }
57
+ end
58
+
59
+ context 'when valid params are provided' do
60
+ subject { FinApps::REST::PasswordResets.new(client).update(:valid_user_id, valid_params) }
61
+
62
+ it { expect { subject }.not_to raise_error }
63
+ it('returns an array') { expect(subject).to be_a(Array) }
64
+ it('performs a post and returns the response') { expect(subject[0]).to respond_to(:token) }
65
+ it('returns no error messages') { expect(subject[1]).to be_empty }
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+ RSpec.describe FinApps::REST::Orders do
3
+ let(:client) { FinApps::REST::Client.new(:company_identifier, :company_token) }
4
+
5
+ describe 'timeout' do
6
+ subject { FinApps::REST::Orders.new(client).show(:timeout) }
7
+ it { expect { subject }.to raise_error(FinApps::ApiSessionTimeoutError) }
8
+ end
9
+ end
@@ -13,7 +13,7 @@ class FakeApi < Sinatra::Base
13
13
  # orders
14
14
  post('/v2/orders/valid_token') { json_response 200, 'order_token.json' }
15
15
  post('/v2/orders/invalid_token') { json_response 404, 'resource_not_found.json' }
16
- get('/v2/orders/:id') { json_response 200, 'resource.json' }
16
+ get('/v2/orders/valid_id') { json_response 200, 'resource.json' }
17
17
  get('/v2/list/orders/:page/:requested/:sort/:asc') { json_response 200, 'orders.json' }
18
18
  get('/v2/orders/valid_id/report.:format') { json_response 200, 'order_report.json' }
19
19
  get('/v2/orders/invalid_id/report.:format') { json_response 404, 'resource_not_found.json' }
@@ -83,6 +83,20 @@ class FakeApi < Sinatra::Base
83
83
  end
84
84
  end
85
85
 
86
+ # password resets
87
+ post('/v2/tenant/valid_user_id/password') { json_response 200, 'password_reset_token.json' }
88
+ post('/v2/tenant/invalid_user_id/password') { json_response 404, 'resource_not_found.json' }
89
+ put('/v2/tenant/valid_user_id/password') do
90
+ request.body.rewind
91
+ request_payload = JSON.parse request.body.read
92
+ if request_payload['token'] == 'valid_token'
93
+ json_response(200, 'user.json')
94
+ else
95
+ json_response(400, 'invalid_request_body.json')
96
+ end
97
+ end
98
+ put('/v2/tenant/invalid_user_id/password') { json_response 404, 'resource_not_found.json' }
99
+
86
100
  # relevance
87
101
  get('/v2/relevance/ruleset/names') { json_response 200, 'relevance_ruleset_names.json' }
88
102
 
@@ -91,6 +105,9 @@ class FakeApi < Sinatra::Base
91
105
  get('/v2/server_error') { status 500 }
92
106
  get('/v2/proxy_error') { status 407 }
93
107
 
108
+ # timeout
109
+ get('/v2/orders/timeout') { status 419 }
110
+
94
111
  private
95
112
 
96
113
  def json_response(response_code, file_name)
@@ -0,0 +1,3 @@
1
+ {
2
+ "token": "D7JpLAprd/vTHIKPFWWPHpD4W650wgW9zpi1thfZlgw="
3
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: finapps
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erich Quintero
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-01 00:00:00.000000000 Z
11
+ date: 2016-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -271,6 +271,7 @@ files:
271
271
  - lib/finapps/rest/order_statuses.rb
272
272
  - lib/finapps/rest/order_tokens.rb
273
273
  - lib/finapps/rest/orders.rb
274
+ - lib/finapps/rest/password_resets.rb
274
275
  - lib/finapps/rest/resources.rb
275
276
  - lib/finapps/rest/sessions.rb
276
277
  - lib/finapps/rest/user_institutions.rb
@@ -298,8 +299,10 @@ files:
298
299
  - spec/rest/order_statuses_spec.rb
299
300
  - spec/rest/order_tokens_spec.rb
300
301
  - spec/rest/orders_spec.rb
302
+ - spec/rest/password_resets_spec.rb
301
303
  - spec/rest/resources_spec.rb
302
304
  - spec/rest/sessions_spec.rb
305
+ - spec/rest/timeout_spec.rb
303
306
  - spec/rest/user_institutions_forms_spec.rb
304
307
  - spec/rest/user_institutions_spec.rb
305
308
  - spec/rest/user_institutions_statuses_spec.rb
@@ -319,6 +322,7 @@ files:
319
322
  - spec/support/fixtures/order_status.json
320
323
  - spec/support/fixtures/order_token.json
321
324
  - spec/support/fixtures/orders.json
325
+ - spec/support/fixtures/password_reset_token.json
322
326
  - spec/support/fixtures/relevance_ruleset_names.json
323
327
  - spec/support/fixtures/resource.json
324
328
  - spec/support/fixtures/resource_not_found.json
@@ -374,6 +378,7 @@ test_files:
374
378
  - spec/spec_helpers/client.rb
375
379
  - spec/spec_helper.rb
376
380
  - spec/rest/credentials_spec.rb
381
+ - spec/rest/password_resets_spec.rb
377
382
  - spec/rest/order_tokens_spec.rb
378
383
  - spec/rest/institutions_spec.rb
379
384
  - spec/rest/users_spec.rb
@@ -383,6 +388,7 @@ test_files:
383
388
  - spec/rest/user_institutions_statuses_spec.rb
384
389
  - spec/rest/user_institutions_spec.rb
385
390
  - spec/rest/client_spec.rb
391
+ - spec/rest/timeout_spec.rb
386
392
  - spec/rest/orders_spec.rb
387
393
  - spec/rest/order_statuses_spec.rb
388
394
  - spec/rest/configuration_spec.rb