et_fake_ccd 1.0.8 → 1.1.4

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
  SHA256:
3
- metadata.gz: de688c1ca8652677740a091259cbbccb016671f695286350f9f8c750b543e1b2
4
- data.tar.gz: 066c43c83e15dc3b7e371b1b8df9532df7b1eeb746159c4111acc23d4c551c7b
3
+ metadata.gz: e5968450f9fb5c522a5ef2843d74bd516795565a7e0ea2db74b99f535b3b218b
4
+ data.tar.gz: 7ef2bf4693eda7b6c427a5ddb4597de610c0d5b30eda626af7e94e735e50b242
5
5
  SHA512:
6
- metadata.gz: 9bb7780b6675018807c4f29c3ebe7c177a90df1a6a4362a1e229805e450a16daeee3894ee04e55bced1f499746463ba44b194e70cedc9d705eb8bd1679c1286f
7
- data.tar.gz: 420a1892328c465b5b95a3d428002c199ddcd07b8266bbbe0330e13e38bff5fecbef871391bb61706407499e216472eed91f327aa14e791652a14e99d2bebcea
6
+ metadata.gz: ec1cd2619dab545b1c59a681c4396da960296eaf31c1a56b5c4c8b085f0c87d9151e75bd181a2a1a5df90697f7b54c8a5696ec944b106133a352e04baefcf574
7
+ data.tar.gz: 23102b8a755b256725c001afd3ea9b7fc87afe645dec8e6dc61278c89cf44ab239a912118153e8da46fa094627f8edd417c7c4063e2d15eba131c63369b53501
data/Gemfile.lock CHANGED
@@ -1,43 +1,42 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- et_fake_ccd (1.0.8)
4
+ et_fake_ccd (1.1.4)
5
5
  activemodel (>= 5.2.3)
6
6
  iodine (~> 0.7)
7
7
  json-schema (~> 2.5)
8
8
  roda (~> 3.21)
9
- rotp (~> 5.1)
9
+ rotp (~> 6.2)
10
10
  thor (~> 1.0)
11
11
  tilt (~> 2.0, >= 2.0.9)
12
12
 
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
- activemodel (6.0.2.2)
17
- activesupport (= 6.0.2.2)
18
- activesupport (6.0.2.2)
16
+ activemodel (6.1.3.1)
17
+ activesupport (= 6.1.3.1)
18
+ activesupport (6.1.3.1)
19
19
  concurrent-ruby (~> 1.0, >= 1.0.2)
20
- i18n (>= 0.7, < 2)
21
- minitest (~> 5.1)
22
- tzinfo (~> 1.1)
23
- zeitwerk (~> 2.2)
20
+ i18n (>= 1.6, < 2)
21
+ minitest (>= 5.1)
22
+ tzinfo (~> 2.0)
23
+ zeitwerk (~> 2.3)
24
24
  addressable (2.7.0)
25
25
  public_suffix (>= 2.0.2, < 5.0)
26
- concurrent-ruby (1.1.6)
26
+ concurrent-ruby (1.1.8)
27
27
  diff-lcs (1.3)
28
- i18n (1.8.2)
28
+ i18n (1.8.10)
29
29
  concurrent-ruby (~> 1.0)
30
- iodine (0.7.38)
30
+ iodine (0.7.44)
31
31
  json-schema (2.8.1)
32
32
  addressable (>= 2.4)
33
- minitest (5.14.0)
34
- public_suffix (4.0.4)
35
- rack (2.2.2)
33
+ minitest (5.14.4)
34
+ public_suffix (4.0.6)
35
+ rack (2.2.3)
36
36
  rake (13.0.1)
37
- roda (3.31.0)
37
+ roda (3.43.1)
38
38
  rack
39
- rotp (5.1.0)
40
- addressable (~> 2.5)
39
+ rotp (6.2.0)
41
40
  rspec (3.9.0)
42
41
  rspec-core (~> 3.9.0)
43
42
  rspec-expectations (~> 3.9.0)
@@ -51,12 +50,11 @@ GEM
51
50
  diff-lcs (>= 1.2.0, < 2.0)
52
51
  rspec-support (~> 3.9.0)
53
52
  rspec-support (3.9.2)
54
- thor (1.0.1)
55
- thread_safe (0.3.6)
53
+ thor (1.1.0)
56
54
  tilt (2.0.10)
