et_fake_ccd 0.1.17 → 0.1.18
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b396e67772f1ba9407c733f98fb6bcbd5c374671fe3f025ae8e4a2440f81136b
|
|
4
|
+
data.tar.gz: 1789651700ab482fac61cb54fea3ca9a82c45082596b38a3deead00fc60713b3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 16e5ad736c2a0d68f2c2de22230f0a8c3e5460fc03a4a68adccc8dc70efdab211b11c1db5cb8391ef7861f601d28ca5dc9c055bda1023283459cb27edbe9a5df
|
|
7
|
+
data.tar.gz: 7ee881410b2c21ac740b49330524a03ccc74b0e39403c03b86de2a10d6974d42321efc5f50f10440ad6707b3284b7c1b484e2ecdeb1684e55be071217e73c6fe
|
data/Gemfile.lock
CHANGED
|
@@ -50,7 +50,7 @@ module EtFakeCcd
|
|
|
50
50
|
errors.add :data, "Case data validation failed", field_error: { id: 'claimantType.claimant_contact_preference', message: "#{pref} is not a valid value" } unless valid_values.include?(pref)
|
|
51
51
|
end
|
|
52
52
|
data.dig('data', 'claimantType', 'claimant_addressUK', 'PostCode').tap do |postcode|
|
|
53
|
-
errors.add :data, "Case data validation failed", field_error: { id: 'claimantType.claimant_addressUK.PostCode', message: "#{postcode} exceed maximum length
|
|
53
|
+
errors.add :data, "Case data validation failed", field_error: { id: 'claimantType.claimant_addressUK.PostCode', message: "#{postcode} exceed maximum length 10" } if postcode.length > 10
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
56
|
end
|
|
@@ -4,6 +4,8 @@ module EtFakeCcd
|
|
|
4
4
|
class UploadDocumentCommand
|
|
5
5
|
include ActiveModel::Model
|
|
6
6
|
include ActiveModel::Attributes
|
|
7
|
+
VALID_FILE_EXTENSIONS = ['.pdf', '.csv', '.rtf'].freeze
|
|
8
|
+
VALID_FILE_CONTENT_TYPES = ['application/pdf', 'text/csv', 'application/rtf'].freeze
|
|
7
9
|
|
|
8
10
|
attribute :data
|
|
9
11
|
|
|
@@ -16,12 +18,22 @@ module EtFakeCcd
|
|
|
16
18
|
private
|
|
17
19
|
|
|
18
20
|
def validate_data
|
|
21
|
+
validate_file
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def validate_file
|
|
25
|
+
return if validate_file_extension && validate_file_content_type
|
|
26
|
+
|
|
27
|
+
errors.add :data, "Your upload contains a disallowed file type", field_error: { "id": "files", "message": "Your upload contains a disallowed file type" }
|
|
28
|
+
end
|
|
19
29
|
|
|
30
|
+
def validate_file_content_type
|
|
31
|
+
VALID_FILE_CONTENT_TYPES.include?(data.dig('files', 'type'))
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def validate_file_extension
|
|
35
|
+
VALID_FILE_EXTENSIONS.include?(File.extname(data.dig('files', 'filename')))
|
|
20
36
|
end
|
|
21
37
|
end
|
|
22
38
|
end
|
|
23
39
|
end
|
|
24
|
-
|
|
25
|
-
#{"exception":"uk.gov.hmcts.ccd.endpoint.exceptions.CaseValidationException","timestamp":"2019-07-01T15:33:41.417","status":422,"error":"Unprocessable Entity","message":"Case data validation failed","path":"/caseworkers/22/jurisdictions/EMPLOYMENT/case-types/EmpTrib_MVP_1.0_Manc/cases","details":{"field_errors":[{"id":"claimantType.claimant_phone_number","message":"The data entered is not valid for this type of field, please delete and re-enter using only valid data"}]},"callbackErrors":null,"callbackWarnings":null}
|
|
26
|
-
#{"exception":"uk.gov.hmcts.ccd.endpoint.exceptions.CaseValidationException","timestamp":"2019-07-01T15:51:15.291","status":422,"error":"Unprocessable Entity","message":"Case data validation failed","path":"/caseworkers/22/jurisdictions/EMPLOYMENT/case-types/EmpTrib_MVP_1.0_Manc/cases","details":{"field_errors":[{"id":"claimantType.claimant_mobile_number","message":"The data entered is not valid for this type of field, please delete and re-enter using only valid data"},{"id":"claimantType.claimant_phone_number","message":"The data entered is not valid for this type of field, please delete and re-enter using only valid data"}]},"callbackErrors":null,"callbackWarnings":null}
|
|
27
|
-
#{"exception":"uk.gov.hmcts.ccd.endpoint.exceptions.CaseValidationException","timestamp":"2019-07-01T16:02:28.045","status":422,"error":"Unprocessable Entity","message":"Case data validation failed","path":"/caseworkers/22/jurisdictions/EMPLOYMENT/case-types/EmpTrib_MVP_1.0_Manc/cases","details":{"field_errors":[{"id":"claimant_TypeOfClaimant","message":"Wrong is not a valid value"},{"id":"claimantType.claimant_mobile_number","message":"The data entered is not valid for this type of field, please delete and re-enter using only valid data"},{"id":"claimantType.claimant_phone_number","message":"The data entered is not valid for this type of field, please delete and re-enter using only valid data"}]},"callbackErrors":null,"callbackWarnings":null}
|
|
@@ -3,6 +3,7 @@ require 'json'
|
|
|
3
3
|
require 'et_fake_ccd/commands'
|
|
4
4
|
require 'et_fake_ccd/auth_service'
|
|
5
5
|
require 'et_fake_ccd/document_store_service'
|
|
6
|
+
require 'active_support/core_ext/hash'
|
|
6
7
|
module EtFakeCcd
|
|
7
8
|
module Service
|
|
8
9
|
class DocumentStoreApp < Roda
|
|
@@ -16,7 +17,7 @@ module EtFakeCcd
|
|
|
16
17
|
r.halt 403, forbidden_error_for(r)
|
|
17
18
|
break
|
|
18
19
|
end
|
|
19
|
-
command = ::EtFakeCcd::Command::UploadDocumentCommand.from_json(r.params)
|
|
20
|
+
command = ::EtFakeCcd::Command::UploadDocumentCommand.from_json(r.params.deep_stringify_keys)
|
|
20
21
|
unless command.valid?
|
|
21
22
|
r.halt 422, render_error_for(command, r)
|
|
22
23
|
break
|
|
@@ -110,6 +111,23 @@ module EtFakeCcd
|
|
|
110
111
|
JSON.generate(j)
|
|
111
112
|
end
|
|
112
113
|
|
|
114
|
+
def render_error_for(command, request)
|
|
115
|
+
j = {
|
|
116
|
+
"exception": "uk.gov.hmcts.ccd.endpoint.exceptions.CaseValidationException",
|
|
117
|
+
"timestamp": "2019-07-01T16:02:28.045",
|
|
118
|
+
"status": 422,
|
|
119
|
+
"error": "Unprocessable Entity",
|
|
120
|
+
"message": "Document validation failed",
|
|
121
|
+
"path": request.path,
|
|
122
|
+
"details": {
|
|
123
|
+
"field_errors": command.errors.details[:data].map {|e| e[:field_error]}
|
|
124
|
+
},
|
|
125
|
+
"callbackErrors": nil,
|
|
126
|
+
"callbackWarnings": nil
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
JSON.generate(j)
|
|
130
|
+
end
|
|
113
131
|
|
|
114
132
|
def forbidden_error_for(r)
|
|
115
133
|
j = {"timestamp":"2019-07-01T07:46:35.405+0000","status":403,"error":"Forbidden","message":"Access Denied","path": r.path}
|
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: 0.1.
|
|
4
|
+
version: 0.1.18
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gary Taylor
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-
|
|
11
|
+
date: 2019-08-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: roda
|