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.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/lib/inferno/apps/web/application.rb +1 -0
  3. data/lib/inferno/apps/web/controllers/controller.rb +6 -8
  4. data/lib/inferno/apps/web/controllers/requests/show.rb +3 -3
  5. data/lib/inferno/apps/web/controllers/test_runs/create.rb +13 -17
  6. data/lib/inferno/apps/web/controllers/test_runs/destroy.rb +8 -10
  7. data/lib/inferno/apps/web/controllers/test_runs/results/index.rb +4 -4
  8. data/lib/inferno/apps/web/controllers/test_runs/show.rb +9 -7
  9. data/lib/inferno/apps/web/controllers/test_sessions/create.rb +9 -8
  10. data/lib/inferno/apps/web/controllers/test_sessions/last_test_run.rb +4 -4
  11. data/lib/inferno/apps/web/controllers/test_sessions/results/index.rb +6 -6
  12. data/lib/inferno/apps/web/controllers/test_sessions/session_data/apply_preset.rb +10 -10
  13. data/lib/inferno/apps/web/controllers/test_sessions/session_data/index.rb +5 -3
  14. data/lib/inferno/apps/web/controllers/test_sessions/show.rb +3 -3
  15. data/lib/inferno/apps/web/controllers/test_suites/check_configuration.rb +3 -3
  16. data/lib/inferno/apps/web/controllers/test_suites/index.rb +2 -2
  17. data/lib/inferno/apps/web/controllers/test_suites/show.rb +3 -3
  18. data/lib/inferno/apps/web/router.rb +55 -41
  19. data/lib/inferno/apps/web/serializers/message.rb +2 -0
  20. data/lib/inferno/apps/web/serializers/preset.rb +2 -5
  21. data/lib/inferno/apps/web/serializers/request.rb +2 -0
  22. data/lib/inferno/apps/web/serializers/result.rb +1 -0
  23. data/lib/inferno/apps/web/serializers/session_data.rb +2 -0
  24. data/lib/inferno/apps/web/serializers/suite_option.rb +2 -0
  25. data/lib/inferno/apps/web/serializers/test.rb +3 -0
  26. data/lib/inferno/apps/web/serializers/test_group.rb +4 -2
  27. data/lib/inferno/apps/web/serializers/test_run.rb +3 -0
  28. data/lib/inferno/apps/web/serializers/test_suite.rb +5 -1
  29. data/lib/inferno/config/application.rb +1 -6
  30. data/lib/inferno/config/boot/web.rb +2 -7
  31. data/lib/inferno/dsl/assertions.rb +2 -2
  32. data/lib/inferno/dsl/configurable.rb +4 -4
  33. data/lib/inferno/dsl/fhir_client.rb +3 -2
  34. data/lib/inferno/dsl/fhir_client_builder.rb +2 -2
  35. data/lib/inferno/dsl/fhir_validation.rb +5 -6
  36. data/lib/inferno/dsl/http_client.rb +17 -18
  37. data/lib/inferno/dsl/http_client_builder.rb +4 -4
  38. data/lib/inferno/dsl/input_output_handling.rb +1 -1
  39. data/lib/inferno/dsl/request_storage.rb +2 -2
  40. data/lib/inferno/dsl/resume_test_route.rb +36 -34
  41. data/lib/inferno/dsl/runnable.rb +8 -9
  42. data/lib/inferno/entities/header.rb +7 -7
  43. data/lib/inferno/entities/request.rb +35 -36
  44. data/lib/inferno/entities/session_data.rb +6 -6
  45. data/lib/inferno/entities/test.rb +4 -4
  46. data/lib/inferno/entities/test_group.rb +2 -2
  47. data/lib/inferno/entities/test_run.rb +1 -1
  48. data/lib/inferno/jobs/execute_test_run.rb +1 -1
  49. data/lib/inferno/jobs/resume_test_run.rb +1 -1
  50. data/lib/inferno/public/bundle.js +2 -2
  51. data/lib/inferno/repositories/messages.rb +1 -1
  52. data/lib/inferno/repositories/repository.rb +1 -1
  53. data/lib/inferno/repositories/requests.rb +6 -6
  54. data/lib/inferno/repositories/results.rb +16 -16
  55. data/lib/inferno/repositories/session_data.rb +6 -6
  56. data/lib/inferno/repositories/test_runs.rb +6 -6
  57. data/lib/inferno/repositories/test_sessions.rb +7 -7
  58. data/lib/inferno/test_runner.rb +3 -3
  59. data/lib/inferno/utils/preset_template_generator.rb +1 -1
  60. data/lib/inferno/version.rb +1 -1
  61. data/spec/factories/test_run.rb +1 -1
  62. data/spec/factories/test_session.rb +1 -1
  63. data/spec/fixtures/basic_test_suite.rb +1 -0
  64. metadata +24 -24
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9bc9822a032ed4fa7c3b1639b24bc14c6ed977e271e60e424f6a1d60fbff657
4
- data.tar.gz: 5d0a9a794ce081c3128e68d7cb6a1802a05aafddbcbb03ab7ee7667696ac81f5
3
+ metadata.gz: 987a2db725cb3b2517f392d2e566614f3e5fcd454f27164e6de64ec615b5661c
4
+ data.tar.gz: 1cce12a803e20d288e72f9f3b1dfd1def94f9cbe1fcb73f4c862f1063c3d5c8c
5
5
  SHA512:
