et_fake_ccd 2.0.0 → 2.1.0

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: 19f862b4da32f61058ec54d35d4b4bead505b74c2bc972d030173950f943bb59
4
- data.tar.gz: 855d443e9fcf3599cae2417a022e5d86afadc4ffa4d5db7b5b2958b4af8b35e7
3
+ metadata.gz: d16faad33fb9a19045a8fe5f0cc0103da22427fd4dd2d83c34f7d524e0f7358d
4
+ data.tar.gz: 9eb55aeef02871275783a05faa0bdf4eede33c74647611e5e26dfee3688a94b8
5
5
  SHA512:
6
- metadata.gz: 526f26ddb766d413fecbd9c43c010d7c644ce45fb16c0e85476b790a1654e397605108659ff62032dbfa69dea19824f0a4dd07d2b2a40243c05b7b603ba2fca8
7
- data.tar.gz: 616440588e17a0928e606fd7c6139f02c84a54f5d519320d7f909681c3b3bc8f437069084b83546fb80f23af64a8aba41c1a04140e3c062fb6c73bb28442b5cb
6
+ metadata.gz: ddce934372a9565fc97fced8ff2471c57fd3d2a7ac7d3ab317148ded2a9abda425dc1c2740af6d280dfcc85e5e2f8070d9dde55a1c053daf11f96649b98dae9f
7
+ data.tar.gz: 126d52b773b5a4860e951c0887c83880705f8bd19069e71cfa61aaa94adfbf97f30369e8bfbaaf50da2396ba2eb5672e98a1dd1ad6067c25bedd54fd88eaac22
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- et_fake_ccd (2.0.0)
4
+ et_fake_ccd (2.1.0)
5
5
  activemodel (~> 7.0)
6
6
  iodine (~> 0.7)
7
7
  json-schema (~> 3.0)
@@ -14,29 +14,29 @@ PATH
14
14
  GEM
15
15
  remote: https://rubygems.org/
16
16
  specs:
17
- activemodel (7.0.4)
18
- activesupport (= 7.0.4)
19
- activesupport (7.0.4)
17
+ activemodel (7.0.4.3)
18
+ activesupport (= 7.0.4.3)
19
+ activesupport (7.0.4.3)
20
20
  concurrent-ruby (~> 1.0, >= 1.0.2)
21
21
  i18n (>= 1.6, < 2)
22
22
  minitest (>= 5.1)
23
23
  tzinfo (~> 2.0)
24
24
  addressable (2.8.1)
25
25
  public_suffix (>= 2.0.2, < 6.0)
26
- concurrent-ruby (1.1.10)
26
+ concurrent-ruby (1.2.2)
27
27
  diff-lcs (1.5.0)
28
28
  i18n (1.12.0)
29
29
  concurrent-ruby (~> 1.0)
30
- iodine (0.7.52)
30
+ iodine (0.7.54)
31
31
  json-schema (3.0.0)
32
32
  addressable (>= 2.8)
33
- minitest (5.16.3)
33
+ minitest (5.18.0)
34
34
  pastel (0.8.0)
35
35
  tty-color (~> 0.5)
36
36
  public_suffix (5.0.1)
37
- rack (3.0.2)
37
+ rack (3.0.7)
38
38
  rake (13.0.6)
39
- roda (3.63.0)
39
+ roda (3.66.0)
40
40
  rack
41
41
  roda-enhanced_logger (0.5.0)
42
42
  roda (>= 3.19.0)
@@ -56,11 +56,11 @@ GEM
56
56
  rspec-support (~> 3.12.0)
57
57
  rspec-support (3.12.0)
58
58
  thor (1.2.1)
59
- tilt (2.0.11)
59
+ tilt (2.1.0)
60
60
  tty-color (0.6.0)
61
61
  tty-logger (0.6.0)
62
62
  pastel (~> 0.8)
63
- tzinfo (2.0.5)
63
+ tzinfo (2.0.6)
64
64
  concurrent-ruby (~> 1.0)
65
65
 
66
66
  PLATFORMS
@@ -25,6 +25,29 @@ module EtFakeCcd
25
25
  list = DataStoreService.list(jid: jid, ctid: ctid, filters: filters, page: page, sort_direction: sort_direction, page_size: 25)
26
26
  cases_response(list, uid, jid, ctid)
27
27
  end
