davinci_crd_test_kit 0.9.1 → 0.11.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 (37) hide show
  1. checksums.yaml +4 -4
  2. data/config/presets/inferno_crd_client_suite.json.erb +110 -0
  3. data/config/presets/inferno_crd_server_suite.json.erb +173 -0
  4. data/config/presets/ri_crd_request_generator.json.erb +74 -0
  5. data/config/presets/ri_crd_server.json.erb +116 -0
  6. data/lib/davinci_crd_test_kit/crd_client_suite.rb +0 -3
  7. data/lib/davinci_crd_test_kit/crd_server_suite.rb +11 -9
  8. data/lib/davinci_crd_test_kit/igs/.keep +0 -0
  9. data/lib/davinci_crd_test_kit/igs/davinci-crd-2.0.1.tgz +0 -0
  10. data/lib/davinci_crd_test_kit/metadata.rb +75 -0
  11. data/lib/davinci_crd_test_kit/server_appointment_book_group.rb +4 -3
  12. data/lib/davinci_crd_test_kit/server_demonstrate_hook_response_group.rb +77 -0
  13. data/lib/davinci_crd_test_kit/server_encounter_discharge_group.rb +4 -3
  14. data/lib/davinci_crd_test_kit/server_encounter_start_group.rb +4 -3
  15. data/lib/davinci_crd_test_kit/server_hook_helper.rb +43 -0
  16. data/lib/davinci_crd_test_kit/server_order_dispatch_group.rb +4 -3
  17. data/lib/davinci_crd_test_kit/server_order_select_group.rb +4 -3
  18. data/lib/davinci_crd_test_kit/server_order_sign_group.rb +4 -3
  19. data/lib/davinci_crd_test_kit/server_tests/additional_orders_validation_test.rb +4 -6
  20. data/lib/davinci_crd_test_kit/server_tests/coverage_information_system_action_received_test.rb +6 -7
  21. data/lib/davinci_crd_test_kit/server_tests/coverage_information_system_action_validation_test.rb +0 -4
  22. data/lib/davinci_crd_test_kit/server_tests/create_or_update_coverage_info_response_validation_test.rb +3 -5
  23. data/lib/davinci_crd_test_kit/server_tests/discovery_endpoint_test.rb +1 -1
  24. data/lib/davinci_crd_test_kit/server_tests/external_reference_card_validation_test.rb +4 -5
  25. data/lib/davinci_crd_test_kit/server_tests/form_completion_response_validation_test.rb +3 -5
  26. data/lib/davinci_crd_test_kit/server_tests/instructions_card_received_test.rb +3 -5
  27. data/lib/davinci_crd_test_kit/server_tests/launch_smart_app_card_validation_test.rb +4 -5
  28. data/lib/davinci_crd_test_kit/server_tests/propose_alternate_request_card_validation_test.rb +3 -5
  29. data/lib/davinci_crd_test_kit/server_tests/service_call_test.rb +23 -8
  30. data/lib/davinci_crd_test_kit/server_tests/service_request_context_validation_test.rb +4 -6
  31. data/lib/davinci_crd_test_kit/server_tests/service_request_optional_fields_validation_test.rb +4 -6
  32. data/lib/davinci_crd_test_kit/server_tests/service_request_required_fields_validation_test.rb +7 -7
  33. data/lib/davinci_crd_test_kit/server_tests/service_response_validation_test.rb +7 -8
  34. data/lib/davinci_crd_test_kit/tags.rb +2 -0
  35. data/lib/davinci_crd_test_kit/version.rb +2 -1
  36. data/lib/davinci_crd_test_kit.rb +1 -0
  37. metadata +20 -10
@@ -1,8 +1,10 @@
1
1
  require_relative '../test_helper'
2
+ require_relative '../server_hook_helper'
2
3
 
3
4
  module DaVinciCRDTestKit
4
5
  class InstructionsCardReceivedTest < Inferno::Test
5
6
  include DaVinciCRDTestKit::TestHelper