6
- metadata.gz: 8645e64fc2c5890378d9693734ce5268b219541c82307b13d14703f7a8e8ff70ddac9c00ddf254ba9db6121bb54015445222e497b0d519b9bc2de1d93ac1c06c
7
- data.tar.gz: 67a64df05660cca2377009e45c13fb6baddae3cd39e3527d7fe85e6b64fc201b2cb871b894bf86c55ca6facc6f3790993e6548dec14ad245b563d8bbc5ac690f
6
+ metadata.gz: 646f385e975efc9eb957aa707934e7c3e04977c97bd73dae4a21a8dbfd60869c1662f1832bfac1a38cb534ed18ebc93d771937a8978a7fb5dba7e0b3db54b974
7
+ data.tar.gz: 106dc72ddaaba5f02be715aef376984adb7c97ae71c62668d45da094bcfe430ee1a7c5d940c99e92bfc645bc31c8bb2013406aaffb2a072fc1d0fc9771a3187f
@@ -1,4 +1,5 @@
1
1
  require 'hanami/middleware/body_parser'
2
+ require_relative 'router'
2
3
 
3
4
  module Inferno
4
5
  module Web
@@ -1,20 +1,18 @@
1
1
  module Inferno
2
2
  module Web
3
3
  module Controllers
4
- class Controller
5
- # Ensure that each request gets a new instance of the controller.
6
- def self.call(params)
7
- new.call(params)
4
+ class Controller < Hanami::Action
5
+ def self.call(...)
6
+ new.call(...)
8
7
  end
9
8
 
10
9
  def self.inherited(subclass)
11
10
  super
12
11
 
13
- # This does some sort of magic that requires it be included in the
14
- # subclass rather than superclass.
15
- subclass.include Hanami::Action
12
+ subclass.include Import[repo: "inferno.repositories.#{subclass.resource_name}"]
16
13
 
17
- subclass.include Import[repo: "repositories.#{subclass.resource_name}"]
14
+ subclass.config.default_request_format = :json
15
+ subclass.config.default_response_format = :json
18
16
 
19
17
  subclass.define_method(:serialize) do |*args|
20
18
  Inferno::Web::Serializers.const_get(self.class.resource_class).render(*args)
@@ -3,11 +3,11 @@ module Inferno
3
3
  module Controllers
4
4
  module Requests
5
5
  class Show < Controller
6
- def call(params)
7
- request = repo.find_full_request(params[:id])
6
+ def handle(req, res)
7
+ request = repo.find_full_request(req.params[:id])
8
8
  halt 404 if request.nil?
9
9
 
10
- self.body = serialize(request, view: :full)
10
+ res.body = serialize(request, view: :full)
11
11
  end
12
12
  end
13
13
  end
@@ -4,9 +4,9 @@ module Inferno
4
4
  module TestRuns
5
5
  class Create < Controller
6
6
  include Import[
7
- test_sessions_repo: 'repositories.test_sessions',
8
- session_data_repo: 'repositories.session_data',
9
- test_runs_repo: 'repositories.test_runs'
7
+ test_sessions_repo: 'inferno.repositories.test_sessions',
8
+ session_data_repo: 'inferno.repositories.session_data',
9
+ test_runs_repo: 'inferno.repositories.test_runs'
10
10
  ]
11
11
 
12
12
  PARAMS = [:test_session_id, :test_suite_id, :test_group_id, :test_id].freeze
