et_fake_acas_server 0.1.11 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +16 -16
- data/lib/et_fake_acas_server/forms/certificate_lookup_form.rb +1 -0
- data/lib/et_fake_acas_server/forms/certificates_lookup_form.rb +22 -0
- data/lib/et_fake_acas_server/json_server.rb +66 -0
- data/lib/et_fake_acas_server/server.rb +4 -63
- data/lib/et_fake_acas_server/soap_server.rb +72 -0
- data/lib/et_fake_acas_server/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56e2f63c2b063682f928f1187c3ad0ae112b0f5f12597e8ed9beae5ad8436794
|
4
|
+
data.tar.gz: 66864c1de7443a10f1a7fb2bb24f5357054c038ea364d12f2e31679bc3ea8d84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8f7b3e0b51236ff2b2937bb671b4ddc8a2bff869f9cb325e907c016aa9a516c82a7604ba114f1642f1f4c86a359ca9637c76e540aa1f1b89716f674ad2b6589
|
7
|
+
data.tar.gz: a06a790a61a14c9cda69c6def8e12bc4c4bb59c8031e943f015819c3ccd8bd0d2463845e290017ca078491ac98526182406dd4ea3667974ea1599f228dc4b4d8
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
et_fake_acas_server (0.1
|
4
|
+
et_fake_acas_server (0.2.1)
|
5
5
|
activesupport (~> 6.1)
|
6
6
|
iodine (~> 0.7)
|
7
7
|
nokogiri (~> 1.8, >= 1.8.2)
|
@@ -12,46 +12,46 @@ PATH
|
|
12
12
|
GEM
|
13
13
|
remote: https://rubygems.org/
|
14
14
|
specs:
|
15
|
-
activesupport (6.1.
|
15
|
+
activesupport (6.1.6)
|
16
16
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
17
|
i18n (>= 1.6, < 2)
|
18
18
|
minitest (>= 5.1)
|
19
19
|
tzinfo (~> 2.0)
|
20
20
|
zeitwerk (~> 2.3)
|
21
|
-
concurrent-ruby (1.1.
|
22
|
-
i18n (1.
|
21
|
+
concurrent-ruby (1.1.10)
|
22
|
+
i18n (1.10.0)
|
23
23
|
concurrent-ruby (~> 1.0)
|
24
|
-
iodine (0.7.
|
25
|
-
mini_portile2 (2.
|
24
|
+
iodine (0.7.47)
|
25
|
+
mini_portile2 (2.8.0)
|
26
26
|
minitest (5.15.0)
|
27
27
|
multi_json (1.15.0)
|
28
28
|
mustermann (1.1.1)
|
29
29
|
ruby2_keywords (~> 0.0.1)
|
30
|
-
nokogiri (1.13.
|
31
|
-
mini_portile2 (~> 2.
|
30
|
+
nokogiri (1.13.6)
|
31
|
+
mini_portile2 (~> 2.8.0)
|
32
32
|
racc (~> 1.4)
|
33
33
|
racc (1.6.0)
|
34
|
-
rack (2.2.3)
|
35
|
-
rack-protection (2.
|
34
|
+
rack (2.2.3.1)
|
35
|
+
rack-protection (2.2.0)
|
36
36
|
rack
|
37
37
|
rake (13.0.1)
|
38
38
|
ruby-mcrypt (0.2.0)
|
39
39
|
ruby2_keywords (0.0.5)
|
40
|
-
sinatra (2.
|
40
|
+
sinatra (2.2.0)
|
41
41
|
mustermann (~> 1.0)
|
42
42
|
rack (~> 2.2)
|
43
|
-
rack-protection (= 2.
|
43
|
+
rack-protection (= 2.2.0)
|
44
44
|
tilt (~> 2.0)
|
45
|
-
sinatra-contrib (2.
|
45
|
+
sinatra-contrib (2.2.0)
|
46
46
|
multi_json
|
47
47
|
mustermann (~> 1.0)
|
48
|
-
rack-protection (= 2.
|
49
|
-
sinatra (= 2.
|
48
|
+
rack-protection (= 2.2.0)
|
49
|
+
sinatra (= 2.2.0)
|
50
50
|
tilt (~> 2.0)
|
51
51
|
tilt (2.0.10)
|
52
52
|
tzinfo (2.0.4)
|
53
53
|
concurrent-ruby (~> 1.0)
|
54
|
-
zeitwerk (2.
|
54
|
+
zeitwerk (2.6.0)
|
55
55
|
|
56
56
|
PLATFORMS
|
57
57
|
ruby
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'base64'
|
2
|
+
require 'active_support'
|
3
|
+
require 'active_support/core_ext/string'
|
4
|
+
module EtFakeAcasServer
|
5
|
+
class CertificatesLookupForm
|
6
|
+
def initialize(payload)
|
7
|
+
self.payload = JSON.parse(payload)
|
8
|
+
end
|
9
|
+
|
10
|
+
def validate
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
def certificate_numbers
|
15
|
+
payload['CertificateNumbers']
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
attr_accessor :payload
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'sinatra/base'
|
2
|
+
require 'sinatra/custom_logger'
|
3
|
+
require 'logger'
|
4
|
+
require 'et_fake_acas_server/forms/certificates_lookup_form'
|
5
|
+
require 'active_support'
|
6
|
+
require 'active_support/core_ext/numeric/time'
|
7
|
+
require 'base64'
|
8
|
+
|
9
|
+
|
10
|
+
module EtFakeAcasServer
|
11
|
+
class JsonServer < Sinatra::Base
|
12
|
+
def initialize(*)
|
13
|
+
super
|
14
|
+
self.subscription_key = ENV.fetch('ACAS_JSON_SUBSCRIPTION_KEY', 'fakesubscriptionkeyfortesting')
|
15
|
+
end
|
16
|
+
|
17
|
+
before do
|
18
|
+
content_type 'application/json'
|
19
|
+
end
|
20
|
+
|
21
|
+
configure :development, :production do
|
22
|
+
logger = Logger.new(STDOUT)
|
23
|
+
logger.level = Logger::DEBUG
|
24
|
+
set :logger, logger
|
25
|
+
end
|
26
|
+
|
27
|
+
post '/ECCLJson' do
|
28
|
+
form = CertificatesLookupForm.new(request.body.read)
|
29
|
+
request.body.rewind
|
30
|
+
form.validate
|
31
|
+
json = form.certificate_numbers.map do |certificate_number|
|
32
|
+
case certificate_number
|
33
|
+
when /\A(R|NE|MU)000200/ then
|
34
|
+
json_builder_for_no_match(certificate_number)
|
35
|
+
else
|
36
|
+
json_builder_for_found(certificate_number)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
JSON.pretty_generate(json)
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
attr_accessor :subscription_key
|
45
|
+
|
46
|
+
def json_builder_for_no_match(certificate_number)
|
47
|
+
{
|
48
|
+
CertificateNumber: certificate_number,
|
49
|
+
CertificateDocument: 'not found'
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
def json_builder_for_found(certificate_number)
|
54
|
+
{
|
55
|
+
CertificateNumber: certificate_number,
|
56
|
+
CertificateDocument: dummy_certificate_as_base_64
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
def dummy_certificate_as_base_64
|
61
|
+
filename = File.absolute_path(File.join('..', 'pdfs', '76 EC (C) Certificate R000080.pdf'), __dir__)
|
62
|
+
Base64.encode64(File.read(filename))
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
@@ -1,71 +1,12 @@
|
|
1
1
|
require 'sinatra/base'
|
2
2
|
require 'sinatra/custom_logger'
|
3
3
|
require 'logger'
|
4
|
-
require 'et_fake_acas_server/
|
5
|
-
require 'et_fake_acas_server/
|
6
|
-
require 'et_fake_acas_server/xml_builders/no_match_xml_builder'
|
7
|
-
require 'et_fake_acas_server/xml_builders/internal_error_xml_builder'
|
8
|
-
require 'et_fake_acas_server/xml_builders/invalid_certificate_format_xml_builder'
|
9
|
-
require 'active_support/core_ext/numeric/time'
|
10
|
-
|
4
|
+
require 'et_fake_acas_server/soap_server'
|
5
|
+
require 'et_fake_acas_server/json_server'
|
11
6
|
|
12
7
|
module EtFakeAcasServer
|
13
8
|
class Server < Sinatra::Base
|
14
|
-
|
15
|
-
|
16
|
-
self.private_key_file = ENV.fetch('ACAS_PRIVATE_KEY_FILE', File.absolute_path(File.join('..', '..', 'temp_x509', 'acas', 'privatekey.pem'), __dir__))
|
17
|
-
self.et_public_key_file = ENV.fetch('ET_PUBLIC_KEY_FILE', File.absolute_path(File.join('..', '..', 'temp_x509', 'et', 'publickey.cer'), __dir__))
|
18
|
-
end
|
19
|
-
|
20
|
-
configure :development, :production do
|
21
|
-
logger = Logger.new(STDOUT)
|
22
|
-
logger.level = Logger::DEBUG
|
23
|
-
set :logger, logger
|
24
|
-
end
|
25
|
-
|
26
|
-
post '/Lookup/ECService.svc' do
|
27
|
-
form = CertificateLookupForm.new(request.body.read, private_key_file: private_key_file)
|
28
|
-
request.body.rewind
|
29
|
-
form.validate
|
30
|
-
case form.certificate_number
|
31
|
-
when /\A(R|NE|MU)000200/ then
|
32
|
-
xml_builder_for_no_match(form).to_xml
|
33
|
-
when /\A(R|NE|MU)000201/ then
|
34
|
-
xml_builder_for_invalid_certificate_format(form).to_xml
|
35
|
-
when /\A(R|NE|MU)000500/ then
|
36
|
-
xml_builder_for_internal_error(form).to_xml
|
37
|
-
else
|
38
|
-
xml_builder_for_found(form).to_xml
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
attr_accessor :private_key_file, :et_public_key_file
|
45
|
-
|
46
|
-
def xml_builder_for_found(form)
|
47
|
-
data = OpenStruct.new claimant_name: 'Claimant’s Name',
|
48
|
-
respondent_name: 'Respondent’s Name',
|
49
|
-
date_of_issue: Time.parse('1 December 2017 12:00:00'),
|
50
|
-
date_of_receipt: Time.parse('1 January 2017 12:00:00'),
|
51
|
-
certificate_number: form.certificate_number,
|
52
|
-
message: 'CertificateFound',
|
53
|
-
method_of_issue: 'Email',
|
54
|
-
certificate_file: File.absolute_path(File.join('..', 'pdfs', '76 EC (C) Certificate R000080.pdf'), __dir__)
|
55
|
-
FoundXmlBuilder.new(form, rsa_et_certificate_path: et_public_key_file).builder(data)
|
56
|
-
end
|
57
|
-
|
58
|
-
def xml_builder_for_no_match(form)
|
59
|
-
NoMatchXmlBuilder.new(form, rsa_et_certificate_path: et_public_key_file).builder
|
60
|
-
end
|
61
|
-
|
62
|
-
def xml_builder_for_internal_error(form)
|
63
|
-
InternalErrorXmlBuilder.new(form, rsa_et_certificate_path: et_public_key_file).builder
|
64
|
-
end
|
65
|
-
|
66
|
-
def xml_builder_for_invalid_certificate_format(form)
|
67
|
-
InvalidCertificateFormatXmlBuilder.new(form, rsa_et_certificate_path: et_public_key_file).builder
|
68
|
-
end
|
9
|
+
post(/\/Lookup\/.*/) { SoapServer.call(env) }
|
10
|
+
post(/\/ECCLJson/) { JsonServer.call(env) }
|
69
11
|
end
|
70
12
|
end
|
71
|
-
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'sinatra/base'
|
2
|
+
require 'sinatra/custom_logger'
|
3
|
+
require 'logger'
|
4
|
+
require 'et_fake_acas_server/forms/certificate_lookup_form'
|
5
|
+
require 'et_fake_acas_server/xml_builders/found_xml_builder'
|
6
|
+
require 'et_fake_acas_server/xml_builders/no_match_xml_builder'
|
7
|
+
require 'et_fake_acas_server/xml_builders/internal_error_xml_builder'
|
8
|
+
require 'et_fake_acas_server/xml_builders/invalid_certificate_format_xml_builder'
|
9
|
+
require 'active_support'
|
10
|
+
require 'active_support/core_ext/numeric/time'
|
11
|
+
|
12
|
+
|
13
|
+
module EtFakeAcasServer
|
14
|
+
class SoapServer < Sinatra::Base
|
15
|
+
def initialize(*)
|
16
|
+
super
|
17
|
+
self.private_key_file = ENV.fetch('ACAS_PRIVATE_KEY_FILE', File.absolute_path(File.join('..', '..', 'temp_x509', 'acas', 'privatekey.pem'), __dir__))
|
18
|
+
self.et_public_key_file = ENV.fetch('ET_PUBLIC_KEY_FILE', File.absolute_path(File.join('..', '..', 'temp_x509', 'et', 'publickey.cer'), __dir__))
|
19
|
+
end
|
20
|
+
|
21
|
+
configure :development, :production do
|
22
|
+
logger = Logger.new(STDOUT)
|
23
|
+
logger.level = Logger::DEBUG
|
24
|
+
set :logger, logger
|
25
|
+
end
|
26
|
+
|
27
|
+
post '/Lookup/ECService.svc' do
|
28
|
+
form = CertificateLookupForm.new(request.body.read, private_key_file: private_key_file)
|
29
|
+
request.body.rewind
|
30
|
+
form.validate
|
31
|
+
case form.certificate_number
|
32
|
+
when /\A(R|NE|MU)000200/ then
|
33
|
+
xml_builder_for_no_match(form).to_xml
|
34
|
+
when /\A(R|NE|MU)000201/ then
|
35
|
+
xml_builder_for_invalid_certificate_format(form).to_xml
|
36
|
+
when /\A(R|NE|MU)000500/ then
|
37
|
+
xml_builder_for_internal_error(form).to_xml
|
38
|
+
else
|
39
|
+
xml_builder_for_found(form).to_xml
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
attr_accessor :private_key_file, :et_public_key_file
|
46
|
+
|
47
|
+
def xml_builder_for_found(form)
|
48
|
+
data = OpenStruct.new claimant_name: 'Claimant’s Name',
|
49
|
+
respondent_name: 'Respondent’s Name',
|
50
|
+
date_of_issue: Time.parse('1 December 2017 12:00:00'),
|
51
|
+
date_of_receipt: Time.parse('1 January 2017 12:00:00'),
|
52
|
+
certificate_number: form.certificate_number,
|
53
|
+
message: 'CertificateFound',
|
54
|
+
method_of_issue: 'Email',
|
55
|
+
certificate_file: File.absolute_path(File.join('..', 'pdfs', '76 EC (C) Certificate R000080.pdf'), __dir__)
|
56
|
+
FoundXmlBuilder.new(form, rsa_et_certificate_path: et_public_key_file).builder(data)
|
57
|
+
end
|
58
|
+
|
59
|
+
def xml_builder_for_no_match(form)
|
60
|
+
NoMatchXmlBuilder.new(form, rsa_et_certificate_path: et_public_key_file).builder
|
61
|
+
end
|
62
|
+
|
63
|
+
def xml_builder_for_internal_error(form)
|
64
|
+
InternalErrorXmlBuilder.new(form, rsa_et_certificate_path: et_public_key_file).builder
|
65
|
+
end
|
66
|
+
|
67
|
+
def xml_builder_for_invalid_certificate_format(form)
|
68
|
+
InvalidCertificateFormatXmlBuilder.new(form, rsa_et_certificate_path: et_public_key_file).builder
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: et_fake_acas_server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gary Taylor
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -159,7 +159,10 @@ files:
|
|
159
159
|
- lib/config.ru
|
160
160
|
- lib/et_fake_acas_server.rb
|
161
161
|
- lib/et_fake_acas_server/forms/certificate_lookup_form.rb
|
162
|
+
- lib/et_fake_acas_server/forms/certificates_lookup_form.rb
|
163
|
+
- lib/et_fake_acas_server/json_server.rb
|
162
164
|
- lib/et_fake_acas_server/server.rb
|
165
|
+
- lib/et_fake_acas_server/soap_server.rb
|
163
166
|
- lib/et_fake_acas_server/version.rb
|
164
167
|
- lib/et_fake_acas_server/xml_builders/found_xml_builder.rb
|
165
168
|
- lib/et_fake_acas_server/xml_builders/internal_error_xml_builder.rb
|