57
- tzinfo (1.2.7)
58
- thread_safe (~> 0.1)
59
- zeitwerk (2.3.0)
55
+ tzinfo (2.0.4)
56
+ concurrent-ruby (~> 1.0)
57
+ zeitwerk (2.4.2)
60
58
 
61
59
  PLATFORMS
62
60
  ruby
data/README.md CHANGED
@@ -97,7 +97,74 @@ So, here is a list of deliberate errors that Im sure will increase in size :-
97
97
  * Use the lead claimant title of "Mr" to only force the error on the first occurence
98
98
  * Use the lead claimant title of "Mrs" to force the error on every occurence
99
99
 
100
+ ### Improved Deliberate Error Control
100
101
 
102
+ The above deliberate error mechanism worked, it does not give quite enough control.
103
+
104
+ A new system has therefore been developed that you can use instead of it.
105
+
106
+ This uses special configuration settings in the 'External System' in the admin.
107
+
108
+ There are 2 key entries
109
+
110
+ 1. 'extra_headers'
111
+ 2. 'send_request_id'
112
+
113
+ #### extra_headers
114
+
115
+ 'extra_headers' should contain a JSON encoded value of a hash. Each entry in the hash is a header
116
+ to add to every request to this fake ccd server.
117
+
118
+ ##### force_failures header
119
+
120
+ The force_failures header should contain a hash which looks like this
121
+
122
+ ```json
123
+ {
124
+ "idam_stage": { ..spec.. },
125
+ "token_stage": { ..spec.. },
126
+ "data_stage": { ..spec.. }
127
+ }
128
+
129
+ ```
130
+
131
+ The 4 different stages give control of when the error will happen
132
+
133
+ The 'idam_stage' is the stage of the transaction when an IDAM token is requested.
134
+ However, this does not happen all of the time because IDAM tokens are cached, so
135
+ you will not necessarily see one request per transaction.
136
+
137
+ The 'token_stage' is used in most transactions such as case creation
138
+ where a 'token' is the starting stage - which then allows the case
139
+ to be created against this token.
140
+
141
+ The 'documents' stage is used in transactions that require documents uploading before the
142
+ case is created.
143
+
144
+ The 'data_stage' is used in most transactions and means the actual data
145
+ creation.
146
+
147
+ The '..spec..' is the same irrespective of which stage and is described below:
148
+
149
+ ```json
150
+ [a, b, c]
151
+ ```
152
+
153
+ a, b, c (you can specify as many as you want here, not just 3)
154
+ are http response codes for the 'nth' request. i.e. the first argument
155
+ is for the first request, the 2nd for the 2nd etc..
156
+ The special value of 0 means allow the normal response and do not force an
157
+ error - allowing for patterns such as error on the 1st, 2nd and 5th.
158
+
159
+ Any non zero value is the http status code to respond with.
160
+
161
+ #### send_request_id
162
+
163
+ 'send_request_id' should be set to 'true' to enable a request identifier to be sent with every
164
+ request to this fake ccd server. This identifier is unique to a particular export from the main system,
165
+ so it will persist even across retries of the same export.
166
+
167
+ This is then used to assist in special rules where errors are forced on the 'nth' request for example.
101
168
 
102
169
 
103
170
  ## Development
data/et_fake_ccd.gemspec CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.add_dependency 'roda', '~> 3.21'
27
27
  spec.add_dependency 'thor', '~> 1.0'
28
28
  spec.add_dependency 'activemodel', '>= 5.2.3'
29
- spec.add_dependency 'rotp', '~> 5.1'
29
+ spec.add_dependency 'rotp', '~> 6.2'
30
30
  spec.add_dependency 'tilt', '~> 2.0', '>= 2.0.9'
31
31
  spec.add_dependency 'iodine', '~> 0.7'
32
32
  spec.add_dependency 'json-schema', '~> 2.5'
@@ -1,7 +1,7 @@
1
1
  require 'active_model'
2
2
  module EtFakeCcd
3
3
  module Command
4
- class CreateBulkActionCaseCommand
4
+ class CreateMultipleCaseCommand
5
5
  include ActiveModel::Model
6
6
  include ActiveModel::Attributes
7
7
 
@@ -1,7 +1,7 @@
1
1
  require 'et_fake_ccd/command/lease_command'