@@ -42,38 +42,34 @@ module Inferno
42
42
  end
43
43
  end
44
44
 
45
- def call(params)
46
- test_session = test_sessions_repo.find(params[:test_session_id])
45
+ def handle(req, res)
46
+ test_session = test_sessions_repo.find(req.params[:test_session_id])
47
47
 
48
48
  # if testsession.nil?
49
49
  if test_runs_repo.active_test_run_for_session?(test_session.id)
50
- self.status = 409
51
- self.body = { error: 'Cannot run new test while another test run is in progress' }.to_json
52
- return
50
+ halt 409, { error: 'Cannot run new test while another test run is in progress' }.to_json
53
51
  end
54
52
 
55
53
  verify_runnable(
56
- repo.build_entity(create_params(params)).runnable,
57
- params[:inputs],
54
+ repo.build_entity(create_params(req.params)).runnable,
55
+ req.params[:inputs],
58
56
  test_session.suite_options
59
57
  )
60
58
 
61
- test_run = repo.create(create_params(params).merge(status: 'queued'))
59
+ test_run = repo.create(create_params(req.params).merge(status: 'queued'))
62
60
 
63
- self.body = serialize(test_run, suite_options: test_session.suite_options)
61
+ res.body = serialize(test_run, suite_options: test_session.suite_options)
64
62
 
65
- persist_inputs(params, test_run)
63
+ persist_inputs(req.params, test_run)
66
64
 
67
65
  Jobs.perform(Jobs::ExecuteTestRun, test_run.id)
68
66
  rescue Sequel::ValidationFailed, Sequel::ForeignKeyConstraintViolation,
69
67
  Inferno::Exceptions::RequiredInputsNotFound,
70
68
  Inferno::Exceptions::NotUserRunnableException => e
71
- self.body = { errors: e.message }.to_json
72
- self.status = 422
69
+ halt 422, { errors: e.message }.to_json
73
70
  rescue StandardError => e
74
71
  Application['logger'].error(e.full_message)
75
- self.body = { errors: e.message }.to_json
76
- self.status = 500
72
+ halt 500, { errors: e.message }.to_json
77
73
  end
78
74
 
79
75
  def create_params(params)
@@ -4,21 +4,20 @@ module Inferno
4
4
  module TestRuns
5
5
  class Destroy < Controller
6
6
  include Import[
7
- test_runs_repo: 'repositories.test_runs',
8
- results_repo: 'repositories.results'
7
+ test_runs_repo: 'inferno.repositories.test_runs',
8
+ results_repo: 'inferno.repositories.results'
9
9
  ]
10
10
 
11
- def call(params)
12
- test_run = test_runs_repo.find(params[:id])
11
+ def handle(req, res)
12
+ test_run = test_runs_repo.find(req.params[:id])
13
13
 
14
14
  if test_run.nil? || ['done', 'cancelling'].include?(test_run.status)
15
15
  # If it doesn't exist, already finished, or currently being cancelled
16
- self.status = 204
17
- return
16
+ halt 204
18
17
  end
19
18
 
20
19
  test_run_is_waiting = (test_run.status == 'waiting')
21
- test_runs_repo.mark_as_cancelling(params[:id])
20
+ test_runs_repo.mark_as_cancelling(req.params[:id])
22
21
 
23
22
  if test_run_is_waiting
24
23
  waiting_result = results_repo.find_waiting_result(test_run_id: test_run.id)
@@ -26,11 +25,10 @@ module Inferno
26
25
  Jobs.perform(Jobs::ResumeTestRun, test_run.id)
27
26
  end
28
27
 
29
- self.status = 204
28
+ res.status = 204
30
29
  rescue StandardError => e
31
30
  Application['logger'].error(e.full_message)
32
- self.body = { errors: e.message }.to_json
33
- self.status = 500
31
+ halt 500, { errors: e.message }.to_json
34
32
  end
35
33
  end
36
34
  end
@@ -4,11 +4,11 @@ module Inferno
4
4
  module TestRuns
5
5
  module Results
6
6
  class Index < Controller
7
- include Import[test_runs_repo: 'repositories.test_runs']
7
+ include Import[test_runs_repo: 'inferno.repositories.test_runs']
8
8
 
9
- def call(params)
10
- results = test_runs_repo.results_for_test_run(params[:test_run_id])
11
- self.body = serialize(results)
9
+ def handle(req, res)
10
+ results = test_runs_repo.results_for_test_run(req.params[:test_run_id])
11
+ res.body = serialize(results)
12
12
  end
