davinci_crd_test_kit 0.12.0 → 0.12.1

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 (56) hide show
  1. checksums.yaml +4 -4
  2. data/config/presets/inferno_crd_server_suite.json.erb +6 -1
  3. data/config/presets/ri_crd_request_generator.json.erb +1 -1
  4. data/lib/davinci_crd_test_kit/client_fhir_api_group.rb +13 -2
  5. data/lib/davinci_crd_test_kit/client_hooks_group.rb +11 -4
  6. data/lib/davinci_crd_test_kit/client_registration_group.rb +26 -0
  7. data/lib/davinci_crd_test_kit/client_tests/appointment_book_receive_request_test.rb +14 -3
  8. data/lib/davinci_crd_test_kit/client_tests/client_appointment_book_group.rb +6 -1
  9. data/lib/davinci_crd_test_kit/client_tests/client_encounter_discharge_group.rb +2 -0
  10. data/lib/davinci_crd_test_kit/client_tests/client_encounter_start_group.rb +3 -0
  11. data/lib/davinci_crd_test_kit/client_tests/client_fhir_api_create_test.rb +1 -0
  12. data/lib/davinci_crd_test_kit/client_tests/client_fhir_api_search_test.rb +2 -2
  13. data/lib/davinci_crd_test_kit/client_tests/client_fhir_api_update_test.rb +1 -0
  14. data/lib/davinci_crd_test_kit/client_tests/client_fhir_api_validation_test.rb +1 -1
  15. data/lib/davinci_crd_test_kit/client_tests/client_order_dispatch_group.rb +10 -1
  16. data/lib/davinci_crd_test_kit/client_tests/client_order_select_group.rb +11 -1
  17. data/lib/davinci_crd_test_kit/client_tests/client_order_sign_group.rb +11 -1
  18. data/lib/davinci_crd_test_kit/client_tests/client_registration_verification_test.rb +88 -0
  19. data/lib/davinci_crd_test_kit/client_tests/encounter_discharge_receive_request_test.rb +12 -3
  20. data/lib/davinci_crd_test_kit/client_tests/encounter_start_receive_request_test.rb +13 -3
  21. data/lib/davinci_crd_test_kit/client_tests/hook_request_optional_fields_test.rb +1 -1
  22. data/lib/davinci_crd_test_kit/client_tests/hook_request_valid_context_test.rb +1 -0
  23. data/lib/davinci_crd_test_kit/client_tests/hook_request_valid_prefetch_test.rb +1 -0
  24. data/lib/davinci_crd_test_kit/client_tests/order_dispatch_receive_request_test.rb +14 -3
  25. data/lib/davinci_crd_test_kit/client_tests/order_select_receive_request_test.rb +13 -3
  26. data/lib/davinci_crd_test_kit/client_tests/order_sign_receive_request_test.rb +13 -3
  27. data/lib/davinci_crd_test_kit/client_tests/retrieve_jwks_test.rb +11 -8
  28. data/lib/davinci_crd_test_kit/client_tests/token_payload_test.rb +3 -3
  29. data/lib/davinci_crd_test_kit/crd_client_suite.rb +30 -2
  30. data/lib/davinci_crd_test_kit/hook_request_field_validation.rb +8 -0
  31. data/lib/davinci_crd_test_kit/requirements/davinci-crd-test-kit_out_of_scope_requirements.csv +1 -0
  32. data/lib/davinci_crd_test_kit/requirements/davinci-crd-test-kit_requirements.csv +368 -0
  33. data/lib/davinci_crd_test_kit/requirements/generated/davinci-crd-test-kit_requirements_coverage.csv +366 -0
  34. data/lib/davinci_crd_test_kit/server_appointment_book_group.rb +2 -0
  35. data/lib/davinci_crd_test_kit/server_discovery_group.rb +2 -1
  36. data/lib/davinci_crd_test_kit/server_encounter_discharge_group.rb +1 -0
  37. data/lib/davinci_crd_test_kit/server_encounter_start_group.rb +1 -0
  38. data/lib/davinci_crd_test_kit/server_hooks_group.rb +2 -0
  39. data/lib/davinci_crd_test_kit/server_order_dispatch_group.rb +2 -0
  40. data/lib/davinci_crd_test_kit/server_order_select_group.rb +1 -0
  41. data/lib/davinci_crd_test_kit/server_order_sign_group.rb +2 -0
  42. data/lib/davinci_crd_test_kit/server_required_card_response_validation_group.rb +3 -0
  43. data/lib/davinci_crd_test_kit/server_tests/coverage_information_system_action_received_test.rb +3 -0
  44. data/lib/davinci_crd_test_kit/server_tests/coverage_information_system_action_validation_test.rb +1 -0
  45. data/lib/davinci_crd_test_kit/server_tests/create_or_update_coverage_info_response_validation_test.rb +1 -0
  46. data/lib/davinci_crd_test_kit/server_tests/external_reference_card_validation_test.rb +1 -0
  47. data/lib/davinci_crd_test_kit/server_tests/form_completion_response_validation_test.rb +1 -0
  48. data/lib/davinci_crd_test_kit/server_tests/launch_smart_app_card_validation_test.rb +1 -0
  49. data/lib/davinci_crd_test_kit/server_tests/service_response_validation_test.rb +3 -3
  50. data/lib/davinci_crd_test_kit/suggestion_actions_validation.rb +1 -1
  51. data/lib/davinci_crd_test_kit/version.rb +2 -2
  52. data/lib/davinci_crd_test_kit.rb +1 -0
  53. data/lib/inferno_requirements_tools/ext/inferno_core/runnable.rb +22 -0
  54. data/lib/inferno_requirements_tools/tasks/requirements_coverage.rb +284 -0
  55. data/lib/requirements_config.yaml +18 -0
  56. metadata +10 -2
