et_fake_ccd 1.1.2 → 1.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +11 -11
- data/README.md +67 -0
- data/et_fake_ccd.gemspec +1 -1
- data/lib/et_fake_ccd/ecm_service.rb +11 -1
- data/lib/et_fake_ccd/forced_error_handling.rb +20 -0
- data/lib/et_fake_ccd/service/auth_app.rb +10 -6
- data/lib/et_fake_ccd/service/authentication_web_app.rb +13 -7
- data/lib/et_fake_ccd/service/data_store_app.rb +78 -50
- data/lib/et_fake_ccd/service/document_store_app.rb +22 -16
- data/lib/et_fake_ccd/service/ecm_app.rb +20 -11
- data/lib/et_fake_ccd/service/sidam_app.rb +12 -6
- data/lib/et_fake_ccd/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd57fcc3c5d480bd2f9d03f845f3725e9c66ecfb474cd45f35a3f71f17c127a4
|
4
|
+
data.tar.gz: 12d45f1ce7902d3e00aa9a72fa679399616cd6ccaf49d14ade8f304ee9a7668e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e85fc5b46ad461ad35ff32931558e05cd9ff952646f82183fd115ba6649e665e84b70e6508fad1651f76a3d35b8dd7bec0c27db03936a7d3f15e3b9effc0cea9
|
7
|
+
data.tar.gz: ac163e07dbf8738d7fe1b1fe634a242f7313547a447e07a25b90c272fdae5ae64d5dc390cebc98c642933774225eab474ccd1205387a54eb6228973452aec60c
|
data/Gemfile.lock
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
et_fake_ccd (1.1.
|
4
|
+
et_fake_ccd (1.1.8)
|
5
5
|
activemodel (>= 5.2.3)
|
6
6
|
iodine (~> 0.7)
|
7
7
|
json-schema (~> 2.5)
|
8
8
|
roda (~> 3.21)
|
9
|
-
rotp (~> 6.
|
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.1.
|
17
|
-
activesupport (= 6.1.
|
18
|
-
activesupport (6.1.
|
16
|
+
activemodel (6.1.3.2)
|
17
|
+
activesupport (= 6.1.3.2)
|
18
|
+
activesupport (6.1.3.2)
|
19
19
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
20
20
|
i18n (>= 1.6, < 2)
|
21
21
|
minitest (>= 5.1)
|
@@ -23,18 +23,18 @@ GEM
|
|
23
23
|
zeitwerk (~> 2.3)
|
24
24
|
addressable (2.7.0)
|
25
25
|
public_suffix (>= 2.0.2, < 5.0)
|
26
|
-
concurrent-ruby (1.1.
|
26
|
+
concurrent-ruby (1.1.8)
|
27
27
|
diff-lcs (1.3)
|
28
|
-
i18n (1.8.
|
28
|
+
i18n (1.8.10)
|
29
29
|
concurrent-ruby (~> 1.0)
|
30
|
-
iodine (0.7.
|
30
|
+
iodine (0.7.44)
|
31
31
|
json-schema (2.8.1)
|
32
32
|
addressable (>= 2.4)
|
33
|
-
minitest (5.14.
|
33
|
+
minitest (5.14.4)
|
34
34
|
public_suffix (4.0.6)
|
35
35
|
rack (2.2.3)
|
36
36
|
rake (13.0.1)
|
37
|
-
roda (3.
|
37
|
+
roda (3.44.0)
|
38
38
|
rack
|
39
39
|
rotp (6.2.0)
|
40
40
|
rspec (3.9.0)
|
@@ -50,7 +50,7 @@ GEM
|
|
50
50
|
diff-lcs (>= 1.2.0, < 2.0)
|
51
51
|
rspec-support (~> 3.9.0)
|
52
52
|
rspec-support (3.9.2)
|
53
|
-
thor (1.0
|
53
|
+
thor (1.1.0)
|
54
54
|
tilt (2.0.10)
|
55
55
|
tzinfo (2.0.4)
|
56
56
|
concurrent-ruby (~> 1.0)
|
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', '~> 6.
|
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'
|
@@ -3,7 +3,17 @@ module EtFakeCcd
|
|
3
3
|
class EcmService
|
4
4
|
OFFICE_CODE_LOOKUP = {
|
5
5
|
'Manchester' => '24',
|
6
|
-
'Glasgow' => '41'
|
6
|
+
'Glasgow' => '41',
|
7
|
+
'Test1' => '60',
|
8
|
+
'Test2' => '61',
|
9
|
+
'Test3' => '62',
|
10
|
+
'Test4' => '63',
|
11
|
+
'Test5' => '64',
|
12
|
+
'Test6' => '65',
|
13
|
+
'Test7' => '66',
|
14
|
+
'Test8' => '67',
|
15
|
+
'Test9' => '68',
|
16
|
+
'Test10' => '69'
|
7
17
|
}
|
8
18
|
Response = Struct.new(:case_reference_count, :start_reference, :multiple_reference)
|
9
19
|
# @param [EtFakeCcd::Command::StartMultipleCommand] command
|
@@ -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
|
@@ -2,19 +2,23 @@ require 'roda'
|
|
2
2
|
require 'json'
|
3
3
|
require 'et_fake_ccd/commands'
|
4
4
|
require 'et_fake_ccd/auth_service'
|
5
|
+
require 'et_fake_ccd/forced_error_handling'
|
5
6
|
module EtFakeCcd
|
6
7
|
module Service
|
7
8
|
class AuthApp < Roda
|
9
|
+
include EtFakeCcd::ForcedErrorHandling
|
8
10
|
plugin :request_headers
|
9
11
|
plugin :halt
|
10
12
|
route do |r|
|
11
13
|
r.is "lease" do
|
12
|
-
r
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
with_forced_error_handling(r, stage: :token) do
|
15
|
+
r.post do
|
16
|
+
command = ::EtFakeCcd::Command::LeaseCommand.from_json JSON.parse(r.body.read)
|
17
|
+
if command.valid?
|
18
|
+
::EtFakeCcd::AuthService.generate_service_token
|
19
|
+
else
|
20
|
+
r.halt 403, render_error_for(command)
|
21
|
+
end
|
18
22
|
end
|
19
23
|
end
|
20
24
|
end
|
@@ -2,24 +2,30 @@ require 'roda'
|
|
2
2
|
require 'json'
|
3
3
|
require 'et_fake_ccd/commands'
|
4
4
|
require 'et_fake_ccd/auth_service'
|
5
|
+
require 'et_fake_ccd/forced_error_handling'
|
5
6
|
module EtFakeCcd
|
6
7
|
module Service
|
7
8
|
class AuthenticationWebApp < Roda
|
9
|
+
include EtFakeCcd::ForcedErrorHandling
|
8
10
|
plugin :request_headers
|
9
11
|
plugin :halt
|
10
12
|
plugin :render
|
11
13
|
route do |r|
|
12
14
|
r.is "login" do
|
13
15
|
r.get do
|
14
|
-
|
15
|
-
|
16
|
+
with_forced_error_handling(r, stage: :token) do
|
17
|
+
file = File.absolute_path(File.join('..', 'views', 'login.html.erb'), __dir__)
|
18
|
+
render(path: file, locals: { oauth2_redirect_url: config.oauth2_redirect_url, oauth2_client_id: config.oauth2_client_id })
|
19
|
+
end
|
16
20
|
end
|
17
21
|
r.post do
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
22
|
+
with_forced_error_handling(r, stage: :token) do
|
23
|
+
command = ::EtFakeCcd::Command::LoginUserCommand.from_json(r.params)
|
24
|
+
if command.valid?
|
25
|
+
r.redirect "/case-management-web/oauth2redirect?code=pfSHb6v4dEDEfqqP"
|
26
|
+
else
|
27
|
+
r.halt 401, "Access Denied"
|
28
|
+
end
|
23
29
|
end
|
24
30
|
end
|
25
31
|
end
|
@@ -1,96 +1,119 @@
|
|
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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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
26
|
r.is "caseworkers", String, "jurisdictions", String, "case-types", String, "event-triggers", "createMultiple", "token" do |uid, jid, ctid|
|
23
27
|
r.get do
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
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
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
r.is "caseworkers", String, "jurisdictions", String, "case-types", String, "cases", String do |uid, jid, ctid, case_id|
|
71
|
+
with_forced_error_handling(r, stage: :data) do
|
42
72
|
if !EtFakeCcd::AuthService.validate_service_token(r.headers['ServiceAuthorization'].gsub(/\ABearer /, '')) || !EtFakeCcd::AuthService.validate_user_token(r.headers['Authorization'].gsub(/\ABearer /, ''))
|
43
73
|
r.halt 403, forbidden_error_for(r)
|
44
74
|
break
|
45
75
|
end
|
46
|
-
|
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
|
-
|
76
|
+
case_response(case_id, uid, jid, ctid)
|
59
77
|
end
|
78
|
+
|
60
79
|
end
|
61
80
|
r.is "caseworkers", String, "jurisdictions", String, "case-types", String, "cases" do |uid, jid, ctid|
|
62
81
|
r.post do
|
63
|
-
|
64
|
-
r.
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
82
|
+
with_forced_error_handling(r, stage: :data) do
|
83
|
+
if !EtFakeCcd::AuthService.validate_service_token(r.headers['ServiceAuthorization'].gsub(/\ABearer /, '')) || !EtFakeCcd::AuthService.validate_user_token(r.headers['Authorization'].gsub(/\ABearer /, ''))
|
84
|
+
r.halt 403, forbidden_error_for(r)
|
85
|
+
break
|
86
|
+
end
|
87
|
+
json = JSON.parse(r.body.read)
|
88
|
+
next if force_deliberate_error(json, r)
|
69
89
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
90
|
+
command = case json.dig('event', 'id')
|
91
|
+
when 'initiateCase' then ::EtFakeCcd::Command::CreateCaseCommand.from_json json
|
92
|
+
when 'createMultiple' then ::EtFakeCcd::Command::CreateMultipleCaseCommand.from_json json
|
93
|
+
else
|
94
|
+
r.halt 400, unknown_event_error_for(r)
|
95
|
+
end
|
96
|
+
if command.valid?
|
97
|
+
id = ::EtFakeCcd::DataStoreService.store_case_data(command.data, jid: jid, ctid: ctid)
|
98
|
+
case_created_response(id, uid, jid, ctid)
|
99
|
+
else
|
100
|
+
r.halt 422, render_error_for(command, r)
|
101
|
+
end
|
81
102
|
end
|
82
103
|
end
|
83
104
|
|
84
105
|
r.get do
|
85
|
-
|
86
|
-
r.
|
87
|
-
|
106
|
+
with_forced_error_handling(r, stage: :data) do
|
107
|
+
if !EtFakeCcd::AuthService.validate_service_token(r.headers['ServiceAuthorization'].gsub(/\ABearer /, '')) || !EtFakeCcd::AuthService.validate_user_token(r.headers['Authorization'].gsub(/\ABearer /, ''))
|
108
|
+
r.halt 403, forbidden_error_for(r)
|
109
|
+
break
|
110
|
+
end
|
111
|
+
filters = r.params.dup
|
112
|
+
page = (filters.delete('page') || "1").to_i
|
113
|
+
sort_direction = filters.delete('sortDirection') || 'asc'
|
114
|
+
list = DataStoreService.list(jid: jid, ctid: ctid, filters: filters, page: page, sort_direction: sort_direction, page_size: 25)
|
115
|
+
cases_response(list, uid, jid, ctid)
|
88
116
|
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
117
|
end
|
95
118
|
end
|
96
119
|
end
|
@@ -242,6 +265,11 @@ module EtFakeCcd
|
|
242
265
|
JSON.generate(j)
|
243
266
|
end
|
244
267
|
|
268
|
+
def case_response(id, uid, jid, ctid)
|
269
|
+
j = case_hash(ctid, id, jid)
|
270
|
+
JSON.generate(j)
|
271
|
+
end
|
272
|
+
|
245
273
|
def case_hash(ctid, id, jid)
|
246
274
|
{
|
247
275
|
"id": id,
|
@@ -4,36 +4,42 @@ require 'et_fake_ccd/commands'
|
|
4
4
|
require 'et_fake_ccd/auth_service'
|
5
5
|
require 'et_fake_ccd/document_store_service'
|
6
6
|
require 'active_support/core_ext/hash'
|
7
|
+
require 'et_fake_ccd/forced_error_handling'
|
7
8
|
module EtFakeCcd
|
8
9
|
module Service
|
9
10
|
class DocumentStoreApp < Roda
|
11
|
+
include EtFakeCcd::ForcedErrorHandling
|
10
12
|
plugin :request_headers
|
11
13
|
plugin :halt
|
12
14
|
plugin :sinatra_helpers
|
13
15
|
route do |r|
|
14
16
|
r.is "documents" do
|
15
17
|
r.post do
|
16
|
-
|
17
|
-
r.
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
18
|
+
with_forced_error_handling(r, stage: :documents) do
|
19
|
+
unless EtFakeCcd::AuthService.validate_service_token(r.headers['ServiceAuthorization'].gsub(/\ABearer /, '')) && EtFakeCcd::AuthService.validate_user_token(r.headers['Authorization'].gsub(/\ABearer /, ''))
|
20
|
+
r.halt 403, forbidden_error_for(r)
|
21
|
+
break
|
22
|
+
end
|
23
|
+
command = ::EtFakeCcd::Command::UploadDocumentCommand.from_json(r.params.deep_stringify_keys)
|
24
|
+
unless command.valid?
|
25
|
+
r.halt 422, render_error_for(command, r)
|
26
|
+
break
|
27
|
+
end
|
25
28
|
|
26
|
-
|
29
|
+
upload_document(r)
|
30
|
+
end
|
27
31
|
end
|
28
32
|
end
|
29
33
|
r.is "documents", String, "binary" do |uuid|
|
30
|
-
r
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
34
|
+
with_forced_error_handling(r, stage: :documents) do
|
35
|
+
r.get do
|
36
|
+
file = ::EtFakeCcd::DocumentStoreService.find_file_by_id(uuid)
|
37
|
+
unless file
|
38
|
+
r.halt 404, not_found_error_for(r)
|
39
|
+
break
|
40
|
+
end
|
41
|
+
send_file file.path
|
35
42
|
end
|
36
|
-
send_file file.path
|
37
43
|
end
|
38
44
|
end
|
39
45
|
end
|
@@ -3,25 +3,29 @@ require 'json'
|
|
3
3
|
require 'et_fake_ccd/commands'
|
4
4
|
require 'et_fake_ccd/auth_service'
|
5
5
|
require 'et_fake_ccd/ecm_service'
|
6
|
+
require 'et_fake_ccd/forced_error_handling'
|
6
7
|
module EtFakeCcd
|
7
8
|
module Service
|
8
9
|
class EcmApp < Roda
|
10
|
+
include EtFakeCcd::ForcedErrorHandling
|
9
11
|
plugin :request_headers
|
10
12
|
plugin :halt
|
11
13
|
route do |r|
|
12
14
|
r.is "generateCaseRefNumbers" do
|
13
15
|
r.post do
|
14
|
-
|
15
|
-
r.
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
16
|
+
with_forced_error_handling(r, stage: :data) 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
|
+
json = JSON.parse(r.body.read)
|
22
|
+
command = ::EtFakeCcd::Command::StartMultipleCommand.from_json json
|
23
|
+
if command.valid?
|
24
|
+
response = ::EtFakeCcd::EcmService.start_multiple(command)
|
25
|
+
start_multiple_response(response)
|
26
|
+
else
|
27
|
+
r.halt 422, render_error_for(command, r)
|
28
|
+
end
|
25
29
|
end
|
26
30
|
end
|
27
31
|
end
|
@@ -61,6 +65,11 @@ module EtFakeCcd
|
|
61
65
|
|
62
66
|
JSON.generate(j)
|
63
67
|
end
|
68
|
+
|
69
|
+
def forbidden_error_for(r)
|
70
|
+
j = {"timestamp":"2019-07-01T07:46:35.405+0000","status":403,"error":"Forbidden","message":"Access Denied","path": r.path}
|
71
|
+
JSON.generate(j)
|
72
|
+
end
|
64
73
|
end
|
65
74
|
end
|
66
75
|
end
|
@@ -2,25 +2,31 @@ require 'roda'
|
|
2
2
|
require 'json'
|
3
3
|
require 'et_fake_ccd/commands'
|
4
4
|
require 'et_fake_ccd/auth_service'
|
5
|
+
require 'et_fake_ccd/forced_error_handling'
|
5
6
|
module EtFakeCcd
|
6
7
|
module Service
|
7
8
|
class SidamApp < Roda
|
9
|
+
include EtFakeCcd::ForcedErrorHandling
|
8
10
|
plugin :request_headers
|
9
11
|
plugin :halt
|
10
12
|
route do |r|
|
11
13
|
r.is "loginUser" do
|
12
14
|
r.post do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
with_forced_error_handling(r, stage: :token) do
|
16
|
+
command = ::EtFakeCcd::Command::LoginUserCommand.from_json(r.params)
|
17
|
+
if command.valid?
|
18
|
+
logged_in_result
|
19
|
+
else
|
20
|
+
r.halt 401, render_error_for(command)
|
21
|
+
end
|
18
22
|
end
|
19
23
|
end
|
20
24
|
end
|
21
25
|
r.is "details" do
|
22
26
|
r.get do
|
23
|
-
|
27
|
+
with_forced_error_handling(r, stage: :token) do
|
28
|
+
details_result
|
29
|
+
end
|
24
30
|
end
|
25
31
|
end
|
26
32
|
end
|
data/lib/et_fake_ccd/version.rb
CHANGED
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.1.
|
4
|
+
version: 1.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gary Taylor
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-13 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: '6.
|
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: '6.
|
68
|
+
version: '6.2'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: tilt
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -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
|
-
|
229
|
-
rubygems_version: 2.7.6
|
229
|
+
rubygems_version: 3.1.4
|
230
230
|
signing_key:
|
231
231
|
specification_version: 4
|
232
232
|
summary: Fake CCD server for employment tribunals
|