13
13
  end
14
14
  end
@@ -1,26 +1,28 @@
1
+ require_relative '../../serializers/test_run'
2
+
1
3
  module Inferno
2
4
  module Web
3
5
  module Controllers
4
6
  module TestRuns
5
7
  class Show < Controller
6
- include Import[test_sessions_repo: 'repositories.test_sessions']
8
+ include Import[test_sessions_repo: 'inferno.repositories.test_sessions']
7
9
 
8
- def call(params)
9
- test_run = repo.find(params[:id])
10
+ def handle(req, res)
11
+ test_run = repo.find(req.params[:id])
10
12
  halt 404 if test_run.nil?
11
13
 
12
- if params[:include_results] == 'true'
14
+ if req.params[:include_results] == 'true'
13
15
  results_repo = Inferno::Repositories::Results.new
14
16
  test_run.results =
15
- if params[:after].present?
16
- results_repo.test_run_results_after(test_run_id: test_run.id, after: Time.parse(params[:after]))
17
+ if req.params[:after].present?
18
+ results_repo.test_run_results_after(test_run_id: test_run.id, after: Time.parse(req.params[:after]))
17
19
  else
18
20
  repo.results_for_test_run(test_run.id)
19
21
  end
20
22
  end
21
23
 
22
24
  test_session = test_sessions_repo.find(test_run.test_session_id)
23
- self.body = serialize(test_run, suite_options: test_session.suite_options)
25
+ res.body = serialize(test_run, suite_options: test_session.suite_options)
24
26
  end
25
27
  end
26
28
  end
@@ -1,3 +1,6 @@
1
+ require_relative '../controller'
2
+ require_relative '../../serializers/test_session'
3
+
1
4
  module Inferno
2
5
  module Web
3
6
  module Controllers
@@ -5,22 +8,20 @@ module Inferno
5
8
  class Create < Controller
6
9
  PARAMS = [:test_suite_id, :suite_options].freeze
7
10
 
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?
11
+ def handle(req, res)
12
+ params = req.params.to_h
13
+ params.merge!(JSON.parse(req.body.string).symbolize_keys) unless req.body.string.blank?
11
14
 
12
15
  session = repo.create(create_params(params))
13
16
 
14
17
  repo.apply_preset(session.id, params[:preset_id]) if params[:preset_id].present?
15
18
 
16
- self.body = serialize(session)
19
+ res.body = serialize(session)
17
20
  rescue Sequel::ValidationFailed, Sequel::ForeignKeyConstraintViolation => e
18
- self.body = { errors: e.message }.to_json
19
- self.status = 422
21
+ halt 422, { errors: e.message }.to_json
20
22
  rescue StandardError => e
21
23
  Application['logger'].error(e.full_message)
22
- self.body = { errors: e.message }.to_json
23
- self.status = 500
24
+ halt 500, { errors: e.message }.to_json
24
25
  end
25
26
 
26
27
  def create_params(params)
@@ -3,12 +3,12 @@ module Inferno
3
3
  module Controllers
4
4
  module TestSessions
5
5
  class LastTestRun < Controller
6
- include Import[test_runs_repo: 'repositories.test_runs']
6
+ include Import[test_runs_repo: 'inferno.repositories.test_runs']
7
7
 
8
- def call(params)
9
- test_run = test_runs_repo.last_test_run(params[:test_session_id])
8
+ def handle(req, res)
9
+ test_run = test_runs_repo.last_test_run(req.params[:id])
10
10
 
11
- self.body =
11
+ res.body =
12
12
  if test_run.nil?
13
13
  nil
14
14
  else
@@ -4,14 +4,14 @@ module Inferno
4
4
  module TestSessions
5
5
  module Results
6
6
  class Index < Controller
7
- include Import[test_sessions_repo: 'repositories.test_sessions']
7
+ include Import[test_sessions_repo: 'inferno.repositories.test_sessions']
8
8
 
9
- def call(params)
10
- self.body =
11
- if params[:all] == 'true'
12
- serialize(test_sessions_repo.results_for_test_session(params[:test_session_id]))
9
+ def handle(req, res)
10
+ res.body =
11
+ if req.params[:all] == 'true'
12
+ serialize(test_sessions_repo.results_for_test_session(req.params[:id]))
13
13
  else