2
2
  require 'et_fake_ccd/command/login_user_command'
3
3
  require 'et_fake_ccd/command/create_case_command'
4
- require 'et_fake_ccd/command/create_bulk_action_case_command'
4
+ require 'et_fake_ccd/command/create_multiple_case_command'
5
5
  require 'et_fake_ccd/command/upload_document_command'
6
6
  require 'et_fake_ccd/command/upload_documents_to_case_command'
7
7
  require 'et_fake_ccd/command/start_multiple_command'
@@ -1,4 +1,5 @@
1
1
  require 'singleton'
2
+ require 'fileutils'
2
3
  module EtFakeCcd
3
4
  class Config
4
5
  include Singleton
@@ -0,0 +1,20 @@
1
+ require 'et_fake_ccd/request_store_service'
2
+ module EtFakeCcd
3
+ module ForcedErrorHandling
4
+ extend ActiveSupport::Concern
5
+
6
+ def with_forced_error_handling(r, stage:)
7
+ request_id = r.headers['request_id']
8
+ RequestStoreService.store "#{stage}-#{request_id}" unless request_id.nil?
9
+ count = request_id.nil? ? 1 : RequestStoreService.count("#{stage}-#{request_id}")
10
+ specs = JSON.parse(r.headers['force_failures'] || '{}')
11
+ spec = specs.fetch("#{stage}_stage", [])
12
+ response_code = spec[count - 1].to_i
13
+ if response_code.zero?
14
+ yield
15
+ else
16
+ r.halt response_code
17
+ end
18
+ end
19
+ end
20
+ end
@@ -9,12 +9,14 @@ module EtFakeCcd
9
9
  plugin :halt
10
10
  route do |r|
11
11
  r.is "lease" do
12
- r.post do
13
- command = ::EtFakeCcd::Command::LeaseCommand.from_json JSON.parse(r.body.read)
14
- if command.valid?
15
- ::EtFakeCcd::AuthService.generate_service_token
16
- else
17
- r.halt 403, render_error_for(command)
12
+ with_forced_error_handling(r, stage: :token) do
13
+ r.post do
14
+ command = ::EtFakeCcd::Command::LeaseCommand.from_json JSON.parse(r.body.read)
15
+ if command.valid?
16
+ ::EtFakeCcd::AuthService.generate_service_token
17
+ else
18
+ r.halt 403, render_error_for(command)
19
+ end
18
20
  end
19
21
  end
20
22
  end
@@ -11,15 +11,19 @@ module EtFakeCcd
11
11
  route do |r|
12
12
  r.is "login" do
13
13
  r.get do
14
- file = File.absolute_path(File.join('..', 'views', 'login.html.erb'), __dir__)
15
- render(path: file, locals: { oauth2_redirect_url: config.oauth2_redirect_url, oauth2_client_id: config.oauth2_client_id })
14
+ with_forced_error_handling(r, stage: :token) do
15
+ file = File.absolute_path(File.join('..', 'views', 'login.html.erb'), __dir__)
16
+ render(path: file, locals: { oauth2_redirect_url: config.oauth2_redirect_url, oauth2_client_id: config.oauth2_client_id })
17
+ end
16
18
  end
17
19
  r.post do
18
- command = ::EtFakeCcd::Command::LoginUserCommand.from_json(r.params)
19
- if command.valid?
20
- r.redirect "/case-management-web/oauth2redirect?code=pfSHb6v4dEDEfqqP"
21
- else
22
- r.halt 401, "Access Denied"
20
+ with_forced_error_handling(r, stage: :token) do
21
+ command = ::EtFakeCcd::Command::LoginUserCommand.from_json(r.params)
22
+ if command.valid?
23
+ r.redirect "/case-management-web/oauth2redirect?code=pfSHb6v4dEDEfqqP"
24
+ else
25
+ r.halt 401, "Access Denied"
26
+ end
23
27
  end
24
28
  end
25
29
  end
@@ -1,96 +1,109 @@
1
1
  require 'roda'
2
2
  require 'json'
3
3
  require 'et_fake_ccd/commands'
4
+ require 'et_fake_ccd/forced_error_handling'
4
5
  require 'et_fake_ccd/auth_service'
5
6
  require 'et_fake_ccd/data_store_service'