28
+
29
+ r.post do
30
+ json = JSON.parse(r.body.read)
31
+
32
+ command = case json.dig('event', 'id')
33
+ when 'initiateCase' then ::EtFakeCcd::Command::CreateCaseCommand.from_json json
34
+ when 'createMultiple' then ::EtFakeCcd::Command::CreateMultipleCaseCommand.from_json json
35
+ else
36
+ r.halt 400, unknown_event_error_for(r)
37
+ end
38
+ if command.valid?
39
+ id = ::EtFakeCcd::DataStoreService.store_case_data(command.data, jid: jid, ctid: ctid)
40
+ case_created_response(id, uid, jid, ctid)
41
+ else
42
+ r.halt 422, render_error_for(command, r)
43
+ end
44
+
45
+ end
46
+ end
47
+ r.is "caseworkers", String, "jurisdictions", String, "case-types", String, "event-triggers", "initiateCase", "token" do |uid, jid, ctid|
48
+ r.get do
49
+ initiate_case(uid, jid, ctid)
50
+ end
28
51
  end
29
52
  end
30
53
  r.on "data" do
@@ -109,6 +132,59 @@ module EtFakeCcd
109
132
  }
110
133
  JSON.generate j
111
134
  end
135
+
136
+ def initiate_case(uid, jid, ctid)
137
+ j = {
138
+ "token": "eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJvZDRwZ3NhbDQwcTdndHI0Y2F1bmVmZGU5aSIsInN1YiI6IjIyIiwiaWF0IjoxNTYxOTY2NzM1LCJldmVudC1pZCI6ImluaXRpYXRlQ2FzZSIsImNhc2UtdHlwZS1pZCI6IkVtcFRyaWJfTVZQXzEuMF9NYW5jIiwianVyaXNkaWN0aW9uLWlkIjoiRU1QTE9ZTUVOVCIsImNhc2UtdmVyc2lvbiI6ImJmMjFhOWU4ZmJjNWEzODQ2ZmIwNWI0ZmEwODU5ZTA5MTdiMjIwMmYifQ.u-OfexKFu52uvSgTNVHJ5kUQ9KTZGClRIRnGXRPSmGY",
139
+ "case_details": {
140
+ "id": nil,
141
+ "jurisdiction": jid,
142
+ "state": nil,
143
+ "case_type_id": ctid,
144
+ "created_date": nil,
145
+ "last_modified": nil,
146
+ "security_classification": nil,
147
+ "case_data": {},
148
+ "data_classification": {},
149
+ "after_submit_callback_response": nil,
150
+ "callback_response_status_code": nil,
151
+ "callback_response_status": nil,
152
+ "delete_draft_response_status_code": nil,
153
+ "delete_draft_response_status": nil,
154
+ "security_classifications": {}
155
+ },
156
+ "event_id": "initiateCase"
157
+ }
158
+ JSON.generate(j)
159
+ end
160
+
161
+ def case_created_response(id, uid, jid, ctid)
162
+ j = case_hash(ctid, id, jid)
163
+ JSON.generate(j)
164
+ end
165
+
166
+ def render_error_for(command, request)
167
+ j = {
168
+ "exception": "uk.gov.hmcts.ccd.endpoint.exceptions.CaseValidationException",
169
+ "timestamp": "2019-07-01T16:02:28.045",
170
+ "status": 422,
171
+ "error": "Unprocessable Entity",
172
+ "message": "Case data validation failed",
173
+ "path": request.path,
174
+ "details": {
175
+ "field_errors": command.errors.details[:data].map {|e| e[:field_error]}
176
+ },
177
+ "callbackErrors": nil,
178
+ "callbackWarnings": nil
179
+ }
180
+
181
+ JSON.generate(j)
182
+ end
183
+
184
+ def unknown_event_error_for(r)
185
+ j = {"timestamp":"2019-07-01T07:46:35.405+0000","status":400,"error":"Unknown event","message":"Unknown event","path": r.path}
186
+ JSON.generate(j)
187
+ end
112
188
  end
113
189
  end
114
190
  end
@@ -1,3 +1,3 @@
1
1
  module EtFakeCcd
2
- VERSION = "2.0.0"
2
+ VERSION = "2.1.0"
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: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gary Taylor
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-19 00:00:00.000000000 Z
11
+ date: 2023-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: roda
@@ -225,7 +225,7 @@ homepage: https://github.com/hmcts/et-fake-ccd
225
225
  licenses:
226
226
  - MIT
227
227
  metadata: {}
228
- post_install_message:
228
+ post_install_message:
229
229
  rdoc_options: []
230
230
  require_paths:
231
231
  - lib
@@ -241,7 +241,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
241
  version: '0'
242
242
  requirements: []
243
243
  rubygems_version: 3.1.6
244
- signing_key:
244
+ signing_key:
245
245
  specification_version: 4
246
246
  summary: Fake CCD server for employment tribunals
247
247
  test_files: []