inferno_core 0.3.12 → 0.4.0
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/lib/inferno/apps/web/application.rb +1 -0
- data/lib/inferno/apps/web/controllers/controller.rb +6 -8
- data/lib/inferno/apps/web/controllers/requests/show.rb +3 -3
- data/lib/inferno/apps/web/controllers/test_runs/create.rb +13 -17
- data/lib/inferno/apps/web/controllers/test_runs/destroy.rb +8 -10
- data/lib/inferno/apps/web/controllers/test_runs/results/index.rb +4 -4
- data/lib/inferno/apps/web/controllers/test_runs/show.rb +9 -7
- data/lib/inferno/apps/web/controllers/test_sessions/create.rb +9 -8
- data/lib/inferno/apps/web/controllers/test_sessions/last_test_run.rb +4 -4
- data/lib/inferno/apps/web/controllers/test_sessions/results/index.rb +6 -6
- data/lib/inferno/apps/web/controllers/test_sessions/session_data/apply_preset.rb +10 -10
- data/lib/inferno/apps/web/controllers/test_sessions/session_data/index.rb +5 -3
- data/lib/inferno/apps/web/controllers/test_sessions/show.rb +3 -3
- data/lib/inferno/apps/web/controllers/test_suites/check_configuration.rb +3 -3
- data/lib/inferno/apps/web/controllers/test_suites/index.rb +2 -2
- data/lib/inferno/apps/web/controllers/test_suites/show.rb +3 -3
- data/lib/inferno/apps/web/router.rb +55 -41
- data/lib/inferno/apps/web/serializers/message.rb +2 -0
- data/lib/inferno/apps/web/serializers/preset.rb +2 -5
- data/lib/inferno/apps/web/serializers/request.rb +2 -0
- data/lib/inferno/apps/web/serializers/result.rb +1 -0
- data/lib/inferno/apps/web/serializers/session_data.rb +2 -0
- data/lib/inferno/apps/web/serializers/suite_option.rb +2 -0
- data/lib/inferno/apps/web/serializers/test.rb +3 -0
- data/lib/inferno/apps/web/serializers/test_group.rb +4 -2
- data/lib/inferno/apps/web/serializers/test_run.rb +3 -0
- data/lib/inferno/apps/web/serializers/test_suite.rb +5 -1
- data/lib/inferno/config/application.rb +1 -6
- data/lib/inferno/config/boot/web.rb +2 -7
- data/lib/inferno/dsl/assertions.rb +2 -2
- data/lib/inferno/dsl/configurable.rb +4 -4
- data/lib/inferno/dsl/fhir_client.rb +3 -2
- data/lib/inferno/dsl/fhir_client_builder.rb +2 -2
- data/lib/inferno/dsl/fhir_validation.rb +5 -6
- data/lib/inferno/dsl/http_client.rb +17 -18
- data/lib/inferno/dsl/http_client_builder.rb +4 -4
- data/lib/inferno/dsl/input_output_handling.rb +1 -1
- data/lib/inferno/dsl/request_storage.rb +2 -2
- data/lib/inferno/dsl/resume_test_route.rb +36 -34
- data/lib/inferno/dsl/runnable.rb +8 -9
- data/lib/inferno/entities/header.rb +7 -7
- data/lib/inferno/entities/request.rb +35 -36
- data/lib/inferno/entities/session_data.rb +6 -6
- data/lib/inferno/entities/test.rb +4 -4
- data/lib/inferno/entities/test_group.rb +2 -2
- data/lib/inferno/entities/test_run.rb +1 -1
- data/lib/inferno/jobs/execute_test_run.rb +1 -1
- data/lib/inferno/jobs/resume_test_run.rb +1 -1
- data/lib/inferno/public/bundle.js +2 -2
- data/lib/inferno/repositories/messages.rb +1 -1
- data/lib/inferno/repositories/repository.rb +1 -1
- data/lib/inferno/repositories/requests.rb +6 -6
- data/lib/inferno/repositories/results.rb +16 -16
- data/lib/inferno/repositories/session_data.rb +6 -6
- data/lib/inferno/repositories/test_runs.rb +6 -6
- data/lib/inferno/repositories/test_sessions.rb +7 -7
- data/lib/inferno/test_runner.rb +3 -3
- data/lib/inferno/utils/preset_template_generator.rb +1 -1
- data/lib/inferno/version.rb +1 -1
- data/spec/factories/test_run.rb +1 -1
- data/spec/factories/test_session.rb +1 -1
- data/spec/fixtures/basic_test_suite.rb +1 -0
- metadata +24 -24
@@ -1,3 +1,7 @@
|
|
1
|
+
require_relative 'preset'
|
2
|
+
require_relative 'suite_option'
|
3
|
+
require_relative 'test_group'
|
4
|
+
|
1
5
|
module Inferno
|
2
6
|
module Web
|
3
7
|
module Serializers
|
@@ -25,7 +29,7 @@ module Inferno
|
|
25
29
|
include_view :summary
|
26
30
|
field :test_groups do |suite, options|
|
27
31
|
suite_options = options[:suite_options]
|
28
|
-
TestGroup.render_as_hash(suite.groups(suite_options), suite_options:
|
32
|
+
TestGroup.render_as_hash(suite.groups(suite_options), suite_options:)
|
29
33
|
end
|
30
34
|
field :configuration_messages
|
31
35
|
field :inputs do |suite, options|
|
@@ -25,13 +25,8 @@ module Inferno
|
|
25
25
|
|
26
26
|
configure do |config|
|
27
27
|
config.root = File.expand_path('../../..', __dir__)
|
28
|
-
config.default_namespace = 'inferno'
|
29
|
-
config.system_dir = File.join('lib', 'inferno', 'config')
|
30
28
|
config.bootable_dirs = [File.join('lib', 'inferno', 'config', 'boot')]
|
31
|
-
|
32
|
-
config.auto_register = 'lib'
|
29
|
+
config.component_dirs.add 'lib'
|
33
30
|
end
|
34
|
-
|
35
|
-
load_paths!('lib')
|
36
31
|
end
|
37
32
|
end
|
@@ -1,15 +1,10 @@
|
|
1
1
|
Inferno::Application.boot(:web) do |_app|
|
2
2
|
init do
|
3
3
|
require 'blueprinter'
|
4
|
-
require 'hanami
|
5
|
-
require 'hanami
|
4
|
+
require 'hanami/router'
|
5
|
+
require 'hanami/controller'
|
6
6
|
require 'oj'
|
7
7
|
|
8
|
-
Hanami::Controller.configure do
|
9
|
-
default_request_format :json
|
10
|
-
default_response_format :json
|
11
|
-
end
|
12
|
-
|
13
8
|
Blueprinter.configure do |config|
|
14
9
|
config.generator = Oj
|
15
10
|
end
|
@@ -58,7 +58,7 @@ module Inferno
|
|
58
58
|
# @param profile_url [String] url of the profile to validate against,
|
59
59
|
# defaults to validating against the base FHIR resource
|
60
60
|
def assert_valid_resource(resource: self.resource, profile_url: nil)
|
61
|
-
assert resource_is_valid?(resource
|
61
|
+
assert resource_is_valid?(resource:, profile_url:),
|
62
62
|
invalid_resource_message(profile_url)
|
63
63
|
end
|
64
64
|
|
@@ -100,7 +100,7 @@ module Inferno
|
|
100
100
|
.map(&:resource)
|
101
101
|
.select { |resource| types_to_check.empty? || types_to_check.include?(resource.resourceType) }
|
102
102
|
.reject do |resource|
|
103
|
-
validation_params = { resource:
|
103
|
+
validation_params = { resource: }
|
104
104
|
profile = types_to_check[resource.resourceType]
|
105
105
|
validation_params[:profile_url] = profile if profile
|
106
106
|
|
@@ -37,7 +37,7 @@ module Inferno
|
|
37
37
|
new_configuration
|
38
38
|
end
|
39
39
|
|
40
|
-
self.configuration = configuration.deep_merge(config_to_apply.
|
40
|
+
self.configuration = configuration.deep_merge(config_to_apply.except(:inputs))
|
41
41
|
|
42
42
|
config_to_apply[:inputs]&.each do |identifier, new_input|
|
43
43
|
add_input(identifier, new_input.to_hash)
|
@@ -58,13 +58,13 @@ module Inferno
|
|
58
58
|
existing_config = input(identifier)
|
59
59
|
|
60
60
|
if existing_config.nil?
|
61
|
-
return inputs[identifier] = Entities::Input.new(default_input_params(identifier).merge(new_config))
|
61
|
+
return inputs[identifier] = Entities::Input.new(**default_input_params(identifier).merge(new_config))
|
62
62
|
end
|
63
63
|
|
64
64
|
inputs[identifier] =
|
65
65
|
Entities::Input
|
66
|
-
.new(existing_config.to_hash)
|
67
|
-
.merge(Entities::Input.new(new_config))
|
66
|
+
.new(**existing_config.to_hash)
|
67
|
+
.merge(Entities::Input.new(**new_config))
|
68
68
|
end
|
69
69
|
|
70
70
|
def default_input_params(identifier)
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require_relative 'fhir_client_builder'
|
1
2
|
require_relative 'request_storage'
|
2
3
|
require_relative 'tcp_exception_handler'
|
3
4
|
|
@@ -136,7 +137,7 @@ module Inferno
|
|
136
137
|
store_request_and_refresh_token(fhir_client(client), name) do
|
137
138
|
tcp_exception_handler do
|
138
139
|
fhir_client(client)
|
139
|
-
.search(fhir_class_from_resource_type(resource_type), { search:
|
140
|
+
.search(fhir_class_from_resource_type(resource_type), { search: })
|
140
141
|
end
|
141
142
|
end
|
142
143
|
end
|
@@ -194,7 +195,7 @@ module Inferno
|
|
194
195
|
name: credentials.name,
|
195
196
|
value: credentials,
|
196
197
|
type: 'oauth_credentials',
|
197
|
-
test_session_id:
|
198
|
+
test_session_id:
|
198
199
|
)
|
199
200
|
end
|
200
201
|
rescue StandardError => e
|
@@ -73,8 +73,8 @@ module Inferno
|
|
73
73
|
end
|
74
74
|
|
75
75
|
# @private
|
76
|
-
def method_missing(name, *args, &
|
77
|
-
return runnable.call(name, *args, &
|
76
|
+
def method_missing(name, *args, &)
|
77
|
+
return runnable.call(name, *args, &) if runnable.respond_to? name
|
78
78
|
|
79
79
|
super
|
80
80
|
end
|
@@ -45,8 +45,8 @@ module Inferno
|
|
45
45
|
attr_reader :requirements
|
46
46
|
|
47
47
|
# @private
|
48
|
-
def initialize(requirements = nil, &
|
49
|
-
instance_eval(&
|
48
|
+
def initialize(requirements = nil, &)
|
49
|
+
instance_eval(&)
|
50
50
|
@requirements = requirements
|
51
51
|
end
|
52
52
|
|
@@ -172,11 +172,10 @@ module Inferno
|
|
172
172
|
# @param profile_url [String]
|
173
173
|
# @return [String] the body of the validation response
|
174
174
|
def validate(resource, profile_url)
|
175
|
-
|
176
|
-
|
177
|
-
resource.source_contents,
|
175
|
+
Faraday.new(
|
176
|
+
url,
|
178
177
|
params: { profile: profile_url }
|
179
|
-
).body
|
178
|
+
).post('validate', resource.source_contents).body
|
180
179
|
end
|
181
180
|
end
|
182
181
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'faraday_middleware'
|
2
2
|
|
3
|
+
require_relative 'http_client_builder'
|
3
4
|
require_relative 'request_storage'
|
4
5
|
require_relative 'tcp_exception_handler'
|
5
6
|
|
@@ -66,18 +67,17 @@ module Inferno
|
|
66
67
|
# @param client [Symbol]
|
67
68
|
# @param name [Symbol] Name for this request to allow it to be used by
|
68
69
|
# other tests
|
69
|
-
# @
|
70
|
-
# must be entered as the last piece of input to this method
|
70
|
+
# @param headers [Hash] Input headers here
|
71
71
|
# @return [Inferno::Entities::Request]
|
72
|
-
def get(url = '', client: :default, name: nil,
|
72
|
+
def get(url = '', client: :default, name: nil, headers: nil)
|
73
73
|
store_request('outgoing', name) do
|
74
74
|
tcp_exception_handler do
|
75
75
|
client = http_client(client)
|
76
76
|
|
77
77
|
if client
|
78
|
-
client.get(url, nil,
|
78
|
+
client.get(url, nil, headers)
|
79
79
|
elsif url.match?(%r{\Ahttps?://})
|
80
|
-
connection.get(url, nil,
|
80
|
+
connection.get(url, nil, headers)
|
81
81
|
else
|
82
82
|
raise StandardError, 'Must use an absolute url or define an HTTP client with a base url'
|
83
83
|
end
|
@@ -102,18 +102,17 @@ module Inferno
|
|
102
102
|
# @param client [Symbol]
|
103
103
|
# @param name [Symbol] Name for this request to allow it to be used by
|
104
104
|
# other tests
|
105
|
-
# @
|
106
|
-
# must be entered as the last piece of input to this method
|
105
|
+
# @param headers [Hash] Input headers here
|
107
106
|
# @return [Inferno::Entities::Request]
|
108
|
-
def post(url = '', body: nil, client: :default, name: nil,
|
107
|
+
def post(url = '', body: nil, client: :default, name: nil, headers: nil)
|
109
108
|
store_request('outgoing', name) do
|
110
109
|
tcp_exception_handler do
|
111
110
|
client = http_client(client)
|
112
111
|
|
113
112
|
if client
|
114
|
-
client.post(url, body,
|
113
|
+
client.post(url, body, headers)
|
115
114
|
elsif url.match?(%r{\Ahttps?://})
|
116
|
-
connection.post(url, body,
|
115
|
+
connection.post(url, body, headers)
|
117
116
|
else
|
118
117
|
raise StandardError, 'Must use an absolute url or define an HTTP client with a base url'
|
119
118
|
end
|
@@ -129,16 +128,17 @@ module Inferno
|
|
129
128
|
# @param client [Symbol]
|
130
129
|
# @param name [Symbol] Name for this request to allow it to be used by
|
131
130
|
# other tests
|
131
|
+
# @param headers [Hash] Input headers here
|
132
132
|
# @return [Inferno::Entities::Request]
|
133
|
-
def delete(url = '', client: :default, name: :nil,
|
133
|
+
def delete(url = '', client: :default, name: :nil, headers: nil)
|
134
134
|
store_request('outgoing', name) do
|
135
135
|
tcp_exception_handler do
|
136
136
|
client = http_client(client)
|
137
137
|
|
138
138
|
if client
|
139
|
-
client.delete(url, nil,
|
139
|
+
client.delete(url, nil, headers)
|
140
140
|
elsif url.match?(%r{\Ahttps?://})
|
141
|
-
connection.delete(url, nil,
|
141
|
+
connection.delete(url, nil, headers)
|
142
142
|
else
|
143
143
|
raise StandardError, 'Must use an absolute url or define an HTTP client with a base url'
|
144
144
|
end
|
@@ -158,10 +158,9 @@ module Inferno
|
|
158
158
|
# @param client [Symbol]
|
159
159
|
# @param name [Symbol] Name for this request to allow it to be used by
|
160
160
|
# other tests
|
161
|
-
# @
|
162
|
-
# must be entered as the last piece of input to this method
|
161
|
+
# @param headers [Hash] Input headers here
|
163
162
|
# @return [Inferno::Entities::Request]
|
164
|
-
def stream(block, url = '', limit = 100, client: :default, name: nil,
|
163
|
+
def stream(block, url = '', limit = 100, client: :default, name: nil, headers: nil)
|
165
164
|
streamed = []
|
166
165
|
|
167
166
|
collector = proc do |chunk, bytes|
|
@@ -175,9 +174,9 @@ module Inferno
|
|
175
174
|
client = http_client(client)
|
176
175
|
|
177
176
|
if client
|
178
|
-
response = client.get(url, nil,
|
177
|
+
response = client.get(url, nil, headers) { |req| req.options.on_data = collector }
|
179
178
|
elsif url.match?(%r{\Ahttps?://})
|
180
|
-
response = connection.get(url, nil,
|
179
|
+
response = connection.get(url, nil, headers) { |req| req.options.on_data = collector }
|
181
180
|
else
|
182
181
|
raise StandardError, 'Must use an absolute url or define an HTTP client with a base url'
|
183
182
|
end
|
@@ -11,8 +11,8 @@ module Inferno
|
|
11
11
|
self.runnable = runnable
|
12
12
|
instance_exec(self, &block)
|
13
13
|
|
14
|
-
params = { url:
|
15
|
-
params.merge!(headers:
|
14
|
+
params = { url: }
|
15
|
+
params.merge!(headers:) if headers
|
16
16
|
|
17
17
|
Faraday.new(params) do |f|
|
18
18
|
f.request :url_encoded
|
@@ -44,8 +44,8 @@ module Inferno
|
|
44
44
|
end
|
45
45
|
|
46
46
|
# @private
|
47
|
-
def method_missing(name, *args, &
|
48
|
-
return runnable.call(name, *args, &
|
47
|
+
def method_missing(name, *args, &)
|
48
|
+
return runnable.call(name, *args, &) if runnable.respond_to? name
|
49
49
|
|
50
50
|
super
|
51
51
|
end
|
@@ -183,7 +183,7 @@ module Inferno
|
|
183
183
|
config.inputs
|
184
184
|
.slice(*inputs)
|
185
185
|
.each_with_object({}) do |(_, input), inputs|
|
186
|
-
inputs[input.name.to_sym] = Entities::Input.new(input.to_hash)
|
186
|
+
inputs[input.name.to_sym] = Entities::Input.new(**input.to_hash)
|
187
187
|
end
|
188
188
|
|
189
189
|
available_inputs.each do |input, current_definition|
|
@@ -49,11 +49,11 @@ module Inferno
|
|
49
49
|
request =
|
50
50
|
if response.is_a? FHIR::ClientReply
|
51
51
|
Entities::Request.from_fhir_client_reply(
|
52
|
-
response, direction
|
52
|
+
response, direction:, name:, test_session_id:
|
53
53
|
)
|
54
54
|
else
|
55
55
|
Entities::Request.from_http_response(
|
56
|
-
response, direction
|
56
|
+
response, direction:, name:, test_session_id:
|
57
57
|
)
|
58
58
|
end
|
59
59
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'hanami
|
1
|
+
require 'hanami/controller'
|
2
2
|
|
3
3
|
module Inferno
|
4
4
|
module DSL
|
@@ -6,44 +6,40 @@ module Inferno
|
|
6
6
|
# an incoming request.
|
7
7
|
# @private
|
8
8
|
# @see Inferno::DSL::Runnable#resume_test_route
|
9
|
-
class ResumeTestRoute
|
10
|
-
include Hanami::Action
|
9
|
+
class ResumeTestRoute < Hanami::Action
|
11
10
|
include Import[
|
12
|
-
requests_repo: 'repositories.requests',
|
13
|
-
results_repo: 'repositories.results',
|
14
|
-
test_runs_repo: 'repositories.test_runs',
|
15
|
-
tests_repo: 'repositories.tests'
|
11
|
+
requests_repo: 'inferno.repositories.requests',
|
12
|
+
results_repo: 'inferno.repositories.results',
|
13
|
+
test_runs_repo: 'inferno.repositories.test_runs',
|
14
|
+
tests_repo: 'inferno.repositories.tests'
|
16
15
|
]
|
17
16
|
|
18
|
-
def self.call(
|
19
|
-
new.call(
|
17
|
+
def self.call(...)
|
18
|
+
new.call(...)
|
20
19
|
end
|
21
20
|
|
22
|
-
#
|
23
|
-
|
24
|
-
|
25
|
-
def request
|
26
|
-
@request ||= Inferno::Entities::Request.from_rack_env(@params.env)
|
21
|
+
# @private
|
22
|
+
def test_run_identifier_block
|
23
|
+
self.class.singleton_class.instance_variable_get(:@test_run_identifier_block)
|
27
24
|
end
|
28
25
|
|
29
26
|
# @private
|
30
|
-
def
|
31
|
-
|
32
|
-
test_runs_repo.find_latest_waiting_by_identifier(test_run_identifier)
|
27
|
+
def find_test_run(test_run_identifier)
|
28
|
+
test_runs_repo.find_latest_waiting_by_identifier(test_run_identifier)
|
33
29
|
end
|
34
30
|
|
35
31
|
# @private
|
36
|
-
def
|
37
|
-
|
32
|
+
def find_waiting_result(test_run)
|
33
|
+
results_repo.find_waiting_result(test_run_id: test_run.id)
|
38
34
|
end
|
39
35
|
|
40
36
|
# @private
|
41
|
-
def update_result
|
37
|
+
def update_result(waiting_result)
|
42
38
|
results_repo.pass_waiting_result(waiting_result.id)
|
43
39
|
end
|
44
40
|
|
45
41
|
# @private
|
46
|
-
def persist_request
|
42
|
+
def persist_request(request, test_run, waiting_result, test)
|
47
43
|
requests_repo.create(
|
48
44
|
request.to_hash.merge(
|
49
45
|
test_session_id: test_run.test_session_id,
|
@@ -54,35 +50,41 @@ module Inferno
|
|
54
50
|
end
|
55
51
|
|
56
52
|
# @private
|
57
|
-
def redirect_route
|
58
|
-
"#{Application['base_url']}/test_sessions/#{test_run.test_session_id}##{resume_ui_at_id}"
|
53
|
+
def redirect_route(test_run, test)
|
54
|
+
"#{Application['base_url']}/test_sessions/#{test_run.test_session_id}##{resume_ui_at_id(test_run, test)}"
|
59
55
|
end
|
60
56
|
|
61
57
|
# @private
|
62
|
-
def
|
63
|
-
|
58
|
+
def find_test(waiting_result)
|
59
|
+
tests_repo.find(waiting_result.test_id)
|
64
60
|
end
|
65
61
|
|
66
62
|
# @private
|
67
|
-
def resume_ui_at_id
|
63
|
+
def resume_ui_at_id(test_run, test)
|
68
64
|
test_run.test_suite_id || test_run.test_group_id || test.parent.id
|
69
65
|
end
|
70
66
|
|
71
67
|
# @private
|
72
|
-
def
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
68
|
+
def handle(req, res)
|
69
|
+
request = Inferno::Entities::Request.from_hanami_request(req)
|
70
|
+
|
71
|
+
test_run_identifier = instance_exec(request, &test_run_identifier_block)
|
72
|
+
|
73
|
+
test_run = find_test_run(test_run_identifier)
|
74
|
+
|
75
|
+
halt 500, "Unable to find test run with identifier '#{test_run_identifier}'." if test_run.nil?
|
77
76
|
|
78
77
|
test_runs_repo.mark_as_no_longer_waiting(test_run.id)
|
79
78
|
|
80
|
-
|
81
|
-
|
79
|
+
waiting_result = find_waiting_result(test_run)
|
80
|
+
test = find_test(waiting_result)
|
81
|
+
|
82
|
+
update_result(waiting_result)
|
83
|
+
persist_request(request, test_run, waiting_result, test)
|
82
84
|
|
83
85
|
Jobs.perform(Jobs::ResumeTestRun, test_run.id)
|
84
86
|
|
85
|
-
redirect_to redirect_route
|
87
|
+
res.redirect_to redirect_route(test_run, test)
|
86
88
|
end
|
87
89
|
end
|
88
90
|
end
|
data/lib/inferno/dsl/runnable.rb
CHANGED
@@ -88,7 +88,7 @@ module Inferno
|
|
88
88
|
# alias the method name they wish to use to define child entities to this
|
89
89
|
# method.
|
90
90
|
# @private
|
91
|
-
def define_child(*args, &
|
91
|
+
def define_child(*args, &)
|
92
92
|
hash_args = process_args(args)
|
93
93
|
|
94
94
|
klass = create_child_class(hash_args)
|
@@ -99,7 +99,7 @@ module Inferno
|
|
99
99
|
|
100
100
|
configure_child_class(klass, hash_args)
|
101
101
|
|
102
|
-
handle_child_definition_block(klass, &
|
102
|
+
handle_child_definition_block(klass, &)
|
103
103
|
|
104
104
|
klass.add_self_to_repository
|
105
105
|
|
@@ -190,8 +190,8 @@ module Inferno
|
|
190
190
|
end
|
191
191
|
|
192
192
|
# @private
|
193
|
-
def handle_child_definition_block(klass, &
|
194
|
-
klass.class_eval(&
|
193
|
+
def handle_child_definition_block(klass, &)
|
194
|
+
klass.class_eval(&) if block_given?
|
195
195
|
end
|
196
196
|
|
197
197
|
# Set/Get a runnable's id
|
@@ -353,9 +353,8 @@ module Inferno
|
|
353
353
|
# {Inferno::Entities::Request} object with the information for the
|
354
354
|
# incoming request.
|
355
355
|
def resume_test_route(method, path, &block)
|
356
|
-
route_class = Class.new(ResumeTestRoute) do
|
357
|
-
|
358
|
-
define_method(:request_name, -> { options[:name] })
|
356
|
+
route_class = Class.new(ResumeTestRoute) do |klass|
|
357
|
+
klass.singleton_class.instance_variable_set(:@test_run_identifier_block, block)
|
359
358
|
end
|
360
359
|
|
361
360
|
route(method, path, route_class)
|
@@ -375,7 +374,7 @@ module Inferno
|
|
375
374
|
# app](http://sinatrarb.com/)) as described in the [Hanami Router
|
376
375
|
# documentation.](https://github.com/hanami/router/tree/f41001d4c3ee9e2d2c7bb142f74b43f8e1d3a265#mount-rack-applications)
|
377
376
|
def route(method, path, handler)
|
378
|
-
Inferno.routes << { method
|
377
|
+
Inferno.routes << { method:, path:, handler:, suite: }
|
379
378
|
end
|
380
379
|
|
381
380
|
# @private
|
@@ -401,7 +400,7 @@ module Inferno
|
|
401
400
|
def required_suite_options(suite_option_requirements)
|
402
401
|
@suite_option_requirements =
|
403
402
|
suite_option_requirements.map do |key, value|
|
404
|
-
DSL::SuiteOption.new(id: key, value:
|
403
|
+
DSL::SuiteOption.new(id: key, value:)
|
405
404
|
end
|
406
405
|
end
|
407
406
|
|
@@ -35,13 +35,13 @@ module Inferno
|
|
35
35
|
|
36
36
|
def to_hash
|
37
37
|
{
|
38
|
-
id
|
39
|
-
request_id
|
40
|
-
type
|
41
|
-
name
|
42
|
-
value
|
43
|
-
created_at
|
44
|
-
updated_at:
|
38
|
+
id:,
|
39
|
+
request_id:,
|
40
|
+
type:,
|
41
|
+
name:,
|
42
|
+
value:,
|
43
|
+
created_at:,
|
44
|
+
updated_at:
|
45
45
|
}.compact
|
46
46
|
end
|
47
47
|
end
|
@@ -89,8 +89,8 @@ module Inferno
|
|
89
89
|
# @return [Hash]
|
90
90
|
def request
|
91
91
|
{
|
92
|
-
verb
|
93
|
-
url
|
92
|
+
verb:,
|
93
|
+
url:,
|
94
94
|
headers: request_headers,
|
95
95
|
body: request_body
|
96
96
|
}
|
@@ -101,7 +101,7 @@ module Inferno
|
|
101
101
|
# @return [Hash]
|
102
102
|
def response
|
103
103
|
{
|
104
|
-
status
|
104
|
+
status:,
|
105
105
|
headers: response_headers,
|
106
106
|
body: response_body
|
107
107
|
}
|
@@ -110,20 +110,20 @@ module Inferno
|
|
110
110
|
# @private
|
111
111
|
def to_hash
|
112
112
|
{
|
113
|
-
id
|
114
|
-
verb
|
115
|
-
url
|
116
|
-
direction
|
117
|
-
status
|
118
|
-
name
|
119
|
-
request_body
|
120
|
-
response_body
|
121
|
-
result_id
|
122
|
-
test_session_id
|
113
|
+
id:,
|
114
|
+
verb:,
|
115
|
+
url:,
|
116
|
+
direction:,
|
117
|
+
status:,
|
118
|
+
name:,
|
119
|
+
request_body:,
|
120
|
+
response_body:,
|
121
|
+
result_id:,
|
122
|
+
test_session_id:,
|
123
123
|
request_headers: request_headers.map(&:to_hash),
|
124
124
|
response_headers: response_headers.map(&:to_hash),
|
125
|
-
created_at
|
126
|
-
updated_at:
|
125
|
+
created_at:,
|
126
|
+
updated_at:
|
127
127
|
}.compact
|
128
128
|
end
|
129
129
|
|
@@ -136,22 +136,21 @@ module Inferno
|
|
136
136
|
|
137
137
|
class << self
|
138
138
|
# @private
|
139
|
-
def
|
140
|
-
|
141
|
-
url
|
142
|
-
url += "?#{rack_request.query_string}" if rack_request.query_string.present?
|
139
|
+
def from_hanami_request(request, name: nil)
|
140
|
+
url = "#{request.base_url}#{request.path}"
|
141
|
+
url += "?#{request.query_string}" if request.query_string.present?
|
143
142
|
request_headers =
|
144
|
-
env
|
143
|
+
request.params.env
|
145
144
|
.select { |key, _| key.start_with? 'HTTP_' }
|
146
145
|
.transform_keys { |key| key.delete_prefix('HTTP_').tr('_', '-').downcase }
|
147
|
-
.map { |header_name, value| Header.new(name: header_name, value
|
146
|
+
.map { |header_name, value| Header.new(name: header_name, value:, type: 'request') }
|
148
147
|
|
149
148
|
new(
|
150
|
-
verb:
|
151
|
-
url
|
149
|
+
verb: request.request_method.downcase,
|
150
|
+
url:,
|
152
151
|
direction: 'incoming',
|
153
|
-
name
|
154
|
-
request_body:
|
152
|
+
name:,
|
153
|
+
request_body: request.body.string,
|
155
154
|
headers: request_headers
|
156
155
|
)
|
157
156
|
end
|
@@ -160,20 +159,20 @@ module Inferno
|
|
160
159
|
def from_http_response(response, test_session_id:, direction: 'outgoing', name: nil)
|
161
160
|
request_headers =
|
162
161
|
response.env.request_headers
|
163
|
-
.map { |header_name, value| Header.new(name: header_name.downcase, value
|
162
|
+
.map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') }
|
164
163
|
response_headers =
|
165
164
|
response.headers
|
166
|
-
.map { |header_name, value| Header.new(name: header_name.downcase, value
|
165
|
+
.map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') }
|
167
166
|
|
168
167
|
new(
|
169
168
|
verb: response.env.method,
|
170
169
|
url: response.env.url.to_s,
|
171
|
-
direction
|
172
|
-
name
|
170
|
+
direction:,
|
171
|
+
name:,
|
173
172
|
status: response.status,
|
174
173
|
request_body: response.env.request_body,
|
175
174
|
response_body: response.body,
|
176
|
-
test_session_id
|
175
|
+
test_session_id:,
|
177
176
|
headers: request_headers + response_headers
|
178
177
|
)
|
179
178
|
end
|
@@ -183,9 +182,9 @@ module Inferno
|
|
183
182
|
request = reply.request
|
184
183
|
response = reply.response
|
185
184
|
request_headers = request[:headers]
|
186
|
-
.map { |header_name, value| Header.new(name: header_name.downcase, value
|
185
|
+
.map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') }
|
187
186
|
response_headers = response[:headers]
|
188
|
-
.map { |header_name, value| Header.new(name: header_name.downcase, value
|
187
|
+
.map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') }
|
189
188
|
request_body =
|
190
189
|
if request.dig(:headers, 'Content-Type')&.include?('application/x-www-form-urlencoded')
|
191
190
|
URI.encode_www_form(request[:payload])
|
@@ -196,12 +195,12 @@ module Inferno
|
|
196
195
|
new(
|
197
196
|
verb: request[:method],
|
198
197
|
url: request[:url],
|
199
|
-
direction
|
200
|
-
name
|
198
|
+
direction:,
|
199
|
+
name:,
|
201
200
|
status: response[:code].to_i,
|
202
|
-
request_body
|
201
|
+
request_body:,
|
203
202
|
response_body: response[:body],
|
204
|
-
test_session_id
|
203
|
+
test_session_id:,
|
205
204
|
headers: request_headers + response_headers
|
206
205
|
)
|
207
206
|
end
|
@@ -26,12 +26,12 @@ module Inferno
|
|
26
26
|
|
27
27
|
def to_hash
|
28
28
|
{
|
29
|
-
id
|
30
|
-
name
|
31
|
-
value
|
32
|
-
test_session_id
|
33
|
-
created_at
|
34
|
-
updated_at:
|
29
|
+
id:,
|
30
|
+
name:,
|
31
|
+
value:,
|
32
|
+
test_session_id:,
|
33
|
+
created_at:,
|
34
|
+
updated_at:
|
35
35
|
}
|
36
36
|
end
|
37
37
|
end
|