6
7
  require 'et_fake_ccd/request_store_service'
7
8
  module EtFakeCcd
8
9
  module Service
9
10
  class DataStoreApp < Roda
11
+ include ForcedErrorHandling
10
12
  plugin :request_headers
11
13
  plugin :halt
12
14
  route do |r|
13
15
  r.is "caseworkers", String, "jurisdictions", String, "case-types", String, "event-triggers", "initiateCase", "token" do |uid, jid, ctid|
14
16
  r.get do
15
- if EtFakeCcd::AuthService.validate_service_token(r.headers['ServiceAuthorization'].gsub(/\ABearer /, '')) && EtFakeCcd::AuthService.validate_user_token(r.headers['Authorization'].gsub(/\ABearer /, ''))
16
- initiate_case(uid, jid, ctid)
17
- else
18
- r.halt 403, forbidden_error_for(r)
17
+ with_forced_error_handling(r, stage: :token) do
18
+ if EtFakeCcd::AuthService.validate_service_token(r.headers['ServiceAuthorization'].gsub(/\ABearer /, '')) && EtFakeCcd::AuthService.validate_user_token(r.headers['Authorization'].gsub(/\ABearer /, ''))
19
+ initiate_case(uid, jid, ctid)
20
+ else
21
+ r.halt 403, forbidden_error_for(r)
22
+ end
19
23
  end
20
24
  end
21
25
  end
22
- r.is "caseworkers", String, "jurisdictions", String, "case-types", String, "event-triggers", "createBulkAction", "token" do |uid, jid, ctid|
26
+ r.is "caseworkers", String, "jurisdictions", String, "case-types", String, "event-triggers", "createMultiple", "token" do |uid, jid, ctid|
23
27
  r.get do
24
- if EtFakeCcd::AuthService.validate_service_token(r.headers['ServiceAuthorization'].gsub(/\ABearer /, '')) && EtFakeCcd::AuthService.validate_user_token(r.headers['Authorization'].gsub(/\ABearer /, ''))
25
- initiate_bulk_case(uid, jid, ctid)
26
- else
27
- r.halt 403, forbidden_error_for(r)
28
+ with_forced_error_handling(r, stage: :token) do
29
+ if EtFakeCcd::AuthService.validate_service_token(r.headers['ServiceAuthorization'].gsub(/\ABearer /, '')) && EtFakeCcd::AuthService.validate_user_token(r.headers['Authorization'].gsub(/\ABearer /, ''))
30
+ initiate_bulk_case(uid, jid, ctid)
31
+ else
32
+ r.halt 403, forbidden_error_for(r)
33
+ end
28
34
  end
29
35
  end
30
36
  end
31
37
  r.is "caseworkers", String, "jurisdictions", String, "case-types", String, "cases", String, "event-triggers", "uploadDocument", "token" do |uid, jid, ctid, cid|
32
38
  r.get do
33
- if EtFakeCcd::AuthService.validate_service_token(r.headers['ServiceAuthorization'].gsub(/\ABearer /, '')) && EtFakeCcd::AuthService.validate_user_token(r.headers['Authorization'].gsub(/\ABearer /, ''))
34
- initiate_upload_document(uid, jid, ctid, cid)
35
- else
36
- r.halt 403, forbidden_error_for(r)
39
+ with_forced_error_handling(r, stage: :documents) do
40
+ if EtFakeCcd::AuthService.validate_service_token(r.headers['ServiceAuthorization'].gsub(/\ABearer /, '')) && EtFakeCcd::AuthService.validate_user_token(r.headers['Authorization'].gsub(/\ABearer /, ''))
41
+ initiate_upload_document(uid, jid, ctid, cid)
42
+ else
43
+ r.halt 403, forbidden_error_for(r)
44
+ end
37
45
  end
38
46
  end
39
47
  end
40
48
  r.is "caseworkers", String, "jurisdictions", String, "case-types", String, "cases", String, "events" do |uid, jid, ctid, cid|
41
49
  r.post do