7
+ include DaVinciCRDTestKit::ServerHookHelper
6
8
 
7
9
  title 'Valid Instructions cards received'
8
10
  id :crd_valid_instructions_card_received
@@ -15,14 +17,10 @@ module DaVinciCRDTestKit
15
17
  input :valid_cards
16
18
  optional
17
19
 
18
- def hook_name
19
- config.options[:hook_name]
20
- end
21
-
22
20
  run do
23
21
  parsed_cards = parse_json(valid_cards)
24
22
  instructions_card = parsed_cards.find { |card| card['links'].blank? && card['suggestions'].blank? }
25
- assert instructions_card, 'Hook response did not contain an Instructions card.'
23
+ assert instructions_card, "#{tested_hook_name} hook response did not contain an Instructions card."
26
24
  end
27
25
  end
28
26
  end
@@ -1,8 +1,10 @@
1
1
  require_relative '../test_helper'
2
+ require_relative '../server_hook_helper'
2
3
 
3
4
  module DaVinciCRDTestKit
4
5
  class LaunchSmartAppCardValidationTest < Inferno::Test
5
6
  include DaVinciCRDTestKit::TestHelper
7
+ include DaVinciCRDTestKit::ServerHookHelper
6
8
 
7
9
  title 'Valid Launch SMART Application cards received'
8
10
  id :crd_launch_smart_app_card_validation
@@ -21,10 +23,6 @@ module DaVinciCRDTestKit
21
23
  optional
22
24
  input :valid_cards_with_links
23
25
 
24
- def hook_name
25
- config.options[:hook_name]
26
- end
27
-
28
26
  run do
29
27
  parsed_cards = parse_json(valid_cards_with_links)
30
28
  external_reference_cards = parsed_cards.select do |card|
@@ -32,7 +30,8 @@ module DaVinciCRDTestKit
32
30
  links.present? && links.all? { |link| link['type'] == 'smart' }
33
31
  end
34
32
 
35
- skip_if external_reference_cards.blank?, "#{hook_name} hook response does not contain any Launch SMART App cards."
33
+ skip_if external_reference_cards.blank?,
34
+ "#{tested_hook_name} hook response does not contain any Launch SMART App cards."
36
35
  end
37
36
  end
38
37
  end
@@ -1,10 +1,12 @@
1
1
  require_relative '../test_helper'
2
2
  require_relative '../suggestion_actions_validation'
3
+ require_relative '../server_hook_helper'
3
4
 
4
5
  module DaVinciCRDTestKit
5
6
  class ProposeAlternateRequestCardValidationTest < Inferno::Test
6
7
  include DaVinciCRDTestKit::TestHelper
7
8
  include DaVinciCRDTestKit::SuggestionActionsValidation
9
+ include DaVinciCRDTestKit::ServerHookHelper
8
10
 
9
11
  title 'Valid Propose Alternate Request cards received'
10
12
  id :crd_propose_alternate_request_card_validation
@@ -24,10 +26,6 @@ module DaVinciCRDTestKit
24
26
  VisionPrescription
25
27
  ].freeze
26
28
 
27
- def hook_name
28
- config.options[:hook_name]
29
- end
30
-
31
29
  def check_action_type(actions, action_type)
32
30
  actions&.any? do |action|
33
31
  action['type'] == action_type && action_resource_type_check(action, EXPECTED_RESOURCE_TYPES)
@@ -51,7 +49,7 @@ module DaVinciCRDTestKit
51
49
  proposed_alternate_cards = parsed_cards.filter { |card| propose_alternate_request_card?(card) }
52
50
 
53
51
  skip_if proposed_alternate_cards.blank?,
54
- "#{hook_name} hook response does not contain a Propose Alternate Request card."
52
+ "#{tested_hook_name} hook response does not contain a Propose Alternate Request card."
55
53
 
56
54
  proposed_alternate_cards.each do |card|
57
55
  card['suggestions'].each do |suggestion|
