inferno_core 0.4.22 → 0.4.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/inferno/apps/cli/services.rb +1 -1
- data/lib/inferno/config/boot/validator.rb +19 -0
- data/lib/inferno/db/migrations/009_add_request_tags.rb +18 -0
- data/lib/inferno/db/schema.rb +19 -0
- data/lib/inferno/dsl/fhir_client.rb +50 -24
- data/lib/inferno/dsl/fhir_resource_validation.rb +299 -0
- data/lib/inferno/dsl/http_client.rb +12 -8
- data/lib/inferno/dsl/request_storage.rb +15 -3
- data/lib/inferno/dsl/resume_test_route.rb +7 -1
- data/lib/inferno/dsl/runnable.rb +4 -2
- data/lib/inferno/dsl.rb +3 -1
- data/lib/inferno/entities/request.rb +23 -7
- data/lib/inferno/entities/test_suite.rb +1 -0
- data/lib/inferno/jobs/invoke_validator_session.rb +23 -0
- data/lib/inferno/jobs.rb +1 -0
- data/lib/inferno/public/bundle.js +1 -1
- data/lib/inferno/repositories/requests.rb +98 -12
- data/lib/inferno/repositories/tags.rb +18 -0
- data/lib/inferno/version.rb +1 -1
- data/spec/factories/request.rb +2 -0
- metadata +7 -2
@@ -23,6 +23,11 @@ module Inferno
|
|
23
23
|
self.class.singleton_class.instance_variable_get(:@test_run_identifier_block)
|
24
24
|
end
|
25
25
|
|
26
|
+
# @private
|
27
|
+
def tags
|
28
|
+
self.class.singleton_class.instance_variable_get(:@tags)
|
29
|
+
end
|
30
|
+
|
26
31
|
# @private
|
27
32
|
def find_test_run(test_run_identifier)
|
28
33
|
test_runs_repo.find_latest_waiting_by_identifier(test_run_identifier)
|
@@ -44,7 +49,8 @@ module Inferno
|
|
44
49
|
request.to_hash.merge(
|
45
50
|
test_session_id: test_run.test_session_id,
|
46
51
|
result_id: waiting_result.id,
|
47
|
-
name: test.config.request_name(test.incoming_request_name)
|
52
|
+
name: test.config.request_name(test.incoming_request_name),
|
53
|
+
tags:
|
48
54
|
)
|
49
55
|
)
|
50
56
|
end
|
data/lib/inferno/dsl/runnable.rb
CHANGED
@@ -318,7 +318,7 @@ module Inferno
|
|
318
318
|
#
|
319
319
|
# @see Inferno::DSL::Results#wait
|
320
320
|
# @example
|
321
|
-
# resume_test_route :get, '/launch' do
|
321
|
+
# resume_test_route :get, '/launch', tags: ['launch'] do
|
322
322
|
# request.query_parameters['iss']
|
323
323
|
# end
|
324
324
|
#
|
@@ -341,15 +341,17 @@ module Inferno
|
|
341
341
|
# [Any of the path options available in Hanami
|
342
342
|
# Router](https://github.com/hanami/router/tree/f41001d4c3ee9e2d2c7bb142f74b43f8e1d3a265#a-beautiful-dsl)
|
343
343
|
# can be used here.
|
344
|
+
# @param tags [Array<String>] a list of tags to assign to the request
|
344
345
|
# @yield This method takes a block which must return the identifier
|
345
346
|
# defined when a test was set to wait for the test run that hit this
|
346
347
|
# route. The block has access to the `request` method which returns a
|
347
348
|
# {Inferno::Entities::Request} object with the information for the
|
348
349
|
# incoming request.
|
349
350
|
# @return [void]
|
350
|
-
def resume_test_route(method, path, &block)
|
351
|
+
def resume_test_route(method, path, tags: [], &block)
|
351
352
|
route_class = Class.new(ResumeTestRoute) do |klass|
|
352
353
|
klass.singleton_class.instance_variable_set(:@test_run_identifier_block, block)
|
354
|
+
klass.singleton_class.instance_variable_set(:@tags, tags)
|
353
355
|
end
|
354
356
|
|
355
357
|
route(method, path, route_class)
|
data/lib/inferno/dsl.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require_relative 'dsl/assertions'
|
2
2
|
require_relative 'dsl/fhir_client'
|
3
3
|
require_relative 'dsl/fhir_validation'
|
4
|
+
require_relative 'dsl/fhir_resource_validation'
|
4
5
|
require_relative 'dsl/http_client'
|
5
6
|
require_relative 'dsl/results'
|
6
7
|
require_relative 'dsl/runnable'
|
@@ -13,7 +14,8 @@ module Inferno
|
|
13
14
|
FHIRClient,
|
14
15
|
HTTPClient,
|
15
16
|
Results,
|
16
|
-
FHIRValidation
|
17
|
+
FHIRValidation,
|
18
|
+
FHIRResourceValidation
|
17
19
|
].freeze
|
18
20
|
|
19
21
|
EXTENDABLE_DSL_MODULES = [
|
@@ -34,7 +34,7 @@ module Inferno
|
|
34
34
|
ATTRIBUTES = [
|
35
35
|
:id, :index, :verb, :url, :direction, :name, :status,
|
36
36
|
:request_body, :response_body, :result_id, :test_session_id, :created_at,
|
37
|
-
:updated_at, :headers
|
37
|
+
:updated_at, :headers, :tags
|
38
38
|
].freeze
|
39
39
|
SUMMARY_FIELDS = [
|
40
40
|
:id, :index, :url, :verb, :direction, :name, :status, :result_id, :created_at, :updated_at
|
@@ -48,6 +48,18 @@ module Inferno
|
|
48
48
|
|
49
49
|
@name = params[:name]&.to_sym
|
50
50
|
@headers = params[:headers]&.map { |header| header.is_a?(Hash) ? Header.new(header) : header } || []
|
51
|
+
format_tags(params[:tags] || [])
|
52
|
+
end
|
53
|
+
|
54
|
+
def format_tags(raw_tags)
|
55
|
+
@tags = raw_tags.map do |tag|
|
56
|
+
case tag
|
57
|
+
when Hash
|
58
|
+
tag[:name]
|
59
|
+
when String
|
60
|
+
tag
|
61
|
+
end
|
62
|
+
end
|
51
63
|
end
|
52
64
|
|
53
65
|
# @return [Hash<String, String>]
|
@@ -124,6 +136,7 @@ module Inferno
|
|
124
136
|
test_session_id:,
|
125
137
|
request_headers: request_headers.map(&:to_hash),
|
126
138
|
response_headers: response_headers.map(&:to_hash),
|
139
|
+
tags:,
|
127
140
|
created_at:,
|
128
141
|
updated_at:
|
129
142
|
}.compact
|
@@ -138,7 +151,7 @@ module Inferno
|
|
138
151
|
|
139
152
|
class << self
|
140
153
|
# @private
|
141
|
-
def from_hanami_request(request, name: nil)
|
154
|
+
def from_hanami_request(request, name: nil, tags: [])
|
142
155
|
url = "#{request.base_url}#{request.path}"
|
143
156
|
url += "?#{request.query_string}" if request.query_string.present?
|
144
157
|
request_headers =
|
@@ -153,12 +166,13 @@ module Inferno
|
|
153
166
|
direction: 'incoming',
|
154
167
|
name:,
|
155
168
|
request_body: request.body.string,
|
156
|
-
headers: request_headers
|
169
|
+
headers: request_headers,
|
170
|
+
tags:
|
157
171
|
)
|
158
172
|
end
|
159
173
|
|
160
174
|
# @private
|
161
|
-
def from_http_response(response, test_session_id:, direction: 'outgoing', name: nil)
|
175
|
+
def from_http_response(response, test_session_id:, direction: 'outgoing', name: nil, tags: [])
|
162
176
|
request_headers =
|
163
177
|
response.env.request_headers
|
164
178
|
.map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') }
|
@@ -175,12 +189,13 @@ module Inferno
|
|
175
189
|
request_body: response.env.request_body,
|
176
190
|
response_body: response.body,
|
177
191
|
test_session_id:,
|
178
|
-
headers: request_headers + response_headers
|
192
|
+
headers: request_headers + response_headers,
|
193
|
+
tags:
|
179
194
|
)
|
180
195
|
end
|
181
196
|
|
182
197
|
# @private
|
183
|
-
def from_fhir_client_reply(reply, test_session_id:, direction: 'outgoing', name: nil)
|
198
|
+
def from_fhir_client_reply(reply, test_session_id:, direction: 'outgoing', name: nil, tags: [])
|
184
199
|
request = reply.request
|
185
200
|
response = reply.response
|
186
201
|
request_headers = request[:headers]
|
@@ -203,7 +218,8 @@ module Inferno
|
|
203
218
|
request_body:,
|
204
219
|
response_body: response[:body],
|
205
220
|
test_session_id:,
|
206
|
-
headers: request_headers + response_headers
|
221
|
+
headers: request_headers + response_headers,
|
222
|
+
tags:
|
207
223
|
)
|
208
224
|
end
|
209
225
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Inferno
|
2
|
+
module Jobs
|
3
|
+
class InvokeValidatorSession
|
4
|
+
include Sidekiq::Worker
|
5
|
+
|
6
|
+
def perform(suite_id, validator_name, validator_index)
|
7
|
+
suite = Inferno::Repositories::TestSuites.new.find suite_id
|
8
|
+
validator = suite.fhir_validators[validator_name.to_sym][validator_index]
|
9
|
+
|
10
|
+
response_body = validator.validate(FHIR::Patient.new, 'http://hl7.org/fhir/StructureDefinition/Patient')
|
11
|
+
|
12
|
+
if response_body.start_with? '{'
|
13
|
+
res = JSON.parse(response_body)
|
14
|
+
session_id = res['sessionId']
|
15
|
+
# TODO: (FI-2311) store this session ID so it can be referenced as needed
|
16
|
+
validator.session_id = session_id
|
17
|
+
else
|
18
|
+
Inferno::Application['logger'].error("InvokeValidatorSession - error from validator: #{response_body}")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|