@@ -10,10 +10,19 @@ module DaVinciCRDTestKit
10
10
  This test waits for multiple incoming [order-select](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#order-select)
11
11
  hook requests and responds to the client with the response types selected as an input.
12
12
  )
13
+ verifies_requirements 'hl7.fhir.us.davinci-crd_2.0.1@209', 'hl7.fhir.us.davinci-crd_2.0.1@243',
14
+ 'hl7.fhir.us.davinci-crd_2.0.1@244', 'hl7.fhir.us.davinci-crd_2.0.1@245'
13
15
 
14
16
  config options: { accepts_multiple_requests: true }
15
17
 
16
- input :iss
18
+ input :cds_jwt_iss,
19
+ title: 'CRD JWT Issuer',
20
+ description: %(
21
+ Value of the `iss` claim that must be sent on the Bearer token in the `Authorization`
22
+ header of all requests. Run or re-run the **Client Registration** group to set or
23
+ change this value.
24
+ ),
25
+ locked: true
17
26
  input :order_select_selected_response_types,
18
27
  title: 'Response types to return from order-select hook requests',
19
28
  description: %(
@@ -70,7 +79,7 @@ module DaVinciCRDTestKit
70
79
 
71
80
  run do
72
81
  wait(
73
- identifier: "order-select #{iss}",
82
+ identifier: "order-select #{cds_jwt_iss}",
74
83
  message: %(
75
84
  **Order Select CDS Service Test**:
76
85
 
@@ -80,7 +89,8 @@ module DaVinciCRDTestKit
80
89
 
81
90
  Inferno will process the requests and return CDS cards if successful.
82
91
 
83
- [Click here](#{resume_pass_url}?token=order-select%20#{iss}) when you have finished submitting requests.
92
+ [Click here](#{resume_pass_url}?token=order-select%20#{cds_jwt_iss}) when you have finished submitting
93
+ requests.
84
94
  )
85
95
  )
86
96
  end
@@ -13,10 +13,20 @@ module DaVinciCRDTestKit
13
13
  system action for these hooks, even if the response indicates that further information is needed or that the
14
14
  level of detail provided is insufficient to determine coverage.
15
15
  )
16
+ verifies_requirements 'hl7.fhir.us.davinci-crd_2.0.1@218', 'hl7.fhir.us.davinci-crd_2.0.1@225',
17
+ 'hl7.fhir.us.davinci-crd_2.0.1@243', 'hl7.fhir.us.davinci-crd_2.0.1@244',
18
+ 'hl7.fhir.us.davinci-crd_2.0.1@245'
16
19
 
17
20
  config options: { accepts_multiple_requests: true }
18
21
 
19
- input :iss
22
+ input :cds_jwt_iss,
23
+ title: 'CRD JWT Issuer',
24
+ description: %(
25
+ Value of the `iss` claim that must be sent on the Bearer token in the `Authorization`
26
+ header of all requests. Run or re-run the **Client Registration** group to set or
27
+ change this value.
28
+ ),
29
+ locked: true
20
30
  input :order_sign_selected_response_types,
21
31
  title: 'Response types to return from order-sign hook requests',
22
32
  description: %(
@@ -73,7 +83,7 @@ module DaVinciCRDTestKit
73
83
 
74
84
  run do
75
85
  wait(
76
- identifier: "order-sign #{iss}",
86
+ identifier: "order-sign #{cds_jwt_iss}",
77
87
  message: %(
78
88
  **Order Sign CDS Service Test**:
79
89
 
@@ -83,7 +93,7 @@ module DaVinciCRDTestKit
83
93
 
84
94
  Inferno will process the requests and return CDS cards if successful.
85
95
 
86
- [Click here](#{resume_pass_url}?token=order-sign%20#{iss}) when you have finished submitting requests.
96
+ [Click here](#{resume_pass_url}?token=order-sign%20#{cds_jwt_iss}) when you have finished submitting requests.
87
97
  )
88
98
  )
89
99
  end
@@ -9,19 +9,22 @@ module DaVinciCRDTestKit
9
9
  description %(
10
10
  Verify that the JWKS can be retrieved from the JWKS uri if it is present in the `jku` field within the JWT token
11
11
  header. As per the [CDS hooks specification](https://cds-hooks.hl7.org/2.0#trusting-cds-clients), if the jku
12
- header field is ommitted, the CDS Client and CDS Service SHALL communicate the JWK Set out-of-band. Therefore,
12
+ header field is omitted, the CDS Client and CDS Service SHALL communicate the JWK Set out-of-band. Therefore,
13
13
  if the client does not make their keys publicly available via a uri in the `jku` field, the user must
14
14
  submit the jwk_set as an input to the test.
15
15
  )
16
16
 
17
17
  input :auth_token_headers_json
18
- input :jwk_set,
19
- title: "The Client's JWK Set containing it's public key",
18
+ input :cds_jwk_set,
19
+ title: 'CRD JSON Web Key Set (JWKS)',
20
+ type: 'textarea',
20
21
  description: %(
21
- Must supply if you do not make your keys publicly available via a uri in the authorization JWT header `jku`
22
- field'
22
+ The client's registered JWK Set containing it's public key, either
23
+ as a publicly accessible url containing the JWKS, or the raw JWKS.
24
+ Run or re-run the **Client Registration** group to set or
25
+ change this value. Used if the `jku` header is not found in the auth token jwt.
23
26
  ),
24
- type: 'textarea',
27
+ locked: true,
25
28
  optional: true
26
29
  output :crd_jwks_json, :crd_jwks_keys_json
27
30
 
@@ -53,11 +56,11 @@ module DaVinciCRDTestKit
53
56
 
54
57
  jwks = JSON.parse(response[:body])
55
58
  else
56
- skip_if jwk_set.blank?,
59
+ skip_if cds_jwk_set.blank?,
57
60
  %(#{request_number}JWK Set must be inputted if Client's JWK Set is not available via a URL
58
61
  identified by the jku header field)
59
62
 
60
- jwks = JSON.parse(jwk_set)
63
+ jwks = JSON.parse(cds_jwk_set)
61
64
  end
62
65
 
63
66
  keys = jwks['keys']
@@ -12,7 +12,7 @@ module DaVinciCRDTestKit
12
12
  The `iss`, `aud`, `exp`, `iat`, and `jti` claims are required.
13
13
  Additionally:
14
14
 
15
- - `iss` must match the `issuer` from the `iss` input
15
+ - `iss` must match the `issuer` from the **CRD JWT Issuer** input
16
16
  - `aud` must match the URL of the CDS Service endpoint being invoked
17
17
  - `exp` must represent a time in the future
18
18
  - `jti` must be a non-blank string that uniquely identifies this authentication JWT
@@ -30,7 +30,7 @@ module DaVinciCRDTestKit
30
30
 
31
31
  input :auth_tokens,
32
32
  :auth_tokens_jwk_json,
33
- :iss
33
+ :cds_jwt_iss
34
34
 
35
35
  run do
36
36
  auth_tokens_list = JSON.parse(auth_tokens)
@@ -51,7 +51,7 @@ module DaVinciCRDTestKit
51
51
  true,
52
52
  algorithms: [jwk[:alg]],
53
53
  exp_leeway: 60,
54
- iss:,
54
+ iss: cds_jwt_iss,
55
55
  aud: hook_url,
56
56
  verify_not_before: false,
57
57
  verify_iat: false,
@@ -1,5 +1,6 @@
1
1
  require_relative 'client_fhir_api_group'
2
2
  require_relative 'client_hooks_group'
3
+ require_relative 'client_registration_group'
3
4
  require_relative 'routes/cds_services_discovery_handler'
4
5
  require_relative 'tags'
5
6
  require_relative 'urls'
@@ -33,8 +34,10 @@ module DaVinciCRDTestKit
33
34
  ## SMART App Launch
34
35
  Use this information when registering Inferno as a SMART App:
35
36
 
36
- * Launch URI: `#{SMARTAppLaunch::AppLaunchTest.config.options[:launch_uri]}`
37
- * Redirect URI: `#{SMARTAppLaunch::AppRedirectTest.config.options[:redirect_uri]}`
37
+ * Launch URI: `#{SMARTAppLaunch::AppLaunchTest.config.options[:launch_uri] ||
38
+ "#{Inferno::Application['base_url']}/custom/smart/launch"}`
39
+ * Redirect URI: `#{SMARTAppLaunch::AppRedirectTest.config.options[:redirect_uri] ||
40
+ "#{Inferno::Application['base_url']}/custom/smart/redirect"}`
38
41
 
39
42
  If a client receives a SMART App Launch card in a response and would like
40
43
  to test their ability to launch Inferno as a SMART App, first run the
@@ -70,6 +73,29 @@ module DaVinciCRDTestKit
70
73
  based on the provided inputs, as the resource might not exist on the
71
74
  client's FHIR server.
72
75
 
76
+ ## Running the Tests aginst the Server Suite
77
+
78
+ You can also run these tests against the Inferno CRD Server test suite.
79
+ The server suite will not render cards like a real CRD client would do,
80
+ but will simulate and verify the interactions between the client and
81
+ server.
82
+
83
+ 1. Start a "Da Vinci CRD Client Test Suite" session.
84
+ 1. Choose the "Inferno CRD Server Suite" preset from the drop down in the upper left.
85
+ 1. Run the Client Registration test group. It should pass.
86
+ 1. Run the Hooks > Appointment Book test group leaving the inputs as is. A
87
+ "User Action Dialog" will appear indicating that Inferno is waiting for the
88
+ `appointment-book` hook invocation.
89
+ 1. In another tab, start a "Da Vinci CRD Server Test Suite" session.
90
+ 1. Choose the "Inferno CRD Client Suite" preset from the drop down in the upper left.
91
+ 1. Run the Discovery test group. It should pass.
92
+ 1. Run the Demonstrate A Hook Response test. It should pass
93
+ 1. Return to the client suite and click the link to continue the tests.
94
+ 1. When the attestation wait dialog appears, return to the server tests and look in test
95
+ **2.04** "All service responses contain valid cards and optional systemActions"
96
+ for the CDS hooks request made and look at the response to verify that the
97
+ indicate cards are present. Attest accordingly in the client suite to complete the tests.
98
+
73
99
  ## Limitations
74
100
  The test suite does not implement any sort of payer business logic, so the
75
101
  responses to hook calls are simple hard-coded responses. Hook
@@ -142,6 +168,8 @@ module DaVinciCRDTestKit
142
168
  CRDClientSuite.extract_token_from_query_params(request)
143
169
  end
144
170
 
171
+ group from: :crd_client_registration
172
+
145
173
  group from: :crd_client_hooks
146
174
 
147
175
  group from: :crd_client_fhir_api
@@ -286,6 +286,14 @@ module DaVinciCRDTestKit
286
286
  end
287
287
 
288
288
  def bundle_entries_check(context, context_field_name, bundle, resource_types, status = nil)
289
+ bundle.entry.each do |entry|
290
+ resource_id = entry.resource.id
291
+ next unless resource_id.blank?
292
+
293
+ error_msg = 'Resource in the FHIR Bundle does not have an id'
294
+ add_message('error', error_msg)
295
+ end
296
+
289
297
  target_resources = bundle.entry.map(&:resource).select { |r| resource_types.include?(r.resourceType) }
290
298
  if target_resources.blank?
291
299
  error_msg = "#{request_number}`#{context_field_name}` bundle must contain at least one of the " \