@@ -1,5 +1,10 @@
1
+ require_relative '../server_hook_helper'
2
+ require_relative '../tags'
3
+
1
4
  module DaVinciCRDTestKit
2
5
  class ServiceCallTest < Inferno::Test
6
+ include ServerHookHelper
7
+
3
8
  title 'Submit user-defined service requests'
4
9
  id :crd_service_call_test
5
10
  description %(
@@ -18,11 +23,17 @@ module DaVinciCRDTestKit
18
23
  The test is deemed successful if the CRD server returns a 200 HTTP response for all requests.
19
24
  )
20
25
  input_order :base_url, :encryption_method, :jwks_kid
21
- input :base_url, :service_ids
26
+ input :base_url
27
+ input :service_ids,
28
+ description: %(
29
+ If blank, Inferno will attempt to infer the service id to use by finding a service entry in the
30
+ Discovery response for the target hook. If it cannot be inferred, the tests will be skipped.
31
+ ),
32
+ optional: true
22
33
  input :service_request_bodies,
23
34
  optional: true,
24
35
  type: 'textarea',
25
- description: 'Provide a list of request bodies send multiple requests. e.g. [json_body_1, json_body_2]'
36
+ description: 'To send multiple requests, provide as a JSON list, e.g., [json_body_1, json_body_2].'
26
37
  input :encryption_method,
27
38
  title: 'JWT Signing Algorithm',
28
39
  description: <<~DESCRIPTION,
@@ -50,10 +61,7 @@ module DaVinciCRDTestKit
50
61
  Defaults to the first JWK in the list if no kid is supplied.
51
62
  DESCRIPTION
52
63
  optional: true
53
-
54
- def hook_name
55
- config.options[:hook_name]
56
- end
64
+ output :invoked_hook
57
65
 
58
66
  run do
59
67
  discovery_url = "#{base_url.chomp('/')}/cds-services"
@@ -62,7 +70,12 @@ module DaVinciCRDTestKit
62
70
  assert_valid_json(service_request_bodies)
63
71
 
64
72
  payloads = [JSON.parse(service_request_bodies)].flatten
65
- service_id = service_ids.split(', ').first.strip
73
+ skip_if tested_hook_name == ANY_HOOK_TAG && payloads.length != 1,
74
+ 'The *Demonstrate a Hook Invocation* test supports only one request body.'
75
+ invoked_hook = identify_hook(payloads)
76
+ service_id = target_service_id(service_ids, invoked_hook)
77
+ skip_if service_id.blank?, "No service id provided or discovered for the #{invoked_hook} hook"
78
+
66
79
  service_endpoint = "#{discovery_url}/#{service_id}"
67
80
  token = JwtHelper.build(
68
81
  aud: service_endpoint,
@@ -74,9 +87,11 @@ module DaVinciCRDTestKit
74
87
  headers = { 'Content-type' => 'application/json', 'Authorization' => "Bearer #{token}" }
75
88
 
76
89
  payloads.each do |payload|
77
- post(service_endpoint, body: payload.to_json, headers:, tags: [hook_name])
90
+ post(service_endpoint, body: payload.to_json, headers:, tags: [tested_hook_name])
78
91
  end
79
92
 
93
+ output(invoked_hook:)
94
+
80
95
  requests.each do |request|
81
96
  assert_response_status(200, request:)
82
97
  assert_valid_json(request.response_body)
@@ -1,10 +1,12 @@
1
1
  require_relative '../server_hook_request_validation'
2
2
  require_relative '../test_helper'
3
+ require_relative '../server_hook_helper'
3
4
 
4
5
  module DaVinciCRDTestKit
5
6
  class ServiceRequestContextValidationTest < Inferno::Test
6
7
  include DaVinciCRDTestKit::ServerHookRequestValidation
7
8
  include DaVinciCRDTestKit::TestHelper
9
+ include DaVinciCRDTestKit::ServerHookHelper
8
10
 
9
11
  title 'All service requests contain valid context'
10
12
  id :crd_service_request_context_validation
@@ -12,16 +14,12 @@ module DaVinciCRDTestKit
12
14
  This test verifies that all service requests `context` field is valid and contains all the
13
15
  required fields.
14
16
  )
