et_fake_ccd 1.1.3 → 1.1.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/Gemfile.lock +10 -10
- data/README.md +67 -0
- data/lib/et_fake_ccd/forced_error_handling.rb +20 -0
- data/lib/et_fake_ccd/service/auth_app.rb +8 -6
- data/lib/et_fake_ccd/service/authentication_web_app.rb +11 -7
- data/lib/et_fake_ccd/service/data_store_app.rb +66 -53
- data/lib/et_fake_ccd/service/document_store_app.rb +20 -16
- data/lib/et_fake_ccd/service/ecm_app.rb +13 -11
- data/lib/et_fake_ccd/service/sidam_app.rb +10 -6
- data/lib/et_fake_ccd/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e5968450f9fb5c522a5ef2843d74bd516795565a7e0ea2db74b99f535b3b218b
|
|
4
|
+
data.tar.gz: 7ef2bf4693eda7b6c427a5ddb4597de610c0d5b30eda626af7e94e735e50b242
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ec1cd2619dab545b1c59a681c4396da960296eaf31c1a56b5c4c8b085f0c87d9151e75bd181a2a1a5df90697f7b54c8a5696ec944b106133a352e04baefcf574
|
|
7
|
+
data.tar.gz: 23102b8a755b256725c001afd3ea9b7fc87afe645dec8e6dc61278c89cf44ab239a912118153e8da46fa094627f8edd417c7c4063e2d15eba131c63369b53501
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
et_fake_ccd (1.1.
|
|
4
|
+
et_fake_ccd (1.1.4)
|
|
5
5
|
activemodel (>= 5.2.3)
|
|
6
6
|
iodine (~> 0.7)
|
|
7
7
|
json-schema (~> 2.5)
|
|
@@ -13,9 +13,9 @@ PATH
|
|
|
13
13
|
GEM
|
|
14
14
|
remote: https://rubygems.org/
|
|
15
15
|
specs:
|
|
16
|
-
activemodel (6.1.1)
|
|
17
|
-
activesupport (= 6.1.1)
|
|
18
|
-
activesupport (6.1.1)
|
|
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
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.43.1)
|
|
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
|
|
@@ -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
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
15
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
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
|
|
42
|
-
|
|
43
|
-
r.
|
|
44
|
-
|
|
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
|
-
|
|
64
|
-
r.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
86
|
-
r.
|
|
87
|
-
|
|
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
|
|
@@ -13,27 +13,31 @@ module EtFakeCcd
|
|
|
13
13
|
route do |r|
|
|
14
14
|
r.is "documents" do
|
|
15
15
|
r.post do
|
|
16
|
-
|
|
17
|
-
r.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
27
|
+
upload_document(r)
|
|
28
|
+
end
|
|
27
29
|
end
|
|
28
30
|
end
|
|
29
31
|
r.is "documents", String, "binary" do |uuid|
|
|
30
|
-
r
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
15
|
-
r.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
25
|
+
with_forced_error_handling(r, stage: :token) do
|
|
26
|
+
details_result
|
|
27
|
+
end
|
|
24
28
|
end
|
|
25
29
|
end
|
|
26
30
|
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.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: 2021-
|
|
11
|
+
date: 2021-04-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: roda
|
|
@@ -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
|