14
- serialize(repo.current_results_for_test_session(params[:test_session_id]))
14
+ serialize(repo.current_results_for_test_session(req.params[:id]))
15
15
  end
16
16
  end
17
17
  end
@@ -1,3 +1,5 @@
1
+ require_relative '../../controller'
2
+
1
3
  module Inferno
2
4
  module Web
3
5
  module Controllers
@@ -5,35 +7,33 @@ module Inferno
5
7
  module SessionData
6
8
  class ApplyPreset < Controller
7
9
  include Import[
8
- test_sessions_repo: 'repositories.test_sessions',
9
- presets_repo: 'repositories.presets'
10
+ test_sessions_repo: 'inferno.repositories.test_sessions',
11
+ presets_repo: 'inferno.repositories.presets'
10
12
  ]
11
13
 
12
14
  def self.resource_class
13
15
  'SessionData'
14
16
  end
15
17
 
16
- def call(params)
17
- test_session_id = params[:test_session_id]
18
+ def handle(req, res)
19
+ test_session_id = req.params[:id]
18
20
  test_session = test_sessions_repo.find(test_session_id)
19
21
 
20
22
  if test_session.nil?
21
23
  Application[:logger].error("Unknown test session #{test_session_id}")
22
- self.status = 404
23
- return
24
+ halt 404
24
25
  end
25
26
 
26
- preset_id = params[:preset_id]
27
+ preset_id = req.params[:preset_id]
27
28
  preset = presets_repo.find(preset_id)
28
29
 
29
30
  if preset.nil?
30
31
  Application[:logger].error("Unknown preset #{preset_id}")
31
- self.status = 404
32
- return
32
+ halt 404
33
33
  end
34
34
 
35
35
  test_sessions_repo.apply_preset(test_session_id, preset_id)
36
- self.status = 200
36
+ res.status = 200
37
37
  end
38
38
  end
39
39
  end
@@ -1,17 +1,19 @@
1
+ require_relative '../../../serializers/session_data'
2
+
1
3
  module Inferno
2
4
  module Web
3
5
  module Controllers
4
6
  module TestSessions
5
7
  module SessionData
6
8
  class Index < Controller
7
- include Import[session_data_repo: 'repositories.session_data']
9
+ include Import[session_data_repo: 'inferno.repositories.session_data']
8
10
 
9
11
  def self.resource_class
10
12
  'SessionData'
11
13
  end
12
14
 
13
- def call(params)
14
- self.body = serialize(session_data_repo.get_all_from_session(params[:test_session_id]))
15
+ def handle(req, res)
16
+ res.body = serialize(session_data_repo.get_all_from_session(req.params[:id]))
15
17
  end
16
18
  end
17
19
  end
@@ -3,11 +3,11 @@ module Inferno
3
3
  module Controllers
4
4
  module TestSessions
5
5
  class Show < Controller
6
- def call(params)
7
- test_session = repo.find(params[:id])
6
+ def handle(req, res)
7
+ test_session = repo.find(req.params[:id])
8
8
  halt 404 if test_session.nil?
9
9
 
10
- self.body = serialize(test_session)
10
+ res.body = serialize(test_session)
11
11
  end
12
12
  end
13
13
  end
@@ -3,11 +3,11 @@ module Inferno
3
3
  module Controllers
4
4
  module TestSuites
5
5
  class CheckConfiguration < Controller
6
- def call(params)
7
- test_suite = repo.find(params[:id])
6
+ def handle(req, res)
7
+ test_suite = repo.find(req.params[:id])
8
8
  halt 404 if test_suite.nil?
9
9
 
10
- self.body =
10
+ res.body =
11
11
  Inferno::Web::Serializers::Message.render(test_suite.configuration_messages(force_recheck: true))
12
12
  end
13
13
  end
@@ -3,8 +3,8 @@ module Inferno
3
3
  module Controllers
4
4
  module TestSuites
5
5
  class Index < Controller
6
- def call(_params)
7
- self.body = serialize(repo.all, view: :summary)
6
+ def handle(_req, res)
7
+ res.body = serialize(repo.all, view: :summary)
8
8
  end
9
9
  end
10
10
  end
@@ -3,11 +3,11 @@ module Inferno
3
3
  module Controllers
4
4
  module TestSuites
5
5
  class Show < Controller
6
- def call(params)
7
- test_suite = repo.find(params[:id])
6
+ def handle(req, res)
7
+ test_suite = repo.find(req.params[:id])
8
8
  halt 404 if test_suite.nil?