15
- input :contexts
16
-
17
- def hook_name
18
- config.options[:hook_name]
19
- end
17
+ input :contexts, :invoked_hook
20
18
 
21
19
  run do
22
20
  parsed_contexts = parse_json(contexts)
23
21
  parsed_contexts.each do |context|
24
- hook_request_context_check(context, hook_name)
22
+ hook_request_context_check(context, invoked_hook)
25
23
  end
26
24
 
27
25
  no_error_validation('Some contexts are not valid.')
@@ -1,8 +1,10 @@
1
1
  require_relative '../server_hook_request_validation'
2
+ require_relative '../server_hook_helper'
2
3
 
3
4
  module DaVinciCRDTestKit
4
5
  class ServiceRequestOptionalFieldsValidationTest < Inferno::Test
5
6
  include DaVinciCRDTestKit::ServerHookRequestValidation
7
+ include DaVinciCRDTestKit::ServerHookHelper
6
8
 
7
9
  title 'All service requests contain optional fields'
8
10
  id :crd_service_request_optional_fields_validation
@@ -15,13 +17,9 @@ module DaVinciCRDTestKit
15
17
  )
16
18
  optional
17
19
 
18
- def hook_name
19
- config.options[:hook_name]
20
- end
21
-
22
20
  run do
23
- load_tagged_requests(hook_name)
24
- skip_if requests.empty?, "No #{hook_name} request was made in a previous test as expected."
21
+ load_tagged_requests(tested_hook_name)
22
+ skip_if requests.empty?, "No #{tested_hook_name} request was made in a previous test as expected."
25
23
 
26
24
  requests.each_with_index do |request, index|
27
25
  @request_number = index + 1
@@ -1,7 +1,10 @@
1
1
  require_relative '../server_hook_request_validation'
2
+ require_relative '../server_hook_helper'
3
+
2
4
  module DaVinciCRDTestKit
3
5
  class ServiceRequestRequiredFieldsValidationTest < Inferno::Test
4
6
  include DaVinciCRDTestKit::ServerHookRequestValidation
7
+ include DaVinciCRDTestKit::ServerHookHelper
5
8
 
6
9
  title 'All service requests contain required fields'
7
10
  id :crd_service_request_required_fields_validation
@@ -11,15 +14,12 @@ module DaVinciCRDTestKit
11
14
  `hook`, `hookInstance`, and `context`. Furthermore, the test checks for the conditional presence of the
12
15
  `fhirServer` field if `fhirAuthorization` is included.
13
16
  )
17
+ input :invoked_hook
14
18
  output :contexts
15
19
 
16
- def hook_name
17
- config.options[:hook_name]
18
- end
19
-
20
20
  run do
21
- load_tagged_requests(hook_name)
22
- skip_if requests.empty?, "No #{hook_name} request was made in a previous test as expected."
21
+ load_tagged_requests(tested_hook_name)
22
+ skip_if requests.empty?, "No #{tested_hook_name} request was made in a previous test as expected."
23
23
  contexts = []
24
24
  requests.each_with_index do |request, index|
25
25
  @request_number = index + 1
@@ -27,7 +27,7 @@ module DaVinciCRDTestKit
27
27
  next if request_body.blank?
28
28
 
29
29
  contexts << request_body['context'] if request_body['context'].is_a?(Hash)
30
- hook_request_required_fields_check(request_body, hook_name)
30
+ hook_request_required_fields_check(request_body, invoked_hook)
31
31
  end
32
32
 
33
33
  output contexts: contexts.to_json
@@ -1,8 +1,10 @@
1
1
  require_relative '../cards_validation'
2
+ require_relative '../server_hook_helper'
2
3
 
3
4
  module DaVinciCRDTestKit
4
5
  class ServiceResponseValidationTest < Inferno::Test
5
6
  include DaVinciCRDTestKit::CardsValidation