42
- if !EtFakeCcd::AuthService.validate_service_token(r.headers['ServiceAuthorization'].gsub(/\ABearer /, '')) || !EtFakeCcd::AuthService.validate_user_token(r.headers['Authorization'].gsub(/\ABearer /, ''))
43
- r.halt 403, forbidden_error_for(r)
44
- break
50
+ with_forced_error_handling(r, stage: :documents) do
51
+ if !EtFakeCcd::AuthService.validate_service_token(r.headers['ServiceAuthorization'].gsub(/\ABearer /, '')) || !EtFakeCcd::AuthService.validate_user_token(r.headers['Authorization'].gsub(/\ABearer /, ''))
52
+ r.halt 403, forbidden_error_for(r)
53
+ break
54
+ end
55
+ json = JSON.parse(r.body.read)
56
+ command = case json.dig('event', 'id')
57
+ when 'uploadDocument' then ::EtFakeCcd::Command::UploadDocumentsToCaseCommand.from_json json
58
+ else
59
+ r.halt 400, unknown_event_error_for(r)
60
+ end
61
+ if command.valid?
62
+ ::EtFakeCcd::DataStoreService.update_case_data(json, jid: jid, ctid: ctid, cid: cid)
63
+ case_updated_response(cid, uid, jid, ctid)
64
+ else
65
+ r.halt 422, render_error_for(command, r)
66
+ end
45
67
  end
46
- json = JSON.parse(r.body.read)
47
- command = case json.dig('event', 'id')
48
- when 'uploadDocument' then ::EtFakeCcd::Command::UploadDocumentsToCaseCommand.from_json json
49
- else
50
- r.halt 400, unknown_event_error_for(r)
51
- end
52
- if command.valid?
53
- ::EtFakeCcd::DataStoreService.update_case_data(json, jid: jid, ctid: ctid, cid: cid)
54
- case_updated_response(cid, uid, jid, ctid)
55
- else
56
- r.halt 422, render_error_for(command, r)
57
- end
58
-
59
68
  end
60
69
  end
61
70
  r.is "caseworkers", String, "jurisdictions", String, "case-types", String, "cases" do |uid, jid, ctid|
62
71
  r.post do
63
- if !EtFakeCcd::AuthService.validate_service_token(r.headers['ServiceAuthorization'].gsub(/\ABearer /, '')) || !EtFakeCcd::AuthService.validate_user_token(r.headers['Authorization'].gsub(/\ABearer /, ''))
64
- r.halt 403, forbidden_error_for(r)
65
- break
66
- end
67
- json = JSON.parse(r.body.read)
68
- next if force_deliberate_error(json, r)
72
+ with_forced_error_handling(r, stage: :data) do
73
+ if !EtFakeCcd::AuthService.validate_service_token(r.headers['ServiceAuthorization'].gsub(/\ABearer /, '')) || !EtFakeCcd::AuthService.validate_user_token(r.headers['Authorization'].gsub(/\ABearer /, ''))
74
+ r.halt 403, forbidden_error_for(r)
75
+ break
76
+ end
77
+ json = JSON.parse(r.body.read)
78
+ next if force_deliberate_error(json, r)
69
79
 
70
- command = case json.dig('event', 'id')
71
- when 'initiateCase' then ::EtFakeCcd::Command::CreateCaseCommand.from_json json
72
- when 'createBulkAction' then ::EtFakeCcd::Command::CreateBulkActionCaseCommand.from_json json
73
- else
74
- r.halt 400, unknown_event_error_for(r)
75
- end
76
- if command.valid?
77
- id = ::EtFakeCcd::DataStoreService.store_case_data(command.data, jid: jid, ctid: ctid)
78
- case_created_response(id, uid, jid, ctid)
79
- else
80
- r.halt 422, render_error_for(command, r)
80
+ command = case json.dig('event', 'id')
81
+ when 'initiateCase' then ::EtFakeCcd::Command::CreateCaseCommand.from_json json
82
+ when 'createMultiple' then ::EtFakeCcd::Command::CreateMultipleCaseCommand.from_json json
83
+ else
84
+ r.halt 400, unknown_event_error_for(r)
85
+ end
86
+ if command.valid?
87
+ id = ::EtFakeCcd::DataStoreService.store_case_data(command.data, jid: jid, ctid: ctid)
88
+ case_created_response(id, uid, jid, ctid)
89
+ else
90
+ r.halt 422, render_error_for(command, r)
91
+ end
81
92
  end
82
93
  end
83
94
 
84
95
  r.get do
