davinci_pas_test_kit 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 35fff0ddc7e7badcd0fe5e9927f9bbafc7be123f908f4eed1f81c8f777189ef4
4
- data.tar.gz: 36fa5c2af21fb2ca92ff958a0f96d97aed08dd45c1bdd454cce2f2a4aabe5af1
3
+ metadata.gz: e7207f98c62ccfb04612a2d98d93623e1d76fd8085527c7876aac18ac84682ac
4
+ data.tar.gz: 818e6468ac830e23ce7f060556d36a3f62ebf133af0604c6b0123e9afdd286f8
5
5
  SHA512:
6
- metadata.gz: 954d086d05f047336a216d2d72947ca8d8d1ffaf944a3b29174a15ea7fd73fe75d6a9e26552af08b20d7b33917102903ec9e98f90000fd2228697ab9cb25defb
7
- data.tar.gz: 8ed7048ddeaad521eda54110707aa8a55e2e151c0f37c2f0a35ba5a57f2823c121e4b5d97796166340afbda10242650a2a83fe6244a6981d74ae5cf9472c4537
6
+ metadata.gz: 822cbab62106199fd7d870ee149bba4a5d7303ae1937b2d4b6ef44d5b208f55fc2809dd373bc584b6562fa2908d113d4fd0164e0bd82a4cf87116433450ac36e
7
+ data.tar.gz: 8186c2bd0d8b3d407f220969d90f339725d8f09863f0d01172a95813ef5fd4dfd99790486ff826189b13d8d43aad353d6b43d5d04aba2a02bb7824a223f5add1
@@ -20,6 +20,7 @@ module DaVinciPASTestKit
20
20
  )
21
21
 
22
22
  run do
23
+ skip_if request.status.between?(400, 499), 'Bad claim submission request.'
23
24
  wait(
24
25
  identifier: access_token,
25
26
  message: %(
@@ -77,6 +77,11 @@ json-encoded FHIR bundle in the "Claim pended response JSON" and "Claim deny res
77
77
  clicking the '*Run All Tests*' button. These responses will be echoed back when a request
78
78
  is made during the corresponding test.
79
79
 
80
+ Selecting the *Example PAS Server Responses* Preset in the dropdown in the upper left will fill in example
81
+ FHIR bundles for the pended and deny responses. It will also fill in a sample value for the Client ID,
82
+ which is only necessary for the *Demonstrate Authorization* test group, which can be skipped in favor of
83
+ manual bearer token input in subsequent tests as described above.
84
+
80
85
  ### Postman-based Demo
81
86
 
82
87
  If you do not have a PAS client but would like to try the tests out, you can use
@@ -25,9 +25,13 @@ module DaVinciPASTestKit
25
25
  operation = request&.url&.split('$')&.last
26
26
  req_bundle = FHIR.from_contents(request&.request_body)
27
27
  claim_entry = req_bundle&.entry&.find { |e| e&.resource&.resourceType == 'Claim' }
28
- root_url = base_url(claim_entry&.fullUrl)
29
- return unless ['submit', 'inquire'].include?(operation) && claim_entry.present?
28
+ claim_full_url = claim_entry&.fullUrl
29
+ if claim_entry.blank? || claim_full_url.blank?
30
+ handle_missing_required_elements(claim_entry, request)
31
+ return
32
+ end
30
33
 
34
+ root_url = base_url(claim_full_url)
31
35
  claim_response = mock_claim_response(claim_entry.resource, req_bundle, operation, root_url)
32
36
 
33
37
  res_bundle = FHIR::Bundle.new(
@@ -137,11 +141,25 @@ module DaVinciPASTestKit
137
141
  request.query_parameters['token']
138
142
  end
139
143
 
144
+ def handle_missing_required_elements(claim_entry, request)
145
+ request.status = 400
146
+ request.response_headers = { 'Content-Type': 'application/json' }
147
+ details = if claim_entry.blank?
148
+ 'Required Claim entry missing from bundle'
149
+ else
150
+ 'Required element fullUrl missing from Claim entry'
151
+ end
152
+ request.response_body = FHIR::OperationOutcome.new(
153
+ issue: FHIR::OperationOutcome::Issue.new(severity: 'fatal', code: 'required',
154
+ details: FHIR::CodeableConcept.new(text: details))
155
+ ).to_json
156
+ end
157
+
140
158
  # Drop the last two segments of a URL, i.e. the resource type and ID of a FHIR resource
141
159
  # e.g. http://example.org/fhir/Patient/123 -> http://example.org/fhir
142
160
  # @private
143
161
  def base_url(url)
144
- return unless url.start_with?('http://', 'https://')
162
+ return unless url&.start_with?('http://', 'https://')
145
163
 
146
164
  # Drop everything after the second to last '/', ignoring a trailing slash
147
165
  url.sub(%r{/[^/]*/[^/]*(/)?\z}, '')
@@ -465,7 +465,7 @@ module DaVinciPASTestKit
465
465
  url_regex = /\A#{URI::DEFAULT_PARSER.make_regexp(%w[http https])}\z/
466
466
  urn_uuid_regex = /\Aurn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\z/i
467
467
 
468
- string.match?(url_regex) || string.match?(urn_uuid_regex)
468
+ string&.match?(url_regex) || string&.match?(urn_uuid_regex)
469
469
  end
470
470
 
471
471
  # This method traverses references within a FHIR resource, ensuring that referenced resources
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: truen
2
2
 
3
3
  module DaVinciPASTestKit
4
- VERSION = '0.9.2'.freeze
4
+ VERSION = '0.9.3'.freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: davinci_pas_test_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Inferno Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-29 00:00:00.000000000 Z
11
+ date: 2024-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inferno_core