7
+ include DaVinciCRDTestKit::ServerHookHelper
6
8
 
7
9
  title 'All service responses contain valid cards and optional systemActions'
8
10
  id :crd_service_response_validation
@@ -14,14 +16,11 @@ module DaVinciCRDTestKit
14
16
  Each card must contain the following required fields: `summary`, `indicator`, and `source`.
15
17
  The required fields must have a valid data structure.
16
18
  )
19
+ input :invoked_hook
17
20
  output :valid_cards, :valid_system_actions
18
21
 
19
22
  SYSTEM_ACTIONS_HOOK_NAMES = ['appointment-book', 'order-sign'].freeze
20
23
 
21
- def hook_name
22
- config.options[:hook_name]
23
- end
24
-
25
24
  def valid_cards
26
25
  @valid_cards ||= []
27
26
  end
@@ -39,9 +38,9 @@ module DaVinciCRDTestKit
39
38
  end
40
39
 
41
40
  def perform_system_actions_validation(system_actions, response_index)
42
- if SYSTEM_ACTIONS_HOOK_NAMES.include?(hook_name) && system_actions.nil?
41
+ if SYSTEM_ACTIONS_HOOK_NAMES.include?(invoked_hook) && system_actions.nil?
43
42
  msg = "Server response #{response_index + 1} did not have `systemActions` field." \
44
- "Must be present for #{hook_name}."
43
+ "Must be present for #{invoked_hook}."
45
44
  add_message('error', msg)
46
45
  end
47
46
  return if system_actions.nil?
@@ -54,8 +53,8 @@ module DaVinciCRDTestKit
54
53
  end
55
54
 
56
55
  run do
57
- load_tagged_requests(hook_name)
58
- skip_if requests.blank?, "No #{hook_name} request was made in a previous test as expected."
56
+ load_tagged_requests(tested_hook_name)
57
+ skip_if requests.blank?, "No #{tested_hook_name} request was made in a previous test as expected."
59
58
  successful_requests = requests.select { |request| request.status == 200 }
60
59
  skip_if successful_requests.empty?, 'All service requests were unsuccessful.'
61
60
 
@@ -5,4 +5,6 @@ module DaVinciCRDTestKit
5
5
  ORDER_DISPATCH_TAG = 'order-dispatch'.freeze
6
6
  ORDER_SELECT_TAG = 'order-select'.freeze
7
7
  ORDER_SIGN_TAG = 'order-sign'.freeze
8
+ DISCOVERY_TAG = 'cds_discovery'.freeze
9
+ ANY_HOOK_TAG = 'any_hook'.freeze
8
10
  end
@@ -1,3 +1,4 @@
1
1
  module DaVinciCRDTestKit
2
- VERSION = '0.9.1'.freeze
2
+ VERSION = '0.11.0'.freeze
3
+ LAST_UPDATED = '2025-02-25'.freeze # TODO: update next release
3
4
  end
@@ -1,2 +1,3 @@
1
+ require_relative 'davinci_crd_test_kit/metadata'
1
2
  require_relative 'davinci_crd_test_kit/crd_server_suite'
2
3
  require_relative 'davinci_crd_test_kit/crd_client_suite'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: davinci_crd_test_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen MacVicar
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-09-19 00:00:00.000000000 Z
13
+ date: 2025-02-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: inferno_core
@@ -18,42 +18,42 @@ dependencies:
18
18
  requirements:
19
19
  - - "~>"
20
20
  - !ruby/object:Gem::Version
21
- version: 0.4.37
21
+ version: 0.6.4
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - "~>"
27
27
  - !ruby/object:Gem::Version
28
- version: 0.4.37
28
+ version: 0.6.4
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: smart_app_launch_test_kit
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
33
  - - "~>"
34
34
  - !ruby/object:Gem::Version
35
- version: 0.4.1
35
+ version: 0.5.0
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - "~>"
41
41
  - !ruby/object:Gem::Version
