inferno_core 0.3.3 → 0.3.6

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.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/lib/inferno/apps/web/controllers/test_runs/create.rb +8 -4
  3. data/lib/inferno/apps/web/controllers/test_sessions/create.rb +6 -3
  4. data/lib/inferno/apps/web/router.rb +5 -0
  5. data/lib/inferno/apps/web/serializers/input.rb +6 -2
  6. data/lib/inferno/apps/web/serializers/suite_option.rb +13 -0
  7. data/lib/inferno/apps/web/serializers/test.rb +4 -1
  8. data/lib/inferno/apps/web/serializers/test_group.rb +12 -3
  9. data/lib/inferno/apps/web/serializers/test_session.rb +5 -3
  10. data/lib/inferno/apps/web/serializers/test_suite.rb +10 -2
  11. data/lib/inferno/config/boot/db.rb +1 -1
  12. data/lib/inferno/config/boot/presets.rb +1 -1
  13. data/lib/inferno/config/boot.rb +1 -1
  14. data/lib/inferno/db/migrations/007_add_suite_options.rb +5 -0
  15. data/lib/inferno/db/schema.rb +1 -0
  16. data/lib/inferno/dsl/configurable.rb +1 -1
  17. data/lib/inferno/dsl/fhir_client.rb +22 -10
  18. data/lib/inferno/dsl/fhir_validation.rb +35 -12
  19. data/lib/inferno/dsl/http_client.rb +57 -35
  20. data/lib/inferno/dsl/http_client_builder.rb +6 -1
  21. data/lib/inferno/dsl/input_output_handling.rb +56 -42
  22. data/lib/inferno/dsl/runnable.rb +36 -10
  23. data/lib/inferno/dsl/suite_option.rb +40 -0
  24. data/lib/inferno/dsl/tcp_exception_handler.rb +11 -0
  25. data/lib/inferno/entities/input.rb +2 -1
  26. data/lib/inferno/entities/test.rb +7 -3
  27. data/lib/inferno/entities/test_group.rb +4 -4
  28. data/lib/inferno/entities/test_session.rb +40 -1
  29. data/lib/inferno/entities/test_suite.rb +18 -14
  30. data/lib/inferno/public/bundle.js +15 -15
  31. data/lib/inferno/repositories/presets.rb +10 -1
  32. data/lib/inferno/repositories/test_sessions.rb +24 -0
  33. data/lib/inferno/test_runner.rb +9 -3
  34. data/lib/inferno/version.rb +1 -1
  35. data/spec/support/factory_bot.rb +6 -0
  36. metadata +34 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 884936b347ee4892198605b7ae408f3889e74bed0a4e33b6ec2a5ee7ed3adcd9
4
- data.tar.gz: b0e30f11313a6a5b690e96a08fdb083ba9d85b94b512ec105fce75631802f0cb
3
+ metadata.gz: 2f0cad7d368810c89ee2571e1f8aa6705d6b74b1ad058b8f179269a7705c2df7
4
+ data.tar.gz: 7f1ab19849ca3454f536b06963df78abc91c5dc7cbde24e796338836cd081e10
5
5
  SHA512:
6
- metadata.gz: 13b145c224d9b762b2ae8019048d6775dea2bd0ce47abcb3450959e3148224a523914eaf06b480a25d1a065c449e32b9c64ed83056118b611e8be2c4d9640755
7
- data.tar.gz: 78a7bd5437739a2e1e7384dc500d46a99c8795f03638023839fdf4c24131fcc9a6ba8ca1ec507cd0b0bd559d8c9741e07ce2c6e3b04954b72bf6ba4ce7158805
6
+ metadata.gz: b7ff909be62d859f3a0755f787fb8d893edaadffd16cc70dd18f47cfe0184b2ec82330a7f51a02617c4b8afb6710e3282492a9a2f23cf82e37650548cbd9dd4b
7
+ data.tar.gz: 5832f7eb12e90626ebd9ca84e945a3afc631e5d63d024381548ed7c3fc373ff85ca9ea34533a79eefedb7e8ab8d80d65229d2fffd180c7d289586528b29dfb03
@@ -11,8 +11,8 @@ module Inferno
11
11
 
