finapps 5.0.3 → 5.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.rubocop.yml +1 -7
- data/.tmuxinator.yml +19 -0
- data/Guardfile +42 -0
- data/finapps.gemspec +3 -1
- data/lib/finapps.rb +1 -7
- data/lib/finapps/rest/client.rb +5 -10
- data/lib/finapps/rest/consumers.rb +2 -1
- data/lib/finapps/rest/operators.rb +8 -2
- data/lib/finapps/rest/order_reports.rb +2 -1
- data/lib/finapps/rest/orders.rb +11 -9
- data/lib/finapps/rest/plaid/plaid_consumer_institutions.rb +15 -0
- data/lib/finapps/rest/portfolios_alerts.rb +2 -1
- data/lib/finapps/rest/portfolios_available_consumers.rb +2 -1
- data/lib/finapps/rest/portfolios_consumers.rb +6 -1
- data/lib/finapps/rest/products.rb +1 -2
- data/lib/finapps/rest/sessions.rb +8 -2
- data/lib/finapps/rest/statements.rb +2 -1
- data/lib/finapps/version.rb +1 -1
- data/spec/rest/alert_definitions_spec.rb +12 -7
- data/spec/rest/alert_occurrences_spec.rb +17 -5
- data/spec/rest/client_spec.rb +115 -57
- data/spec/rest/consumers_portfolios_spec.rb +9 -4
- data/spec/rest/consumers_spec.rb +76 -20
- data/spec/rest/operators_password_resets_spec.rb +19 -10
- data/spec/rest/operators_spec.rb +60 -22
- data/spec/rest/order_assignments_spec.rb +11 -5
- data/spec/rest/order_notifications_spec.rb +6 -2
- data/spec/rest/order_refreshes_spec.rb +11 -5
- data/spec/rest/order_reports_spec.rb +15 -5
- data/spec/rest/order_statuses_spec.rb +12 -4
- data/spec/rest/order_tokens_spec.rb +17 -5
- data/spec/rest/orders_spec.rb +80 -34
- data/spec/rest/password_resets_spec.rb +51 -14
- data/spec/rest/plaid/plaid_webhooks_spec.rb +7 -3
- data/spec/rest/portfolio_reports_spec.rb +9 -4
- data/spec/rest/portfolios_alerts_spec.rb +18 -10
- data/spec/rest/portfolios_available_consumers_spec.rb +9 -4
- data/spec/rest/portfolios_consumers_spec.rb +29 -11
- data/spec/rest/portfolios_spec.rb +51 -22
- data/spec/rest/products_spec.rb +5 -2
- data/spec/rest/sessions_spec.rb +36 -14
- data/spec/rest/statements_spec.rb +6 -2
- data/spec/rest/tenant_app_settings_spec.rb +13 -5
- data/spec/rest/tenant_settings_spec.rb +13 -5
- data/spec/rest/version_spec.rb +3 -1
- data/spec/spec_helper.rb +6 -4
- data/spec/spec_helpers/client.rb +2 -1
- data/spec/support/fake_api.rb +253 -119
- data/spec/utils/query_builder_spec.rb +8 -3
- data/tags +6 -0
- metadata +48 -25
- data/lib/finapps/rest/consumer_institution_refresh.rb +0 -14
- data/lib/finapps/rest/consumer_institution_refreshes.rb +0 -12
- data/lib/finapps/rest/institutions.rb +0 -34
- data/lib/finapps/rest/institutions_forms.rb +0 -14
- data/lib/finapps/rest/user_institutions.rb +0 -54
- data/lib/finapps/rest/user_institutions_forms.rb +0 -14
- data/lib/finapps/rest/user_institutions_statuses.rb +0 -19
- data/spec/rest/consumer_institution_refresh_spec.rb +0 -44
- data/spec/rest/consumer_institution_refreshes_spec.rb +0 -20
- data/spec/rest/institutions_forms_spec.rb +0 -29
- data/spec/rest/institutions_spec.rb +0 -55
- data/spec/rest/user_institutions_forms_spec.rb +0 -30
- data/spec/rest/user_institutions_spec.rb +0 -144
- data/spec/rest/user_institutions_statuses_spec.rb +0 -43
@@ -11,7 +11,7 @@ RSpec.describe FinApps::REST::TenantSettings do
|
|
11
11
|
|
12
12
|
it { expect { show }.not_to raise_error }
|
13
13
|
it('performs a get and returns the response') do
|
14
|
-
expect(show[RESULTS]).to
|
14
|
+
expect(show[RESULTS]).to have_key(:iav_default_product)
|
15
15
|
end
|
16
16
|
it('returns no error messages') { expect(show[ERROR_MESSAGES]).to be_empty }
|
17
17
|
end
|
@@ -21,15 +21,21 @@ RSpec.describe FinApps::REST::TenantSettings do
|
|
21
21
|
|
22
22
|
context 'when missing params' do
|
23
23
|
let(:params) { nil }
|
24
|
-
it
|
24
|
+
it do
|
25
|
+
expect { update }.to raise_error(FinAppsCore::MissingArgumentsError)
|
26
|
+
end
|
25
27
|
end
|
26
28
|
|
27
29
|
context 'when valid params are provided' do
|
28
30
|
let(:params) { { iav_default_product: 'valid' } }
|
29
31
|
|
30
32
|
it { expect { update }.not_to raise_error }
|
31
|
-
it('performs put and returns no content')
|
32
|
-
|
33
|
+
it('performs put and returns no content') do
|
34
|
+
expect(update[RESULTS]).to be_nil
|
35
|
+
end
|
36
|
+
it('error_messages array is empty') do
|
37
|
+
expect(update[ERROR_MESSAGES]).to be_empty
|
38
|
+
end
|
33
39
|
end
|
34
40
|
|
35
41
|
context 'when invalid params are provided' do
|
@@ -37,7 +43,9 @@ RSpec.describe FinApps::REST::TenantSettings do
|
|
37
43
|
|
38
44
|
it { expect { update }.not_to raise_error }
|
39
45
|
it('results is nil') { expect(update[RESULTS]).to be_nil }
|
40
|
-
it('error_messages array is populated')
|
46
|
+
it('error_messages array is populated') do
|
47
|
+
expect(update[ERROR_MESSAGES]).not_to be_empty
|
48
|
+
end
|
41
49
|
end
|
42
50
|
end
|
43
51
|
end
|
data/spec/rest/version_spec.rb
CHANGED
@@ -7,6 +7,8 @@ RSpec.describe FinApps::REST::Version do
|
|
7
7
|
describe '#show' do
|
8
8
|
it { expect { subject.show }.not_to raise_error }
|
9
9
|
it('returns a string') { expect(subject.show[0]).to be_a(String) }
|
10
|
-
it('starts with the words "Version =>"')
|
10
|
+
it('starts with the words "Version =>"') do
|
11
|
+
expect(subject.show[0]).to start_with('Version =>')
|
12
|
+
end
|
11
13
|
end
|
12
14
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -21,7 +21,7 @@ RSpec.configure do |config|
|
|
21
21
|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
22
22
|
expectations.syntax = :expect
|
23
23
|
end
|
24
|
-
config.mock_with(:rspec) {|mocks| mocks.verify_partial_doubles = true }
|
24
|
+
config.mock_with(:rspec) { |mocks| mocks.verify_partial_doubles = true }
|
25
25
|
# config.filter_run_including :focus => true
|
26
26
|
config.default_formatter = 'doc' if config.files_to_run.one?
|
27
27
|
config.order = :random
|
@@ -30,14 +30,16 @@ RSpec.configure do |config|
|
|
30
30
|
Kernel.srand config.seed
|
31
31
|
|
32
32
|
config.before(:each) do
|
33
|
-
base_url =
|
33
|
+
base_url =
|
34
|
+
"#{FinAppsCore::REST::Defaults::DEFAULTS[:host]}/v#{FinAppsCore::REST::Defaults::API_VERSION}/"
|
34
35
|
stub_request(:any, /#{base_url}/).to_rack(::FakeApi)
|
35
36
|
end
|
36
37
|
WebMock.disable_net_connect!(allow: 'codeclimate.com')
|
37
38
|
end
|
38
39
|
|
39
|
-
VALID_CREDENTIALS = {
|
40
|
-
|
40
|
+
VALID_CREDENTIALS = {
|
41
|
+
identifier: '49fb918d-7e71-44dd-7378-58f19606df2a', token: 'hohoho='
|
42
|
+
}.freeze
|
41
43
|
|
42
44
|
RESULTS = 0
|
43
45
|
ERROR_MESSAGES = 1
|
data/spec/spec_helpers/client.rb
CHANGED
data/spec/support/fake_api.rb
CHANGED
@@ -4,19 +4,19 @@ require 'sinatra/base'
|
|
4
4
|
|
5
5
|
# the FakeApi class is used to mock API requests while testing.
|
6
6
|
class FakeApi < Sinatra::Base
|
7
|
-
def self.
|
7
|
+
def self.version
|
8
8
|
"v#{FinAppsCore::REST::Defaults::API_VERSION}"
|
9
9
|
end
|
10
10
|
|
11
11
|
# resource
|
12
|
-
post("/#{
|
13
|
-
get("/#{
|
14
|
-
get("/#{
|
15
|
-
put("/#{
|
16
|
-
delete("/#{
|
12
|
+
post("/#{version}/resources") { json_response 201, 'resource.json' }
|
13
|
+
get("/#{version}/resources/:id") { json_response 200, 'resource.json' }
|
14
|
+
get("/#{version}/resources") { json_response 200, 'resources.json' }
|
15
|
+
put("/#{version}/resources") { json_response 201, 'resource.json' }
|
16
|
+
delete("/#{version}/resources/:id") { status 202 }
|
17
17
|
|
18
18
|
# plaid
|
19
|
-
post("/#{
|
19
|
+
post("/#{version}/p/webhook") do
|
20
20
|
tenant_token = request.env['HTTP_X_TENANT_TOKEN']
|
21
21
|
if tenant_token == 'invalid_tenant_token'
|
22
22
|
json_response 404, 'resource_not_found.json'
|
@@ -26,11 +26,13 @@ class FakeApi < Sinatra::Base
|
|
26
26
|
end
|
27
27
|
|
28
28
|
# version
|
29
|
-
get("/#{
|
29
|
+
get("/#{version}/version") { 'Version => 2.1.29-.20161208.172810' }
|
30
30
|
|
31
31
|
# tenants
|
32
|
-
get("/#{
|
33
|
-
|
32
|
+
get("/#{version}/settings/tenant") do
|
33
|
+
json_response 200, 'tenant_settings.json'
|
34
|
+
end
|
35
|
+
put("/#{version}/settings/tenant") do
|
34
36
|
request.body.rewind
|
35
37
|
request_payload = JSON.parse request.body.read
|
36
38
|
if request_payload['bad_params']
|
@@ -39,8 +41,10 @@ class FakeApi < Sinatra::Base
|
|
39
41
|
status 204
|
40
42
|
end
|
41
43
|
end
|
42
|
-
get("/#{
|
43
|
-
|
44
|
+
get("/#{version}/settings/app") do
|
45
|
+
json_response 200, 'tenant_app_settings.json'
|
46
|
+
end
|
47
|
+
put("/#{version}/settings/app") do
|
44
48
|
request.body.rewind
|
45
49
|
request_payload = JSON.parse request.body.read
|
46
50
|
if request_payload['pdf_statement_months']
|
@@ -51,22 +55,44 @@ class FakeApi < Sinatra::Base
|
|
51
55
|
end
|
52
56
|
|
53
57
|
# orders
|
54
|
-
post("/#{
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
get("/#{
|
61
|
-
get("/#{
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
58
|
+
post("/#{version}/orders/valid_token") do
|
59
|
+
json_response 200, 'order_token.json'
|
60
|
+
end
|
61
|
+
post("/#{version}/orders/invalid_token") do
|
62
|
+
json_response 404, 'resource_not_found.json'
|
63
|
+
end
|
64
|
+
get("/#{version}/orders/valid_id") { json_response 200, 'order.json' }
|
65
|
+
get("/#{version}/orders") { json_response 200, 'orders.json' }
|
66
|
+
get("/#{version}/orders/valid_id/report.:format") do
|
67
|
+
json_response 200, 'order_report.json'
|
68
|
+
end
|
69
|
+
get("/#{version}/orders/invalid_id/report.:format") do
|
70
|
+
json_response 404, 'resource_not_found.json'
|
71
|
+
end
|
72
|
+
get("/#{version}/orders/valid_id/status") do
|
73
|
+
json_response 200, 'order_status.json'
|
74
|
+
end
|
75
|
+
get("/#{version}/orders/invalid_id/status") do
|
76
|
+
json_response 404, 'resource_not_found.json'
|
77
|
+
end
|
78
|
+
put("/#{version}/orders/valid_id/cancel") { status 204 }
|
79
|
+
put("/#{version}/orders/invalid_id/cancel") do
|
80
|
+
json_response 404, 'resource_not_found.json'
|
81
|
+
end
|
82
|
+
put("/#{version}/orders/valid_id/notify") { status 204 }
|
83
|
+
put("/#{version}/orders/invalid_id/notify") do
|
84
|
+
json_response 404, 'resource_not_found.json'
|
85
|
+
end
|
86
|
+
put("/#{version}/orders/valid_id/refresh") do
|
87
|
+
json_response 200, 'order_refresh.json'
|
88
|
+
end
|
89
|
+
put("/#{version}/orders/invalid_id/refresh") do
|
90
|
+
json_response 404, 'resource_not_found.json'
|
91
|
+
end
|
92
|
+
put("/#{version}/orders/invalid_id") do
|
93
|
+
json_response 404, 'resource_not_found.json'
|
94
|
+
end
|
95
|
+
put("/#{version}/orders/valid_id") do
|
70
96
|
request.body.rewind
|
71
97
|
request_payload = JSON.parse request.body.read
|
72
98
|
if request_payload['accounts'] == 'valid_account'
|
@@ -75,10 +101,10 @@ class FakeApi < Sinatra::Base
|
|
75
101
|
json_response 400, 'invalid_request_body.json'
|
76
102
|
end
|
77
103
|
end
|
78
|
-
post("/#{
|
104
|
+
post("/#{version}/orders") do
|
79
105
|
request.body.rewind
|
80
106
|
request_payload = JSON.parse request.body.read
|
81
|
-
if %w[applicant institutions product].all? {|s| request_payload.key? s }
|
107
|
+
if %w[applicant institutions product].all? { |s| request_payload.key? s }
|
82
108
|
json_response 200, 'order_token.json'
|
83
109
|
else
|
84
110
|
json_response 400, 'invalid_request_body.json'
|
@@ -86,34 +112,72 @@ class FakeApi < Sinatra::Base
|
|
86
112
|
end
|
87
113
|
|
88
114
|
# institutions
|
89
|
-
get("/#{
|
90
|
-
|
91
|
-
|
92
|
-
get("/#{
|
93
|
-
|
94
|
-
|
115
|
+
get("/#{version}/institutions/site/valid_site_id/form") do
|
116
|
+
json_response 200, 'institution_login_form.json'
|
117
|
+
end
|
118
|
+
get("/#{version}/institutions/site/invalid_site_id/form") do
|
119
|
+
json_response 400, 'invalid_institution_id.json'
|
120
|
+
end
|
121
|
+
post("/#{version}/institutions/site/valid_site_id/add") do
|
122
|
+
json_response 200, 'institution_add.json'
|
123
|
+
end
|
124
|
+
get("/#{version}/institutions/search/:search_term") do
|
125
|
+
json_response 200, 'institutions_search_list.json'
|
126
|
+
end
|
127
|
+
get("/#{version}/institutions/routing/:routing_number") do
|
128
|
+
json_response 200, 'institutions_routing_number.json'
|
129
|
+
end
|
130
|
+
get("/#{version}/institutions/site/:site_id") do
|
131
|
+
json_response 200, 'institutions_routing_number.json'
|
132
|
+
end
|
95
133
|
|
96
134
|
# user institutions
|
97
|
-
get("/#{
|
98
|
-
|
135
|
+
get("/#{version}/institutions/consumer/valid_id/status") do
|
136
|
+
json_response 200, 'user_institution_status.json'
|
137
|
+
end
|
138
|
+
get("/#{version}/institutions/consumer/invalid_id/status") do
|
99
139
|
json_response 400, 'invalid_user_institution_id.json'
|
100
140
|
end
|
101
|
-
get("/#{
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
141
|
+
get("/#{version}/institutions/consumer") do
|
142
|
+
json_response 200, 'user_institutions_list.json'
|
143
|
+
end
|
144
|
+
get("/#{version}/institutions/consumer/valid_id") do
|
145
|
+
json_response 200, 'user_institutions_show.json'
|
146
|
+
end
|
147
|
+
get("/#{version}/institutions/consumer/invalid_id") do
|
107
148
|
json_response 400, 'invalid_user_institution_id.json'
|
108
149
|
end
|
109
|
-
put("/#{
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
put("/#{
|
116
|
-
|
150
|
+
put("/#{version}/institutions/consumer/refresh") do
|
151
|
+
json_response 200, 'user_institutions_refresh_all.json'
|
152
|
+
end
|
153
|
+
put("/#{version}/institutions/consumer/valid_id/credentials") do
|
154
|
+
json_response 200, 'institution_add.json'
|
155
|
+
end
|
156
|
+
put("/#{version}/institutions/consumer/invalid_id/credentials") do
|
157
|
+
json_response 400, 'invalid_user_institution_id.json'
|
158
|
+
end
|
159
|
+
put("/#{version}/institutions/consumer/valid_id/mfa") do
|
160
|
+
json_response 200, 'institution_add.json'
|
161
|
+
end
|
162
|
+
put("/#{version}/institutions/consumer/invalid_id/mfa") do
|
163
|
+
json_response 400, 'invalid_user_institution_id.json'
|
164
|
+
end
|
165
|
+
delete("/#{version}/institutions/consumer/valid_id") { status 204 }
|
166
|
+
delete("/#{version}/institutions/consumer/invalid_id") do
|
167
|
+
json_response 400, 'invalid_user_institution_id.json'
|
168
|
+
end
|
169
|
+
get("/#{version}/institutions/consumer/valid_id/form") do
|
170
|
+
json_response 200, 'institution_login_form.json'
|
171
|
+
end
|
172
|
+
get("/#{version}/institutions/consumer/invalid_id/form") do
|
173
|
+
json_response 400, 'invalid_institution_id.json'
|
174
|
+
end
|
175
|
+
put("/#{version}/institutions/refresh") do
|
176
|
+
json_response 200, 'user_institution_refresh.json'
|
177
|
+
end
|
178
|
+
put(
|
179
|
+
"/#{version}/institutions/consumer/valid_consumer_institution_id/refresh"
|
180
|
+
) do
|
117
181
|
request.body.rewind
|
118
182
|
request_payload = JSON.parse request.body.read
|
119
183
|
if request_payload['token'] == 'invalid_token'
|
@@ -124,9 +188,13 @@ class FakeApi < Sinatra::Base
|
|
124
188
|
end
|
125
189
|
|
126
190
|
# consumers
|
127
|
-
get("/#{
|
128
|
-
|
129
|
-
|
191
|
+
get("/#{version}/consumers/valid_public_id") do
|
192
|
+
json_response 200, 'user.json'
|
193
|
+
end
|
194
|
+
get("/#{version}/consumers/invalid_public_id") do
|
195
|
+
json_response 404, 'resource_not_found.json'
|
196
|
+
end
|
197
|
+
post("/#{version}/consumers") do
|
130
198
|
request.body.rewind
|
131
199
|
request_payload = JSON.parse request.body.read
|
132
200
|
if request_payload['password']
|
@@ -135,31 +203,55 @@ class FakeApi < Sinatra::Base
|
|
135
203
|
json_response 400, 'invalid_request_body.json'
|
136
204
|
end
|
137
205
|
end
|
138
|
-
put("/#{
|
139
|
-
put("/#{
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
206
|
+
put("/#{version}/consumers/valid_public_id") { status 204 }
|
207
|
+
put("/#{version}/consumers/invalid_public_id") do
|
208
|
+
json_response 400, 'invalid_user_id.json'
|
209
|
+
end
|
210
|
+
put("/#{version}/consumers/valid_public_id/password") do
|
211
|
+
json_response 200, 'user.json'
|
212
|
+
end
|
213
|
+
put("/#{version}/consumers/invalid_public_id/password") do
|
214
|
+
json_response 404, 'resource_not_found.json'
|
215
|
+
end
|
216
|
+
delete("/#{version}/consumers/valid_public_id") { status 204 }
|
217
|
+
delete("/#{version}/consumers/invalid_public_id") do
|
218
|
+
json_response 404, 'resource_not_found.json'
|
219
|
+
end
|
220
|
+
post("/#{version}/logout") { status 204 }
|
145
221
|
|
146
222
|
# accounts
|
147
|
-
get("/#{
|
148
|
-
|
223
|
+
get("/#{version}/accounts/valid_id/statement/valid_id") do
|
224
|
+
json_response 200, 'fake_pdf_statement.json'
|
225
|
+
end
|
226
|
+
get("/#{version}/accounts/invalid_id/statement/valid_id") do
|
227
|
+
json_response 404, 'resource_not_found.json'
|
228
|
+
end
|
149
229
|
|
150
230
|
# operators
|
151
|
-
get("/#{
|
152
|
-
get("/#{
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
231
|
+
get("/#{version}/operators") { json_response 200, 'operator_list.json' }
|
232
|
+
get("/#{version}/operators/invalid_id") do
|
233
|
+
json_response 404, 'resource_not_found.json'
|
234
|
+
end
|
235
|
+
get("/#{version}/operators/valid_id") { json_response 200, 'operator.json' }
|
236
|
+
delete("/#{version}/operators/invalid_id") do
|
237
|
+
json_response 404, 'resource_not_found.json'
|
238
|
+
end
|
239
|
+
delete("/#{version}/operators/valid_id") { status 204 }
|
240
|
+
post("/#{version}/operators/password/change") do
|
241
|
+
json_response 200, 'operator.json'
|
242
|
+
end
|
243
|
+
put("/#{version}/operators/invalid_id") do
|
244
|
+
json_response 404, 'resource_not_found.json'
|
245
|
+
end
|
246
|
+
put("/#{version}/operators/valid_id") { json_response 200, 'operator.json' }
|
247
|
+
put("/#{version}/operators/valid_id/assign") { status 204 }
|
248
|
+
put("/#{version}/operators/invalid_id/assign") do
|
249
|
+
json_response 404, 'resource_not_found.json'
|
250
|
+
end
|
251
|
+
post("/#{version}/operators/password/forgot") do
|
252
|
+
json_response 200, 'operator_forgot_password.json'
|
253
|
+
end
|
254
|
+
post("/#{version}/operators/password/reset") do
|
163
255
|
request.body.rewind
|
164
256
|
request_payload = JSON.parse request.body.read
|
165
257
|
if request_payload['params'] == 'valid'
|
@@ -168,7 +260,7 @@ class FakeApi < Sinatra::Base
|
|
168
260
|
json_response 400, 'invalid_request_body.json'
|
169
261
|
end
|
170
262
|
end
|
171
|
-
post("/#{
|
263
|
+
post("/#{version}/operators") do
|
172
264
|
request.body.rewind
|
173
265
|
request_payload = JSON.parse request.body.read
|
174
266
|
if request_payload['params'] == 'valid'
|
@@ -179,7 +271,7 @@ class FakeApi < Sinatra::Base
|
|
179
271
|
end
|
180
272
|
|
181
273
|
# session
|
182
|
-
post("/#{
|
274
|
+
post("/#{version}/login") do
|
183
275
|
request.body.rewind
|
184
276
|
request_payload = JSON.parse request.body.read
|
185
277
|
if request_payload['password'] == 'valid_password'
|
@@ -188,12 +280,16 @@ class FakeApi < Sinatra::Base
|
|
188
280
|
json_response(401, 'unauthorized.json')
|
189
281
|
end
|
190
282
|
end
|
191
|
-
post("/#{
|
283
|
+
post("/#{version}/operators/login") { json_response 200, 'operator.json' }
|
192
284
|
|
193
285
|
# password resets
|
194
|
-
post("/#{
|
195
|
-
|
196
|
-
|
286
|
+
post("/#{version}/tenant/valid_user_id/password") do
|
287
|
+
json_response 200, 'password_reset_token.json'
|
288
|
+
end
|
289
|
+
post("/#{version}/tenant/invalid_user_id/password") do
|
290
|
+
json_response 404, 'resource_not_found.json'
|
291
|
+
end
|
292
|
+
put("/#{version}/tenant/valid_user_id/password") do
|
197
293
|
request.body.rewind
|
198
294
|
request_payload = JSON.parse request.body.read
|
199
295
|
if request_payload['token'] == 'valid_token'
|
@@ -202,16 +298,20 @@ class FakeApi < Sinatra::Base
|
|
202
298
|
json_response(400, 'invalid_request_body.json')
|
203
299
|
end
|
204
300
|
end
|
205
|
-
put("/#{
|
301
|
+
put("/#{version}/tenant/invalid_user_id/password") do
|
302
|
+
json_response 404, 'resource_not_found.json'
|
303
|
+
end
|
206
304
|
|
207
305
|
# products
|
208
|
-
get("/#{
|
306
|
+
get("/#{version}/products") { json_response 200, 'products.json' }
|
209
307
|
|
210
308
|
# portfolios
|
211
|
-
get("/#{
|
212
|
-
get("/#{
|
213
|
-
get("/#{
|
214
|
-
|
309
|
+
get("/#{version}/portfolios") { json_response 200, 'portfolios.json' }
|
310
|
+
get("/#{version}/portfolios/valid_id") { json_response 200, 'portfolio.json' }
|
311
|
+
get("/#{version}/portfolios/invalid_id") do
|
312
|
+
json_response 404, 'resource_not_found.json'
|
313
|
+
end
|
314
|
+
post("/#{version}/portfolios") do
|
215
315
|
request.body.rewind
|
216
316
|
request_payload = JSON.parse request.body.read
|
217
317
|
if request_payload['product'] == 'invalid'
|
@@ -220,63 +320,97 @@ class FakeApi < Sinatra::Base
|
|
220
320
|
json_response(200, 'portfolio.json')
|
221
321
|
end
|
222
322
|
end
|
223
|
-
put("/#{
|
224
|
-
put("/#{
|
225
|
-
|
226
|
-
|
323
|
+
put("/#{version}/portfolios/valid_id") { json_response 200, 'portfolio.json' }
|
324
|
+
put("/#{version}/portfolios/invalid_id") do
|
325
|
+
json_response 404, 'resource_not_found.json'
|
326
|
+
end
|
327
|
+
delete("/#{version}/portfolios/valid_id") { status 204 }
|
328
|
+
delete("/#{version}/portfolios/invalid_id") do
|
329
|
+
json_response 404, 'resource_not_found.json'
|
330
|
+
end
|
227
331
|
|
228
332
|
# alert definitions
|
229
|
-
get("/#{
|
230
|
-
|
231
|
-
|
333
|
+
get("/#{version}/portfolio/alerts/definitions") do
|
334
|
+
json_response 200, 'alert_definitions.json'
|
335
|
+
end
|
336
|
+
get("/#{version}/portfolio/alerts/definitions/valid_id") do
|
337
|
+
json_response 200, 'alert_definition.json'
|
338
|
+
end
|
339
|
+
get("/#{version}/portfolio/alerts/definitions/invalid_id") do
|
340
|
+
json_response 404, 'resource_not_found.json'
|
341
|
+
end
|
232
342
|
|
233
343
|
# alert occurrences
|
234
|
-
get("/#{
|
344
|
+
get("/#{version}/portfolio/alerts/occurrences") do
|
345
|
+
json_response 200, 'alert_occurrences.json'
|
346
|
+
end
|
235
347
|
|
236
348
|
# portfolios alerts
|
237
|
-
get("/#{
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
349
|
+
get("/#{version}/portfolios/valid_id/alerts") do
|
350
|
+
json_response 200, 'portfolios_alerts.json'
|
351
|
+
end
|
352
|
+
get("/#{version}/portfolios/invalid_id/alerts") do
|
353
|
+
json_response 404, 'resource_not_found.json'
|
354
|
+
end
|
355
|
+
put("/#{version}/portfolios/valid_id/alerts/valid_id") { status 204 }
|
356
|
+
put("/#{version}/portfolios/invalid_id/alerts/invalid_id") do
|
357
|
+
json_response 404, 'resource_not_found.json'
|
358
|
+
end
|
359
|
+
delete("/#{version}/portfolios/valid_id/alerts/valid_id") { status 204 }
|
360
|
+
delete("/#{version}/portfolios/invalid_id/alerts/invalid_id") do
|
361
|
+
json_response 404, 'resource_not_found.json'
|
362
|
+
end
|
243
363
|
|
244
364
|
# portfolios consumers
|
245
|
-
get("/#{
|
246
|
-
|
247
|
-
|
248
|
-
|
365
|
+
get("/#{version}/portfolios/valid_id/consumers") do
|
366
|
+
json_response 200, 'portfolios_consumers.json'
|
367
|
+
end
|
368
|
+
get("/#{version}/portfolios/invalid_id/consumers") do
|
369
|
+
json_response 404, 'resource_not_found.json'
|
370
|
+
end
|
371
|
+
post("/#{version}/portfolios/valid_id/consumers") { status 204 }
|
372
|
+
post("/#{version}/portfolios/invalid_id/consumers") do
|
249
373
|
json_response 400, 'multiple_consumer_subscribe_error.json'
|
250
374
|
end
|
251
|
-
post("/#{
|
252
|
-
post("/#{
|
375
|
+
post("/#{version}/portfolios/valid_id/consumers/valid_id") { status 204 }
|
376
|
+
post("/#{version}/portfolios/invalid_id/consumers/invalid_id") do
|
253
377
|
json_response 400, 'single_consumer_subscribe_error.json'
|
254
378
|
end
|
255
|
-
delete("/#{
|
256
|
-
delete("/#{
|
379
|
+
delete("/#{version}/portfolios/valid_id/consumers/valid_id") { status 204 }
|
380
|
+
delete("/#{version}/portfolios/invalid_id/consumers/invalid_id") do
|
381
|
+
json_response 404, 'resource_not_found.json'
|
382
|
+
end
|
257
383
|
|
258
384
|
# portfolios available consumers
|
259
|
-
get("/#{
|
385
|
+
get("/#{version}/portfolios/:id/consumers/available") do
|
260
386
|
json_response 200, 'portfolios_available_consumers.json'
|
261
387
|
end
|
262
388
|
|
263
389
|
# consumers portfolios
|
264
|
-
get("/#{
|
265
|
-
|
390
|
+
get("/#{version}/consumers/valid_id/portfolios") do
|
391
|
+
json_response 200, 'portfolios.json'
|
392
|
+
end
|
393
|
+
get("/#{version}/consumers/invalid_id/portfolios") do
|
394
|
+
json_response 404, 'resource_not_found.json'
|
395
|
+
end
|
266
396
|
|
267
397
|
# portfolio reports
|
268
|
-
get("/#{
|
398
|
+
get("/#{version}/portfolio/reports") do
|
399
|
+
json_response 200, 'portfolio_reports.json'
|
400
|
+
end
|
269
401
|
|
270
402
|
# relevance
|
271
|
-
get("/#{
|
403
|
+
get("/#{version}/relevance/ruleset/names") do
|
404
|
+
json_response 200, 'relevance_ruleset_names.json'
|
405
|
+
end
|
272
406
|
|
273
407
|
# errors
|
274
|
-
get("/#{
|
275
|
-
get("/#{
|
276
|
-
get("/#{
|
408
|
+
get("/#{version}/client_error") { json_response 400, 'error.json' }
|
409
|
+
get("/#{version}/server_error") { status 500 }
|
410
|
+
get("/#{version}/proxy_error") { status 407 }
|
277
411
|
|
278
412
|
# timeout
|
279
|
-
get("/#{
|
413
|
+
get("/#{version}/orders/timeout") { status 419 }
|
280
414
|
|
281
415
|
private
|
282
416
|
|