Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auth info #17

Merged
merged 5 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ GEM
blueprinter (0.25.2)
byebug (11.1.3)
coderay (1.1.3)
concurrent-ruby (1.3.3)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
crack (1.0.0)
bigdecimal
Expand Down Expand Up @@ -61,7 +61,7 @@ GEM
zeitwerk (~> 2.6)
factory_bot (6.4.6)
activesupport (>= 5.0.0)
faraday (1.10.3)
faraday (1.10.4)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
Expand All @@ -84,7 +84,7 @@ GEM
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
faraday_middleware (1.2.0)
faraday_middleware (1.2.1)
faraday (~> 1.0)
fhir_client (5.0.3)
activesupport (>= 3)
Expand Down Expand Up @@ -130,11 +130,11 @@ GEM
hansi (0.2.1)
hashdiff (1.1.0)
http-accept (1.7.0)
http-cookie (1.0.6)
http-cookie (1.0.7)
domain_name (~> 0.5)
i18n (1.14.5)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
inferno_core (0.4.39)
inferno_core (0.4.42)
activesupport (~> 6.1.7.5)
base62-rb (= 0.3.1)
blueprinter (= 0.25.2)
Expand Down Expand Up @@ -165,17 +165,17 @@ GEM
rdoc (>= 4.0.0)
reline (>= 0.4.2)
json (2.7.2)
jwt (2.8.2)
jwt (2.9.1)
base64
kramdown (2.4.0)
rexml
language_server-protocol (3.17.0.3)
method_source (1.1.0)
mime-types (3.5.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2024.0806)
mime-types-data (3.2024.0903)
mini_portile2 (2.8.7)
minitest (5.24.1)
minitest (5.25.1)
multi_json (1.15.0)
multi_xml (0.7.1)
bigdecimal (~> 3.1)
Expand Down Expand Up @@ -218,7 +218,7 @@ GEM
psych (5.1.2)
stringio
public_suffix (6.0.1)
puma (5.6.8)
puma (5.6.9)
nio4r (~> 2.0)
racc (1.8.1)
rack (2.2.9)
Expand All @@ -236,9 +236,8 @@ GEM
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rexml (3.3.4)
strscan
rouge (4.3.0)
rexml (3.3.7)
rouge (4.4.0)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
Expand Down Expand Up @@ -288,7 +287,6 @@ GEM
unicode-display_width (>= 1.5, < 3.0)
unicode_utils (~> 1.4)
strings-ansi (0.2.0)
strscan (3.1.0)
thor (1.2.2)
tilt (2.4.0)
tty-color (0.6.0)
Expand All @@ -302,13 +300,13 @@ GEM
tty-screen (0.8.2)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
unicode-display_width (2.6.0)
unicode_utils (1.4.0)
webmock (3.23.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
zeitwerk (2.6.17)
zeitwerk (2.6.18)

PLATFORMS
arm64-darwin-21
Expand Down
21 changes: 12 additions & 9 deletions lib/davinci_pas_test_kit/generated/v2.0.1/server_suite.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require_relative '../../validator_suppressions'
require_relative '../../custom_groups/v2.0.1/pas_error_group'
require_relative '../../version.rb'
require_relative '../../version'
require_relative 'pas_server_approval_use_case_group'
require_relative 'pas_server_denial_use_case_group'
require_relative 'pas_server_pended_use_case_group'
Expand All @@ -15,12 +15,12 @@ class ServerSuite < Inferno::TestSuite
description File.read(File.join(__dir__, '..', '..', 'docs', 'server_suite_description_v201.md'))

links [
{
label: 'Report Issue',
url: 'https://github.com/inferno-framework/davinci-pas-test-kit/issues/'
{
label: 'Report Issue',
url: 'https://github.com/inferno-framework/davinci-pas-test-kit/issues/'
},
{
label: 'Open Source',
label: 'Open Source',
url: 'https://github.com/inferno-framework/davinci-pas-test-kit/'
},
{
Expand Down Expand Up @@ -50,12 +50,15 @@ class ServerSuite < Inferno::TestSuite

input :smart_credentials,
title: 'OAuth Credentials',
type: :oauth_credentials,
type: :auth_info,
options: {
mode: 'access'
},
optional: true

fhir_client do
url :server_endpoint
oauth_credentials :smart_credentials
auth_info :smart_credentials
end

# Used for attestation experiment - see pas_claim_response_decision_test.rb
Expand All @@ -66,14 +69,14 @@ class ServerSuite < Inferno::TestSuite
# resume_test_route :get, RESUME_FAIL_PATH, result: 'fail' do |request|
# request.query_parameters['token']
# end

group 'Demonstrate Workflow Support' do
description %(
The workflow tests validate that the server can participate in complete
end-to-end prior authorization interactions, returning responses that are
conformant and also contain the correct codes.
)

group from: :pas_server_v201_approval_use_case
group from: :pas_server_v201_denial_use_case
group from: :pas_server_v201_pended_use_case
Expand Down
19 changes: 11 additions & 8 deletions lib/davinci_pas_test_kit/generator/templates/suite.rb.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require_relative '../../validator_suppressions'
require_relative '<%= error_group_file_name %>'
require_relative '../../version.rb'
require_relative '../../version'
<% group_file_list.each do |file_name| %>require_relative '<%= file_name %>'
<% end %>
module DaVinciPASTestKit
Expand All @@ -12,12 +12,12 @@ module DaVinciPASTestKit
description File.read(File.join(__dir__, '..', '..', 'docs', 'server_suite_description_<%= ig_metadata.reformatted_version %>.md'))

links [
{
label: 'Report Issue',
url: 'https://github.com/inferno-framework/davinci-pas-test-kit/issues/'
{
label: 'Report Issue',
url: 'https://github.com/inferno-framework/davinci-pas-test-kit/issues/'
},
{
label: 'Open Source',
label: 'Open Source',
url: 'https://github.com/inferno-framework/davinci-pas-test-kit/'
},
{
Expand Down Expand Up @@ -47,12 +47,15 @@ module DaVinciPASTestKit

input :smart_credentials,
title: 'OAuth Credentials',
type: :oauth_credentials,
type: :auth_info,
options: {
mode: 'access'
},
optional: true
vanessuniq marked this conversation as resolved.
Show resolved Hide resolved

fhir_client do
url :server_endpoint
oauth_credentials :smart_credentials
auth_info :smart_credentials
end

# Used for attestation experiment - see pas_claim_response_decision_test.rb
Expand All @@ -63,7 +66,7 @@ module DaVinciPASTestKit
# resume_test_route :get, RESUME_FAIL_PATH, result: 'fail' do |request|
# request.query_parameters['token']
# end

group 'Demonstrate Workflow Support' do
description %(
The workflow tests validate that the server can participate in complete
Expand Down
33 changes: 4 additions & 29 deletions lib/davinci_pas_test_kit/pas_bundle_validation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,10 @@ def handle_claim_profile(reference_elements, current_entry_profile_url)
# @param bundle_map [Hash] A map of the bundle contents.
# @param version [String] The FHIR version.
def process_reference_element(reference_element, current_entry, bundle_entry, bundle_map, version)
reference_element_values = evaluate_fhirpath_expression(current_entry.resource, reference_element[:path])
fhirpath_result = evaluate_fhirpath(resource: current_entry.resource, path: reference_element[:path])
reference_element_values = fhirpath_result.map do |entry|
entry['element']&.reference if entry['type'] == 'Reference'
end.compact
tstrass marked this conversation as resolved.
Show resolved Hide resolved
referenced_instances = reference_element_values.map do |value|
find_referenced_instance_in_bundle(value, current_entry.fullUrl, bundle_map)
end.compact
Expand Down Expand Up @@ -363,34 +366,6 @@ def bundle_entry_map(bundle_entry)
end
end

# Evaluates a FHIRPath expression against a FHIR resource using an external FHIRPath validator.
# @param resource [Object] The FHIR resource to be evaluated.
# @param expression [String] The FHIRPath expression to evaluate.
# @return [Array] An array of references extracted from the evaluation result, or an empty array in case of failure.
def evaluate_fhirpath_expression(resource, expression)
return [] unless expression && resource

logger = Logger.new($stdout)
begin
fhirpath_url = ENV.fetch('FHIRPATH_URL')
path = "#{fhirpath_url}/evaluate?path=#{expression}"

response = Faraday.post(path, resource.to_json, 'Content-Type' => 'application/json')
if response.status.to_s.start_with? '2'
result = JSON.parse(response.body)
return result.map { |entry| entry.dig('element', 'reference') if entry['type'] == 'Reference' }.compact
else
logger.error "External FHIRPath service failed: #{response.status}"
raise 'FHIRPath service not available'
end
rescue Faraday::Error => e
logger.error "HTTP request failed: #{e.message}"
raise 'FHIRPath service not available'
end

[]
end

# Finds a referenced instance in a FHIR bundle based on a reference and the full URL of the enclosing entry.
# @param reference [String] The reference to find.
# @param enclosing_entry_fullurl [String] The full URL of the enclosing entry.
Expand Down
Loading