12
12
  PARAMS = [:test_session_id, :test_suite_id, :test_group_id, :test_id].freeze
13
13
 
14
- def verify_runnable(runnable, inputs)
15
- missing_inputs = runnable&.missing_inputs(inputs)
14
+ def verify_runnable(runnable, inputs, selected_suite_options)
15
+ missing_inputs = runnable&.missing_inputs(inputs, selected_suite_options)
16
16
  user_runnable = runnable&.user_runnable?
17
17
  raise Inferno::Exceptions::RequiredInputsNotFound, missing_inputs if missing_inputs&.any?
18
18
  raise Inferno::Exceptions::NotUserRunnableException unless user_runnable
@@ -26,7 +26,7 @@ module Inferno
26
26
  &.last
27
27
 
28
28
  if input.nil?
29
- Inferno::Application['logger'].warning(
29
+ Inferno::Application['logger'].warn(
30
30
  "Unknown input `#{input_params[:name]}` for #{test_run.runnable.id}: #{test_run.runnable.title}"
31
31
  )
32
32
  next
@@ -51,7 +51,11 @@ module Inferno
51
51
  return
52
52
  end
53
53
 
54
- verify_runnable(repo.build_entity(create_params(params)).runnable, params[:inputs])
54
+ verify_runnable(
55
+ repo.build_entity(create_params(params)).runnable,
56
+ params[:inputs],
57
+ test_session.suite_options
58
+ )
55
59
 
56
60
  test_run = repo.create(create_params(params).merge(status: 'queued'))
57
61
 
@@ -3,9 +3,12 @@ module Inferno
3
3
  module Controllers
4
4
  module TestSessions
5
5
  class Create < Controller
6
- PARAMS = [:test_suite_id].freeze
6
+ PARAMS = [:test_suite_id, :suite_options].freeze
7
+
8
+ def call(raw_params)
9
+ params = raw_params.to_h
10
+ params.merge!(JSON.parse(request.body.string).symbolize_keys) unless request.body.string.blank?
7
11
 
8
- def call(params)
9
12
  session = repo.create(create_params(params))
10
13
 
11
14
  repo.apply_preset(session.id, params[:preset_id]) if params[:preset_id].present?
@@ -21,7 +24,7 @@ module Inferno
21
24
  end
22
25
 
23
26
  def create_params(params)
24
- params.to_h.slice(*PARAMS)
27
+ params.slice(*PARAMS)
25
28
  end
26
29
  end
27
30
  end
@@ -51,6 +51,11 @@ module Inferno
51
51
  send(route[:method], path, to: route[:handler])
52
52
  end
53
53
  end
54
+
55
+ Inferno::Repositories::TestSuites.all.map { |suite| "/#{suite.id}" }.each do |suite_path|
56
+ Application['logger'].info("Registering suite route: #{suite_path}")
57
+ get suite_path, to: ->(_env) { [200, {}, [client_page]] }
58
+ end
54
59
  end
55
60
  end
56
61
  end
@@ -6,9 +6,13 @@ module Inferno
6
6
  class Input < Serializer
7
7
  identifier :name
8
8
 
9
- field :label, if: :field_present?
9
+ field :title, if: :field_present?
10
10
  field :description, if: :field_present?
11
- field :required, if: :field_present?
11
+ field :type, if: :field_present?
12
+ field :default, if: :field_present?
13
+ field :optional, if: :field_present?
14
+ field :options, if: :field_present?
15
+ field :locked, if: :field_present?
12
16
  field :value, if: :field_present?
13
17
  end
14
18
  end
@@ -0,0 +1,13 @@
1
+ module Inferno
2
+ module Web
3
+ module Serializers
4
+ class SuiteOption < Serializer
5
+ identifier :id
6
+ field :title, if: :field_present?
7
+ field :description, if: :field_present?
8
+ field :list_options, if: :field_present?
9
+ field :value, if: :field_present?
10
+ end
11
+ end
12
+ end
13
+ end
@@ -7,7 +7,10 @@ module Inferno
7
7
  field :short_id
8
8
  field :title
9
9
  field :short_title
10
- field :available_inputs, name: :inputs, extractor: HashValueExtractor, blueprint: Input
10
+ field :inputs do |test, options|
11
+ suite_options = options[:suite_options]
12
+ Input.render_as_hash(test.available_inputs(suite_options).values)
13
+ end
11
14
  field :output_definitions, name: :outputs, extractor: HashValueExtractor
12
15
  field :description
13
16
  field :short_description
@@ -15,9 +15,18 @@ module Inferno
15
15
  field :user_runnable?, name: :user_runnable
16
16
  field :optional?, name: :optional
17
17
 
18
- association :groups, name: :test_groups, blueprint: TestGroup
19
- association :tests, blueprint: Test
20
- field :available_inputs, name: :inputs, extractor: HashValueExtractor, blueprint: Input
18
+ field :test_groups do |group, options|
19
+ suite_options = options[:suite_options]
20
+ TestGroup.render_as_hash(group.groups(suite_options), suite_options: suite_options)
21
+ end
22
+ field :tests do |group, options|
23
+ suite_options = options[:suite_options]
24
+ Test.render_as_hash(group.tests(suite_options), suite_options: suite_options)
25
+ end
26
+ field :inputs do |group, options|
27
+ suite_options = options[:suite_options]
28
+ Input.render_as_hash(group.available_inputs(suite_options).values)
29
+ end
21
30
  field :output_definitions, name: :outputs, extractor: HashValueExtractor
22
31
  end
23
32
  end
@@ -1,3 +1,4 @@
1
+ require_relative 'suite_option'
1
2
  require_relative 'test_suite'
2
3
 
3
4
  module Inferno
@@ -7,10 +8,11 @@ module Inferno
7
8
  identifier :id
8
9
 
9
10
  field :test_suite_id
11
+ association :suite_options, blueprint: SuiteOption
10
12
 
11
- association :test_suite, blueprint: TestSuite, view: :full
12
- # association :test_runs, blueprint: TestRun
13
- # association :results, blueprint: Result
13
+ field :test_suite do |session, _options|
14
+ TestSuite.render_as_hash(session.test_suite, view: :full, suite_options: session.suite_options)
15
+ end
14
16
  end
15
17
  end
16
18
  end
@@ -11,14 +11,22 @@ module Inferno
11
11
  field :input_instructions
12
12
  field :test_count
13
13
  field :version
14
+ field :links
15
+ association :suite_options, blueprint: SuiteOption
14
16
  association :presets, view: :summary, blueprint: Preset
15
17
  end
16
18
 
17
19
  view :full do
18
20
  include_view :summary
19
- association :groups, name: :test_groups, blueprint: TestGroup
21
+ field :test_groups do |suite, options|
22
+ suite_options = options[:suite_options]
23
+ TestGroup.render_as_hash(suite.groups(suite_options), suite_options: suite_options)
24
+ end
20
25
  field :configuration_messages
21
- field :available_inputs, name: :inputs, extractor: HashValueExtractor, blueprint: Input
26
+ field :inputs do |suite, options|
27
+ suite_options = options[:suite_options]
28
+ Input.render_as_hash(suite.available_inputs(suite_options).values)
29
+ end
22
30
  end
23
31
  end
24
32
  end
@@ -11,7 +11,7 @@ Inferno::Application.boot(:db) do
11
11
 
12
12
  config_path = File.expand_path('database.yml', File.join(Dir.pwd, 'config'))
13
13
  config_contents = ERB.new(File.read(config_path)).result
14
- config = YAML.safe_load(config_contents)[ENV['APP_ENV']]
14
+ config = YAML.safe_load(config_contents)[ENV.fetch('APP_ENV', nil)]
15
15
  .merge(logger: Inferno::Application['logger'])
16
16
  connection_attempts_remaining = ENV.fetch('MAX_DB_CONNECTION_ATTEMPTS', '10').to_i
17
17
  connection_retry_delay = ENV.fetch('DB_CONNECTION_RETRY_DELAY', '5').to_i
@@ -4,7 +4,7 @@ Inferno::Application.boot(:presets) do
4
4
  init do
5
5
  use :suites
6
6
 
7
- files_to_load = Dir.glob(File.join(Dir.pwd, 'config', 'presets', '*.json'))
7
+ files_to_load = Dir.glob(['config/presets/*.json', 'config/presets/*.json.erb'])
8
8
  files_to_load.map! { |path| File.realpath(path) }
9
9
  presets_repo = Inferno::Repositories::Presets.new
10
10
 
@@ -4,4 +4,4 @@ ENV['APP_ENV'] ||= 'development'
4
4
 
5
5
  root_path = Dir.pwd
6
6
 
7
- Dotenv.load(File.join(root_path, '.env'), File.join(root_path, ".env.#{ENV['APP_ENV']}"))
7
+ Dotenv.load(File.join(root_path, '.env'), File.join(root_path, ".env.#{ENV.fetch('APP_ENV', nil)}"))
@@ -0,0 +1,5 @@
1
+ Sequel.migration do
2
+ change do
3
+ add_column :test_sessions, :suite_options, String, text: true, size: 255
4
+ end
5
+ end
@@ -9,6 +9,7 @@ Sequel.migration do
9
9
  String :test_suite_id, :size=>255, :null=>false
10
10
  DateTime :created_at, :null=>false
11
11
  DateTime :updated_at, :null=>false
12
+ String :suite_options, :text=>true
12
13
 
13
14
  primary_key [:id]
14
15
  end
@@ -16,7 +16,7 @@ module Inferno
16
16
 
17
17
  @config.apply(new_configuration)
18
18
 
19
- children.each { |child| child.config(new_configuration) }
19
+ all_children.each { |child| child.config(new_configuration) }
20
20
 
21
21
  @config
22
22
  end
@@ -1,4 +1,5 @@
1
1
  require_relative 'request_storage'
2
+ require_relative 'tcp_exception_handler'
2
3
 
3
4
  module Inferno
4
5
  module DSL
@@ -40,6 +41,7 @@ module Inferno
40
41
  klass.extend ClassMethods
41
42
  klass.extend Forwardable
42
43
  klass.include RequestStorage
44
+ klass.include TCPExceptionHandler
43
45
 
44
46
  klass.def_delegators 'self.class', :profile_url, :validator_url
45
47
  end
@@ -73,11 +75,13 @@ module Inferno
73
75
  # @return [Inferno::Entities::Request]
74
76
  def fhir_operation(path, body: nil, client: :default, name: nil, headers: {})
75
77
  store_request_and_refresh_token(fhir_client(client), name) do
76
- operation_headers = fhir_client(client).fhir_headers
77
- operation_headers.merge!('Content-Type' => 'application/fhir+json') if body.present?
78
- operation_headers.merge!(headers) if headers.present?
78
+ tcp_exception_handler do
79
+ operation_headers = fhir_client(client).fhir_headers
80
+ operation_headers.merge!('Content-Type' => 'application/fhir+json') if body.present?
81
+ operation_headers.merge!(headers) if headers.present?
79
82
 
80
- fhir_client(client).send(:post, path, body, operation_headers)
83
+ fhir_client(client).send(:post, path, body, operation_headers)
84
+ end
81
85
  end
82
86
  end
83
87
 
@@ -89,8 +93,10 @@ module Inferno
89
93
  # @return [Inferno::Entities::Request]
90
94
  def fhir_get_capability_statement(client: :default, name: nil)
91
95
  store_request_and_refresh_token(fhir_client(client), name) do
92
- fhir_client(client).conformance_statement
93
- fhir_client(client).reply
96
+ tcp_exception_handler do
97
+ fhir_client(client).conformance_statement
98
+ fhir_client(client).reply
99
+ end
94
100
  end
95
101
  end
96
102
 
@@ -104,7 +110,9 @@ module Inferno
104
110
  # @return [Inferno::Entities::Request]
105
111
  def fhir_read(resource_type, id, client: :default, name: nil)
106
112
  store_request_and_refresh_token(fhir_client(client), name) do
107
- fhir_client(client).read(fhir_class_from_resource_type(resource_type), id)
113
+ tcp_exception_handler do
114
+ fhir_client(client).read(fhir_class_from_resource_type(resource_type), id)
115
+ end
108
116
  end
109
117
  end
110
118
 
@@ -126,8 +134,10 @@ module Inferno
126
134
  end
127
135
 
128
136
  store_request_and_refresh_token(fhir_client(client), name) do
129
- fhir_client(client)
130
- .search(fhir_class_from_resource_type(resource_type), { search: search })
137
+ tcp_exception_handler do
138
+ fhir_client(client)
139
+ .search(fhir_class_from_resource_type(resource_type), { search: search })
140
+ end
131
141
  end
132
142
  end
133
143
 
@@ -141,7 +151,9 @@ module Inferno
141
151
  # @return [Inferno::Entities::Request]
142
152
  def fhir_delete(resource_type, id, client: :default, name: nil)
143
153
  store_request('outgoing', name) do
144
- fhir_client(client).destroy(fhir_class_from_resource_type(resource_type), id)
154
+ tcp_exception_handler do
155
+ fhir_client(client).destroy(fhir_class_from_resource_type(resource_type), id)
156
+ end
145
157
  end
146
158
  end
147
159
 
@@ -1,5 +1,4 @@
1
1
  require_relative '../ext/fhir_models'
2
-
3
2
  module Inferno
4
3
  module DSL
5
4
  # This module contains the methods needed to configure a validator to
@@ -39,13 +38,16 @@ module Inferno
39
38
  # Find a particular validator. Looks through a runnable's parents up to
40
39
  # the suite to find a validator with a particular name
41
40
  def find_validator(validator_name)
42
- self.class.find_validator(validator_name)
41
+ self.class.find_validator(validator_name, suite_options)
43
42
  end
44
43
 
45
44
  class Validator
45
+ attr_reader :requirements
46
+
46
47
  # @private
47
- def initialize(&block)
48
+ def initialize(requirements = nil, &block)
48
49
  instance_eval(&block)
50
+ @requirements = requirements
49
51
  end
50
52
 
51
53
  # @private
@@ -115,7 +117,7 @@ module Inferno
115
117
 
116
118
  outcome = FHIR::OperationOutcome.new(JSON.parse(validate(resource, profile_url)))
117
119
 
118
- message_hashes = outcome.issue&.map { |issue| message_hash_from_issue(issue) } || []
120
+ message_hashes = outcome.issue&.map { |issue| message_hash_from_issue(issue, resource) } || []
119
121
 
120
122
  message_hashes.concat(additional_validation_messages(resource, profile_url))
121
123
 
@@ -132,10 +134,10 @@ module Inferno
132
134
  end
133
135
 
134
136
  # @private
135
- def message_hash_from_issue(issue)
137
+ def message_hash_from_issue(issue, resource)
136
138
  {
137
139
  type: issue_severity(issue),
138
- message: issue_message(issue)
140
+ message: issue_message(issue, resource)
139
141
  }
140
142
  end
141
143
 
@@ -152,14 +154,16 @@ module Inferno
152
154
  end
153
155
 
154
156
  # @private
155
- def issue_message(issue)
157
+ def issue_message(issue, resource)
156
158
  location = if issue.respond_to?(:expression)
157
159
  issue.expression&.join(', ')
158
160
  else
159
161
  issue.location&.join(', ')
160
162
  end
161
163
 
162
- "#{location}: #{issue&.details&.text}"
164
+ location_prefix = resource.id ? "#{resource.resourceType}/#{resource.id}" : resource.resourceType
165
+
166
+ "#{location_prefix}: #{location}: #{issue&.details&.text}"
163
167
  end
164
168
 
165
169
  # Post a resource to the validation service for validating.
@@ -198,14 +202,33 @@ module Inferno
198
202
  #
199
203
  # @param name [Symbol] the name of the validator, only needed if you are
200
204
  # using multiple validators
201
- def validator(name = :default, &block)
202
- fhir_validators[name] = Inferno::DSL::FHIRValidation::Validator.new(&block)
205
+ # @param required_suite_options [Hash] suite options that must be
206
+ # selected in order to use this validator
207
+ def validator(name = :default, required_suite_options: nil, &block)
208
+ current_validators = fhir_validators[name] || []
209
+
210
+ new_validator = Inferno::DSL::FHIRValidation::Validator.new(required_suite_options, &block)
211
+
212
+ current_validators.reject! { |validator| validator.requirements == required_suite_options }
213
+ current_validators << new_validator
214
+
215
+ fhir_validators[name] = current_validators
203
216
  end
204
217
 
205
218
  # Find a particular validator. Looks through a runnable's parents up to
206
219
  # the suite to find a validator with a particular name
207
- def find_validator(validator_name)
208
- validator = fhir_validators[validator_name] || parent&.find_validator(validator_name)
220
+ def find_validator(validator_name, selected_suite_options = nil)
221
+ validators = fhir_validators[validator_name] ||
222
+ Array.wrap(parent&.find_validator(validator_name, selected_suite_options))
223
+
224
+ validator =
225
+ if selected_suite_options.present?
226
+ validators.find do |possible_validator|
227
+ possible_validator.requirements.nil? || selected_suite_options >= possible_validator.requirements
228
+ end
229
+ else
230
+ validators.first
231
+ end
209
232
 
210
233
  raise Exceptions::ValidatorNotFoundException, validator_name if validator.nil?
211
234
 
@@ -1,4 +1,7 @@
1
+ require 'faraday_middleware'
2
+
1
3
  require_relative 'request_storage'
4
+ require_relative 'tcp_exception_handler'
2
5
 
3
6
  module Inferno
4
7
  module DSL
@@ -31,6 +34,7 @@ module Inferno
31
34
  def self.included(klass)
32
35
  klass.extend ClassMethods
33
36
  klass.include RequestStorage
37
+ klass.include TCPExceptionHandler
34
38
  end
35
39
 
36
40
  # Return a previously defined HTTP client
@@ -44,7 +48,9 @@ module Inferno
44
48
  definition = self.class.http_client_definitions[client]
45
49
  return nil if definition.nil?
46
50
 
47
- http_clients[client] = HTTPClientBuilder.new.build(self, definition)
51
+ tcp_exception_handler do
52
+ http_clients[client] = HTTPClientBuilder.new.build(self, definition)
53
+ end
48
54
  end
49
55
 
50
56
  # @private
@@ -65,18 +71,28 @@ module Inferno
65
71
  # @return [Inferno::Entities::Request]
66
72
  def get(url = '', client: :default, name: nil, **options)
67
73
  store_request('outgoing', name) do
68
- client = http_client(client)
69
-
70
- if client
71
- client.get(url, nil, options[:headers])
72
- elsif url.match?(%r{\Ahttps?://})
73
- Faraday.get(url, nil, options[:headers])
74
- else
75
- raise StandardError, 'Must use an absolute url or define an HTTP client with a base url'
74
+ tcp_exception_handler do
75
+ client = http_client(client)
76
+
77
+ if client
78
+ client.get(url, nil, options[:headers])
79
+ elsif url.match?(%r{\Ahttps?://})
80
+ connection.get(url, nil, options[:headers])
81
+ else
82
+ raise StandardError, 'Must use an absolute url or define an HTTP client with a base url'
83
+ end
76
84
  end
77
85
  end
78
86
  end
79
87
 
88
+ # @private
89
+ def connection
90
+ Faraday.new do |f|
91
+ f.request :url_encoded
92
+ f.use FaradayMiddleware::FollowRedirects
93
+ end
94
+ end
95
+
80
96
  # Perform an HTTP POST request
81
97
  #
82
98
  # @param url [String] if this request is using a defined client, this will
@@ -91,14 +107,16 @@ module Inferno
91
107
  # @return [Inferno::Entities::Request]
92
108
  def post(url = '', body: nil, client: :default, name: nil, **options)
93
109
  store_request('outgoing', name) do
94
- client = http_client(client)
95
-
96
- if client
97
- client.post(url, body, options[:headers])
98
- elsif url.match?(%r{\Ahttps?://})
99
- Faraday.post(url, body, options[:headers])
100
- else
101
- raise StandardError, 'Must use an absolute url or define an HTTP client with a base url'
110
+ tcp_exception_handler do
111
+ client = http_client(client)
112
+
113
+ if client
114
+ client.post(url, body, options[:headers])
115
+ elsif url.match?(%r{\Ahttps?://})
116
+ connection.post(url, body, options[:headers])
117
+ else
118
+ raise StandardError, 'Must use an absolute url or define an HTTP client with a base url'
119
+ end
102
120
  end
103
121
  end
104
122
  end
@@ -114,14 +132,16 @@ module Inferno
114
132
  # @return [Inferno::Entities::Request]
115
133
  def delete(url = '', client: :default, name: :nil, **options)
116
134
  store_request('outgoing', name) do
117
- client = http_client(client)
118
-
119
- if client
120
- client.delete(url, nil, options[:headers])
121
- elsif url.match?(%r{\Ahttps?://})
122
- Faraday.delete(url, nil, options[:headers])
123
- else
124
- raise StandardError, 'Must use an absolute url or define an HTTP client with a base url'
135
+ tcp_exception_handler do
136
+ client = http_client(client)
137
+
138
+ if client
139
+ client.delete(url, nil, options[:headers])
140
+ elsif url.match?(%r{\Ahttps?://})
141
+ connection.delete(url, nil, options[:headers])
142
+ else
143
+ raise StandardError, 'Must use an absolute url or define an HTTP client with a base url'
144
+ end
125
145
  end
126
146
  end
127
147
  end
@@ -151,17 +171,19 @@ module Inferno
151
171
  end
152
172
 
153
173
  store_request('outgoing', name) do
154
- client = http_client(client)
155
-
156
- if client
157
- response = client.get(url, nil, options[:headers]) { |req| req.options.on_data = collector }
158
- elsif url.match?(%r{\Ahttps?://})
159
- response = Faraday.get(url, nil, options[:headers]) { |req| req.options.on_data = collector }
160
- else
161
- raise StandardError, 'Must use an absolute url or define an HTTP client with a base url'
174
+ tcp_exception_handler do
175
+ client = http_client(client)
176
+
177
+ if client
178
+ response = client.get(url, nil, options[:headers]) { |req| req.options.on_data = collector }
179
+ elsif url.match?(%r{\Ahttps?://})
180
+ response = connection.get(url, nil, options[:headers]) { |req| req.options.on_data = collector }
181
+ else
182
+ raise StandardError, 'Must use an absolute url or define an HTTP client with a base url'
183
+ end
184
+ response.env.body = streamed.join
185
+ response
162
186
  end
163
- response.env.body = streamed.join
164
- response
165
187
  end
166
188
  end
167
189
 
@@ -1,3 +1,5 @@
1
+ require 'faraday_middleware'
2
+
1
3
  module Inferno
2
4
  module DSL
3
5
  # This module contains the HTTP DSL available to test writers.
@@ -12,7 +14,10 @@ module Inferno
12
14
  params = { url: url }
13
15
  params.merge!(headers: headers) if headers
14
16
 
15
- Faraday.new(params)
17
+ Faraday.new(params) do |f|
18
+ f.request :url_encoded
19
+ f.use FaradayMiddleware::FollowRedirects
20
+ end
16
21
  end
17
22
 
18
23
  # Define the base url for an HTTP client. A string or symbol can be