9
9
 
10
- self.body = serialize(test_suite, view: :full)
10
+ res.body = serialize(test_suite, view: :full)
11
11
  end
12
12
  end
13
13
  end
@@ -1,62 +1,76 @@
1
1
  require 'erb'
2
2
 
3
+ Dir.glob(File.join(__dir__, 'controllers', '**', '*.rb')).each { |path| require_relative path }
4
+
3
5
  module Inferno
4
6
  module Web
5
7
  client_page = ERB.new(File.read(File.join(Inferno::Application.root, 'lib', 'inferno', 'apps', 'web',
6
8
  'index.html.erb'))).result
7
9
 
8
- Router = Hanami::Router.new(namespace: Inferno::Web::Controllers) do
9
- namespace Application['base_path'] do
10
- namespace 'api' do
11
- resources 'test_runs', only: [:create, :show, :destroy] do
12
- resources 'results', only: [:index]
13
- end
14
-
15
- resources 'test_sessions', only: [:create, :show] do
16
- resources 'results', only: [:index]
17
- resources 'session_data', only: [:index] do
18
- collection do
19
- put '/apply_preset',
20
- to: Inferno::Web::Controllers::TestSessions::SessionData::ApplyPreset,
21
- as: :apply_preset
22
- end
23
- end
24
- end
25
- get 'test_sessions/:test_session_id/last_test_run',
10
+ base_path = Application['base_path']
11
+ base_path = "/#{base_path.delete_prefix('/')}" if base_path.present?
12
+
13
+ Router = Hanami::Router.new(prefix: base_path) do
14
+ scope 'api' do
15
+ scope 'test_runs' do
16
+ post '/', to: Inferno::Web::Controllers::TestRuns::Create, as: :create
17
+ get '/:id', to: Inferno::Web::Controllers::TestRuns::Show, as: :show
18
+ delete '/:id', to: Inferno::Web::Controllers::TestRuns::Destroy, as: :destroy
19
+
20
+ get '/results', to: Inferno::Web::Controllers::TestRuns::Results::Index, as: :results
21
+ end
22
+
23
+ scope 'test_sessions' do
24
+ post '/', to: Inferno::Web::Controllers::TestSessions::Create, as: :create
25
+ get '/:id', to: Inferno::Web::Controllers::TestSessions::Show, as: :show
26
+
27
+ get '/:id/last_test_run',
26
28
  to: Inferno::Web::Controllers::TestSessions::LastTestRun,
27
29
  as: :last_test_run
30
+ get '/:id/results',
31
+ to: Inferno::Web::Controllers::TestSessions::Results::Index,
32
+ as: :results
33
+ get '/:id/session_data',
34
+ to: Inferno::Web::Controllers::TestSessions::SessionData::Index
35
+ put '/:id/session_data/apply_preset',
36
+ to: Inferno::Web::Controllers::TestSessions::SessionData::ApplyPreset,
37
+ as: :session_data_apply_preset
38
+ end
28
39
 
29
- resources 'test_suites', only: [:index, :show]
30
- put 'test_suites/:id/check_configuration',
40
+ scope 'test_suites' do
41
+ get '/', to: Inferno::Web::Controllers::TestSuites::Index, as: :index
42
+ get '/:id', to: Inferno::Web::Controllers::TestSuites::Show, as: :show
43
+
44
+ put '/:id/check_configuration',
31
45
  to: Inferno::Web::Controllers::TestSuites::CheckConfiguration,
32
46
  as: :check_configuration
47
+ end
33
48
 
34
- resources 'requests', only: [:show]
49
+ get '/requests/:id', to: Inferno::Web::Controllers::Requests::Show, as: :requests_show
35
50
 
36
- get '/version', to: ->(_env) { [200, {}, [{ 'version' => Inferno::VERSION.to_s }.to_json]] }, as: :api_version
37
- end
51
+ get '/version', to: ->(_env) { [200, {}, [{ 'version' => Inferno::VERSION.to_s }.to_json]] }, as: :version
52
+ end
38
53
 