85
- if !EtFakeCcd::AuthService.validate_service_token(r.headers['ServiceAuthorization'].gsub(/\ABearer /, '')) || !EtFakeCcd::AuthService.validate_user_token(r.headers['Authorization'].gsub(/\ABearer /, ''))
86
- r.halt 403, forbidden_error_for(r)
87
- break
96
+ with_forced_error_handling(r, stage: :data) do
97
+ if !EtFakeCcd::AuthService.validate_service_token(r.headers['ServiceAuthorization'].gsub(/\ABearer /, '')) || !EtFakeCcd::AuthService.validate_user_token(r.headers['Authorization'].gsub(/\ABearer /, ''))
98
+ r.halt 403, forbidden_error_for(r)
99
+ break
100
+ end
101
+ filters = r.params.dup
102
+ page = (filters.delete('page') || "1").to_i
103
+ sort_direction = filters.delete('sortDirection') || 'asc'
104
+ list = DataStoreService.list(jid: jid, ctid: ctid, filters: filters, page: page, sort_direction: sort_direction, page_size: 25)
105
+ cases_response(list, uid, jid, ctid)
88
106
  end
89
- filters = r.params.dup
90
- page = (filters.delete('page') || "1").to_i
91
- sort_direction = filters.delete('sortDirection') || 'asc'
92
- list = DataStoreService.list(jid: jid, ctid: ctid, filters: filters, page: page, sort_direction: sort_direction, page_size: 25)
93
- cases_response(list, uid, jid, ctid)
94
107
  end
95
108
  end
96
109
  end
@@ -202,7 +215,7 @@ module EtFakeCcd
202
215
  "delete_draft_response_status": nil,
203
216
  "security_classifications": {}
204
217
  },
205
- "event_id": "createBulkAction"
218
+ "event_id": "createMultiple"
206
219
  }
207
220
  JSON.generate(j)
208
221
  end
@@ -13,27 +13,31 @@ module EtFakeCcd
13
13
  route do |r|
14
14
  r.is "documents" do
15
15
  r.post do
16
- unless EtFakeCcd::AuthService.validate_service_token(r.headers['ServiceAuthorization'].gsub(/\ABearer /, '')) && EtFakeCcd::AuthService.validate_user_token(r.headers['Authorization'].gsub(/\ABearer /, ''))
17
- r.halt 403, forbidden_error_for(r)
18
- break
19
- end
20
- command = ::EtFakeCcd::Command::UploadDocumentCommand.from_json(r.params.deep_stringify_keys)
21
- unless command.valid?
22
- r.halt 422, render_error_for(command, r)
23
- break
24
- end
16
+ with_forced_error_handling(r, stage: :documents) do
17
+ unless EtFakeCcd::AuthService.validate_service_token(r.headers['ServiceAuthorization'].gsub(/\ABearer /, '')) && EtFakeCcd::AuthService.validate_user_token(r.headers['Authorization'].gsub(/\ABearer /, ''))
18
+ r.halt 403, forbidden_error_for(r)
19
+ break
20
+ end
21
+ command = ::EtFakeCcd::Command::UploadDocumentCommand.from_json(r.params.deep_stringify_keys)
22
+ unless command.valid?
23
+ r.halt 422, render_error_for(command, r)
24
+ break
25
+ end
25
26
 
26
- upload_document(r)
27
+ upload_document(r)
28
+ end
27
29
  end
28
30
  end
29
31
  r.is "documents", String, "binary" do |uuid|
30
- r.get do
31
- file = ::EtFakeCcd::DocumentStoreService.find_file_by_id(uuid)
32
- unless file
33
- r.halt 404, not_found_error_for(r)
34
- break
32
+ with_forced_error_handling(r, stage: :documents) do
33
+ r.get do
34
+ file = ::EtFakeCcd::DocumentStoreService.find_file_by_id(uuid)
35
+ unless file
36
+ r.halt 404, not_found_error_for(r)
37
+ break
38
+ end
39
+ send_file file.path
35
40
  end
36
- send_file file.path
37
41
  end
38
42
  end
39
43
  end
@@ -11,17 +11,19 @@ module EtFakeCcd
11
11
  route do |r|
12
12
  r.is "generateCaseRefNumbers" do
13
13
  r.post do