42
- version: 0.4.1
42
+ version: 0.5.0
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: tls_test_kit
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: 0.2.1
49
+ version: 0.3.0
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - "~>"
55
55
  - !ruby/object:Gem::Version
56
- version: 0.2.1
56
+ version: 0.3.0
57
57
  description: DaVinci CRD Test Kit
58
58
  email:
59
59
  - inferno@groups.mitre.org
@@ -62,6 +62,10 @@ extensions: []
62
62
  extra_rdoc_files: []
63
63
  files:
64
64
  - LICENSE
65
+ - config/presets/inferno_crd_client_suite.json.erb
66
+ - config/presets/inferno_crd_server_suite.json.erb
67
+ - config/presets/ri_crd_request_generator.json.erb
68
+ - config/presets/ri_crd_server.json.erb
65
69
  - lib/davinci_crd_test_kit.rb
66
70
  - lib/davinci_crd_test_kit/card_responses/companions_prerequisites.json
67
71
  - lib/davinci_crd_test_kit/card_responses/create_update_coverage_information.json
@@ -107,17 +111,22 @@ files:
107
111
  - lib/davinci_crd_test_kit/crd_server_suite.rb
108
112
  - lib/davinci_crd_test_kit/ext/inferno_core/runnable.rb
109
113
  - lib/davinci_crd_test_kit/hook_request_field_validation.rb
114
+ - lib/davinci_crd_test_kit/igs/.keep
115
+ - lib/davinci_crd_test_kit/igs/davinci-crd-2.0.1.tgz
110
116
  - lib/davinci_crd_test_kit/jwks.rb
111
117
  - lib/davinci_crd_test_kit/jwt_helper.rb
118
+ - lib/davinci_crd_test_kit/metadata.rb
112
119
  - lib/davinci_crd_test_kit/mock_service_response.rb
113
120
  - lib/davinci_crd_test_kit/routes/cds-services.json
114
121
  - lib/davinci_crd_test_kit/routes/cds_services_discovery_handler.rb
115
122
  - lib/davinci_crd_test_kit/routes/hook_request_endpoint.rb
116
123
  - lib/davinci_crd_test_kit/routes/jwk_set_endpoint_handler.rb
117
124
  - lib/davinci_crd_test_kit/server_appointment_book_group.rb
125
+ - lib/davinci_crd_test_kit/server_demonstrate_hook_response_group.rb
118
126
  - lib/davinci_crd_test_kit/server_discovery_group.rb
119
127
  - lib/davinci_crd_test_kit/server_encounter_discharge_group.rb
120
128
  - lib/davinci_crd_test_kit/server_encounter_start_group.rb
129
+ - lib/davinci_crd_test_kit/server_hook_helper.rb
121
130
  - lib/davinci_crd_test_kit/server_hook_request_validation.rb
122
131
  - lib/davinci_crd_test_kit/server_hooks_group.rb
123
132
  - lib/davinci_crd_test_kit/server_order_dispatch_group.rb
@@ -153,6 +162,7 @@ homepage: https://github.com/inferno-framework/davinci-crd-test-kit
153
162
  licenses:
154
163
  - Apache-2.0
155
164
  metadata:
165
+ inferno_test_kit: 'true'
156
166
  homepage_uri: https://github.com/inferno-framework/davinci-crd-test-kit
157
167
  source_code_uri: https://github.com/inferno-framework/davinci-crd-test-kit
158
168
  post_install_message:
@@ -163,14 +173,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
163
173
  requirements:
164
174
  - - ">="
165
175
  - !ruby/object:Gem::Version
166
- version: 3.1.2
176
+ version: 3.3.6
167
177
  required_rubygems_version: !ruby/object:Gem::Requirement
168
178
  requirements:
169
179
  - - ">="
170
180
  - !ruby/object:Gem::Version
171
181
  version: '0'
172
182
  requirements: []
173
- rubygems_version: 3.5.9
183
+ rubygems_version: 3.5.22
174
184
  signing_key:
175
185
  specification_version: 4
176
186
  summary: DaVinci CRD Test Kit