39
- # Should not need Content-Type header but GitHub Codespaces will not work without them.
40
- # This could be investigated and likely removed if addressed properly elsewhere.
41
- get '/', to: ->(_env) { [200, { 'Content-Type' => 'text/html' }, [client_page]] }
42
- get '/test_sessions/:id', to: ->(_env) { [200, { 'Content-Type' => 'text/html' }, [client_page]] }
43
-
44
- Inferno.routes.each do |route|
45
- cleaned_id = route[:suite].id.gsub(/[^a-zA-Z\d\-._~]/, '_')
46
- path = "/custom/#{cleaned_id}#{route[:path]}"
47
- Application['logger'].info("Registering custom route: #{path}")
48
- if route[:method] == :all
49
- mount route[:handler], at: path
50
- else
51
- send(route[:method], path, to: route[:handler])
52
- end
53
- end
54
+ # Should not need Content-Type header but GitHub Codespaces will not work without them.
55
+ # This could be investigated and likely removed if addressed properly elsewhere.
56
+ get '/', to: ->(_env) { [200, { 'Content-Type' => 'text/html' }, [client_page]] }
57
+ get '/test_sessions/:id', to: ->(_env) { [200, { 'Content-Type' => 'text/html' }, [client_page]] }
54
58
 
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]] }
59
+ Inferno.routes.each do |route|
60
+ cleaned_id = route[:suite].id.gsub(/[^a-zA-Z\d\-._~]/, '_')
61
+ path = "/custom/#{cleaned_id}#{route[:path]}"
62
+ Application['logger'].info("Registering custom route: #{path}")
63
+ if route[:method] == :all
64
+ mount route[:handler], at: path
65
+ else
66
+ send(route[:method], path, to: route[:handler])
58
67
  end
59
68
  end
69
+
70
+ Inferno::Repositories::TestSuites.all.map { |suite| "/#{suite.id}" }.each do |suite_path|
71
+ Application['logger'].info("Registering suite route: #{suite_path}")
72
+ get suite_path, to: ->(_env) { [200, {}, [client_page]] }
73
+ end
60
74
  end
61
75
  end
62
76
  end
@@ -1,3 +1,5 @@
1
+ require_relative 'serializer'
2
+
1
3
  module Inferno
2
4
  module Web
3
5
  module Serializers
@@ -1,3 +1,5 @@
1
+ require_relative 'serializer'
2
+
1
3
  module Inferno
2
4
  module Web
3
5
  module Serializers
@@ -6,11 +8,6 @@ module Inferno
6
8
  identifier :id
7
9
  field :title
8
10
  end
9
-
10
- # view :full do
11
- # include_view :summary
12
- # field :inputs, blueprint: Input
13
- # end
14
11
  end
15
12
  end
16
13
  end
@@ -1,3 +1,5 @@
1
+ require_relative 'header'
2
+
1
3
  module Inferno
2
4
  module Web
3
5
  module Serializers
@@ -1,4 +1,5 @@
1
1
  require 'json'
2
+ require_relative 'message'
2
3
  require_relative 'request'
3
4
 
4
5
  module Inferno
@@ -1,3 +1,5 @@
1
+ require_relative 'serializer'
2
+
1
3
  module Inferno
2
4
  module Web
3
5
  module Serializers
@@ -1,3 +1,5 @@
1
+ require_relative 'serializer'
2
+
1
3
  module Inferno
2
4
  module Web
3
5
  module Serializers
@@ -1,3 +1,6 @@
1
+ require_relative 'hash_value_extractor'
2
+ require_relative 'input'
3
+
1
4
  module Inferno
2
5
  module Web
3
6
  module Serializers
@@ -1,3 +1,5 @@
1
+ require_relative 'test'
2
+
1
3
  module Inferno
2
4
  module Web
3
5
  module Serializers
@@ -19,11 +21,11 @@ module Inferno
19
21
  end
20
22
  field :test_groups do |group, options|
21
23
  suite_options = options[:suite_options]
22
- TestGroup.render_as_hash(group.groups(suite_options), suite_options: suite_options)
24
+ TestGroup.render_as_hash(group.groups(suite_options), suite_options:)
23
25
  end
24
26
  field :tests do |group, options|
25
27
  suite_options = options[:suite_options]
26
- Test.render_as_hash(group.tests(suite_options), suite_options: suite_options)
28
+ Test.render_as_hash(group.tests(suite_options), suite_options:)
27
29
  end
28
30
  field :inputs do |group, options|
29
31
  suite_options = options[:suite_options]
@@ -1,3 +1,6 @@
1
+ require_relative 'input'
2
+ require_relative 'result'
3
+
1
4
  module Inferno
2
5
  module Web
3
6
  module Serializers