Skip to content

Commit

Permalink
FI-2945: Refactor Service Base URL Tests (#25)
Browse files Browse the repository at this point in the history
* Refactor tests, fix test spacing and format, update spec test

* Fix Accept header typo from rebase

* Clarify input language, change service base url test group to run_as_group,  and change terminology from Service Base URL List to Service Base URL Publication
  • Loading branch information
emichaud998 authored Sep 6, 2024
1 parent f6941d7 commit fb0a8d0
Show file tree
Hide file tree
Showing 6 changed files with 257 additions and 146 deletions.
4 changes: 2 additions & 2 deletions config/presets/local_host_endpoint_list_preset.json.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"test_suite_id": "service_base_url",
"inputs": [
{
"name": "service_base_url_list_url",
"name": "service_base_url_publication_url",
"value": "<%= Inferno::Application['base_url'] %>/custom/service_base_url/examples/testBundleValid.json",
"title": "Service Base URL List URL",
"title": "Service Base URL Publication URL",
"type": "text"
}
]
Expand Down
24 changes: 15 additions & 9 deletions lib/service_base_url_test_kit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,33 @@ class ServiceBaseURLTestSuite < Inferno::TestSuite
170.315(g)(10) are centrally managed by the Certified API Developer or
locally deployed by an API Information Source. These service base URLs and
organization details must conform to the following:
- Service base URLs must be publicly published in Endpoint resource format
according to the standard adopted in § 170.215(a) (FHIR v4.0.1).
- Organization details for each service base URL must be publicly published in Organization
resource format according to the standard adopted in § 170.215(a) (FHIR v4.0.1). Each
Organization resource must contain:
Organization resource must contain:
- A reference, in the Organization endpoint element, to the Endpoint
resources containing service base URLs managed by this organization.
- The organizations name, location, and facility identifier.
- The organization's name, location, and facility identifier.
- Endpoint and Organization resources must be:
- Collected into a Bundle resource formatted according to the standard
adopted in § 170.215(a) (FHIR v4.0.1) for publication;
adopted in § 170.215(a) (FHIR v4.0.1) for publication;
- and Reviewed quarterly and, as
necessary, updated.
)
version VERSION

input_instructions <<~INSTRUCTIONS
For systems that make their Service Base URL Bundle available at a public endpoint, please input
the Service Base URL Publication URL to retreive the Bundle from there in order to perform validation.
For systems that do not have a Service Base URL Bundle served at a public endpoint, testers can validate by
providing the Service Base URL Publication Bundle as an input.
INSTRUCTIONS