14
- unless EtFakeCcd::AuthService.validate_service_token(r.headers['ServiceAuthorization'].gsub(/\ABearer /, '')) && EtFakeCcd::AuthService.validate_user_token(r.headers['Authorization'].gsub(/\ABearer /, ''))
15
- r.halt 403, forbidden_error_for(r)
16
- break
17
- end
18
- json = JSON.parse(r.body.read)
19
- command = ::EtFakeCcd::Command::StartMultipleCommand.from_json json
20
- if command.valid?
21
- response = ::EtFakeCcd::EcmService.start_multiple(command)
22
- start_multiple_response(response)
23
- else
24
- r.halt 422, render_error_for(command, r)
14
+ with_forced_error_handling(r, stage: :data) do
15
+ unless EtFakeCcd::AuthService.validate_service_token(r.headers['ServiceAuthorization'].gsub(/\ABearer /, '')) && EtFakeCcd::AuthService.validate_user_token(r.headers['Authorization'].gsub(/\ABearer /, ''))
16
+ r.halt 403, forbidden_error_for(r)
17
+ break
18
+ end
19
+ json = JSON.parse(r.body.read)
20
+ command = ::EtFakeCcd::Command::StartMultipleCommand.from_json json
21
+ if command.valid?
22
+ response = ::EtFakeCcd::EcmService.start_multiple(command)
23
+ start_multiple_response(response)
24
+ else
25
+ r.halt 422, render_error_for(command, r)
26
+ end
25
27
  end
26
28
  end
27
29
  end
@@ -10,17 +10,21 @@ module EtFakeCcd
10
10
  route do |r|
11
11
  r.is "loginUser" do
12
12
  r.post do
13
- command = ::EtFakeCcd::Command::LoginUserCommand.from_json(r.params)
14
- if command.valid?
15
- logged_in_result
16
- else
17
- r.halt 401, render_error_for(command)
13
+ with_forced_error_handling(r, stage: :token) do
14
+ command = ::EtFakeCcd::Command::LoginUserCommand.from_json(r.params)
15
+ if command.valid?
16
+ logged_in_result
17
+ else
18
+ r.halt 401, render_error_for(command)
19
+ end
18
20
  end
19
21
  end
20
22
  end
21
23
  r.is "details" do
22
24
  r.get do
23
- details_result
25
+ with_forced_error_handling(r, stage: :token) do
26
+ details_result
27
+ end
24
28
  end
25
29
  end
26
30
  end
@@ -1,3 +1,3 @@
1
1
  module EtFakeCcd
2
- VERSION = "1.0.8"
2
+ VERSION = "1.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: et_fake_ccd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gary Taylor
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-30 00:00:00.000000000 Z
11
+ date: 2021-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: roda
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '5.1'
61
+ version: '6.2'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '5.1'
68
+ version: '6.2'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: tilt
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -180,8 +180,8 @@ files:
180
180
  - lib/et_fake_ccd/auth_service.rb
181
181
  - lib/et_fake_ccd/cli.rb
182
182
  - lib/et_fake_ccd/cli/root.rb
183
- - lib/et_fake_ccd/command/create_bulk_action_case_command.rb
184
183
  - lib/et_fake_ccd/command/create_case_command.rb
184
+ - lib/et_fake_ccd/command/create_multiple_case_command.rb
185
185
  - lib/et_fake_ccd/command/lease_command.rb
186
186
  - lib/et_fake_ccd/command/login_user_command.rb
187
187
  - lib/et_fake_ccd/command/start_multiple_command.rb
@@ -192,6 +192,7 @@ files:
192
192
  - lib/et_fake_ccd/data_store_service.rb
193
193
  - lib/et_fake_ccd/document_store_service.rb
194
194
  - lib/et_fake_ccd/ecm_service.rb
195
+ - lib/et_fake_ccd/forced_error_handling.rb
195
196
  - lib/et_fake_ccd/iodine.rb
196
197
  - lib/et_fake_ccd/request_store_service.rb
197
198
  - lib/et_fake_ccd/root_app.rb
@@ -225,8 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
225
226
  - !ruby/object:Gem::Version
226
227
  version: '0'
227
228
  requirements: []
228
- rubyforge_project:
229
- rubygems_version: 2.7.7
229
+ rubygems_version: 3.1.4
230
230
  signing_key:
231
231
  specification_version: 4
232
232
  summary: Fake CCD server for employment tribunals