links [
{
label: 'Report Issue',
Expand All @@ -78,11 +86,9 @@ class ServiceBaseURLTestSuite < Inferno::TestSuite
my_bundle = JSON.parse(erb_template.result).to_json
filename = filename.delete_suffix('.erb')
end
if filename.include?("CapabilityStatement")
filename = filename.delete_suffix('.json') + "/metadata"
end
filename = "#{filename.delete_suffix('.json')}/metadata" if filename.include?('CapabilityStatement')
my_bundle_route_handler = proc { [200, { 'Content-Type' => 'application/json' }, [my_bundle]] }

# Serve a JSON file at INFERNO_PATH/custom/service_base_url/examples/filename
route :get, File.join('/examples/', filename), my_bundle_route_handler
end
Expand All @@ -101,4 +107,4 @@ class ServiceBaseURLTestSuite < Inferno::TestSuite

group from: :service_base_url_test_group
end
end
end
26 changes: 13 additions & 13 deletions lib/service_base_url_test_kit/service_base_url_retrieve_group.rb
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
module ServiceBaseURLTestKit
class ServiceBaseURLEndpointQueryGroup < Inferno::TestGroup
id :service_base_url_retrieve_list
title 'Retrieve Service Base URL List'
title 'Retrieve Service Base URL Publication'
description %(
A developer's Service Base URL list must be publicly available. This test
A developer's Service Base URL publication must be publicly available. This test
issues a HTTP GET request against the supplied URL and expects to receive
the service base url list at this location.
the service base url publication at this location.
)
run_as_group

input :service_base_url_list_url,
title: 'Service Base URL List URL',
description: 'The URL to the developer\'s public Service Base URL List'

http_client do
url :service_base_url_list_url
headers 'Accept': 'application/json, application/fhir+json'
url :service_base_url_publication_url
headers Accept: 'application/json, application/fhir+json'
end

test do
id :service_base_url_retrieve_list_test
title 'Server returns publicly accessible Service Base URL List'
title 'Server returns publicly accessible Service Base URL Publication'
description %(
Verify that the developer's list of Service Base URLs can be publicly
accessed at the supplied URL location.
)

input :service_base_url_publication_url,
optional: true

output :bundle_response

makes_request :bundle_request

run do
get
omit_if service_base_url_publication_url.blank?, 'URL for Service Base URL Publication not Inputted.'

get(tags: ['service_base_url_bundle'])
assert_response_status(200)
output bundle_response: resource.to_json
end
end
end
end
end
41 changes: 34 additions & 7 deletions lib/service_base_url_test_kit/service_base_url_test_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,53 @@
module ServiceBaseURLTestKit
class ServiceBaseURLGroup < Inferno::TestGroup
id :service_base_url_test_group
title 'Retrieve and Validate Service Base URL List'
description %(
title 'Validate Service Base URL Publication'
description %(
Verify that the developer makes its Service Base URL publication publicly available
in the Bundle resource format with valid Endpoint and Organization entries.
This test group will issue a HTTP GET request against the supplied URL to
retrieve the developer's Service Base URL list and ensure the list is
retrieve the developer's Service Base URL publication and ensure the list is
publicly accessible. It will then ensure that the returned service base URL
publication is in the Bundle resource format containing its service base URLs and
related organizational details in valid Endpoint and Organization resources
that follow the specifications detailed in the HTI-1 rule and the API
Condition and Maintenance of Certification.
For systems that provide the service base URL Bundle at a URL, please run
all tests within this group. While it is the expectation of the
this test with the Service Base URL Publication URL input populated. While it is the expectation of the
specification for the service base URL Bundle to be served at a
public-facing endpoint, testers can validate a Service Base URL Bundle not
served at a public endpoint by running Test 1.2: Validate Service Base URL
List validation individually.
served at a public endpoint by running these tests with the Service Base URL Publication Bundle input populated
and the Service Base URL Publication URL input left blank.
)


input_instructions <<~INSTRUCTIONS
For systems that make their Service Base URL Bundle available at a public endpoint, please input
the Service Base URL Publication URL to retreive the Bundle from there in order to perform validation.
For systems that do not have a Service Base URL Bundle served at a public endpoint, testers can validate by
providing the Service Base URL Publication Bundle as an input and leaving the Service Base URL Publication URL
input blank.
INSTRUCTIONS

run_as_group

input :service_base_url_publication_url,
title: 'Service Base URL Publication URL',
description: %(The URL to the developer's public Service Base URL Publication. Insert your Service Base URL
publication URL if you host your Bundle at a public-facing endpoint and want Inferno to retrieve the Bundle
from there.),
optional: true

input :service_base_url_bundle,
title: 'Service Base URL Publication Bundle',
description: %(The developer's Service Base URL Publication in the JSON string format. If this input is
populated, Inferno will use the Bundle inserted here to do validation. Insert your Service Base URL
Publication Bundle in the JSON format in this input to validate your list without Inferno needing to access
the Bundle via a public-facing endpoint.),
type: 'textarea',
optional: true

group from: :service_base_url_retrieve_list
group from: :service_base_url_validate_list
end
Expand Down
Loading

0 comments on commit fb0a8d0

Please sign in to comment.