From fda96b786145335e6c4e5d8f3506cf60b166c2c5 Mon Sep 17 00:00:00 2001 From: "aholmes@mitre.org" <14923551+holmesie@users.noreply.github.com> Date: Tue, 31 Dec 2024 15:29:46 -0600 Subject: [PATCH 01/20] Add basic Bulk Data client test suite, groups, and tests --- lib/bulk_data_test_kit.rb | 1 + .../v1.0.1/bulk_data_test_suite.rb | 2 +- .../v2.0.0/bulk_data_test_suite.rb | 2 +- .../client/bulk_data_client_test_suite.rb | 63 +++++++ .../v2.0.0/client/docs/suite_description.md | 10 ++ .../v2.0.0/client/endpoints/delete.rb | 32 ++++ .../v2.0.0/client/endpoints/kick_off.rb | 48 ++++++ .../v2.0.0/client/endpoints/output.rb | 34 ++++ .../v2.0.0/client/endpoints/status.rb | 49 ++++++ .../v2.0.0/client/export_types.rb | 14 ++ .../v2.0.0/client/groups/delete.rb | 101 +++++++++++ .../v2.0.0/client/groups/export.rb | 102 +++++++++++ .../postman/delete.postman_collection.json | 117 +++++++++++++ .../system_export.postman_collection.json | 162 ++++++++++++++++++ lib/bulk_data_test_kit/v2.0.0/client/tags.rb | 18 ++ .../v2.0.0/client/tests/delete.rb | 39 +++++ .../v2.0.0/client/tests/kick_off.rb | 49 ++++++ .../v2.0.0/client/tests/output.rb | 38 ++++ .../v2.0.0/client/tests/status.rb | 39 +++++ lib/bulk_data_test_kit/v2.0.0/client/urls.rb | 47 +++++ .../client/bulk_data_client_spec.rb | 126 ++++++++++++++ 21 files changed, 1091 insertions(+), 2 deletions(-) create mode 100644 lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_test_suite.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0/client/docs/suite_description.md create mode 100644 lib/bulk_data_test_kit/v2.0.0/client/endpoints/delete.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0/client/endpoints/kick_off.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0/client/endpoints/output.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0/client/endpoints/status.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0/client/export_types.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0/client/groups/delete.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0/client/groups/export.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0/client/postman/delete.postman_collection.json create mode 100644 lib/bulk_data_test_kit/v2.0.0/client/postman/system_export.postman_collection.json create mode 100644 lib/bulk_data_test_kit/v2.0.0/client/tags.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0/client/tests/delete.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0/client/tests/kick_off.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0/client/tests/output.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0/client/tests/status.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0/client/urls.rb create mode 100644 spec/bulk_data_test_kit/client/bulk_data_client_spec.rb diff --git a/lib/bulk_data_test_kit.rb b/lib/bulk_data_test_kit.rb index 764fb8a..6ccb4f2 100644 --- a/lib/bulk_data_test_kit.rb +++ b/lib/bulk_data_test_kit.rb @@ -2,3 +2,4 @@ require_relative 'inferno_requirements_tools/ext/inferno_core/runnable' require_relative 'bulk_data_test_kit/v1.0.1/bulk_data_test_suite' require_relative 'bulk_data_test_kit/v2.0.0/bulk_data_test_suite' +require_relative 'bulk_data_test_kit/v2.0.0/client/bulk_data_client_test_suite' diff --git a/lib/bulk_data_test_kit/v1.0.1/bulk_data_test_suite.rb b/lib/bulk_data_test_kit/v1.0.1/bulk_data_test_suite.rb index 93b4a3b..84fd623 100644 --- a/lib/bulk_data_test_kit/v1.0.1/bulk_data_test_suite.rb +++ b/lib/bulk_data_test_kit/v1.0.1/bulk_data_test_suite.rb @@ -7,7 +7,7 @@ module BulkDataTestKit module BulkDataV101 class BulkDataTestSuite < Inferno::TestSuite - title 'Bulk Data Access v1.0.1' + title 'Bulk Data Access v1.0.1 Server' version VERSION id :bulk_data_v101 links [ diff --git a/lib/bulk_data_test_kit/v2.0.0/bulk_data_test_suite.rb b/lib/bulk_data_test_kit/v2.0.0/bulk_data_test_suite.rb index e44e324..b6bd3b2 100644 --- a/lib/bulk_data_test_kit/v2.0.0/bulk_data_test_suite.rb +++ b/lib/bulk_data_test_kit/v2.0.0/bulk_data_test_suite.rb @@ -7,7 +7,7 @@ module BulkDataTestKit module BulkDataV200 class BulkDataTestSuite < Inferno::TestSuite - title 'Bulk Data Access v2.0.0' + title 'Bulk Data Access v2.0.0 Server' version VERSION id :bulk_data_v200 links [ diff --git a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_test_suite.rb b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_test_suite.rb new file mode 100644 index 0000000..85fdf3b --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_test_suite.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true + +require_relative '../../version' + +require_relative './endpoints/delete' +require_relative './endpoints/kick_off' +require_relative './endpoints/output' +require_relative './endpoints/status' + +require_relative './groups/export' +require_relative './groups/delete' + +module BulkDataTestKit + module BulkDataV200 + module Client + # Bulk Data Access v2.0.0 Client Test Suite + class BulkDataClientTestSuite < Inferno::TestSuite + include URLs + + title 'Bulk Data Access v2.0.0 Client' + + description File.read(File.join(__dir__, 'docs', 'suite_description.md')) + + version VERSION + + id :bulk_data_v200_client + + links [ + { + label: 'Report Issue', + url: 'https://github.com/inferno-framework/bulk-data-test-kit/issues/' + }, + { + label: 'Open Source', + url: 'https://github.com/inferno-framework/bulk-data-test-kit/' + }, + { + label: 'Download', + url: 'https://github.com/inferno-framework/bulk-data-test-kit/releases' + }, + { + label: 'Implementation Guide', + url: 'https://hl7.org/fhir/uv/bulkdata/STU2/' + } + ] + + suite_endpoint :get, PATIENT_KICKOFF_ROUTE, Endpoints::KickOff + suite_endpoint :get, GROUP_KICKOFF_ROUTE, Endpoints::KickOff + suite_endpoint :get, SYSTEM_KICKOFF_ROUTE, Endpoints::KickOff + suite_endpoint :get, STATUS_ROUTE, Endpoints::Status + suite_endpoint :get, OUTPUT_ROUTE, Endpoints::Output + suite_endpoint :delete, STATUS_ROUTE, Endpoints::Delete + + resume_test_route :get, RESUME_PASS_PATH do |request| + request.query_parameters['id'] + end + + group from: :bulk_data_client_export_group + group from: :bulk_data_client_delete_group + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/docs/suite_description.md b/lib/bulk_data_test_kit/v2.0.0/client/docs/suite_description.md new file mode 100644 index 0000000..474398d --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0/client/docs/suite_description.md @@ -0,0 +1,10 @@ +The Bulk Data Access v2.0.0 Client test suite validates the conformance of a client +to the [FHIR Bulk Data Access IG STU2](http://hl7.org/fhir/uv/bulkdata/STU2). + +## Scope + +These tests are a **DRAFT** intended to allow implementers to perform +preliminary checks of their systems against the requirements stated for Bulk Data client actors +and [provide feedback](https://github.com/inferno-framework/bulk-data-test-kit/issues) +on the tests. Future versions of these tests may verify other +requirements and may change the test verification logic. diff --git a/lib/bulk_data_test_kit/v2.0.0/client/endpoints/delete.rb b/lib/bulk_data_test_kit/v2.0.0/client/endpoints/delete.rb new file mode 100644 index 0000000..8020ad4 --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0/client/endpoints/delete.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require_relative '../tags' + +module BulkDataTestKit + module BulkDataV200 + module Client + module Endpoints + # Delete Endpoint + class Delete < Inferno::DSL::SuiteEndpoint + include Tags + + def test_run_identifier + export_id + end + + def make_response + response.status = 202 + end + + def tags + [DELETE_TAG] + end + + def export_id + request.params[:export_id] + end + end + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/endpoints/kick_off.rb b/lib/bulk_data_test_kit/v2.0.0/client/endpoints/kick_off.rb new file mode 100644 index 0000000..6f294b4 --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0/client/endpoints/kick_off.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +require_relative '../tags' +require_relative '../urls' +require_relative '../export_types' + +module BulkDataTestKit + module BulkDataV200 + module Client + module Endpoints + # Kick Off Endpoint + class KickOff < Inferno::DSL::SuiteEndpoint + include Tags + include URLs + include ExportTypes + + def test_run_identifier + export_id + end + + def make_response + response.status = 202 + response.headers['Content-Location'] = status_url(export_id) + end + + def tags + case request_type.titleize + when PATIENT_EXPORT_TYPE + [PATIENT_KICKOFF_TAG] + when GROUP_EXPORT_TYPE + [GROUP_KICKOFF_TAG] + when SYSTEM_EXPORT_TYPE + [SYSTEM_KICKOFF_TAG] + end + end + + def export_id + request.params[:export_id] + end + + def request_type + request.params[:type] || SYSTEM_EXPORT_TYPE + end + end + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/endpoints/output.rb b/lib/bulk_data_test_kit/v2.0.0/client/endpoints/output.rb new file mode 100644 index 0000000..f4e3eea --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0/client/endpoints/output.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +require_relative '../tags' + +module BulkDataTestKit + module BulkDataV200 + module Client + module Endpoints + # Output Endpoint + class Output < Inferno::DSL::SuiteEndpoint + include Tags + + def test_run_identifier + export_id + end + + def make_response + response.status = 200 + response.headers['Content-Type'] = 'application/fhir+ndjson' + response.body = "#{FHIR::Patient.new.to_json.squish}\n" + end + + def tags + [OUTPUT_TAG] + end + + def export_id + request.params[:export_id] + end + end + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/endpoints/status.rb b/lib/bulk_data_test_kit/v2.0.0/client/endpoints/status.rb new file mode 100644 index 0000000..aae0965 --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0/client/endpoints/status.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +require_relative '../tags' +require_relative '../urls' + +module BulkDataTestKit + module BulkDataV200 + module Client + module Endpoints + # Status Endpoint + class Status < Inferno::DSL::SuiteEndpoint + include Tags + include URLs + + def test_run_identifier + export_id + end + + def make_response + response.status = 200 + response.body = response_body.to_json + response.format = :json + end + + def tags + [STATUS_TAG] + end + + def export_id + request.params[:export_id] + end + + def response_body + { + transactionTime: DateTime.now.iso8601, + request: kickoff_url(export_id), + requiresAccessToken: false, + output: [{ + type: 'Patient', + url: output_url(export_id) + }], + error: [] + } + end + end + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/export_types.rb b/lib/bulk_data_test_kit/v2.0.0/client/export_types.rb new file mode 100644 index 0000000..7712e3c --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0/client/export_types.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module BulkDataTestKit + module BulkDataV200 + module Client + # Export types for use in Bulk Data Client tests and endpoints + module ExportTypes + PATIENT_EXPORT_TYPE = 'Patient' + GROUP_EXPORT_TYPE = 'Group' + SYSTEM_EXPORT_TYPE = 'System' + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/groups/delete.rb b/lib/bulk_data_test_kit/v2.0.0/client/groups/delete.rb new file mode 100644 index 0000000..3a316a1 --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0/client/groups/delete.rb @@ -0,0 +1,101 @@ +# frozen_string_literal: true + +require_relative '../export_types' +require_relative '../urls' + +require_relative '../tests/kick_off' +require_relative '../tests/delete' + +module BulkDataTestKit + module BulkDataV200 + module Client + module Groups + # Bulk Data Client Delete Tests + class Delete < Inferno::TestGroup + include ExportTypes + include URLs + + title 'Bulk Data Client Delete Tests' + + description %( + The Bulk Data Client Delete tests verify the ability of a client to delete + a kicked-off bulk data export request. + ) + + id :bulk_data_client_delete_group + + run_as_group + + input :export_type, + title: 'Export Type', + description: 'The export endpoint type to test against.', + type: 'radio', + default: SYSTEM_EXPORT_TYPE, + options: { + list_options: [ + { + label: 'All Patients', + value: PATIENT_EXPORT_TYPE + }, + { + label: 'Group of Patients', + value: GROUP_EXPORT_TYPE + }, + { + label: 'System Level Export', + value: SYSTEM_EXPORT_TYPE + } + ] + } + + input :group_id, + title: 'Group ID', + description: 'If using the Group endpoint, the identifier of the Group to export.', + default: 1, + locked: true + + test do + title 'Wait For Request Sequence' + + description %( + This test will receive bulk data export requests until the user confirms they are finished. + ) + + input :export_type, :group_id + + output :export_id + + run do + export_id = SecureRandom.uuid + + output export_id: export_id + + wait( + identifier: export_id, + message: %( + Kick-off a #{export_type} endpoint type bulk export using the following base URL: + + #{kickoff_url(export_id)} + + #{export_type == GROUP_EXPORT_TYPE ? "Ensure the Group ID is set to #{group_id}." : ''} + + Once the export request has been kicked-off, + [delete the export](https://build.fhir.org/ig/HL7/bulk-data/export.html#bulk-data-delete-request). + + The entire request sequence will be recorded and used in the subsequent tests to + verify comformity to the + [Bulk Data IG](https://build.fhir.org/ig/HL7/bulk-data/export.html#sequence-overview). + + [Click here](#{resume_pass_url}?id=#{export_id}) when finished. + ) + ) + end + end + + test from: :bulk_data_client_kick_off + test from: :bulk_data_client_delete + end + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/groups/export.rb b/lib/bulk_data_test_kit/v2.0.0/client/groups/export.rb new file mode 100644 index 0000000..fa0de7e --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0/client/groups/export.rb @@ -0,0 +1,102 @@ +# frozen_string_literal: true + +require_relative '../export_types' +require_relative '../urls' + +require_relative '../tests/kick_off' +require_relative '../tests/status' +require_relative '../tests/output' + +module BulkDataTestKit + module BulkDataV200 + module Client + module Groups + # Bulk Data Client Export Tests + class Export < Inferno::TestGroup + include ExportTypes + include URLs + + title 'Bulk Data Client Export Tests' + + description %( + The Bulk Data Client Export tests verify the ability of a client to: + - Kick-off a new bulk data export request + - Poll the in-progress request for status updates + - Download a completed bulk data export file + ) + + id :bulk_data_client_export_group + + run_as_group + + input :export_type, + title: 'Export Type', + description: 'The export endpoint type to test against.', + type: 'radio', + default: SYSTEM_EXPORT_TYPE, + options: { + list_options: [ + { + label: 'All Patients', + value: PATIENT_EXPORT_TYPE + }, + { + label: 'Group of Patients', + value: GROUP_EXPORT_TYPE + }, + { + label: 'System Level Export', + value: SYSTEM_EXPORT_TYPE + } + ] + } + + input :group_id, + title: 'Group ID', + description: 'If using the Group endpoint, the identifier of the Group to export.', + default: 1, + locked: true + + test do + title 'Wait For Request Sequence' + + description %( + This test will receive bulk data export requests until the user confirms they are finished. + ) + + input :export_type, :group_id + + output :export_id + + run do + export_id = SecureRandom.uuid + + output export_id: export_id + + wait( + identifier: export_id, + message: %( + Perform a #{export_type} endpoint type bulk export using the following base URL: + + #{kickoff_url(export_id)} + + #{export_type == GROUP_EXPORT_TYPE ? "Ensure the Group ID is set to #{group_id}." : ''} + + The entire request sequence will be recorded and used in the subsequent tests to + verify comformity to the + [Bulk Data IG](https://build.fhir.org/ig/HL7/bulk-data/export.html#sequence-overview). + + [Click here](#{resume_pass_url}?id=#{export_id}) when finished. + ) + ) + end + end + + test from: :bulk_data_client_kick_off + test from: :bulk_data_client_status + test from: :bulk_data_client_output + end + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/postman/delete.postman_collection.json b/lib/bulk_data_test_kit/v2.0.0/client/postman/delete.postman_collection.json new file mode 100644 index 0000000..f79653f --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0/client/postman/delete.postman_collection.json @@ -0,0 +1,117 @@ +{ + "info": { + "name": "Bulk Data Client - System Export Delete", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + }, + "item": [ + { + "name": "Kickoff", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"kick-off was accepted\", function () {", + " pm.response.to.have.status(202);", + "});", + "", + "pm.collectionVariables.set(\"status-url\", pm.response.headers.get('Content-Location'));", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{kickoff-base-url}}/$export", + "host": [ + "{{kickoff-base-url}}" + ], + "path": [ + "$export" + ] + } + }, + "response": [] + }, + { + "name": "Delete", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "let responseData = pm.response.json();", + "", + "pm.test(\"export was deleted\", function () {", + " pm.response.to.have.status(202);", + "});", + "" + ], + "type": "text/javascript", + "packages": {} + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{status-url}}", + "host": [ + "{{status-url}}" + ] + } + }, + "response": [] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "type": "text/javascript", + "packages": {}, + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "type": "text/javascript", + "packages": {}, + "exec": [ + "" + ] + } + } + ], + "variable": [ + { + "key": "kickoff-base-url", + "value": "", + "type": "string" + }, + { + "key": "status-url", + "value": "", + "type": "string" + } + ] +} \ No newline at end of file diff --git a/lib/bulk_data_test_kit/v2.0.0/client/postman/system_export.postman_collection.json b/lib/bulk_data_test_kit/v2.0.0/client/postman/system_export.postman_collection.json new file mode 100644 index 0000000..af53517 --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0/client/postman/system_export.postman_collection.json @@ -0,0 +1,162 @@ +{ + "info": { + "name": "Bulk Data Client - System Export", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + }, + "item": [ + { + "name": "Kickoff", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"kick-off was accepted\", function () {", + " pm.response.to.have.status(202);", + "});", + "", + "pm.collectionVariables.set(\"status-url\", pm.response.headers.get('Content-Location'));", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{kickoff-base-url}}/$export", + "host": [ + "{{kickoff-base-url}}" + ], + "path": [ + "$export" + ] + } + }, + "response": [] + }, + { + "name": "Status", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "let responseData = pm.response.json();", + "", + "pm.test(\"export is complete\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.collectionVariables.set(\"download-url\", responseData.output[0].url);", + "" + ], + "type": "text/javascript", + "packages": {} + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{status-url}}", + "host": [ + "{{status-url}}" + ] + } + }, + "response": [] + }, + { + "name": "Download", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"downlaod is successful\", function () {", + " pm.response.to.have.status(200);", + "});", + "" + ], + "type": "text/javascript", + "packages": {} + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{download-url}}", + "host": [ + "{{download-url}}" + ] + } + }, + "response": [] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "type": "text/javascript", + "packages": {}, + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "type": "text/javascript", + "packages": {}, + "exec": [ + "" + ] + } + } + ], + "variable": [ + { + "key": "kickoff-base-url", + "value": "", + "type": "string" + }, + { + "key": "status-url", + "value": "", + "type": "string" + }, + { + "key": "download-url", + "value": "" + } + ] +} \ No newline at end of file diff --git a/lib/bulk_data_test_kit/v2.0.0/client/tags.rb b/lib/bulk_data_test_kit/v2.0.0/client/tags.rb new file mode 100644 index 0000000..043838c --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0/client/tags.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module BulkDataTestKit + module BulkDataV200 + module Client + # Tags for use in Bulk Data Client tests and endpoints + module Tags + METADATA_TAG = 'metadata_req' + PATIENT_KICKOFF_TAG = 'kickoff_patient_req' + GROUP_KICKOFF_TAG = 'kickoff_group_req' + SYSTEM_KICKOFF_TAG = 'kickoff_system_req' + STATUS_TAG = 'status_req' + OUTPUT_TAG = 'output_req' + DELETE_TAG = 'delete_req' + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/tests/delete.rb b/lib/bulk_data_test_kit/v2.0.0/client/tests/delete.rb new file mode 100644 index 0000000..f61df11 --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0/client/tests/delete.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require_relative '../tags' +require_relative '../urls' + +module BulkDataTestKit + module BulkDataV200 + module Client + module Tests + # Bulk Data Client - Delete + class Delete < Inferno::Test + include Tags + include URLs + + FAIL = 'Did not receive a delete request.' + + title 'Bulk Data Delete Request' + + description %( + This test verifies that after a Bulk Data request has been started, the client can send a + DELETE request to the URL provided in the Content-Location header to + [delete the request](https://hl7.org/fhir/uv/bulkdata/STU2/export.html#bulk-data-delete-request), + as described in the [FHIR Asynchronous Request Pattern](https://www.hl7.org/fhir/R4/async.html). + ) + + id :bulk_data_client_delete + + verifies_requirements 'hl7.fhir.uv.bulkdata_2.0.0@119' + + input :export_id + + run do + assert load_tagged_requests(DELETE_TAG).any?, FAIL + end + end + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/tests/kick_off.rb b/lib/bulk_data_test_kit/v2.0.0/client/tests/kick_off.rb new file mode 100644 index 0000000..f292271 --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0/client/tests/kick_off.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +require_relative '../tags' +require_relative '../urls' +require_relative '../export_types' + +module BulkDataTestKit + module BulkDataV200 + module Client + module Tests + # Bulk Data Client Kick-off + class KickOff < Inferno::Test + include Tags + include URLs + include ExportTypes + + PATIENT_FAIL = 'Did not receive a Patient type kick-off request.' + GROUP_FAIL = 'Did not receive a Group type kick-off request.' + SYSTEM_FAIL = 'Did not receive a System type kick-off request.' + + title 'Bulk Data Kick-off Request' + + description %( + This test verifies that a client can + [kick-off a Bulk Data request](https://hl7.org/fhir/uv/bulkdata/STU2/export.html#roles) + using the `$export` operation against the proper endpoint type. + ) + + id :bulk_data_client_kick_off + + verifies_requirements 'hl7.fhir.uv.bulkdata_2.0.0@17' + + input :export_id, :export_type, :group_id + + run do + case export_type + when PATIENT_EXPORT_TYPE + assert load_tagged_requests(PATIENT_KICKOFF_TAG).any?, PATIENT_FAIL + when GROUP_EXPORT_TYPE + assert load_tagged_requests(GROUP_KICKOFF_TAG).any?, GROUP_FAIL + when SYSTEM_EXPORT_TYPE + assert load_tagged_requests(SYSTEM_KICKOFF_TAG).any?, SYSTEM_FAIL + end + end + end + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/tests/output.rb b/lib/bulk_data_test_kit/v2.0.0/client/tests/output.rb new file mode 100644 index 0000000..69782c4 --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0/client/tests/output.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +require_relative '../tags' +require_relative '../urls' + +module BulkDataTestKit + module BulkDataV200 + module Client + module Tests + # Bulk Data Client Output + class Output < Inferno::Test + include Tags + include URLs + + FAIL = 'Did not receive a download request.' + + title 'Bulk Data Output File Request' + + description %( + This test verifies that the client, using the URL supplied in the Complete Status response body, + can [download](https://hl7.org/fhir/uv/bulkdata/STU2/export.html#bulk-data-output-file-request) + the generated Bulk Data file. + ) + + id :bulk_data_client_output + + verifies_requirements 'hl7.fhir.uv.bulkdata_2.0.0@200' + + input :export_id + + run do + assert load_tagged_requests(OUTPUT_TAG).any?, FAIL + end + end + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/tests/status.rb b/lib/bulk_data_test_kit/v2.0.0/client/tests/status.rb new file mode 100644 index 0000000..7c4be21 --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0/client/tests/status.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require_relative '../tags' +require_relative '../urls' + +module BulkDataTestKit + module BulkDataV200 + module Client + module Tests + # Bulk Data Client Status + class Status < Inferno::Test + include Tags + include URLs + + FAIL = 'Did not receive a status request.' + + title 'Bulk Data Status Request' + + description %( + This test verifies that after a Bulk Data request has been started, the client can + [poll the status URL](https://hl7.org/fhir/uv/bulkdata/STU2/export.html#bulk-data-status-request) + provided in the Content-Location header, as as described in the + [FHIR Asynchronous Request Pattern](https://www.hl7.org/fhir/R4/async.html). + ) + + id :bulk_data_client_status + + verifies_requirements 'hl7.fhir.uv.bulkdata_2.0.0@123' + + input :export_id + + run do + assert load_tagged_requests(STATUS_TAG).any?, FAIL + end + end + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/urls.rb b/lib/bulk_data_test_kit/v2.0.0/client/urls.rb new file mode 100644 index 0000000..ef44335 --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0/client/urls.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +module BulkDataTestKit + module BulkDataV200 + module Client + # URLs for use in Bulk Data Client tests and endpoints + module URLs + RESUME_PASS_PATH = '/resume_pass' + BASE_ROUTE = '/:export_id/fhir' + METADATA_ROUTE = "#{BASE_ROUTE}/metadata".freeze + PATIENT_KICKOFF_ROUTE = "#{BASE_ROUTE}/:type/$export".freeze + GROUP_KICKOFF_ROUTE = "#{BASE_ROUTE}/:type/:group_id/$export".freeze + SYSTEM_KICKOFF_ROUTE = "#{BASE_ROUTE}/$export".freeze + STATUS_ROUTE = '/status/:export_id' + OUTPUT_ROUTE = '/output/:export_id.ndjson' + + def base_url + "#{Inferno::Application['base_url']}/custom/#{suite_id}" + end + + def resume_pass_url + base_url + RESUME_PASS_PATH + end + + def kickoff_url(export_id) + base_url + BASE_ROUTE.gsub(':export_id', export_id) + end + + def status_url(export_id) + base_url + STATUS_ROUTE.gsub(':export_id', export_id) + end + + def output_url(export_id) + base_url + OUTPUT_ROUTE.gsub(':export_id', export_id) + end + + def suite_id + if respond_to?('result') # If being used with a suite endpoint + result.test_id.split('-').first + elsif self.class.respond_to?('suite') # If being used with a test/group/suite + self.class.suite.id + end + end + end + end + end +end diff --git a/spec/bulk_data_test_kit/client/bulk_data_client_spec.rb b/spec/bulk_data_test_kit/client/bulk_data_client_spec.rb new file mode 100644 index 0000000..0cb1a04 --- /dev/null +++ b/spec/bulk_data_test_kit/client/bulk_data_client_spec.rb @@ -0,0 +1,126 @@ +# frozen_string_literal: true + +require_relative '../../../lib/bulk_data_test_kit/v2.0.0/client/tags' +require_relative '../../../lib/bulk_data_test_kit/v2.0.0/client/urls' + +RSpec.describe BulkDataTestKit::BulkDataV200::Client do + let(:suite) { Inferno::Repositories::TestSuites.new.find('bulk_data_v200_client') } + let(:session_data_repo) { Inferno::Repositories::SessionData.new } + let(:results_repo) { Inferno::Repositories::Results.new } + let(:requests_repo) { Inferno::Repositories::Requests.new } + let(:test_session) { repo_create(:test_session, test_suite_id: 'bulk_data_v200_client') } + + let(:kickoff_test) { Inferno::Repositories::Tests.new.find('bulk_data_client_kick_off') } + let(:status_test) { Inferno::Repositories::Tests.new.find('bulk_data_client_status') } + let(:output_test) { Inferno::Repositories::Tests.new.find('bulk_data_client_output') } + let(:delete_test) { Inferno::Repositories::Tests.new.find('bulk_data_client_delete') } + + let(:patient_kickoff_tag) { BulkDataTestKit::BulkDataV200::Client::Tags::PATIENT_KICKOFF_TAG } + let(:group_kickoff_tag) { BulkDataTestKit::BulkDataV200::Client::Tags::GROUP_KICKOFF_TAG } + let(:system_kickoff_tag) { BulkDataTestKit::BulkDataV200::Client::Tags::SYSTEM_KICKOFF_TAG } + let(:status_tag) { BulkDataTestKit::BulkDataV200::Client::Tags::STATUS_TAG } + let(:output_tag) { BulkDataTestKit::BulkDataV200::Client::Tags::OUTPUT_TAG } + let(:delete_tag) { BulkDataTestKit::BulkDataV200::Client::Tags::DELETE_TAG } + + let(:patient_fail) { BulkDataTestKit::BulkDataV200::Client::Tests::KickOff::PATIENT_FAIL } + let(:group_fail) { BulkDataTestKit::BulkDataV200::Client::Tests::KickOff::GROUP_FAIL } + let(:system_fail) { BulkDataTestKit::BulkDataV200::Client::Tests::KickOff::SYSTEM_FAIL } + let(:status_fail) { BulkDataTestKit::BulkDataV200::Client::Tests::Status::FAIL } + let(:output_fail) { BulkDataTestKit::BulkDataV200::Client::Tests::Output::FAIL } + let(:delete_fail) { BulkDataTestKit::BulkDataV200::Client::Tests::Delete::FAIL } + + def run(runnable, inputs = {}) + test_run_params = { test_session_id: test_session.id }.merge(runnable.reference_hash) + test_run = Inferno::Repositories::TestRuns.new.create(test_run_params) + inputs.each do |name, value| + session_data_repo.save( + test_session_id: test_session.id, + name:, + value:, + type: runnable.config.input_type(name) + ) + end + Inferno::TestRunner.new(test_session:, test_run:).run(runnable) + end + + def mock_request(result, tags, verb = 'get') + requests_repo.create({ + verb:, + url: 'https://www.example.com/', + direction: 'incoming', + result_id: result.id, + test_session_id: test_session.id, + tags: + }) + end + + describe 'Bulk Data Client' do + describe 'kick-off test' do + %w[Patient Group System].each do |type| + describe "for #{type} type" do + it 'passes after kick-off request received' do + allow(kickoff_test).to receive_messages(suite:) + result = run(kickoff_test, export_id: 'foobar', export_type: type, group_id: 1) + + expect(result.result).to eq('fail') + expect(result.result_message).to eq(send("#{type.downcase}_fail")) + + mock_request(result, [send("#{type.downcase}_kickoff_tag")]) + + result = run(kickoff_test, export_id: 'foobar', export_type: type, group_id: 1) + + expect(result.result).to eq('pass') + end + end + end + end + + describe 'status test' do + it 'passes after status request received' do + allow(status_test).to receive_messages(suite:) + result = run(status_test, export_id: 'foobar') + + expect(result.result).to eq('fail') + expect(result.result_message).to eq(status_fail) + + mock_request(result, [status_tag]) + + result = run(status_test, export_id: 'foobar') + + expect(result.result).to eq('pass') + end + end + + describe 'output test' do + it 'passes after export downloaded' do + allow(output_test).to receive_messages(suite:) + result = run(output_test, export_id: 'foobar') + + expect(result.result).to eq('fail') + expect(result.result_message).to eq(output_fail) + + mock_request(result, [output_tag]) + + result = run(output_test, export_id: 'foobar') + + expect(result.result).to eq('pass') + end + end + + describe 'delete test' do + it 'passes after delete request received' do + allow(delete_test).to receive_messages(suite:) + result = run(delete_test, export_id: 'foobar') + + expect(result.result).to eq('fail') + expect(result.result_message).to eq(delete_fail) + + mock_request(result, [delete_tag], 'delete') + + result = run(delete_test, export_id: 'foobar') + + expect(result.result).to eq('pass') + end + end + end +end From b5320266782a67a5d439160e32dc36fe65839b6a Mon Sep 17 00:00:00 2001 From: "aholmes@mitre.org" <14923551+holmesie@users.noreply.github.com> Date: Tue, 7 Jan 2025 09:09:59 -0600 Subject: [PATCH 02/20] Remove ./ in relative requires --- .../v2.0.0/client/bulk_data_client_test_suite.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_test_suite.rb b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_test_suite.rb index 85fdf3b..4f12996 100644 --- a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_test_suite.rb +++ b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_test_suite.rb @@ -2,13 +2,13 @@ require_relative '../../version' -require_relative './endpoints/delete' -require_relative './endpoints/kick_off' -require_relative './endpoints/output' -require_relative './endpoints/status' +require_relative 'endpoints/delete' +require_relative 'endpoints/kick_off' +require_relative 'endpoints/output' +require_relative 'endpoints/status' -require_relative './groups/export' -require_relative './groups/delete' +require_relative 'groups/export' +require_relative 'groups/delete' module BulkDataTestKit module BulkDataV200 From cd44d9fd8c0c56fc5d97284e5b3e1092a1faed7a Mon Sep 17 00:00:00 2001 From: "aholmes@mitre.org" <14923551+holmesie@users.noreply.github.com> Date: Tue, 7 Jan 2025 09:32:33 -0600 Subject: [PATCH 03/20] Remove extra commas from postman collection json --- .../v2.0.0/client/postman/delete.postman_collection.json | 2 +- .../v2.0.0/client/postman/system_export.postman_collection.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/bulk_data_test_kit/v2.0.0/client/postman/delete.postman_collection.json b/lib/bulk_data_test_kit/v2.0.0/client/postman/delete.postman_collection.json index f79653f..4cb0710 100644 --- a/lib/bulk_data_test_kit/v2.0.0/client/postman/delete.postman_collection.json +++ b/lib/bulk_data_test_kit/v2.0.0/client/postman/delete.postman_collection.json @@ -1,7 +1,7 @@ { "info": { "name": "Bulk Data Client - System Export Delete", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, "item": [ { diff --git a/lib/bulk_data_test_kit/v2.0.0/client/postman/system_export.postman_collection.json b/lib/bulk_data_test_kit/v2.0.0/client/postman/system_export.postman_collection.json index af53517..ddd60d6 100644 --- a/lib/bulk_data_test_kit/v2.0.0/client/postman/system_export.postman_collection.json +++ b/lib/bulk_data_test_kit/v2.0.0/client/postman/system_export.postman_collection.json @@ -1,7 +1,7 @@ { "info": { "name": "Bulk Data Client - System Export", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, "item": [ { From c2b22c09f1c4b34e607e0f17a76d5d04c8d5b636 Mon Sep 17 00:00:00 2001 From: "aholmes@mitre.org" <14923551+holmesie@users.noreply.github.com> Date: Tue, 7 Jan 2025 09:47:07 -0600 Subject: [PATCH 04/20] Add more detail to patient example --- lib/bulk_data_test_kit/v2.0.0/client/endpoints/output.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/bulk_data_test_kit/v2.0.0/client/endpoints/output.rb b/lib/bulk_data_test_kit/v2.0.0/client/endpoints/output.rb index f4e3eea..10e07a6 100644 --- a/lib/bulk_data_test_kit/v2.0.0/client/endpoints/output.rb +++ b/lib/bulk_data_test_kit/v2.0.0/client/endpoints/output.rb @@ -17,7 +17,7 @@ def test_run_identifier def make_response response.status = 200 response.headers['Content-Type'] = 'application/fhir+ndjson' - response.body = "#{FHIR::Patient.new.to_json.squish}\n" + response.body = "#{example_patient.to_json.squish}\n" end def tags @@ -27,6 +27,13 @@ def tags def export_id request.params[:export_id] end + + def example_patient + FHIR::Patient.new( + id: test_run_identifier, + name: FHIR::HumanName.new(given: 'Example', family: 'Patient') + ) + end end end end From 671c25a734b5d1aaf6393985a896a876ec525521 Mon Sep 17 00:00:00 2001 From: "aholmes@mitre.org" <14923551+holmesie@users.noreply.github.com> Date: Tue, 7 Jan 2025 09:54:19 -0600 Subject: [PATCH 05/20] Break out wait tests into files --- .../v2.0.0/client/groups/delete.rb | 41 +------------- .../v2.0.0/client/groups/export.rb | 37 +----------- .../v2.0.0/client/tests/delete_wait.rb | 56 +++++++++++++++++++ .../v2.0.0/client/tests/export_wait.rb | 53 ++++++++++++++++++ 4 files changed, 114 insertions(+), 73 deletions(-) create mode 100644 lib/bulk_data_test_kit/v2.0.0/client/tests/delete_wait.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0/client/tests/export_wait.rb diff --git a/lib/bulk_data_test_kit/v2.0.0/client/groups/delete.rb b/lib/bulk_data_test_kit/v2.0.0/client/groups/delete.rb index 3a316a1..d76cfec 100644 --- a/lib/bulk_data_test_kit/v2.0.0/client/groups/delete.rb +++ b/lib/bulk_data_test_kit/v2.0.0/client/groups/delete.rb @@ -3,6 +3,7 @@ require_relative '../export_types' require_relative '../urls' +require_relative '../tests/delete_wait' require_relative '../tests/kick_off' require_relative '../tests/delete' @@ -54,44 +55,8 @@ class Delete < Inferno::TestGroup default: 1, locked: true - test do - title 'Wait For Request Sequence' - - description %( - This test will receive bulk data export requests until the user confirms they are finished. - ) - - input :export_type, :group_id - - output :export_id - - run do - export_id = SecureRandom.uuid - - output export_id: export_id - - wait( - identifier: export_id, - message: %( - Kick-off a #{export_type} endpoint type bulk export using the following base URL: - - #{kickoff_url(export_id)} - - #{export_type == GROUP_EXPORT_TYPE ? "Ensure the Group ID is set to #{group_id}." : ''} - - Once the export request has been kicked-off, - [delete the export](https://build.fhir.org/ig/HL7/bulk-data/export.html#bulk-data-delete-request). - - The entire request sequence will be recorded and used in the subsequent tests to - verify comformity to the - [Bulk Data IG](https://build.fhir.org/ig/HL7/bulk-data/export.html#sequence-overview). - - [Click here](#{resume_pass_url}?id=#{export_id}) when finished. - ) - ) - end - end - + test from: :bulk_data_client_delete_wait + test from: :bulk_data_client_kick_off test from: :bulk_data_client_kick_off test from: :bulk_data_client_delete end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/groups/export.rb b/lib/bulk_data_test_kit/v2.0.0/client/groups/export.rb index fa0de7e..b7cbe50 100644 --- a/lib/bulk_data_test_kit/v2.0.0/client/groups/export.rb +++ b/lib/bulk_data_test_kit/v2.0.0/client/groups/export.rb @@ -3,6 +3,7 @@ require_relative '../export_types' require_relative '../urls' +require_relative '../tests/export_wait' require_relative '../tests/kick_off' require_relative '../tests/status' require_relative '../tests/output' @@ -57,41 +58,7 @@ class Export < Inferno::TestGroup default: 1, locked: true - test do - title 'Wait For Request Sequence' - - description %( - This test will receive bulk data export requests until the user confirms they are finished. - ) - - input :export_type, :group_id - - output :export_id - - run do - export_id = SecureRandom.uuid - - output export_id: export_id - - wait( - identifier: export_id, - message: %( - Perform a #{export_type} endpoint type bulk export using the following base URL: - - #{kickoff_url(export_id)} - - #{export_type == GROUP_EXPORT_TYPE ? "Ensure the Group ID is set to #{group_id}." : ''} - - The entire request sequence will be recorded and used in the subsequent tests to - verify comformity to the - [Bulk Data IG](https://build.fhir.org/ig/HL7/bulk-data/export.html#sequence-overview). - - [Click here](#{resume_pass_url}?id=#{export_id}) when finished. - ) - ) - end - end - + test from: :bulk_data_client_export_wait test from: :bulk_data_client_kick_off test from: :bulk_data_client_status test from: :bulk_data_client_output diff --git a/lib/bulk_data_test_kit/v2.0.0/client/tests/delete_wait.rb b/lib/bulk_data_test_kit/v2.0.0/client/tests/delete_wait.rb new file mode 100644 index 0000000..7e24ec8 --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0/client/tests/delete_wait.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +require_relative '../urls' +require_relative '../export_types' + +module BulkDataTestKit + module BulkDataV200 + module Client + module Tests + # Bulk Data Client - Delete Wait + class DeleteWait < Inferno::Test + include URLs + include ExportTypes + + title 'Wait For Request Sequence' + + description %( + This test will receive bulk data export requests until the user confirms they are finished. + ) + + id :bulk_data_client_delete_wait + + input :export_type, :group_id + + output :export_id + + run do + export_id = SecureRandom.uuid + + output export_id: export_id + + wait( + identifier: export_id, + message: %( + Kick-off a #{export_type} endpoint type bulk export using the following base URL: + + #{kickoff_url(export_id)} + + #{export_type == GROUP_EXPORT_TYPE ? "Ensure the Group ID is set to #{group_id}." : ''} + + Once the export request has been kicked-off, + [delete the export](https://build.fhir.org/ig/HL7/bulk-data/export.html#bulk-data-delete-request). + + The entire request sequence will be recorded and used in the subsequent tests to + verify comformity to the + [Bulk Data IG](https://build.fhir.org/ig/HL7/bulk-data/export.html#sequence-overview). + + [Click here](#{resume_pass_url}?id=#{export_id}) when finished. + ) + ) + end + end + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/tests/export_wait.rb b/lib/bulk_data_test_kit/v2.0.0/client/tests/export_wait.rb new file mode 100644 index 0000000..d5c88c8 --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0/client/tests/export_wait.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +require_relative '../urls' +require_relative '../export_types' + +module BulkDataTestKit + module BulkDataV200 + module Client + module Tests + # Bulk Data Client - Export Wait + class ExportWait < Inferno::Test + include URLs + include ExportTypes + + title 'Wait For Request Sequence' + + description %( + This test will receive bulk data export requests until the user confirms they are finished. + ) + + id :bulk_data_client_export_wait + + input :export_type, :group_id + + output :export_id + + run do + export_id = SecureRandom.uuid + + output export_id: export_id + + wait( + identifier: export_id, + message: %( + Perform a #{export_type} endpoint type bulk export using the following base URL: + + #{kickoff_url(export_id)} + + #{export_type == GROUP_EXPORT_TYPE ? "Ensure the Group ID is set to #{group_id}." : ''} + + The entire request sequence will be recorded and used in the subsequent tests to + verify comformity to the + [Bulk Data IG](https://build.fhir.org/ig/HL7/bulk-data/export.html#sequence-overview). + + [Click here](#{resume_pass_url}?id=#{export_id}) when finished. + ) + ) + end + end + end + end + end +end From ccb48cbe3138a0c6444eb928f7642fa09ac4607b Mon Sep 17 00:00:00 2001 From: "aholmes@mitre.org" <14923551+holmesie@users.noreply.github.com> Date: Tue, 7 Jan 2025 09:58:47 -0600 Subject: [PATCH 06/20] Add input options to suite --- .../client/bulk_data_client_test_suite.rb | 31 +++++++++++++++++ .../v2.0.0/client/groups/delete.rb | 34 ------------------- .../v2.0.0/client/groups/export.rb | 34 ------------------- 3 files changed, 31 insertions(+), 68 deletions(-) diff --git a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_test_suite.rb b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_test_suite.rb index 4f12996..1360efa 100644 --- a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_test_suite.rb +++ b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_test_suite.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true require_relative '../../version' +require_relative 'urls' +require_relative 'export_types' require_relative 'endpoints/delete' require_relative 'endpoints/kick_off' @@ -16,6 +18,7 @@ module Client # Bulk Data Access v2.0.0 Client Test Suite class BulkDataClientTestSuite < Inferno::TestSuite include URLs + include ExportTypes title 'Bulk Data Access v2.0.0 Client' @@ -44,6 +47,34 @@ class BulkDataClientTestSuite < Inferno::TestSuite } ] + input :export_type, + title: 'Export Type', + description: 'The export endpoint type to test against.', + type: 'radio', + default: SYSTEM_EXPORT_TYPE, + options: { + list_options: [ + { + label: 'All Patients', + value: PATIENT_EXPORT_TYPE + }, + { + label: 'Group of Patients', + value: GROUP_EXPORT_TYPE + }, + { + label: 'System Level Export', + value: SYSTEM_EXPORT_TYPE + } + ] + } + + input :group_id, + title: 'Group ID', + description: 'If using the Group endpoint, the identifier of the Group to export.', + default: 1, + locked: true + suite_endpoint :get, PATIENT_KICKOFF_ROUTE, Endpoints::KickOff suite_endpoint :get, GROUP_KICKOFF_ROUTE, Endpoints::KickOff suite_endpoint :get, SYSTEM_KICKOFF_ROUTE, Endpoints::KickOff diff --git a/lib/bulk_data_test_kit/v2.0.0/client/groups/delete.rb b/lib/bulk_data_test_kit/v2.0.0/client/groups/delete.rb index d76cfec..5272630 100644 --- a/lib/bulk_data_test_kit/v2.0.0/client/groups/delete.rb +++ b/lib/bulk_data_test_kit/v2.0.0/client/groups/delete.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -require_relative '../export_types' -require_relative '../urls' - require_relative '../tests/delete_wait' require_relative '../tests/kick_off' require_relative '../tests/delete' @@ -13,9 +10,6 @@ module Client module Groups # Bulk Data Client Delete Tests class Delete < Inferno::TestGroup - include ExportTypes - include URLs - title 'Bulk Data Client Delete Tests' description %( @@ -27,34 +21,6 @@ class Delete < Inferno::TestGroup run_as_group - input :export_type, - title: 'Export Type', - description: 'The export endpoint type to test against.', - type: 'radio', - default: SYSTEM_EXPORT_TYPE, - options: { - list_options: [ - { - label: 'All Patients', - value: PATIENT_EXPORT_TYPE - }, - { - label: 'Group of Patients', - value: GROUP_EXPORT_TYPE - }, - { - label: 'System Level Export', - value: SYSTEM_EXPORT_TYPE - } - ] - } - - input :group_id, - title: 'Group ID', - description: 'If using the Group endpoint, the identifier of the Group to export.', - default: 1, - locked: true - test from: :bulk_data_client_delete_wait test from: :bulk_data_client_kick_off test from: :bulk_data_client_kick_off diff --git a/lib/bulk_data_test_kit/v2.0.0/client/groups/export.rb b/lib/bulk_data_test_kit/v2.0.0/client/groups/export.rb index b7cbe50..cc0bdaf 100644 --- a/lib/bulk_data_test_kit/v2.0.0/client/groups/export.rb +++ b/lib/bulk_data_test_kit/v2.0.0/client/groups/export.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -require_relative '../export_types' -require_relative '../urls' - require_relative '../tests/export_wait' require_relative '../tests/kick_off' require_relative '../tests/status' @@ -14,9 +11,6 @@ module Client module Groups # Bulk Data Client Export Tests class Export < Inferno::TestGroup - include ExportTypes - include URLs - title 'Bulk Data Client Export Tests' description %( @@ -30,34 +24,6 @@ class Export < Inferno::TestGroup run_as_group - input :export_type, - title: 'Export Type', - description: 'The export endpoint type to test against.', - type: 'radio', - default: SYSTEM_EXPORT_TYPE, - options: { - list_options: [ - { - label: 'All Patients', - value: PATIENT_EXPORT_TYPE - }, - { - label: 'Group of Patients', - value: GROUP_EXPORT_TYPE - }, - { - label: 'System Level Export', - value: SYSTEM_EXPORT_TYPE - } - ] - } - - input :group_id, - title: 'Group ID', - description: 'If using the Group endpoint, the identifier of the Group to export.', - default: 1, - locked: true - test from: :bulk_data_client_export_wait test from: :bulk_data_client_kick_off test from: :bulk_data_client_status From 0f3b3f3bb185856747bebd38bec1173d5874e9d0 Mon Sep 17 00:00:00 2001 From: "aholmes@mitre.org" <14923551+holmesie@users.noreply.github.com> Date: Tue, 7 Jan 2025 10:03:26 -0600 Subject: [PATCH 07/20] Add more detail around export wait test expectations --- lib/bulk_data_test_kit/v2.0.0/client/tests/export_wait.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/bulk_data_test_kit/v2.0.0/client/tests/export_wait.rb b/lib/bulk_data_test_kit/v2.0.0/client/tests/export_wait.rb index d5c88c8..cdabed1 100644 --- a/lib/bulk_data_test_kit/v2.0.0/client/tests/export_wait.rb +++ b/lib/bulk_data_test_kit/v2.0.0/client/tests/export_wait.rb @@ -32,12 +32,16 @@ class ExportWait < Inferno::Test wait( identifier: export_id, message: %( - Perform a #{export_type} endpoint type bulk export using the following base URL: + Perform a #{export_type} endpoint type bulk export kick-off using the following base URL: #{kickoff_url(export_id)} #{export_type == GROUP_EXPORT_TYPE ? "Ensure the Group ID is set to #{group_id}." : ''} + After the kick-off is made, a subsequent status request (using the URL provided in the response + to the kick-off request) and then a download request (using the URL provided in the response to + the status request) are expected. + The entire request sequence will be recorded and used in the subsequent tests to verify comformity to the [Bulk Data IG](https://build.fhir.org/ig/HL7/bulk-data/export.html#sequence-overview). From 6221b7882d3abfa93304b508b2bcc5d1ca86e0e9 Mon Sep 17 00:00:00 2001 From: "aholmes@mitre.org" <14923551+holmesie@users.noreply.github.com> Date: Tue, 7 Jan 2025 10:06:02 -0600 Subject: [PATCH 08/20] Tweak tags --- lib/bulk_data_test_kit/v2.0.0/client/tags.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/bulk_data_test_kit/v2.0.0/client/tags.rb b/lib/bulk_data_test_kit/v2.0.0/client/tags.rb index 043838c..e5d2969 100644 --- a/lib/bulk_data_test_kit/v2.0.0/client/tags.rb +++ b/lib/bulk_data_test_kit/v2.0.0/client/tags.rb @@ -5,13 +5,13 @@ module BulkDataV200 module Client # Tags for use in Bulk Data Client tests and endpoints module Tags - METADATA_TAG = 'metadata_req' - PATIENT_KICKOFF_TAG = 'kickoff_patient_req' - GROUP_KICKOFF_TAG = 'kickoff_group_req' - SYSTEM_KICKOFF_TAG = 'kickoff_system_req' - STATUS_TAG = 'status_req' - OUTPUT_TAG = 'output_req' - DELETE_TAG = 'delete_req' + METADATA_TAG = 'bulk_data_metadata' + PATIENT_KICKOFF_TAG = 'bulk_data_kickoff_patient' + GROUP_KICKOFF_TAG = 'bulk_data_kickoff_group' + SYSTEM_KICKOFF_TAG = 'bulk_data_kickoff_system' + STATUS_TAG = 'bulk_data_status' + OUTPUT_TAG = 'bulk_data_output' + DELETE_TAG = 'bulk_data_delete' end end end From 22c8b872efd4c72142a5fde9c5f2540e2ef81da7 Mon Sep 17 00:00:00 2001 From: "aholmes@mitre.org" <14923551+holmesie@users.noreply.github.com> Date: Tue, 7 Jan 2025 10:07:01 -0600 Subject: [PATCH 09/20] Remove unecessary input from delete test --- lib/bulk_data_test_kit/v2.0.0/client/tests/delete.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/bulk_data_test_kit/v2.0.0/client/tests/delete.rb b/lib/bulk_data_test_kit/v2.0.0/client/tests/delete.rb index f61df11..36a4c4a 100644 --- a/lib/bulk_data_test_kit/v2.0.0/client/tests/delete.rb +++ b/lib/bulk_data_test_kit/v2.0.0/client/tests/delete.rb @@ -27,8 +27,6 @@ class Delete < Inferno::Test verifies_requirements 'hl7.fhir.uv.bulkdata_2.0.0@119' - input :export_id - run do assert load_tagged_requests(DELETE_TAG).any?, FAIL end From 5ff5dd7f248a5b4fa4d4b3016403a1f8d8937c71 Mon Sep 17 00:00:00 2001 From: "aholmes@mitre.org" <14923551+holmesie@users.noreply.github.com> Date: Tue, 7 Jan 2025 10:12:35 -0600 Subject: [PATCH 10/20] Refactor fail messages into methods --- .../v2.0.0/client/tests/delete.rb | 8 ++++--- .../v2.0.0/client/tests/kick_off.rb | 22 +++++++++++++------ .../v2.0.0/client/tests/output.rb | 8 ++++--- .../v2.0.0/client/tests/status.rb | 8 ++++--- .../client/bulk_data_client_spec.rb | 16 +++++++------- 5 files changed, 38 insertions(+), 24 deletions(-) diff --git a/lib/bulk_data_test_kit/v2.0.0/client/tests/delete.rb b/lib/bulk_data_test_kit/v2.0.0/client/tests/delete.rb index 36a4c4a..0fd6dff 100644 --- a/lib/bulk_data_test_kit/v2.0.0/client/tests/delete.rb +++ b/lib/bulk_data_test_kit/v2.0.0/client/tests/delete.rb @@ -12,8 +12,6 @@ class Delete < Inferno::Test include Tags include URLs - FAIL = 'Did not receive a delete request.' - title 'Bulk Data Delete Request' description %( @@ -28,7 +26,11 @@ class Delete < Inferno::Test verifies_requirements 'hl7.fhir.uv.bulkdata_2.0.0@119' run do - assert load_tagged_requests(DELETE_TAG).any?, FAIL + assert load_tagged_requests(DELETE_TAG).any?, fail_message + end + + def fail_message + 'Did not receive a delete request.' end end end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/tests/kick_off.rb b/lib/bulk_data_test_kit/v2.0.0/client/tests/kick_off.rb index f292271..c973875 100644 --- a/lib/bulk_data_test_kit/v2.0.0/client/tests/kick_off.rb +++ b/lib/bulk_data_test_kit/v2.0.0/client/tests/kick_off.rb @@ -14,10 +14,6 @@ class KickOff < Inferno::Test include URLs include ExportTypes - PATIENT_FAIL = 'Did not receive a Patient type kick-off request.' - GROUP_FAIL = 'Did not receive a Group type kick-off request.' - SYSTEM_FAIL = 'Did not receive a System type kick-off request.' - title 'Bulk Data Kick-off Request' description %( @@ -35,13 +31,25 @@ class KickOff < Inferno::Test run do case export_type when PATIENT_EXPORT_TYPE - assert load_tagged_requests(PATIENT_KICKOFF_TAG).any?, PATIENT_FAIL + assert load_tagged_requests(PATIENT_KICKOFF_TAG).any?, patient_fail_message when GROUP_EXPORT_TYPE - assert load_tagged_requests(GROUP_KICKOFF_TAG).any?, GROUP_FAIL + assert load_tagged_requests(GROUP_KICKOFF_TAG).any?, group_fail_message when SYSTEM_EXPORT_TYPE - assert load_tagged_requests(SYSTEM_KICKOFF_TAG).any?, SYSTEM_FAIL + assert load_tagged_requests(SYSTEM_KICKOFF_TAG).any?, system_fail_message end end + + def patient_fail_message + 'Did not receive a Patient type kick-off request.' + end + + def group_fail_message + 'Did not receive a Group type kick-off request.' + end + + def system_fail_message + 'Did not receive a System type kick-off request.' + end end end end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/tests/output.rb b/lib/bulk_data_test_kit/v2.0.0/client/tests/output.rb index 69782c4..8599b50 100644 --- a/lib/bulk_data_test_kit/v2.0.0/client/tests/output.rb +++ b/lib/bulk_data_test_kit/v2.0.0/client/tests/output.rb @@ -12,8 +12,6 @@ class Output < Inferno::Test include Tags include URLs - FAIL = 'Did not receive a download request.' - title 'Bulk Data Output File Request' description %( @@ -29,7 +27,11 @@ class Output < Inferno::Test input :export_id run do - assert load_tagged_requests(OUTPUT_TAG).any?, FAIL + assert load_tagged_requests(OUTPUT_TAG).any?, fail_message + end + + def fail_message + 'Did not receive a download request.' end end end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/tests/status.rb b/lib/bulk_data_test_kit/v2.0.0/client/tests/status.rb index 7c4be21..faf1d5d 100644 --- a/lib/bulk_data_test_kit/v2.0.0/client/tests/status.rb +++ b/lib/bulk_data_test_kit/v2.0.0/client/tests/status.rb @@ -12,8 +12,6 @@ class Status < Inferno::Test include Tags include URLs - FAIL = 'Did not receive a status request.' - title 'Bulk Data Status Request' description %( @@ -30,7 +28,11 @@ class Status < Inferno::Test input :export_id run do - assert load_tagged_requests(STATUS_TAG).any?, FAIL + assert load_tagged_requests(STATUS_TAG).any?, fail_message + end + + def fail_message + 'Did not receive a status request.' end end end diff --git a/spec/bulk_data_test_kit/client/bulk_data_client_spec.rb b/spec/bulk_data_test_kit/client/bulk_data_client_spec.rb index 0cb1a04..be4ff4b 100644 --- a/spec/bulk_data_test_kit/client/bulk_data_client_spec.rb +++ b/spec/bulk_data_test_kit/client/bulk_data_client_spec.rb @@ -22,12 +22,12 @@ let(:output_tag) { BulkDataTestKit::BulkDataV200::Client::Tags::OUTPUT_TAG } let(:delete_tag) { BulkDataTestKit::BulkDataV200::Client::Tags::DELETE_TAG } - let(:patient_fail) { BulkDataTestKit::BulkDataV200::Client::Tests::KickOff::PATIENT_FAIL } - let(:group_fail) { BulkDataTestKit::BulkDataV200::Client::Tests::KickOff::GROUP_FAIL } - let(:system_fail) { BulkDataTestKit::BulkDataV200::Client::Tests::KickOff::SYSTEM_FAIL } - let(:status_fail) { BulkDataTestKit::BulkDataV200::Client::Tests::Status::FAIL } - let(:output_fail) { BulkDataTestKit::BulkDataV200::Client::Tests::Output::FAIL } - let(:delete_fail) { BulkDataTestKit::BulkDataV200::Client::Tests::Delete::FAIL } + let(:patient_fail) { 'Did not receive a Patient type kick-off request.' } + let(:group_fail) { 'Did not receive a Group type kick-off request.' } + let(:system_fail) { 'Did not receive a System type kick-off request.' } + let(:status_fail) { 'Did not receive a status request.' } + let(:output_fail) { 'Did not receive a download request.' } + let(:delete_fail) { 'Did not receive a delete request.' } def run(runnable, inputs = {}) test_run_params = { test_session_id: test_session.id }.merge(runnable.reference_hash) @@ -110,14 +110,14 @@ def mock_request(result, tags, verb = 'get') describe 'delete test' do it 'passes after delete request received' do allow(delete_test).to receive_messages(suite:) - result = run(delete_test, export_id: 'foobar') + result = run(delete_test) expect(result.result).to eq('fail') expect(result.result_message).to eq(delete_fail) mock_request(result, [delete_tag], 'delete') - result = run(delete_test, export_id: 'foobar') + result = run(delete_test) expect(result.result).to eq('pass') end From 1b5934ab344b0ddcc910110a9c7c88b848e138b1 Mon Sep 17 00:00:00 2001 From: "aholmes@mitre.org" <14923551+holmesie@users.noreply.github.com> Date: Tue, 7 Jan 2025 10:16:56 -0600 Subject: [PATCH 11/20] Remove unecessary inputs from tests --- .../v2.0.0/client/tests/kick_off.rb | 2 +- lib/bulk_data_test_kit/v2.0.0/client/tests/output.rb | 2 -- lib/bulk_data_test_kit/v2.0.0/client/tests/status.rb | 2 -- .../client/bulk_data_client_spec.rb | 12 ++++++------ 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/bulk_data_test_kit/v2.0.0/client/tests/kick_off.rb b/lib/bulk_data_test_kit/v2.0.0/client/tests/kick_off.rb index c973875..40e8fec 100644 --- a/lib/bulk_data_test_kit/v2.0.0/client/tests/kick_off.rb +++ b/lib/bulk_data_test_kit/v2.0.0/client/tests/kick_off.rb @@ -26,7 +26,7 @@ class KickOff < Inferno::Test verifies_requirements 'hl7.fhir.uv.bulkdata_2.0.0@17' - input :export_id, :export_type, :group_id + input :export_type run do case export_type diff --git a/lib/bulk_data_test_kit/v2.0.0/client/tests/output.rb b/lib/bulk_data_test_kit/v2.0.0/client/tests/output.rb index 8599b50..b5773df 100644 --- a/lib/bulk_data_test_kit/v2.0.0/client/tests/output.rb +++ b/lib/bulk_data_test_kit/v2.0.0/client/tests/output.rb @@ -24,8 +24,6 @@ class Output < Inferno::Test verifies_requirements 'hl7.fhir.uv.bulkdata_2.0.0@200' - input :export_id - run do assert load_tagged_requests(OUTPUT_TAG).any?, fail_message end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/tests/status.rb b/lib/bulk_data_test_kit/v2.0.0/client/tests/status.rb index faf1d5d..01c040c 100644 --- a/lib/bulk_data_test_kit/v2.0.0/client/tests/status.rb +++ b/lib/bulk_data_test_kit/v2.0.0/client/tests/status.rb @@ -25,8 +25,6 @@ class Status < Inferno::Test verifies_requirements 'hl7.fhir.uv.bulkdata_2.0.0@123' - input :export_id - run do assert load_tagged_requests(STATUS_TAG).any?, fail_message end diff --git a/spec/bulk_data_test_kit/client/bulk_data_client_spec.rb b/spec/bulk_data_test_kit/client/bulk_data_client_spec.rb index be4ff4b..acc9089 100644 --- a/spec/bulk_data_test_kit/client/bulk_data_client_spec.rb +++ b/spec/bulk_data_test_kit/client/bulk_data_client_spec.rb @@ -60,14 +60,14 @@ def mock_request(result, tags, verb = 'get') describe "for #{type} type" do it 'passes after kick-off request received' do allow(kickoff_test).to receive_messages(suite:) - result = run(kickoff_test, export_id: 'foobar', export_type: type, group_id: 1) + result = run(kickoff_test, export_type: type) expect(result.result).to eq('fail') expect(result.result_message).to eq(send("#{type.downcase}_fail")) mock_request(result, [send("#{type.downcase}_kickoff_tag")]) - result = run(kickoff_test, export_id: 'foobar', export_type: type, group_id: 1) + result = run(kickoff_test, export_type: type) expect(result.result).to eq('pass') end @@ -78,14 +78,14 @@ def mock_request(result, tags, verb = 'get') describe 'status test' do it 'passes after status request received' do allow(status_test).to receive_messages(suite:) - result = run(status_test, export_id: 'foobar') + result = run(status_test) expect(result.result).to eq('fail') expect(result.result_message).to eq(status_fail) mock_request(result, [status_tag]) - result = run(status_test, export_id: 'foobar') + result = run(status_test) expect(result.result).to eq('pass') end @@ -94,14 +94,14 @@ def mock_request(result, tags, verb = 'get') describe 'output test' do it 'passes after export downloaded' do allow(output_test).to receive_messages(suite:) - result = run(output_test, export_id: 'foobar') + result = run(output_test) expect(result.result).to eq('fail') expect(result.result_message).to eq(output_fail) mock_request(result, [output_tag]) - result = run(output_test, export_id: 'foobar') + result = run(output_test) expect(result.result).to eq('pass') end From d315446d6c848c58ba0e1c6e5d549da0c44bbf2a Mon Sep 17 00:00:00 2001 From: "aholmes@mitre.org" <14923551+holmesie@users.noreply.github.com> Date: Tue, 7 Jan 2025 10:23:34 -0600 Subject: [PATCH 12/20] Remove unused requires --- lib/bulk_data_test_kit/v2.0.0/client/tests/delete.rb | 2 -- lib/bulk_data_test_kit/v2.0.0/client/tests/kick_off.rb | 2 -- lib/bulk_data_test_kit/v2.0.0/client/tests/output.rb | 2 -- lib/bulk_data_test_kit/v2.0.0/client/tests/status.rb | 2 -- 4 files changed, 8 deletions(-) diff --git a/lib/bulk_data_test_kit/v2.0.0/client/tests/delete.rb b/lib/bulk_data_test_kit/v2.0.0/client/tests/delete.rb index 0fd6dff..e7a5e2b 100644 --- a/lib/bulk_data_test_kit/v2.0.0/client/tests/delete.rb +++ b/lib/bulk_data_test_kit/v2.0.0/client/tests/delete.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require_relative '../tags' -require_relative '../urls' module BulkDataTestKit module BulkDataV200 @@ -10,7 +9,6 @@ module Tests # Bulk Data Client - Delete class Delete < Inferno::Test include Tags - include URLs title 'Bulk Data Delete Request' diff --git a/lib/bulk_data_test_kit/v2.0.0/client/tests/kick_off.rb b/lib/bulk_data_test_kit/v2.0.0/client/tests/kick_off.rb index 40e8fec..adce776 100644 --- a/lib/bulk_data_test_kit/v2.0.0/client/tests/kick_off.rb +++ b/lib/bulk_data_test_kit/v2.0.0/client/tests/kick_off.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require_relative '../tags' -require_relative '../urls' require_relative '../export_types' module BulkDataTestKit @@ -11,7 +10,6 @@ module Tests # Bulk Data Client Kick-off class KickOff < Inferno::Test include Tags - include URLs include ExportTypes title 'Bulk Data Kick-off Request' diff --git a/lib/bulk_data_test_kit/v2.0.0/client/tests/output.rb b/lib/bulk_data_test_kit/v2.0.0/client/tests/output.rb index b5773df..d99222c 100644 --- a/lib/bulk_data_test_kit/v2.0.0/client/tests/output.rb +++ b/lib/bulk_data_test_kit/v2.0.0/client/tests/output.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require_relative '../tags' -require_relative '../urls' module BulkDataTestKit module BulkDataV200 @@ -10,7 +9,6 @@ module Tests # Bulk Data Client Output class Output < Inferno::Test include Tags - include URLs title 'Bulk Data Output File Request' diff --git a/lib/bulk_data_test_kit/v2.0.0/client/tests/status.rb b/lib/bulk_data_test_kit/v2.0.0/client/tests/status.rb index 01c040c..7e5488a 100644 --- a/lib/bulk_data_test_kit/v2.0.0/client/tests/status.rb +++ b/lib/bulk_data_test_kit/v2.0.0/client/tests/status.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require_relative '../tags' -require_relative '../urls' module BulkDataTestKit module BulkDataV200 @@ -10,7 +9,6 @@ module Tests # Bulk Data Client Status class Status < Inferno::Test include Tags - include URLs title 'Bulk Data Status Request' From 512d865e1fd46f8a27921dde846cb5e56481cbff Mon Sep 17 00:00:00 2001 From: "aholmes@mitre.org" <14923551+holmesie@users.noreply.github.com> Date: Tue, 7 Jan 2025 10:41:30 -0600 Subject: [PATCH 13/20] Refactor directory structure --- .../client/bulk_data_client_delete_group.rb | 30 ++++++++++ .../client/bulk_data_client_delete_test.rb | 33 +++++++++++ .../bulk_data_client_delete_wait_test.rb | 51 +++++++++++++++++ .../client/bulk_data_client_export_group.rb | 33 +++++++++++ .../bulk_data_client_export_wait_test.rb | 52 +++++++++++++++++ .../client/bulk_data_client_kick_off_test.rb | 50 ++++++++++++++++ .../client/bulk_data_client_output_test.rb | 32 +++++++++++ .../client/bulk_data_client_status_test.rb | 33 +++++++++++ .../client/bulk_data_client_test_suite.rb | 5 +- .../v2.0.0/client/groups/delete.rb | 32 ----------- .../v2.0.0/client/groups/export.rb | 35 ------------ .../v2.0.0/client/tests/delete.rb | 37 ------------ .../v2.0.0/client/tests/delete_wait.rb | 56 ------------------ .../v2.0.0/client/tests/export_wait.rb | 57 ------------------- .../v2.0.0/client/tests/kick_off.rb | 55 ------------------ .../v2.0.0/client/tests/output.rb | 36 ------------ .../v2.0.0/client/tests/status.rb | 37 ------------ 17 files changed, 317 insertions(+), 347 deletions(-) create mode 100644 lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_delete_group.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_delete_test.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_delete_wait_test.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_export_group.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_export_wait_test.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_kick_off_test.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_output_test.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_status_test.rb delete mode 100644 lib/bulk_data_test_kit/v2.0.0/client/groups/delete.rb delete mode 100644 lib/bulk_data_test_kit/v2.0.0/client/groups/export.rb delete mode 100644 lib/bulk_data_test_kit/v2.0.0/client/tests/delete.rb delete mode 100644 lib/bulk_data_test_kit/v2.0.0/client/tests/delete_wait.rb delete mode 100644 lib/bulk_data_test_kit/v2.0.0/client/tests/export_wait.rb delete mode 100644 lib/bulk_data_test_kit/v2.0.0/client/tests/kick_off.rb delete mode 100644 lib/bulk_data_test_kit/v2.0.0/client/tests/output.rb delete mode 100644 lib/bulk_data_test_kit/v2.0.0/client/tests/status.rb diff --git a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_delete_group.rb b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_delete_group.rb new file mode 100644 index 0000000..43d1e85 --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_delete_group.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +require_relative 'bulk_data_client_delete_wait_test' +require_relative 'bulk_data_client_kick_off_test' +require_relative 'bulk_data_client_delete_test' + +module BulkDataTestKit + module BulkDataV200 + module Client + # Bulk Data Client Delete Tests + class DeleteGroup < Inferno::TestGroup + title 'Bulk Data Client Delete Tests' + + description %( + The Bulk Data Client Delete tests verify the ability of a client to delete + a kicked-off bulk data export request. + ) + + id :bulk_data_client_delete_group + + run_as_group + + test from: :bulk_data_client_delete_wait + test from: :bulk_data_client_kick_off + test from: :bulk_data_client_kick_off + test from: :bulk_data_client_delete + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_delete_test.rb b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_delete_test.rb new file mode 100644 index 0000000..7e80dc8 --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_delete_test.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module BulkDataTestKit + module BulkDataV200 + module Client + # Bulk Data Client - Delete + class DeleteTest < Inferno::Test + include Tags + + title 'Bulk Data Delete Request' + + description %( + This test verifies that after a Bulk Data request has been started, the client can send a + DELETE request to the URL provided in the Content-Location header to + [delete the request](https://hl7.org/fhir/uv/bulkdata/STU2/export.html#bulk-data-delete-request), + as described in the [FHIR Asynchronous Request Pattern](https://www.hl7.org/fhir/R4/async.html). + ) + + id :bulk_data_client_delete + + verifies_requirements 'hl7.fhir.uv.bulkdata_2.0.0@119' + + run do + assert load_tagged_requests(DELETE_TAG).any?, fail_message + end + + def fail_message + 'Did not receive a delete request.' + end + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_delete_wait_test.rb b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_delete_wait_test.rb new file mode 100644 index 0000000..55e06c8 --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_delete_wait_test.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +module BulkDataTestKit + module BulkDataV200 + module Client + # Bulk Data Client - Delete Wait + class DeleteWaitTest < Inferno::Test + include URLs + include ExportTypes + + title 'Wait For Request Sequence' + + description %( + This test will receive bulk data export requests until the user confirms they are finished. + ) + + id :bulk_data_client_delete_wait + + input :export_type, :group_id + + output :export_id + + run do + export_id = SecureRandom.uuid + + output export_id: export_id + + wait( + identifier: export_id, + message: %( + Kick-off a #{export_type} endpoint type bulk export using the following base URL: + + #{kickoff_url(export_id)} + + #{export_type == GROUP_EXPORT_TYPE ? "Ensure the Group ID is set to #{group_id}." : ''} + + Once the export request has been kicked-off, + [delete the export](https://build.fhir.org/ig/HL7/bulk-data/export.html#bulk-data-delete-request). + + The entire request sequence will be recorded and used in the subsequent tests to + verify comformity to the + [Bulk Data IG](https://build.fhir.org/ig/HL7/bulk-data/export.html#sequence-overview). + + [Click here](#{resume_pass_url}?id=#{export_id}) when finished. + ) + ) + end + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_export_group.rb b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_export_group.rb new file mode 100644 index 0000000..f3eaad2 --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_export_group.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +require_relative 'bulk_data_client_export_wait_test' +require_relative 'bulk_data_client_kick_off_test' +require_relative 'bulk_data_client_status_test' +require_relative 'bulk_data_client_output_test' + +module BulkDataTestKit + module BulkDataV200 + module Client + # Bulk Data Client Export Tests + class ExportGroup < Inferno::TestGroup + title 'Bulk Data Client Export Tests' + + description %( + The Bulk Data Client Export tests verify the ability of a client to: + - Kick-off a new bulk data export request + - Poll the in-progress request for status updates + - Download a completed bulk data export file + ) + + id :bulk_data_client_export_group + + run_as_group + + test from: :bulk_data_client_export_wait + test from: :bulk_data_client_kick_off + test from: :bulk_data_client_status + test from: :bulk_data_client_output + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_export_wait_test.rb b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_export_wait_test.rb new file mode 100644 index 0000000..4b738c1 --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_export_wait_test.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +module BulkDataTestKit + module BulkDataV200 + module Client + # Bulk Data Client - Export Wait + class ExportWaitTest < Inferno::Test + include URLs + include ExportTypes + + title 'Wait For Request Sequence' + + description %( + This test will receive bulk data export requests until the user confirms they are finished. + ) + + id :bulk_data_client_export_wait + + input :export_type, :group_id + + output :export_id + + run do + export_id = SecureRandom.uuid + + output export_id: export_id + + wait( + identifier: export_id, + message: %( + Perform a #{export_type} endpoint type bulk export kick-off using the following base URL: + + #{kickoff_url(export_id)} + + #{export_type == GROUP_EXPORT_TYPE ? "Ensure the Group ID is set to #{group_id}." : ''} + + After the kick-off is made, a subsequent status request (using the URL provided in the response + to the kick-off request) and then a download request (using the URL provided in the response to + the status request) are expected. + + The entire request sequence will be recorded and used in the subsequent tests to + verify comformity to the + [Bulk Data IG](https://build.fhir.org/ig/HL7/bulk-data/export.html#sequence-overview). + + [Click here](#{resume_pass_url}?id=#{export_id}) when finished. + ) + ) + end + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_kick_off_test.rb b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_kick_off_test.rb new file mode 100644 index 0000000..d728ca5 --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_kick_off_test.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +module BulkDataTestKit + module BulkDataV200 + module Client + # Bulk Data Client Kick-off + class KickOffTest < Inferno::Test + include Tags + include ExportTypes + + title 'Bulk Data Kick-off Request' + + description %( + This test verifies that a client can + [kick-off a Bulk Data request](https://hl7.org/fhir/uv/bulkdata/STU2/export.html#roles) + using the `$export` operation against the proper endpoint type. + ) + + id :bulk_data_client_kick_off + + verifies_requirements 'hl7.fhir.uv.bulkdata_2.0.0@17' + + input :export_type + + run do + case export_type + when PATIENT_EXPORT_TYPE + assert load_tagged_requests(PATIENT_KICKOFF_TAG).any?, patient_fail_message + when GROUP_EXPORT_TYPE + assert load_tagged_requests(GROUP_KICKOFF_TAG).any?, group_fail_message + when SYSTEM_EXPORT_TYPE + assert load_tagged_requests(SYSTEM_KICKOFF_TAG).any?, system_fail_message + end + end + + def patient_fail_message + 'Did not receive a Patient type kick-off request.' + end + + def group_fail_message + 'Did not receive a Group type kick-off request.' + end + + def system_fail_message + 'Did not receive a System type kick-off request.' + end + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_output_test.rb b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_output_test.rb new file mode 100644 index 0000000..69833c5 --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_output_test.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +module BulkDataTestKit + module BulkDataV200 + module Client + # Bulk Data Client Output + class OutputTest < Inferno::Test + include Tags + + title 'Bulk Data Output File Request' + + description %( + This test verifies that the client, using the URL supplied in the Complete Status response body, + can [download](https://hl7.org/fhir/uv/bulkdata/STU2/export.html#bulk-data-output-file-request) + the generated Bulk Data file. + ) + + id :bulk_data_client_output + + verifies_requirements 'hl7.fhir.uv.bulkdata_2.0.0@200' + + run do + assert load_tagged_requests(OUTPUT_TAG).any?, fail_message + end + + def fail_message + 'Did not receive a download request.' + end + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_status_test.rb b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_status_test.rb new file mode 100644 index 0000000..9d1ddc9 --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_status_test.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module BulkDataTestKit + module BulkDataV200 + module Client + # Bulk Data Client Status + class StatusTest < Inferno::Test + include Tags + + title 'Bulk Data Status Request' + + description %( + This test verifies that after a Bulk Data request has been started, the client can + [poll the status URL](https://hl7.org/fhir/uv/bulkdata/STU2/export.html#bulk-data-status-request) + provided in the Content-Location header, as as described in the + [FHIR Asynchronous Request Pattern](https://www.hl7.org/fhir/R4/async.html). + ) + + id :bulk_data_client_status + + verifies_requirements 'hl7.fhir.uv.bulkdata_2.0.0@123' + + run do + assert load_tagged_requests(STATUS_TAG).any?, fail_message + end + + def fail_message + 'Did not receive a status request.' + end + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_test_suite.rb b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_test_suite.rb index 1360efa..52349d4 100644 --- a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_test_suite.rb +++ b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_test_suite.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require_relative '../../version' +require_relative 'tags' require_relative 'urls' require_relative 'export_types' @@ -9,8 +10,8 @@ require_relative 'endpoints/output' require_relative 'endpoints/status' -require_relative 'groups/export' -require_relative 'groups/delete' +require_relative 'bulk_data_client_export_group' +require_relative 'bulk_data_client_delete_group' module BulkDataTestKit module BulkDataV200 diff --git a/lib/bulk_data_test_kit/v2.0.0/client/groups/delete.rb b/lib/bulk_data_test_kit/v2.0.0/client/groups/delete.rb deleted file mode 100644 index 5272630..0000000 --- a/lib/bulk_data_test_kit/v2.0.0/client/groups/delete.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -require_relative '../tests/delete_wait' -require_relative '../tests/kick_off' -require_relative '../tests/delete' - -module BulkDataTestKit - module BulkDataV200 - module Client - module Groups - # Bulk Data Client Delete Tests - class Delete < Inferno::TestGroup - title 'Bulk Data Client Delete Tests' - - description %( - The Bulk Data Client Delete tests verify the ability of a client to delete - a kicked-off bulk data export request. - ) - - id :bulk_data_client_delete_group - - run_as_group - - test from: :bulk_data_client_delete_wait - test from: :bulk_data_client_kick_off - test from: :bulk_data_client_kick_off - test from: :bulk_data_client_delete - end - end - end - end -end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/groups/export.rb b/lib/bulk_data_test_kit/v2.0.0/client/groups/export.rb deleted file mode 100644 index cc0bdaf..0000000 --- a/lib/bulk_data_test_kit/v2.0.0/client/groups/export.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -require_relative '../tests/export_wait' -require_relative '../tests/kick_off' -require_relative '../tests/status' -require_relative '../tests/output' - -module BulkDataTestKit - module BulkDataV200 - module Client - module Groups - # Bulk Data Client Export Tests - class Export < Inferno::TestGroup - title 'Bulk Data Client Export Tests' - - description %( - The Bulk Data Client Export tests verify the ability of a client to: - - Kick-off a new bulk data export request - - Poll the in-progress request for status updates - - Download a completed bulk data export file - ) - - id :bulk_data_client_export_group - - run_as_group - - test from: :bulk_data_client_export_wait - test from: :bulk_data_client_kick_off - test from: :bulk_data_client_status - test from: :bulk_data_client_output - end - end - end - end -end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/tests/delete.rb b/lib/bulk_data_test_kit/v2.0.0/client/tests/delete.rb deleted file mode 100644 index e7a5e2b..0000000 --- a/lib/bulk_data_test_kit/v2.0.0/client/tests/delete.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -require_relative '../tags' - -module BulkDataTestKit - module BulkDataV200 - module Client - module Tests - # Bulk Data Client - Delete - class Delete < Inferno::Test - include Tags - - title 'Bulk Data Delete Request' - - description %( - This test verifies that after a Bulk Data request has been started, the client can send a - DELETE request to the URL provided in the Content-Location header to - [delete the request](https://hl7.org/fhir/uv/bulkdata/STU2/export.html#bulk-data-delete-request), - as described in the [FHIR Asynchronous Request Pattern](https://www.hl7.org/fhir/R4/async.html). - ) - - id :bulk_data_client_delete - - verifies_requirements 'hl7.fhir.uv.bulkdata_2.0.0@119' - - run do - assert load_tagged_requests(DELETE_TAG).any?, fail_message - end - - def fail_message - 'Did not receive a delete request.' - end - end - end - end - end -end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/tests/delete_wait.rb b/lib/bulk_data_test_kit/v2.0.0/client/tests/delete_wait.rb deleted file mode 100644 index 7e24ec8..0000000 --- a/lib/bulk_data_test_kit/v2.0.0/client/tests/delete_wait.rb +++ /dev/null @@ -1,56 +0,0 @@ -# frozen_string_literal: true - -require_relative '../urls' -require_relative '../export_types' - -module BulkDataTestKit - module BulkDataV200 - module Client - module Tests - # Bulk Data Client - Delete Wait - class DeleteWait < Inferno::Test - include URLs - include ExportTypes - - title 'Wait For Request Sequence' - - description %( - This test will receive bulk data export requests until the user confirms they are finished. - ) - - id :bulk_data_client_delete_wait - - input :export_type, :group_id - - output :export_id - - run do - export_id = SecureRandom.uuid - - output export_id: export_id - - wait( - identifier: export_id, - message: %( - Kick-off a #{export_type} endpoint type bulk export using the following base URL: - - #{kickoff_url(export_id)} - - #{export_type == GROUP_EXPORT_TYPE ? "Ensure the Group ID is set to #{group_id}." : ''} - - Once the export request has been kicked-off, - [delete the export](https://build.fhir.org/ig/HL7/bulk-data/export.html#bulk-data-delete-request). - - The entire request sequence will be recorded and used in the subsequent tests to - verify comformity to the - [Bulk Data IG](https://build.fhir.org/ig/HL7/bulk-data/export.html#sequence-overview). - - [Click here](#{resume_pass_url}?id=#{export_id}) when finished. - ) - ) - end - end - end - end - end -end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/tests/export_wait.rb b/lib/bulk_data_test_kit/v2.0.0/client/tests/export_wait.rb deleted file mode 100644 index cdabed1..0000000 --- a/lib/bulk_data_test_kit/v2.0.0/client/tests/export_wait.rb +++ /dev/null @@ -1,57 +0,0 @@ -# frozen_string_literal: true - -require_relative '../urls' -require_relative '../export_types' - -module BulkDataTestKit - module BulkDataV200 - module Client - module Tests - # Bulk Data Client - Export Wait - class ExportWait < Inferno::Test - include URLs - include ExportTypes - - title 'Wait For Request Sequence' - - description %( - This test will receive bulk data export requests until the user confirms they are finished. - ) - - id :bulk_data_client_export_wait - - input :export_type, :group_id - - output :export_id - - run do - export_id = SecureRandom.uuid - - output export_id: export_id - - wait( - identifier: export_id, - message: %( - Perform a #{export_type} endpoint type bulk export kick-off using the following base URL: - - #{kickoff_url(export_id)} - - #{export_type == GROUP_EXPORT_TYPE ? "Ensure the Group ID is set to #{group_id}." : ''} - - After the kick-off is made, a subsequent status request (using the URL provided in the response - to the kick-off request) and then a download request (using the URL provided in the response to - the status request) are expected. - - The entire request sequence will be recorded and used in the subsequent tests to - verify comformity to the - [Bulk Data IG](https://build.fhir.org/ig/HL7/bulk-data/export.html#sequence-overview). - - [Click here](#{resume_pass_url}?id=#{export_id}) when finished. - ) - ) - end - end - end - end - end -end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/tests/kick_off.rb b/lib/bulk_data_test_kit/v2.0.0/client/tests/kick_off.rb deleted file mode 100644 index adce776..0000000 --- a/lib/bulk_data_test_kit/v2.0.0/client/tests/kick_off.rb +++ /dev/null @@ -1,55 +0,0 @@ -# frozen_string_literal: true - -require_relative '../tags' -require_relative '../export_types' - -module BulkDataTestKit - module BulkDataV200 - module Client - module Tests - # Bulk Data Client Kick-off - class KickOff < Inferno::Test - include Tags - include ExportTypes - - title 'Bulk Data Kick-off Request' - - description %( - This test verifies that a client can - [kick-off a Bulk Data request](https://hl7.org/fhir/uv/bulkdata/STU2/export.html#roles) - using the `$export` operation against the proper endpoint type. - ) - - id :bulk_data_client_kick_off - - verifies_requirements 'hl7.fhir.uv.bulkdata_2.0.0@17' - - input :export_type - - run do - case export_type - when PATIENT_EXPORT_TYPE - assert load_tagged_requests(PATIENT_KICKOFF_TAG).any?, patient_fail_message - when GROUP_EXPORT_TYPE - assert load_tagged_requests(GROUP_KICKOFF_TAG).any?, group_fail_message - when SYSTEM_EXPORT_TYPE - assert load_tagged_requests(SYSTEM_KICKOFF_TAG).any?, system_fail_message - end - end - - def patient_fail_message - 'Did not receive a Patient type kick-off request.' - end - - def group_fail_message - 'Did not receive a Group type kick-off request.' - end - - def system_fail_message - 'Did not receive a System type kick-off request.' - end - end - end - end - end -end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/tests/output.rb b/lib/bulk_data_test_kit/v2.0.0/client/tests/output.rb deleted file mode 100644 index d99222c..0000000 --- a/lib/bulk_data_test_kit/v2.0.0/client/tests/output.rb +++ /dev/null @@ -1,36 +0,0 @@ -# frozen_string_literal: true - -require_relative '../tags' - -module BulkDataTestKit - module BulkDataV200 - module Client - module Tests - # Bulk Data Client Output - class Output < Inferno::Test - include Tags - - title 'Bulk Data Output File Request' - - description %( - This test verifies that the client, using the URL supplied in the Complete Status response body, - can [download](https://hl7.org/fhir/uv/bulkdata/STU2/export.html#bulk-data-output-file-request) - the generated Bulk Data file. - ) - - id :bulk_data_client_output - - verifies_requirements 'hl7.fhir.uv.bulkdata_2.0.0@200' - - run do - assert load_tagged_requests(OUTPUT_TAG).any?, fail_message - end - - def fail_message - 'Did not receive a download request.' - end - end - end - end - end -end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/tests/status.rb b/lib/bulk_data_test_kit/v2.0.0/client/tests/status.rb deleted file mode 100644 index 7e5488a..0000000 --- a/lib/bulk_data_test_kit/v2.0.0/client/tests/status.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -require_relative '../tags' - -module BulkDataTestKit - module BulkDataV200 - module Client - module Tests - # Bulk Data Client Status - class Status < Inferno::Test - include Tags - - title 'Bulk Data Status Request' - - description %( - This test verifies that after a Bulk Data request has been started, the client can - [poll the status URL](https://hl7.org/fhir/uv/bulkdata/STU2/export.html#bulk-data-status-request) - provided in the Content-Location header, as as described in the - [FHIR Asynchronous Request Pattern](https://www.hl7.org/fhir/R4/async.html). - ) - - id :bulk_data_client_status - - verifies_requirements 'hl7.fhir.uv.bulkdata_2.0.0@123' - - run do - assert load_tagged_requests(STATUS_TAG).any?, fail_message - end - - def fail_message - 'Did not receive a status request.' - end - end - end - end - end -end From 30211981c19c82059eb96b5fc18ca702800f6f92 Mon Sep 17 00:00:00 2001 From: "aholmes@mitre.org" <14923551+holmesie@users.noreply.github.com> Date: Tue, 7 Jan 2025 10:55:11 -0600 Subject: [PATCH 14/20] Add postman section to suite doc --- .../v2.0.0/client/docs/suite_description.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/bulk_data_test_kit/v2.0.0/client/docs/suite_description.md b/lib/bulk_data_test_kit/v2.0.0/client/docs/suite_description.md index 474398d..ce6cd7a 100644 --- a/lib/bulk_data_test_kit/v2.0.0/client/docs/suite_description.md +++ b/lib/bulk_data_test_kit/v2.0.0/client/docs/suite_description.md @@ -8,3 +8,18 @@ preliminary checks of their systems against the requirements stated for Bulk Dat and [provide feedback](https://github.com/inferno-framework/bulk-data-test-kit/issues) on the tests. Future versions of these tests may verify other requirements and may change the test verification logic. + +### Sample Execution - Postman + +To try out these tests without a Bulk Data client implementation, you may +run them using [this "bulk data client system export" Postman collection](https://github.com/inferno-framework/bulk-data-test-kit/blob/main/lib/bulk_data_test_kit/v2.0.0/client/postman/system_export.postman_collection.json) and [this "bulk data client delete" Postman collection](https://github.com/inferno-framework/bulk-data-test-kit/blob/main/lib/bulk_data_test_kit/v2.0.0/client/postman/delete.postman_collection.json). + +To run client tests against one of the Postman collections: +1. Start an Inferno session of the Bulk Data Client test suite. +2. Navigate to either the export tests group or the delete tests group (depending on which Postman collection you want to use). +3. Click the "Run Tests" button in the upper right and select the "System Level Export" option for export type. +4. Click the "Submit" button. The simulated server will then be waiting for an interaction. +5. Open Postman and import the relevant Postman collection. +6. Set the `kickoff-base-url` variable equal to the base URL provided by inferno. +7. Run the collection. +8. Once the postman collection has run, click the "Click here" link in the wait dialog to evaluate the requests. From 3560f0f09f6fbe0217a78cf623f63d6ca3b2a276 Mon Sep 17 00:00:00 2001 From: "aholmes@mitre.org" <14923551+holmesie@users.noreply.github.com> Date: Wed, 8 Jan 2025 12:30:13 -0600 Subject: [PATCH 15/20] Fix postman collection script --- .../v2.0.0/client/postman/delete.postman_collection.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/bulk_data_test_kit/v2.0.0/client/postman/delete.postman_collection.json b/lib/bulk_data_test_kit/v2.0.0/client/postman/delete.postman_collection.json index 4cb0710..31bbd00 100644 --- a/lib/bulk_data_test_kit/v2.0.0/client/postman/delete.postman_collection.json +++ b/lib/bulk_data_test_kit/v2.0.0/client/postman/delete.postman_collection.json @@ -45,8 +45,6 @@ "listen": "test", "script": { "exec": [ - "let responseData = pm.response.json();", - "", "pm.test(\"export was deleted\", function () {", " pm.response.to.have.status(202);", "});", From b93dc39cdcd6218abd53ab7205258f1336913544 Mon Sep 17 00:00:00 2001 From: "aholmes@mitre.org" <14923551+holmesie@users.noreply.github.com> Date: Wed, 8 Jan 2025 12:47:25 -0600 Subject: [PATCH 16/20] Refactor client suite in line with server suites --- lib/bulk_data_test_kit.rb | 2 +- .../client/bulk_data_client_delete_group.rb | 30 ------ .../client/bulk_data_client_delete_test.rb | 33 ------- .../bulk_data_client_delete_wait_test.rb | 51 ---------- .../client/bulk_data_client_export_group.rb | 33 ------- .../bulk_data_client_export_wait_test.rb | 52 ---------- .../client/bulk_data_client_kick_off_test.rb | 50 ---------- .../client/bulk_data_client_output_test.rb | 32 ------- .../client/bulk_data_client_status_test.rb | 33 ------- .../client/bulk_data_client_test_suite.rb | 95 ------------------- .../v2.0.0/client/endpoints/delete.rb | 32 ------- .../v2.0.0/client/endpoints/kick_off.rb | 48 ---------- .../v2.0.0/client/endpoints/output.rb | 41 -------- .../v2.0.0/client/endpoints/status.rb | 49 ---------- .../v2.0.0/client/export_types.rb | 14 --- lib/bulk_data_test_kit/v2.0.0/client/tags.rb | 18 ---- lib/bulk_data_test_kit/v2.0.0/client/urls.rb | 47 --------- .../bulk_data_client_delete_group.rb | 27 ++++++ .../bulk_data_client_delete_test.rb | 31 ++++++ .../bulk_data_client_delete_wait_test.rb | 49 ++++++++++ .../bulk_data_client_export_group.rb | 31 ++++++ .../bulk_data_client_export_wait_test.rb | 50 ++++++++++ .../bulk_data_client_kick_off_test.rb | 48 ++++++++++ .../bulk_data_client_output_test.rb | 30 ++++++ .../bulk_data_client_status_test.rb | 31 ++++++ .../bulk_data_client_test_suite.rb | 93 ++++++++++++++++++ .../docs/suite_description.md | 0 .../v2.0.0_client/endpoints/delete.rb | 30 ++++++ .../v2.0.0_client/endpoints/kick_off.rb | 46 +++++++++ .../v2.0.0_client/endpoints/output.rb | 39 ++++++++ .../v2.0.0_client/endpoints/status.rb | 47 +++++++++ .../v2.0.0_client/export_types.rb | 12 +++ .../postman/delete.postman_collection.json | 0 .../system_export.postman_collection.json | 0 lib/bulk_data_test_kit/v2.0.0_client/tags.rb | 16 ++++ lib/bulk_data_test_kit/v2.0.0_client/urls.rb | 45 +++++++++ .../bulk_data_client_spec.rb | 18 ++-- 37 files changed, 635 insertions(+), 668 deletions(-) delete mode 100644 lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_delete_group.rb delete mode 100644 lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_delete_test.rb delete mode 100644 lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_delete_wait_test.rb delete mode 100644 lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_export_group.rb delete mode 100644 lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_export_wait_test.rb delete mode 100644 lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_kick_off_test.rb delete mode 100644 lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_output_test.rb delete mode 100644 lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_status_test.rb delete mode 100644 lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_test_suite.rb delete mode 100644 lib/bulk_data_test_kit/v2.0.0/client/endpoints/delete.rb delete mode 100644 lib/bulk_data_test_kit/v2.0.0/client/endpoints/kick_off.rb delete mode 100644 lib/bulk_data_test_kit/v2.0.0/client/endpoints/output.rb delete mode 100644 lib/bulk_data_test_kit/v2.0.0/client/endpoints/status.rb delete mode 100644 lib/bulk_data_test_kit/v2.0.0/client/export_types.rb delete mode 100644 lib/bulk_data_test_kit/v2.0.0/client/tags.rb delete mode 100644 lib/bulk_data_test_kit/v2.0.0/client/urls.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_delete_group.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_delete_test.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_delete_wait_test.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_export_group.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_export_wait_test.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_kick_off_test.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_output_test.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_status_test.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_test_suite.rb rename lib/bulk_data_test_kit/{v2.0.0/client => v2.0.0_client}/docs/suite_description.md (100%) create mode 100644 lib/bulk_data_test_kit/v2.0.0_client/endpoints/delete.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0_client/endpoints/kick_off.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0_client/endpoints/output.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0_client/endpoints/status.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0_client/export_types.rb rename lib/bulk_data_test_kit/{v2.0.0/client => v2.0.0_client}/postman/delete.postman_collection.json (100%) rename lib/bulk_data_test_kit/{v2.0.0/client => v2.0.0_client}/postman/system_export.postman_collection.json (100%) create mode 100644 lib/bulk_data_test_kit/v2.0.0_client/tags.rb create mode 100644 lib/bulk_data_test_kit/v2.0.0_client/urls.rb rename spec/bulk_data_test_kit/{client => v2.0.0_client}/bulk_data_client_spec.rb (84%) diff --git a/lib/bulk_data_test_kit.rb b/lib/bulk_data_test_kit.rb index 6ccb4f2..d6a0dc8 100644 --- a/lib/bulk_data_test_kit.rb +++ b/lib/bulk_data_test_kit.rb @@ -2,4 +2,4 @@ require_relative 'inferno_requirements_tools/ext/inferno_core/runnable' require_relative 'bulk_data_test_kit/v1.0.1/bulk_data_test_suite' require_relative 'bulk_data_test_kit/v2.0.0/bulk_data_test_suite' -require_relative 'bulk_data_test_kit/v2.0.0/client/bulk_data_client_test_suite' +require_relative 'bulk_data_test_kit/v2.0.0_client/bulk_data_client_test_suite' diff --git a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_delete_group.rb b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_delete_group.rb deleted file mode 100644 index 43d1e85..0000000 --- a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_delete_group.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -require_relative 'bulk_data_client_delete_wait_test' -require_relative 'bulk_data_client_kick_off_test' -require_relative 'bulk_data_client_delete_test' - -module BulkDataTestKit - module BulkDataV200 - module Client - # Bulk Data Client Delete Tests - class DeleteGroup < Inferno::TestGroup - title 'Bulk Data Client Delete Tests' - - description %( - The Bulk Data Client Delete tests verify the ability of a client to delete - a kicked-off bulk data export request. - ) - - id :bulk_data_client_delete_group - - run_as_group - - test from: :bulk_data_client_delete_wait - test from: :bulk_data_client_kick_off - test from: :bulk_data_client_kick_off - test from: :bulk_data_client_delete - end - end - end -end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_delete_test.rb b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_delete_test.rb deleted file mode 100644 index 7e80dc8..0000000 --- a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_delete_test.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -module BulkDataTestKit - module BulkDataV200 - module Client - # Bulk Data Client - Delete - class DeleteTest < Inferno::Test - include Tags - - title 'Bulk Data Delete Request' - - description %( - This test verifies that after a Bulk Data request has been started, the client can send a - DELETE request to the URL provided in the Content-Location header to - [delete the request](https://hl7.org/fhir/uv/bulkdata/STU2/export.html#bulk-data-delete-request), - as described in the [FHIR Asynchronous Request Pattern](https://www.hl7.org/fhir/R4/async.html). - ) - - id :bulk_data_client_delete - - verifies_requirements 'hl7.fhir.uv.bulkdata_2.0.0@119' - - run do - assert load_tagged_requests(DELETE_TAG).any?, fail_message - end - - def fail_message - 'Did not receive a delete request.' - end - end - end - end -end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_delete_wait_test.rb b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_delete_wait_test.rb deleted file mode 100644 index 55e06c8..0000000 --- a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_delete_wait_test.rb +++ /dev/null @@ -1,51 +0,0 @@ -# frozen_string_literal: true - -module BulkDataTestKit - module BulkDataV200 - module Client - # Bulk Data Client - Delete Wait - class DeleteWaitTest < Inferno::Test - include URLs - include ExportTypes - - title 'Wait For Request Sequence' - - description %( - This test will receive bulk data export requests until the user confirms they are finished. - ) - - id :bulk_data_client_delete_wait - - input :export_type, :group_id - - output :export_id - - run do - export_id = SecureRandom.uuid - - output export_id: export_id - - wait( - identifier: export_id, - message: %( - Kick-off a #{export_type} endpoint type bulk export using the following base URL: - - #{kickoff_url(export_id)} - - #{export_type == GROUP_EXPORT_TYPE ? "Ensure the Group ID is set to #{group_id}." : ''} - - Once the export request has been kicked-off, - [delete the export](https://build.fhir.org/ig/HL7/bulk-data/export.html#bulk-data-delete-request). - - The entire request sequence will be recorded and used in the subsequent tests to - verify comformity to the - [Bulk Data IG](https://build.fhir.org/ig/HL7/bulk-data/export.html#sequence-overview). - - [Click here](#{resume_pass_url}?id=#{export_id}) when finished. - ) - ) - end - end - end - end -end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_export_group.rb b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_export_group.rb deleted file mode 100644 index f3eaad2..0000000 --- a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_export_group.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -require_relative 'bulk_data_client_export_wait_test' -require_relative 'bulk_data_client_kick_off_test' -require_relative 'bulk_data_client_status_test' -require_relative 'bulk_data_client_output_test' - -module BulkDataTestKit - module BulkDataV200 - module Client - # Bulk Data Client Export Tests - class ExportGroup < Inferno::TestGroup - title 'Bulk Data Client Export Tests' - - description %( - The Bulk Data Client Export tests verify the ability of a client to: - - Kick-off a new bulk data export request - - Poll the in-progress request for status updates - - Download a completed bulk data export file - ) - - id :bulk_data_client_export_group - - run_as_group - - test from: :bulk_data_client_export_wait - test from: :bulk_data_client_kick_off - test from: :bulk_data_client_status - test from: :bulk_data_client_output - end - end - end -end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_export_wait_test.rb b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_export_wait_test.rb deleted file mode 100644 index 4b738c1..0000000 --- a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_export_wait_test.rb +++ /dev/null @@ -1,52 +0,0 @@ -# frozen_string_literal: true - -module BulkDataTestKit - module BulkDataV200 - module Client - # Bulk Data Client - Export Wait - class ExportWaitTest < Inferno::Test - include URLs - include ExportTypes - - title 'Wait For Request Sequence' - - description %( - This test will receive bulk data export requests until the user confirms they are finished. - ) - - id :bulk_data_client_export_wait - - input :export_type, :group_id - - output :export_id - - run do - export_id = SecureRandom.uuid - - output export_id: export_id - - wait( - identifier: export_id, - message: %( - Perform a #{export_type} endpoint type bulk export kick-off using the following base URL: - - #{kickoff_url(export_id)} - - #{export_type == GROUP_EXPORT_TYPE ? "Ensure the Group ID is set to #{group_id}." : ''} - - After the kick-off is made, a subsequent status request (using the URL provided in the response - to the kick-off request) and then a download request (using the URL provided in the response to - the status request) are expected. - - The entire request sequence will be recorded and used in the subsequent tests to - verify comformity to the - [Bulk Data IG](https://build.fhir.org/ig/HL7/bulk-data/export.html#sequence-overview). - - [Click here](#{resume_pass_url}?id=#{export_id}) when finished. - ) - ) - end - end - end - end -end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_kick_off_test.rb b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_kick_off_test.rb deleted file mode 100644 index d728ca5..0000000 --- a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_kick_off_test.rb +++ /dev/null @@ -1,50 +0,0 @@ -# frozen_string_literal: true - -module BulkDataTestKit - module BulkDataV200 - module Client - # Bulk Data Client Kick-off - class KickOffTest < Inferno::Test - include Tags - include ExportTypes - - title 'Bulk Data Kick-off Request' - - description %( - This test verifies that a client can - [kick-off a Bulk Data request](https://hl7.org/fhir/uv/bulkdata/STU2/export.html#roles) - using the `$export` operation against the proper endpoint type. - ) - - id :bulk_data_client_kick_off - - verifies_requirements 'hl7.fhir.uv.bulkdata_2.0.0@17' - - input :export_type - - run do - case export_type - when PATIENT_EXPORT_TYPE - assert load_tagged_requests(PATIENT_KICKOFF_TAG).any?, patient_fail_message - when GROUP_EXPORT_TYPE - assert load_tagged_requests(GROUP_KICKOFF_TAG).any?, group_fail_message - when SYSTEM_EXPORT_TYPE - assert load_tagged_requests(SYSTEM_KICKOFF_TAG).any?, system_fail_message - end - end - - def patient_fail_message - 'Did not receive a Patient type kick-off request.' - end - - def group_fail_message - 'Did not receive a Group type kick-off request.' - end - - def system_fail_message - 'Did not receive a System type kick-off request.' - end - end - end - end -end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_output_test.rb b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_output_test.rb deleted file mode 100644 index 69833c5..0000000 --- a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_output_test.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -module BulkDataTestKit - module BulkDataV200 - module Client - # Bulk Data Client Output - class OutputTest < Inferno::Test - include Tags - - title 'Bulk Data Output File Request' - - description %( - This test verifies that the client, using the URL supplied in the Complete Status response body, - can [download](https://hl7.org/fhir/uv/bulkdata/STU2/export.html#bulk-data-output-file-request) - the generated Bulk Data file. - ) - - id :bulk_data_client_output - - verifies_requirements 'hl7.fhir.uv.bulkdata_2.0.0@200' - - run do - assert load_tagged_requests(OUTPUT_TAG).any?, fail_message - end - - def fail_message - 'Did not receive a download request.' - end - end - end - end -end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_status_test.rb b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_status_test.rb deleted file mode 100644 index 9d1ddc9..0000000 --- a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_status_test.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -module BulkDataTestKit - module BulkDataV200 - module Client - # Bulk Data Client Status - class StatusTest < Inferno::Test - include Tags - - title 'Bulk Data Status Request' - - description %( - This test verifies that after a Bulk Data request has been started, the client can - [poll the status URL](https://hl7.org/fhir/uv/bulkdata/STU2/export.html#bulk-data-status-request) - provided in the Content-Location header, as as described in the - [FHIR Asynchronous Request Pattern](https://www.hl7.org/fhir/R4/async.html). - ) - - id :bulk_data_client_status - - verifies_requirements 'hl7.fhir.uv.bulkdata_2.0.0@123' - - run do - assert load_tagged_requests(STATUS_TAG).any?, fail_message - end - - def fail_message - 'Did not receive a status request.' - end - end - end - end -end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_test_suite.rb b/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_test_suite.rb deleted file mode 100644 index 52349d4..0000000 --- a/lib/bulk_data_test_kit/v2.0.0/client/bulk_data_client_test_suite.rb +++ /dev/null @@ -1,95 +0,0 @@ -# frozen_string_literal: true - -require_relative '../../version' -require_relative 'tags' -require_relative 'urls' -require_relative 'export_types' - -require_relative 'endpoints/delete' -require_relative 'endpoints/kick_off' -require_relative 'endpoints/output' -require_relative 'endpoints/status' - -require_relative 'bulk_data_client_export_group' -require_relative 'bulk_data_client_delete_group' - -module BulkDataTestKit - module BulkDataV200 - module Client - # Bulk Data Access v2.0.0 Client Test Suite - class BulkDataClientTestSuite < Inferno::TestSuite - include URLs - include ExportTypes - - title 'Bulk Data Access v2.0.0 Client' - - description File.read(File.join(__dir__, 'docs', 'suite_description.md')) - - version VERSION - - id :bulk_data_v200_client - - links [ - { - label: 'Report Issue', - url: 'https://github.com/inferno-framework/bulk-data-test-kit/issues/' - }, - { - label: 'Open Source', - url: 'https://github.com/inferno-framework/bulk-data-test-kit/' - }, - { - label: 'Download', - url: 'https://github.com/inferno-framework/bulk-data-test-kit/releases' - }, - { - label: 'Implementation Guide', - url: 'https://hl7.org/fhir/uv/bulkdata/STU2/' - } - ] - - input :export_type, - title: 'Export Type', - description: 'The export endpoint type to test against.', - type: 'radio', - default: SYSTEM_EXPORT_TYPE, - options: { - list_options: [ - { - label: 'All Patients', - value: PATIENT_EXPORT_TYPE - }, - { - label: 'Group of Patients', - value: GROUP_EXPORT_TYPE - }, - { - label: 'System Level Export', - value: SYSTEM_EXPORT_TYPE - } - ] - } - - input :group_id, - title: 'Group ID', - description: 'If using the Group endpoint, the identifier of the Group to export.', - default: 1, - locked: true - - suite_endpoint :get, PATIENT_KICKOFF_ROUTE, Endpoints::KickOff - suite_endpoint :get, GROUP_KICKOFF_ROUTE, Endpoints::KickOff - suite_endpoint :get, SYSTEM_KICKOFF_ROUTE, Endpoints::KickOff - suite_endpoint :get, STATUS_ROUTE, Endpoints::Status - suite_endpoint :get, OUTPUT_ROUTE, Endpoints::Output - suite_endpoint :delete, STATUS_ROUTE, Endpoints::Delete - - resume_test_route :get, RESUME_PASS_PATH do |request| - request.query_parameters['id'] - end - - group from: :bulk_data_client_export_group - group from: :bulk_data_client_delete_group - end - end - end -end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/endpoints/delete.rb b/lib/bulk_data_test_kit/v2.0.0/client/endpoints/delete.rb deleted file mode 100644 index 8020ad4..0000000 --- a/lib/bulk_data_test_kit/v2.0.0/client/endpoints/delete.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -require_relative '../tags' - -module BulkDataTestKit - module BulkDataV200 - module Client - module Endpoints - # Delete Endpoint - class Delete < Inferno::DSL::SuiteEndpoint - include Tags - - def test_run_identifier - export_id - end - - def make_response - response.status = 202 - end - - def tags - [DELETE_TAG] - end - - def export_id - request.params[:export_id] - end - end - end - end - end -end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/endpoints/kick_off.rb b/lib/bulk_data_test_kit/v2.0.0/client/endpoints/kick_off.rb deleted file mode 100644 index 6f294b4..0000000 --- a/lib/bulk_data_test_kit/v2.0.0/client/endpoints/kick_off.rb +++ /dev/null @@ -1,48 +0,0 @@ -# frozen_string_literal: true - -require_relative '../tags' -require_relative '../urls' -require_relative '../export_types' - -module BulkDataTestKit - module BulkDataV200 - module Client - module Endpoints - # Kick Off Endpoint - class KickOff < Inferno::DSL::SuiteEndpoint - include Tags - include URLs - include ExportTypes - - def test_run_identifier - export_id - end - - def make_response - response.status = 202 - response.headers['Content-Location'] = status_url(export_id) - end - - def tags - case request_type.titleize - when PATIENT_EXPORT_TYPE - [PATIENT_KICKOFF_TAG] - when GROUP_EXPORT_TYPE - [GROUP_KICKOFF_TAG] - when SYSTEM_EXPORT_TYPE - [SYSTEM_KICKOFF_TAG] - end - end - - def export_id - request.params[:export_id] - end - - def request_type - request.params[:type] || SYSTEM_EXPORT_TYPE - end - end - end - end - end -end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/endpoints/output.rb b/lib/bulk_data_test_kit/v2.0.0/client/endpoints/output.rb deleted file mode 100644 index 10e07a6..0000000 --- a/lib/bulk_data_test_kit/v2.0.0/client/endpoints/output.rb +++ /dev/null @@ -1,41 +0,0 @@ -# frozen_string_literal: true - -require_relative '../tags' - -module BulkDataTestKit - module BulkDataV200 - module Client - module Endpoints - # Output Endpoint - class Output < Inferno::DSL::SuiteEndpoint - include Tags - - def test_run_identifier - export_id - end - - def make_response - response.status = 200 - response.headers['Content-Type'] = 'application/fhir+ndjson' - response.body = "#{example_patient.to_json.squish}\n" - end - - def tags - [OUTPUT_TAG] - end - - def export_id - request.params[:export_id] - end - - def example_patient - FHIR::Patient.new( - id: test_run_identifier, - name: FHIR::HumanName.new(given: 'Example', family: 'Patient') - ) - end - end - end - end - end -end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/endpoints/status.rb b/lib/bulk_data_test_kit/v2.0.0/client/endpoints/status.rb deleted file mode 100644 index aae0965..0000000 --- a/lib/bulk_data_test_kit/v2.0.0/client/endpoints/status.rb +++ /dev/null @@ -1,49 +0,0 @@ -# frozen_string_literal: true - -require_relative '../tags' -require_relative '../urls' - -module BulkDataTestKit - module BulkDataV200 - module Client - module Endpoints - # Status Endpoint - class Status < Inferno::DSL::SuiteEndpoint - include Tags - include URLs - - def test_run_identifier - export_id - end - - def make_response - response.status = 200 - response.body = response_body.to_json - response.format = :json - end - - def tags - [STATUS_TAG] - end - - def export_id - request.params[:export_id] - end - - def response_body - { - transactionTime: DateTime.now.iso8601, - request: kickoff_url(export_id), - requiresAccessToken: false, - output: [{ - type: 'Patient', - url: output_url(export_id) - }], - error: [] - } - end - end - end - end - end -end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/export_types.rb b/lib/bulk_data_test_kit/v2.0.0/client/export_types.rb deleted file mode 100644 index 7712e3c..0000000 --- a/lib/bulk_data_test_kit/v2.0.0/client/export_types.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -module BulkDataTestKit - module BulkDataV200 - module Client - # Export types for use in Bulk Data Client tests and endpoints - module ExportTypes - PATIENT_EXPORT_TYPE = 'Patient' - GROUP_EXPORT_TYPE = 'Group' - SYSTEM_EXPORT_TYPE = 'System' - end - end - end -end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/tags.rb b/lib/bulk_data_test_kit/v2.0.0/client/tags.rb deleted file mode 100644 index e5d2969..0000000 --- a/lib/bulk_data_test_kit/v2.0.0/client/tags.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -module BulkDataTestKit - module BulkDataV200 - module Client - # Tags for use in Bulk Data Client tests and endpoints - module Tags - METADATA_TAG = 'bulk_data_metadata' - PATIENT_KICKOFF_TAG = 'bulk_data_kickoff_patient' - GROUP_KICKOFF_TAG = 'bulk_data_kickoff_group' - SYSTEM_KICKOFF_TAG = 'bulk_data_kickoff_system' - STATUS_TAG = 'bulk_data_status' - OUTPUT_TAG = 'bulk_data_output' - DELETE_TAG = 'bulk_data_delete' - end - end - end -end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/urls.rb b/lib/bulk_data_test_kit/v2.0.0/client/urls.rb deleted file mode 100644 index ef44335..0000000 --- a/lib/bulk_data_test_kit/v2.0.0/client/urls.rb +++ /dev/null @@ -1,47 +0,0 @@ -# frozen_string_literal: true - -module BulkDataTestKit - module BulkDataV200 - module Client - # URLs for use in Bulk Data Client tests and endpoints - module URLs - RESUME_PASS_PATH = '/resume_pass' - BASE_ROUTE = '/:export_id/fhir' - METADATA_ROUTE = "#{BASE_ROUTE}/metadata".freeze - PATIENT_KICKOFF_ROUTE = "#{BASE_ROUTE}/:type/$export".freeze - GROUP_KICKOFF_ROUTE = "#{BASE_ROUTE}/:type/:group_id/$export".freeze - SYSTEM_KICKOFF_ROUTE = "#{BASE_ROUTE}/$export".freeze - STATUS_ROUTE = '/status/:export_id' - OUTPUT_ROUTE = '/output/:export_id.ndjson' - - def base_url - "#{Inferno::Application['base_url']}/custom/#{suite_id}" - end - - def resume_pass_url - base_url + RESUME_PASS_PATH - end - - def kickoff_url(export_id) - base_url + BASE_ROUTE.gsub(':export_id', export_id) - end - - def status_url(export_id) - base_url + STATUS_ROUTE.gsub(':export_id', export_id) - end - - def output_url(export_id) - base_url + OUTPUT_ROUTE.gsub(':export_id', export_id) - end - - def suite_id - if respond_to?('result') # If being used with a suite endpoint - result.test_id.split('-').first - elsif self.class.respond_to?('suite') # If being used with a test/group/suite - self.class.suite.id - end - end - end - end - end -end diff --git a/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_delete_group.rb b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_delete_group.rb new file mode 100644 index 0000000..5b5f71c --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_delete_group.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require_relative 'bulk_data_client_delete_wait_test' +require_relative 'bulk_data_client_kick_off_test' +require_relative 'bulk_data_client_delete_test' + +module BulkDataTestKit + module BulkDataV200Client + # Bulk Data Client Delete Tests + class DeleteGroup < Inferno::TestGroup + title 'Bulk Data Client Delete Tests' + + description %( + The Bulk Data Client Delete tests verify the ability of a client to delete + a kicked-off bulk data export request. + ) + + id :bulk_data_client_delete_group + + run_as_group + + test from: :bulk_data_client_delete_wait + test from: :bulk_data_client_kick_off + test from: :bulk_data_client_delete + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_delete_test.rb b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_delete_test.rb new file mode 100644 index 0000000..ca03c54 --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_delete_test.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +module BulkDataTestKit + module BulkDataV200Client + # Bulk Data Client - Delete + class DeleteTest < Inferno::Test + include Tags + + title 'Bulk Data Delete Request' + + description %( + This test verifies that after a Bulk Data request has been started, the client can send a + DELETE request to the URL provided in the Content-Location header to + [delete the request](https://hl7.org/fhir/uv/bulkdata/STU2/export.html#bulk-data-delete-request), + as described in the [FHIR Asynchronous Request Pattern](https://www.hl7.org/fhir/R4/async.html). + ) + + id :bulk_data_client_delete + + verifies_requirements 'hl7.fhir.uv.bulkdata_2.0.0@119' + + run do + assert load_tagged_requests(DELETE_TAG).any?, fail_message + end + + def fail_message + 'Did not receive a delete request.' + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_delete_wait_test.rb b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_delete_wait_test.rb new file mode 100644 index 0000000..cf3fd18 --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_delete_wait_test.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +module BulkDataTestKit + module BulkDataV200Client + # Bulk Data Client - Delete Wait + class DeleteWaitTest < Inferno::Test + include URLs + include ExportTypes + + title 'Wait For Request Sequence' + + description %( + This test will receive bulk data export requests until the user confirms they are finished. + ) + + id :bulk_data_client_delete_wait + + input :export_type, :group_id + + output :export_id + + run do + export_id = SecureRandom.uuid + + output export_id: export_id + + wait( + identifier: export_id, + message: %( + Kick-off a #{export_type} endpoint type bulk export using the following base URL: + + #{kickoff_url(export_id)} + + #{export_type == GROUP_EXPORT_TYPE ? "Ensure the Group ID is set to #{group_id}." : ''} + + Once the export request has been kicked-off, + [delete the export](https://build.fhir.org/ig/HL7/bulk-data/export.html#bulk-data-delete-request). + + The entire request sequence will be recorded and used in the subsequent tests to + verify comformity to the + [Bulk Data IG](https://build.fhir.org/ig/HL7/bulk-data/export.html#sequence-overview). + + [Click here](#{resume_pass_url}?id=#{export_id}) when finished. + ) + ) + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_export_group.rb b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_export_group.rb new file mode 100644 index 0000000..7da13ce --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_export_group.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require_relative 'bulk_data_client_export_wait_test' +require_relative 'bulk_data_client_kick_off_test' +require_relative 'bulk_data_client_status_test' +require_relative 'bulk_data_client_output_test' + +module BulkDataTestKit + module BulkDataV200Client + # Bulk Data Client Export Tests + class ExportGroup < Inferno::TestGroup + title 'Bulk Data Client Export Tests' + + description %( + The Bulk Data Client Export tests verify the ability of a client to: + - Kick-off a new bulk data export request + - Poll the in-progress request for status updates + - Download a completed bulk data export file + ) + + id :bulk_data_client_export_group + + run_as_group + + test from: :bulk_data_client_export_wait + test from: :bulk_data_client_kick_off + test from: :bulk_data_client_status + test from: :bulk_data_client_output + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_export_wait_test.rb b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_export_wait_test.rb new file mode 100644 index 0000000..8a6c6c5 --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_export_wait_test.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +module BulkDataTestKit + module BulkDataV200Client + # Bulk Data Client - Export Wait + class ExportWaitTest < Inferno::Test + include URLs + include ExportTypes + + title 'Wait For Request Sequence' + + description %( + This test will receive bulk data export requests until the user confirms they are finished. + ) + + id :bulk_data_client_export_wait + + input :export_type, :group_id + + output :export_id + + run do + export_id = SecureRandom.uuid + + output export_id: export_id + + wait( + identifier: export_id, + message: %( + Perform a #{export_type} endpoint type bulk export kick-off using the following base URL: + + #{kickoff_url(export_id)} + + #{export_type == GROUP_EXPORT_TYPE ? "Ensure the Group ID is set to #{group_id}." : ''} + + After the kick-off is made, a subsequent status request (using the URL provided in the response + to the kick-off request) and then a download request (using the URL provided in the response to + the status request) are expected. + + The entire request sequence will be recorded and used in the subsequent tests to + verify comformity to the + [Bulk Data IG](https://build.fhir.org/ig/HL7/bulk-data/export.html#sequence-overview). + + [Click here](#{resume_pass_url}?id=#{export_id}) when finished. + ) + ) + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_kick_off_test.rb b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_kick_off_test.rb new file mode 100644 index 0000000..9085245 --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_kick_off_test.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +module BulkDataTestKit + module BulkDataV200Client + # Bulk Data Client Kick-off + class KickOffTest < Inferno::Test + include Tags + include ExportTypes + + title 'Bulk Data Kick-off Request' + + description %( + This test verifies that a client can + [kick-off a Bulk Data request](https://hl7.org/fhir/uv/bulkdata/STU2/export.html#roles) + using the `$export` operation against the proper endpoint type. + ) + + id :bulk_data_client_kick_off + + verifies_requirements 'hl7.fhir.uv.bulkdata_2.0.0@17' + + input :export_type + + run do + case export_type + when PATIENT_EXPORT_TYPE + assert load_tagged_requests(PATIENT_KICKOFF_TAG).any?, patient_fail_message + when GROUP_EXPORT_TYPE + assert load_tagged_requests(GROUP_KICKOFF_TAG).any?, group_fail_message + when SYSTEM_EXPORT_TYPE + assert load_tagged_requests(SYSTEM_KICKOFF_TAG).any?, system_fail_message + end + end + + def patient_fail_message + 'Did not receive a Patient type kick-off request.' + end + + def group_fail_message + 'Did not receive a Group type kick-off request.' + end + + def system_fail_message + 'Did not receive a System type kick-off request.' + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_output_test.rb b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_output_test.rb new file mode 100644 index 0000000..c58c1fd --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_output_test.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +module BulkDataTestKit + module BulkDataV200Client + # Bulk Data Client Output + class OutputTest < Inferno::Test + include Tags + + title 'Bulk Data Output File Request' + + description %( + This test verifies that the client, using the URL supplied in the Complete Status response body, + can [download](https://hl7.org/fhir/uv/bulkdata/STU2/export.html#bulk-data-output-file-request) + the generated Bulk Data file. + ) + + id :bulk_data_client_output + + verifies_requirements 'hl7.fhir.uv.bulkdata_2.0.0@200' + + run do + assert load_tagged_requests(OUTPUT_TAG).any?, fail_message + end + + def fail_message + 'Did not receive a download request.' + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_status_test.rb b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_status_test.rb new file mode 100644 index 0000000..35c5de0 --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_status_test.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +module BulkDataTestKit + module BulkDataV200Client + # Bulk Data Client Status + class StatusTest < Inferno::Test + include Tags + + title 'Bulk Data Status Request' + + description %( + This test verifies that after a Bulk Data request has been started, the client can + [poll the status URL](https://hl7.org/fhir/uv/bulkdata/STU2/export.html#bulk-data-status-request) + provided in the Content-Location header, as as described in the + [FHIR Asynchronous Request Pattern](https://www.hl7.org/fhir/R4/async.html). + ) + + id :bulk_data_client_status + + verifies_requirements 'hl7.fhir.uv.bulkdata_2.0.0@123' + + run do + assert load_tagged_requests(STATUS_TAG).any?, fail_message + end + + def fail_message + 'Did not receive a status request.' + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_test_suite.rb b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_test_suite.rb new file mode 100644 index 0000000..d1b9c8f --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_test_suite.rb @@ -0,0 +1,93 @@ +# frozen_string_literal: true + +require_relative '../version' +require_relative 'tags' +require_relative 'urls' +require_relative 'export_types' + +require_relative 'endpoints/delete' +require_relative 'endpoints/kick_off' +require_relative 'endpoints/output' +require_relative 'endpoints/status' + +require_relative 'bulk_data_client_export_group' +require_relative 'bulk_data_client_delete_group' + +module BulkDataTestKit + module BulkDataV200Client + # Bulk Data Access v2.0.0 Client Test Suite + class BulkDataClientTestSuite < Inferno::TestSuite + include URLs + include ExportTypes + + title 'Bulk Data Access v2.0.0 Client' + + description File.read(File.join(__dir__, 'docs', 'suite_description.md')) + + version VERSION + + id :bulk_data_v200_client + + links [ + { + label: 'Report Issue', + url: 'https://github.com/inferno-framework/bulk-data-test-kit/issues/' + }, + { + label: 'Open Source', + url: 'https://github.com/inferno-framework/bulk-data-test-kit/' + }, + { + label: 'Download', + url: 'https://github.com/inferno-framework/bulk-data-test-kit/releases' + }, + { + label: 'Implementation Guide', + url: 'https://hl7.org/fhir/uv/bulkdata/STU2/' + } + ] + + input :export_type, + title: 'Export Type', + description: 'The export endpoint type to test against.', + type: 'radio', + default: SYSTEM_EXPORT_TYPE, + options: { + list_options: [ + { + label: 'All Patients', + value: PATIENT_EXPORT_TYPE + }, + { + label: 'Group of Patients', + value: GROUP_EXPORT_TYPE + }, + { + label: 'System Level Export', + value: SYSTEM_EXPORT_TYPE + } + ] + } + + input :group_id, + title: 'Group ID', + description: 'If using the Group endpoint, the identifier of the Group to export.', + default: 1, + locked: true + + suite_endpoint :get, PATIENT_KICKOFF_ROUTE, Endpoints::KickOff + suite_endpoint :get, GROUP_KICKOFF_ROUTE, Endpoints::KickOff + suite_endpoint :get, SYSTEM_KICKOFF_ROUTE, Endpoints::KickOff + suite_endpoint :get, STATUS_ROUTE, Endpoints::Status + suite_endpoint :get, OUTPUT_ROUTE, Endpoints::Output + suite_endpoint :delete, STATUS_ROUTE, Endpoints::Delete + + resume_test_route :get, RESUME_PASS_PATH do |request| + request.query_parameters['id'] + end + + group from: :bulk_data_client_export_group + group from: :bulk_data_client_delete_group + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/docs/suite_description.md b/lib/bulk_data_test_kit/v2.0.0_client/docs/suite_description.md similarity index 100% rename from lib/bulk_data_test_kit/v2.0.0/client/docs/suite_description.md rename to lib/bulk_data_test_kit/v2.0.0_client/docs/suite_description.md diff --git a/lib/bulk_data_test_kit/v2.0.0_client/endpoints/delete.rb b/lib/bulk_data_test_kit/v2.0.0_client/endpoints/delete.rb new file mode 100644 index 0000000..14da252 --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0_client/endpoints/delete.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +require_relative '../tags' + +module BulkDataTestKit + module BulkDataV200Client + module Endpoints + # Delete Endpoint + class Delete < Inferno::DSL::SuiteEndpoint + include Tags + + def test_run_identifier + export_id + end + + def make_response + response.status = 202 + end + + def tags + [DELETE_TAG] + end + + def export_id + request.params[:export_id] + end + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0_client/endpoints/kick_off.rb b/lib/bulk_data_test_kit/v2.0.0_client/endpoints/kick_off.rb new file mode 100644 index 0000000..bf64c35 --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0_client/endpoints/kick_off.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +require_relative '../tags' +require_relative '../urls' +require_relative '../export_types' + +module BulkDataTestKit + module BulkDataV200Client + module Endpoints + # Kick Off Endpoint + class KickOff < Inferno::DSL::SuiteEndpoint + include Tags + include URLs + include ExportTypes + + def test_run_identifier + export_id + end + + def make_response + response.status = 202 + response.headers['Content-Location'] = status_url(export_id) + end + + def tags + case request_type.titleize + when PATIENT_EXPORT_TYPE + [PATIENT_KICKOFF_TAG] + when GROUP_EXPORT_TYPE + [GROUP_KICKOFF_TAG] + when SYSTEM_EXPORT_TYPE + [SYSTEM_KICKOFF_TAG] + end + end + + def export_id + request.params[:export_id] + end + + def request_type + request.params[:type] || SYSTEM_EXPORT_TYPE + end + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0_client/endpoints/output.rb b/lib/bulk_data_test_kit/v2.0.0_client/endpoints/output.rb new file mode 100644 index 0000000..61cc50e --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0_client/endpoints/output.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require_relative '../tags' + +module BulkDataTestKit + module BulkDataV200Client + module Endpoints + # Output Endpoint + class Output < Inferno::DSL::SuiteEndpoint + include Tags + + def test_run_identifier + export_id + end + + def make_response + response.status = 200 + response.headers['Content-Type'] = 'application/fhir+ndjson' + response.body = "#{example_patient.to_json.squish}\n" + end + + def tags + [OUTPUT_TAG] + end + + def export_id + request.params[:export_id] + end + + def example_patient + FHIR::Patient.new( + id: test_run_identifier, + name: FHIR::HumanName.new(given: 'Example', family: 'Patient') + ) + end + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0_client/endpoints/status.rb b/lib/bulk_data_test_kit/v2.0.0_client/endpoints/status.rb new file mode 100644 index 0000000..6366bc2 --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0_client/endpoints/status.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +require_relative '../tags' +require_relative '../urls' + +module BulkDataTestKit + module BulkDataV200Client + module Endpoints + # Status Endpoint + class Status < Inferno::DSL::SuiteEndpoint + include Tags + include URLs + + def test_run_identifier + export_id + end + + def make_response + response.status = 200 + response.body = response_body.to_json + response.format = :json + end + + def tags + [STATUS_TAG] + end + + def export_id + request.params[:export_id] + end + + def response_body + { + transactionTime: DateTime.now.iso8601, + request: kickoff_url(export_id), + requiresAccessToken: false, + output: [{ + type: 'Patient', + url: output_url(export_id) + }], + error: [] + } + end + end + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0_client/export_types.rb b/lib/bulk_data_test_kit/v2.0.0_client/export_types.rb new file mode 100644 index 0000000..8eabb52 --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0_client/export_types.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module BulkDataTestKit + module BulkDataV200Client + # Export types for use in Bulk Data Client tests and endpoints + module ExportTypes + PATIENT_EXPORT_TYPE = 'Patient' + GROUP_EXPORT_TYPE = 'Group' + SYSTEM_EXPORT_TYPE = 'System' + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0/client/postman/delete.postman_collection.json b/lib/bulk_data_test_kit/v2.0.0_client/postman/delete.postman_collection.json similarity index 100% rename from lib/bulk_data_test_kit/v2.0.0/client/postman/delete.postman_collection.json rename to lib/bulk_data_test_kit/v2.0.0_client/postman/delete.postman_collection.json diff --git a/lib/bulk_data_test_kit/v2.0.0/client/postman/system_export.postman_collection.json b/lib/bulk_data_test_kit/v2.0.0_client/postman/system_export.postman_collection.json similarity index 100% rename from lib/bulk_data_test_kit/v2.0.0/client/postman/system_export.postman_collection.json rename to lib/bulk_data_test_kit/v2.0.0_client/postman/system_export.postman_collection.json diff --git a/lib/bulk_data_test_kit/v2.0.0_client/tags.rb b/lib/bulk_data_test_kit/v2.0.0_client/tags.rb new file mode 100644 index 0000000..050ac77 --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0_client/tags.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module BulkDataTestKit + module BulkDataV200Client + # Tags for use in Bulk Data Client tests and endpoints + module Tags + METADATA_TAG = 'bulk_data_metadata' + PATIENT_KICKOFF_TAG = 'bulk_data_kickoff_patient' + GROUP_KICKOFF_TAG = 'bulk_data_kickoff_group' + SYSTEM_KICKOFF_TAG = 'bulk_data_kickoff_system' + STATUS_TAG = 'bulk_data_status' + OUTPUT_TAG = 'bulk_data_output' + DELETE_TAG = 'bulk_data_delete' + end + end +end diff --git a/lib/bulk_data_test_kit/v2.0.0_client/urls.rb b/lib/bulk_data_test_kit/v2.0.0_client/urls.rb new file mode 100644 index 0000000..70c2e9c --- /dev/null +++ b/lib/bulk_data_test_kit/v2.0.0_client/urls.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +module BulkDataTestKit + module BulkDataV200Client + # URLs for use in Bulk Data Client tests and endpoints + module URLs + RESUME_PASS_PATH = '/resume_pass' + BASE_ROUTE = '/:export_id/fhir' + METADATA_ROUTE = "#{BASE_ROUTE}/metadata".freeze + PATIENT_KICKOFF_ROUTE = "#{BASE_ROUTE}/:type/$export".freeze + GROUP_KICKOFF_ROUTE = "#{BASE_ROUTE}/:type/:group_id/$export".freeze + SYSTEM_KICKOFF_ROUTE = "#{BASE_ROUTE}/$export".freeze + STATUS_ROUTE = '/status/:export_id' + OUTPUT_ROUTE = '/output/:export_id.ndjson' + + def base_url + "#{Inferno::Application['base_url']}/custom/#{suite_id}" + end + + def resume_pass_url + base_url + RESUME_PASS_PATH + end + + def kickoff_url(export_id) + base_url + BASE_ROUTE.gsub(':export_id', export_id) + end + + def status_url(export_id) + base_url + STATUS_ROUTE.gsub(':export_id', export_id) + end + + def output_url(export_id) + base_url + OUTPUT_ROUTE.gsub(':export_id', export_id) + end + + def suite_id + if respond_to?('result') # If being used with a suite endpoint + result.test_id.split('-').first + elsif self.class.respond_to?('suite') # If being used with a test/group/suite + self.class.suite.id + end + end + end + end +end diff --git a/spec/bulk_data_test_kit/client/bulk_data_client_spec.rb b/spec/bulk_data_test_kit/v2.0.0_client/bulk_data_client_spec.rb similarity index 84% rename from spec/bulk_data_test_kit/client/bulk_data_client_spec.rb rename to spec/bulk_data_test_kit/v2.0.0_client/bulk_data_client_spec.rb index acc9089..284cd26 100644 --- a/spec/bulk_data_test_kit/client/bulk_data_client_spec.rb +++ b/spec/bulk_data_test_kit/v2.0.0_client/bulk_data_client_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require_relative '../../../lib/bulk_data_test_kit/v2.0.0/client/tags' -require_relative '../../../lib/bulk_data_test_kit/v2.0.0/client/urls' +require_relative '../../../lib/bulk_data_test_kit/v2.0.0_client/tags' +require_relative '../../../lib/bulk_data_test_kit/v2.0.0_client/urls' -RSpec.describe BulkDataTestKit::BulkDataV200::Client do +RSpec.describe BulkDataTestKit::BulkDataV200Client do let(:suite) { Inferno::Repositories::TestSuites.new.find('bulk_data_v200_client') } let(:session_data_repo) { Inferno::Repositories::SessionData.new } let(:results_repo) { Inferno::Repositories::Results.new } @@ -15,12 +15,12 @@ let(:output_test) { Inferno::Repositories::Tests.new.find('bulk_data_client_output') } let(:delete_test) { Inferno::Repositories::Tests.new.find('bulk_data_client_delete') } - let(:patient_kickoff_tag) { BulkDataTestKit::BulkDataV200::Client::Tags::PATIENT_KICKOFF_TAG } - let(:group_kickoff_tag) { BulkDataTestKit::BulkDataV200::Client::Tags::GROUP_KICKOFF_TAG } - let(:system_kickoff_tag) { BulkDataTestKit::BulkDataV200::Client::Tags::SYSTEM_KICKOFF_TAG } - let(:status_tag) { BulkDataTestKit::BulkDataV200::Client::Tags::STATUS_TAG } - let(:output_tag) { BulkDataTestKit::BulkDataV200::Client::Tags::OUTPUT_TAG } - let(:delete_tag) { BulkDataTestKit::BulkDataV200::Client::Tags::DELETE_TAG } + let(:patient_kickoff_tag) { BulkDataTestKit::BulkDataV200Client::Tags::PATIENT_KICKOFF_TAG } + let(:group_kickoff_tag) { BulkDataTestKit::BulkDataV200Client::Tags::GROUP_KICKOFF_TAG } + let(:system_kickoff_tag) { BulkDataTestKit::BulkDataV200Client::Tags::SYSTEM_KICKOFF_TAG } + let(:status_tag) { BulkDataTestKit::BulkDataV200Client::Tags::STATUS_TAG } + let(:output_tag) { BulkDataTestKit::BulkDataV200Client::Tags::OUTPUT_TAG } + let(:delete_tag) { BulkDataTestKit::BulkDataV200Client::Tags::DELETE_TAG } let(:patient_fail) { 'Did not receive a Patient type kick-off request.' } let(:group_fail) { 'Did not receive a Group type kick-off request.' } From 5dc88662de1cbce25b9df87376c36f080ec7ba82 Mon Sep 17 00:00:00 2001 From: "aholmes@mitre.org" <14923551+holmesie@users.noreply.github.com> Date: Wed, 8 Jan 2025 12:55:59 -0600 Subject: [PATCH 17/20] Refactor consts --- .../bulk_data_client_delete_test.rb | 2 -- .../bulk_data_client_delete_wait_test.rb | 1 - .../bulk_data_client_export_wait_test.rb | 1 - .../bulk_data_client_kick_off_test.rb | 3 --- .../bulk_data_client_output_test.rb | 2 -- .../bulk_data_client_status_test.rb | 2 -- .../bulk_data_client_test_suite.rb | 3 --- .../v2.0.0_client/endpoints/delete.rb | 4 ---- .../v2.0.0_client/endpoints/kick_off.rb | 6 ------ .../v2.0.0_client/endpoints/output.rb | 4 ---- .../v2.0.0_client/endpoints/status.rb | 4 ---- .../v2.0.0_client/export_types.rb | 9 +++------ lib/bulk_data_test_kit/v2.0.0_client/tags.rb | 17 +++++++---------- lib/bulk_data_test_kit/v2.0.0_client/urls.rb | 18 +++++++++--------- .../v2.0.0_client/bulk_data_client_spec.rb | 12 ++++++------ 15 files changed, 25 insertions(+), 63 deletions(-) diff --git a/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_delete_test.rb b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_delete_test.rb index ca03c54..7ea0f40 100644 --- a/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_delete_test.rb +++ b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_delete_test.rb @@ -4,8 +4,6 @@ module BulkDataTestKit module BulkDataV200Client # Bulk Data Client - Delete class DeleteTest < Inferno::Test - include Tags - title 'Bulk Data Delete Request' description %( diff --git a/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_delete_wait_test.rb b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_delete_wait_test.rb index cf3fd18..97e3ce5 100644 --- a/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_delete_wait_test.rb +++ b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_delete_wait_test.rb @@ -5,7 +5,6 @@ module BulkDataV200Client # Bulk Data Client - Delete Wait class DeleteWaitTest < Inferno::Test include URLs - include ExportTypes title 'Wait For Request Sequence' diff --git a/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_export_wait_test.rb b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_export_wait_test.rb index 8a6c6c5..9ce3303 100644 --- a/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_export_wait_test.rb +++ b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_export_wait_test.rb @@ -5,7 +5,6 @@ module BulkDataV200Client # Bulk Data Client - Export Wait class ExportWaitTest < Inferno::Test include URLs - include ExportTypes title 'Wait For Request Sequence' diff --git a/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_kick_off_test.rb b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_kick_off_test.rb index 9085245..229f71e 100644 --- a/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_kick_off_test.rb +++ b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_kick_off_test.rb @@ -4,9 +4,6 @@ module BulkDataTestKit module BulkDataV200Client # Bulk Data Client Kick-off class KickOffTest < Inferno::Test - include Tags - include ExportTypes - title 'Bulk Data Kick-off Request' description %( diff --git a/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_output_test.rb b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_output_test.rb index c58c1fd..6ba383d 100644 --- a/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_output_test.rb +++ b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_output_test.rb @@ -4,8 +4,6 @@ module BulkDataTestKit module BulkDataV200Client # Bulk Data Client Output class OutputTest < Inferno::Test - include Tags - title 'Bulk Data Output File Request' description %( diff --git a/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_status_test.rb b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_status_test.rb index 35c5de0..2303707 100644 --- a/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_status_test.rb +++ b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_status_test.rb @@ -4,8 +4,6 @@ module BulkDataTestKit module BulkDataV200Client # Bulk Data Client Status class StatusTest < Inferno::Test - include Tags - title 'Bulk Data Status Request' description %( diff --git a/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_test_suite.rb b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_test_suite.rb index d1b9c8f..8cb242a 100644 --- a/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_test_suite.rb +++ b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_test_suite.rb @@ -17,9 +17,6 @@ module BulkDataTestKit module BulkDataV200Client # Bulk Data Access v2.0.0 Client Test Suite class BulkDataClientTestSuite < Inferno::TestSuite - include URLs - include ExportTypes - title 'Bulk Data Access v2.0.0 Client' description File.read(File.join(__dir__, 'docs', 'suite_description.md')) diff --git a/lib/bulk_data_test_kit/v2.0.0_client/endpoints/delete.rb b/lib/bulk_data_test_kit/v2.0.0_client/endpoints/delete.rb index 14da252..3740b09 100644 --- a/lib/bulk_data_test_kit/v2.0.0_client/endpoints/delete.rb +++ b/lib/bulk_data_test_kit/v2.0.0_client/endpoints/delete.rb @@ -1,14 +1,10 @@ # frozen_string_literal: true -require_relative '../tags' - module BulkDataTestKit module BulkDataV200Client module Endpoints # Delete Endpoint class Delete < Inferno::DSL::SuiteEndpoint - include Tags - def test_run_identifier export_id end diff --git a/lib/bulk_data_test_kit/v2.0.0_client/endpoints/kick_off.rb b/lib/bulk_data_test_kit/v2.0.0_client/endpoints/kick_off.rb index bf64c35..4b467fa 100644 --- a/lib/bulk_data_test_kit/v2.0.0_client/endpoints/kick_off.rb +++ b/lib/bulk_data_test_kit/v2.0.0_client/endpoints/kick_off.rb @@ -1,17 +1,11 @@ # frozen_string_literal: true -require_relative '../tags' -require_relative '../urls' -require_relative '../export_types' - module BulkDataTestKit module BulkDataV200Client module Endpoints # Kick Off Endpoint class KickOff < Inferno::DSL::SuiteEndpoint - include Tags include URLs - include ExportTypes def test_run_identifier export_id diff --git a/lib/bulk_data_test_kit/v2.0.0_client/endpoints/output.rb b/lib/bulk_data_test_kit/v2.0.0_client/endpoints/output.rb index 61cc50e..914ddc8 100644 --- a/lib/bulk_data_test_kit/v2.0.0_client/endpoints/output.rb +++ b/lib/bulk_data_test_kit/v2.0.0_client/endpoints/output.rb @@ -1,14 +1,10 @@ # frozen_string_literal: true -require_relative '../tags' - module BulkDataTestKit module BulkDataV200Client module Endpoints # Output Endpoint class Output < Inferno::DSL::SuiteEndpoint - include Tags - def test_run_identifier export_id end diff --git a/lib/bulk_data_test_kit/v2.0.0_client/endpoints/status.rb b/lib/bulk_data_test_kit/v2.0.0_client/endpoints/status.rb index 6366bc2..d04731c 100644 --- a/lib/bulk_data_test_kit/v2.0.0_client/endpoints/status.rb +++ b/lib/bulk_data_test_kit/v2.0.0_client/endpoints/status.rb @@ -1,14 +1,10 @@ # frozen_string_literal: true -require_relative '../tags' -require_relative '../urls' - module BulkDataTestKit module BulkDataV200Client module Endpoints # Status Endpoint class Status < Inferno::DSL::SuiteEndpoint - include Tags include URLs def test_run_identifier diff --git a/lib/bulk_data_test_kit/v2.0.0_client/export_types.rb b/lib/bulk_data_test_kit/v2.0.0_client/export_types.rb index 8eabb52..25f47bf 100644 --- a/lib/bulk_data_test_kit/v2.0.0_client/export_types.rb +++ b/lib/bulk_data_test_kit/v2.0.0_client/export_types.rb @@ -2,11 +2,8 @@ module BulkDataTestKit module BulkDataV200Client - # Export types for use in Bulk Data Client tests and endpoints - module ExportTypes - PATIENT_EXPORT_TYPE = 'Patient' - GROUP_EXPORT_TYPE = 'Group' - SYSTEM_EXPORT_TYPE = 'System' - end + PATIENT_EXPORT_TYPE = 'Patient' + GROUP_EXPORT_TYPE = 'Group' + SYSTEM_EXPORT_TYPE = 'System' end end diff --git a/lib/bulk_data_test_kit/v2.0.0_client/tags.rb b/lib/bulk_data_test_kit/v2.0.0_client/tags.rb index 050ac77..5990f22 100644 --- a/lib/bulk_data_test_kit/v2.0.0_client/tags.rb +++ b/lib/bulk_data_test_kit/v2.0.0_client/tags.rb @@ -2,15 +2,12 @@ module BulkDataTestKit module BulkDataV200Client - # Tags for use in Bulk Data Client tests and endpoints - module Tags - METADATA_TAG = 'bulk_data_metadata' - PATIENT_KICKOFF_TAG = 'bulk_data_kickoff_patient' - GROUP_KICKOFF_TAG = 'bulk_data_kickoff_group' - SYSTEM_KICKOFF_TAG = 'bulk_data_kickoff_system' - STATUS_TAG = 'bulk_data_status' - OUTPUT_TAG = 'bulk_data_output' - DELETE_TAG = 'bulk_data_delete' - end + METADATA_TAG = 'bulk_data_metadata' + PATIENT_KICKOFF_TAG = 'bulk_data_kickoff_patient' + GROUP_KICKOFF_TAG = 'bulk_data_kickoff_group' + SYSTEM_KICKOFF_TAG = 'bulk_data_kickoff_system' + STATUS_TAG = 'bulk_data_status' + OUTPUT_TAG = 'bulk_data_output' + DELETE_TAG = 'bulk_data_delete' end end diff --git a/lib/bulk_data_test_kit/v2.0.0_client/urls.rb b/lib/bulk_data_test_kit/v2.0.0_client/urls.rb index 70c2e9c..8ac7c5f 100644 --- a/lib/bulk_data_test_kit/v2.0.0_client/urls.rb +++ b/lib/bulk_data_test_kit/v2.0.0_client/urls.rb @@ -2,17 +2,17 @@ module BulkDataTestKit module BulkDataV200Client + RESUME_PASS_PATH = '/resume_pass' + BASE_ROUTE = '/:export_id/fhir' + METADATA_ROUTE = "#{BASE_ROUTE}/metadata".freeze + PATIENT_KICKOFF_ROUTE = "#{BASE_ROUTE}/:type/$export".freeze + GROUP_KICKOFF_ROUTE = "#{BASE_ROUTE}/:type/:group_id/$export".freeze + SYSTEM_KICKOFF_ROUTE = "#{BASE_ROUTE}/$export".freeze + STATUS_ROUTE = '/status/:export_id' + OUTPUT_ROUTE = '/output/:export_id.ndjson' + # URLs for use in Bulk Data Client tests and endpoints module URLs - RESUME_PASS_PATH = '/resume_pass' - BASE_ROUTE = '/:export_id/fhir' - METADATA_ROUTE = "#{BASE_ROUTE}/metadata".freeze - PATIENT_KICKOFF_ROUTE = "#{BASE_ROUTE}/:type/$export".freeze - GROUP_KICKOFF_ROUTE = "#{BASE_ROUTE}/:type/:group_id/$export".freeze - SYSTEM_KICKOFF_ROUTE = "#{BASE_ROUTE}/$export".freeze - STATUS_ROUTE = '/status/:export_id' - OUTPUT_ROUTE = '/output/:export_id.ndjson' - def base_url "#{Inferno::Application['base_url']}/custom/#{suite_id}" end diff --git a/spec/bulk_data_test_kit/v2.0.0_client/bulk_data_client_spec.rb b/spec/bulk_data_test_kit/v2.0.0_client/bulk_data_client_spec.rb index 284cd26..fad7f78 100644 --- a/spec/bulk_data_test_kit/v2.0.0_client/bulk_data_client_spec.rb +++ b/spec/bulk_data_test_kit/v2.0.0_client/bulk_data_client_spec.rb @@ -15,12 +15,12 @@ let(:output_test) { Inferno::Repositories::Tests.new.find('bulk_data_client_output') } let(:delete_test) { Inferno::Repositories::Tests.new.find('bulk_data_client_delete') } - let(:patient_kickoff_tag) { BulkDataTestKit::BulkDataV200Client::Tags::PATIENT_KICKOFF_TAG } - let(:group_kickoff_tag) { BulkDataTestKit::BulkDataV200Client::Tags::GROUP_KICKOFF_TAG } - let(:system_kickoff_tag) { BulkDataTestKit::BulkDataV200Client::Tags::SYSTEM_KICKOFF_TAG } - let(:status_tag) { BulkDataTestKit::BulkDataV200Client::Tags::STATUS_TAG } - let(:output_tag) { BulkDataTestKit::BulkDataV200Client::Tags::OUTPUT_TAG } - let(:delete_tag) { BulkDataTestKit::BulkDataV200Client::Tags::DELETE_TAG } + let(:patient_kickoff_tag) { BulkDataTestKit::BulkDataV200Client::PATIENT_KICKOFF_TAG } + let(:group_kickoff_tag) { BulkDataTestKit::BulkDataV200Client::GROUP_KICKOFF_TAG } + let(:system_kickoff_tag) { BulkDataTestKit::BulkDataV200Client::SYSTEM_KICKOFF_TAG } + let(:status_tag) { BulkDataTestKit::BulkDataV200Client::STATUS_TAG } + let(:output_tag) { BulkDataTestKit::BulkDataV200Client::OUTPUT_TAG } + let(:delete_tag) { BulkDataTestKit::BulkDataV200Client::DELETE_TAG } let(:patient_fail) { 'Did not receive a Patient type kick-off request.' } let(:group_fail) { 'Did not receive a Group type kick-off request.' } From f5adc33c137715cff3a56630bc2472f894f86d5e Mon Sep 17 00:00:00 2001 From: "aholmes@mitre.org" <14923551+holmesie@users.noreply.github.com> Date: Thu, 9 Jan 2025 12:54:07 -0600 Subject: [PATCH 18/20] Fix description postman collection links --- lib/bulk_data_test_kit/v2.0.0_client/docs/suite_description.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bulk_data_test_kit/v2.0.0_client/docs/suite_description.md b/lib/bulk_data_test_kit/v2.0.0_client/docs/suite_description.md index ce6cd7a..713efee 100644 --- a/lib/bulk_data_test_kit/v2.0.0_client/docs/suite_description.md +++ b/lib/bulk_data_test_kit/v2.0.0_client/docs/suite_description.md @@ -12,7 +12,7 @@ requirements and may change the test verification logic. ### Sample Execution - Postman To try out these tests without a Bulk Data client implementation, you may -run them using [this "bulk data client system export" Postman collection](https://github.com/inferno-framework/bulk-data-test-kit/blob/main/lib/bulk_data_test_kit/v2.0.0/client/postman/system_export.postman_collection.json) and [this "bulk data client delete" Postman collection](https://github.com/inferno-framework/bulk-data-test-kit/blob/main/lib/bulk_data_test_kit/v2.0.0/client/postman/delete.postman_collection.json). +run them using [this "bulk data client system export" Postman collection](https://github.com/inferno-framework/bulk-data-test-kit/blob/main/lib/bulk_data_test_kit/v2.0.0_client/postman/system_export.postman_collection.json) and [this "bulk data client delete" Postman collection](https://github.com/inferno-framework/bulk-data-test-kit/blob/main/lib/bulk_data_test_kit/v2.0.0_client/postman/delete.postman_collection.json). To run client tests against one of the Postman collections: 1. Start an Inferno session of the Bulk Data Client test suite. From aafd2fcd52cdb588a247a80d12b7420f3f388f04 Mon Sep 17 00:00:00 2001 From: "aholmes@mitre.org" <14923551+holmesie@users.noreply.github.com> Date: Mon, 13 Jan 2025 12:11:18 -0600 Subject: [PATCH 19/20] Refactor to use bearer token as test id --- .../bulk_data_client_delete_wait_test.rb | 20 ++++----- .../bulk_data_client_export_wait_test.rb | 20 ++++----- .../bulk_data_client_test_suite.rb | 4 ++ .../v2.0.0_client/docs/suite_description.md | 12 ++++- .../v2.0.0_client/endpoints/delete.rb | 6 +-- .../v2.0.0_client/endpoints/kick_off.rb | 8 +--- .../v2.0.0_client/endpoints/output.rb | 6 +-- .../v2.0.0_client/endpoints/status.rb | 12 ++--- .../postman/delete.postman_collection.json | 36 +++++++++++---- .../system_export.postman_collection.json | 45 +++++++++++++------ lib/bulk_data_test_kit/v2.0.0_client/urls.rb | 18 ++++---- 11 files changed, 106 insertions(+), 81 deletions(-) diff --git a/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_delete_wait_test.rb b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_delete_wait_test.rb index 97e3ce5..858ab6a 100644 --- a/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_delete_wait_test.rb +++ b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_delete_wait_test.rb @@ -14,23 +14,19 @@ class DeleteWaitTest < Inferno::Test id :bulk_data_client_delete_wait - input :export_type, :group_id - - output :export_id + input :access_token, :export_type, :group_id run do - export_id = SecureRandom.uuid - - output export_id: export_id - wait( - identifier: export_id, + identifier: access_token, message: %( - Kick-off a #{export_type} endpoint type bulk export using the following base URL: + Kick-off a **#{export_type}** endpoint type bulk export using the following base URL: + + #{kickoff_url} - #{kickoff_url(export_id)} + #{export_type == GROUP_EXPORT_TYPE ? "Ensure the Group ID is set to **#{group_id}**." : ''} - #{export_type == GROUP_EXPORT_TYPE ? "Ensure the Group ID is set to #{group_id}." : ''} + Include the following bearer access token with all requests: **#{access_token}** Once the export request has been kicked-off, [delete the export](https://build.fhir.org/ig/HL7/bulk-data/export.html#bulk-data-delete-request). @@ -39,7 +35,7 @@ class DeleteWaitTest < Inferno::Test verify comformity to the [Bulk Data IG](https://build.fhir.org/ig/HL7/bulk-data/export.html#sequence-overview). - [Click here](#{resume_pass_url}?id=#{export_id}) when finished. + [Click here](#{resume_pass_url}?id=#{access_token}) when finished. ) ) end diff --git a/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_export_wait_test.rb b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_export_wait_test.rb index 9ce3303..715eb6a 100644 --- a/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_export_wait_test.rb +++ b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_export_wait_test.rb @@ -14,23 +14,19 @@ class ExportWaitTest < Inferno::Test id :bulk_data_client_export_wait - input :export_type, :group_id - - output :export_id + input :access_token, :export_type, :group_id run do - export_id = SecureRandom.uuid - - output export_id: export_id - wait( - identifier: export_id, + identifier: access_token, message: %( - Perform a #{export_type} endpoint type bulk export kick-off using the following base URL: + Perform a **#{export_type}** endpoint type bulk export kick-off using the following base URL: + + #{kickoff_url} - #{kickoff_url(export_id)} + #{export_type == GROUP_EXPORT_TYPE ? "Ensure the Group ID is set to **#{group_id}**." : ''} - #{export_type == GROUP_EXPORT_TYPE ? "Ensure the Group ID is set to #{group_id}." : ''} + Include the following bearer access token with all requests: **#{access_token}** After the kick-off is made, a subsequent status request (using the URL provided in the response to the kick-off request) and then a download request (using the URL provided in the response to @@ -40,7 +36,7 @@ class ExportWaitTest < Inferno::Test verify comformity to the [Bulk Data IG](https://build.fhir.org/ig/HL7/bulk-data/export.html#sequence-overview). - [Click here](#{resume_pass_url}?id=#{export_id}) when finished. + [Click here](#{resume_pass_url}?id=#{access_token}) when finished. ) ) end diff --git a/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_test_suite.rb b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_test_suite.rb index 8cb242a..2959023 100644 --- a/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_test_suite.rb +++ b/lib/bulk_data_test_kit/v2.0.0_client/bulk_data_client_test_suite.rb @@ -44,6 +44,10 @@ class BulkDataClientTestSuite < Inferno::TestSuite } ] + input :access_token, + title: 'Access Token', + description: 'The access token that will be included in all client requests during testing.' + input :export_type, title: 'Export Type', description: 'The export endpoint type to test against.', diff --git a/lib/bulk_data_test_kit/v2.0.0_client/docs/suite_description.md b/lib/bulk_data_test_kit/v2.0.0_client/docs/suite_description.md index 713efee..219cc27 100644 --- a/lib/bulk_data_test_kit/v2.0.0_client/docs/suite_description.md +++ b/lib/bulk_data_test_kit/v2.0.0_client/docs/suite_description.md @@ -9,6 +9,14 @@ and [provide feedback](https://github.com/inferno-framework/bulk-data-test-kit/i on the tests. Future versions of these tests may verify other requirements and may change the test verification logic. +## Running the Tests + +### Quick Start + +Inferno needs to be able to identify when requests come from the client under test. Testers must provide a bearer access token that will be provided within the Authentication header (Bearer ) on all requests made to Inferno endpoints during the test. Inferno uses this information to associate the message with the test session and determine how to respond. How the token provided to Inferno is generated is up to the tester. + +Note: authentication options for these tests have not been finalized and are subject to change as the requirements evolve. If the implemented approach prevents you from using these tests, please provide feedback so the limitations can be addressed. + ### Sample Execution - Postman To try out these tests without a Bulk Data client implementation, you may @@ -17,9 +25,9 @@ run them using [this "bulk data client system export" Postman collection](https: To run client tests against one of the Postman collections: 1. Start an Inferno session of the Bulk Data Client test suite. 2. Navigate to either the export tests group or the delete tests group (depending on which Postman collection you want to use). -3. Click the "Run Tests" button in the upper right and select the "System Level Export" option for export type. +3. Click the "Run Tests" button in the upper right, enter any value (e.g. `test`) as the access token, and select the "System Level Export" option for export type. 4. Click the "Submit" button. The simulated server will then be waiting for an interaction. 5. Open Postman and import the relevant Postman collection. -6. Set the `kickoff-base-url` variable equal to the base URL provided by inferno. +6. Set the `access_token` variable equal to the value entered in step 3 (the value is also displayed on the test modal in the Inferno UI for reference). 7. Run the collection. 8. Once the postman collection has run, click the "Click here" link in the wait dialog to evaluate the requests. diff --git a/lib/bulk_data_test_kit/v2.0.0_client/endpoints/delete.rb b/lib/bulk_data_test_kit/v2.0.0_client/endpoints/delete.rb index 3740b09..1bb84b9 100644 --- a/lib/bulk_data_test_kit/v2.0.0_client/endpoints/delete.rb +++ b/lib/bulk_data_test_kit/v2.0.0_client/endpoints/delete.rb @@ -6,7 +6,7 @@ module Endpoints # Delete Endpoint class Delete < Inferno::DSL::SuiteEndpoint def test_run_identifier - export_id + request.get_header('HTTP_AUTHORIZATION')&.split&.last end def make_response @@ -16,10 +16,6 @@ def make_response def tags [DELETE_TAG] end - - def export_id - request.params[:export_id] - end end end end diff --git a/lib/bulk_data_test_kit/v2.0.0_client/endpoints/kick_off.rb b/lib/bulk_data_test_kit/v2.0.0_client/endpoints/kick_off.rb index 4b467fa..815327d 100644 --- a/lib/bulk_data_test_kit/v2.0.0_client/endpoints/kick_off.rb +++ b/lib/bulk_data_test_kit/v2.0.0_client/endpoints/kick_off.rb @@ -8,12 +8,12 @@ class KickOff < Inferno::DSL::SuiteEndpoint include URLs def test_run_identifier - export_id + request.get_header('HTTP_AUTHORIZATION')&.split&.last end def make_response response.status = 202 - response.headers['Content-Location'] = status_url(export_id) + response.headers['Content-Location'] = status_url end def tags @@ -27,10 +27,6 @@ def tags end end - def export_id - request.params[:export_id] - end - def request_type request.params[:type] || SYSTEM_EXPORT_TYPE end diff --git a/lib/bulk_data_test_kit/v2.0.0_client/endpoints/output.rb b/lib/bulk_data_test_kit/v2.0.0_client/endpoints/output.rb index 914ddc8..fa66e56 100644 --- a/lib/bulk_data_test_kit/v2.0.0_client/endpoints/output.rb +++ b/lib/bulk_data_test_kit/v2.0.0_client/endpoints/output.rb @@ -6,7 +6,7 @@ module Endpoints # Output Endpoint class Output < Inferno::DSL::SuiteEndpoint def test_run_identifier - export_id + request.get_header('HTTP_AUTHORIZATION')&.split&.last end def make_response @@ -19,10 +19,6 @@ def tags [OUTPUT_TAG] end - def export_id - request.params[:export_id] - end - def example_patient FHIR::Patient.new( id: test_run_identifier, diff --git a/lib/bulk_data_test_kit/v2.0.0_client/endpoints/status.rb b/lib/bulk_data_test_kit/v2.0.0_client/endpoints/status.rb index d04731c..138f98f 100644 --- a/lib/bulk_data_test_kit/v2.0.0_client/endpoints/status.rb +++ b/lib/bulk_data_test_kit/v2.0.0_client/endpoints/status.rb @@ -8,7 +8,7 @@ class Status < Inferno::DSL::SuiteEndpoint include URLs def test_run_identifier - export_id + request.get_header('HTTP_AUTHORIZATION')&.split&.last end def make_response @@ -21,18 +21,14 @@ def tags [STATUS_TAG] end - def export_id - request.params[:export_id] - end - def response_body { transactionTime: DateTime.now.iso8601, - request: kickoff_url(export_id), - requiresAccessToken: false, + request: kickoff_url, + requiresAccessToken: true, output: [{ type: 'Patient', - url: output_url(export_id) + url: output_url }], error: [] } diff --git a/lib/bulk_data_test_kit/v2.0.0_client/postman/delete.postman_collection.json b/lib/bulk_data_test_kit/v2.0.0_client/postman/delete.postman_collection.json index 31bbd00..e19383b 100644 --- a/lib/bulk_data_test_kit/v2.0.0_client/postman/delete.postman_collection.json +++ b/lib/bulk_data_test_kit/v2.0.0_client/postman/delete.postman_collection.json @@ -1,6 +1,6 @@ { "info": { - "name": "Bulk Data Client - System Export Delete", + "name": "Bulk Data Client - Delete", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, "item": [ @@ -15,7 +15,7 @@ " pm.response.to.have.status(202);", "});", "", - "pm.collectionVariables.set(\"status-url\", pm.response.headers.get('Content-Location'));", + "pm.collectionVariables.set(\"status_url\", pm.response.headers.get('Content-Location'));", "" ], "type": "text/javascript", @@ -27,11 +27,14 @@ "method": "GET", "header": [], "url": { - "raw": "{{kickoff-base-url}}/$export", + "raw": "{{base_url}}/custom/bulk_data_v200_client/fhir/$export", "host": [ - "{{kickoff-base-url}}" + "{{base_url}}" ], "path": [ + "custom", + "bulk_data_v200_client", + "fhir", "$export" ] } @@ -69,15 +72,25 @@ "method": "DELETE", "header": [], "url": { - "raw": "{{status-url}}", + "raw": "{{status_url}}", "host": [ - "{{status-url}}" + "{{status_url}}" ] } }, "response": [] } ], + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{access_token}}", + "type": "string" + } + ] + }, "event": [ { "listen": "prerequest", @@ -102,12 +115,17 @@ ], "variable": [ { - "key": "kickoff-base-url", - "value": "", + "key": "access_token", + "value": "test", + "type": "string" + }, + { + "key": "base_url", + "value": "http://localhost:4567", "type": "string" }, { - "key": "status-url", + "key": "status_url", "value": "", "type": "string" } diff --git a/lib/bulk_data_test_kit/v2.0.0_client/postman/system_export.postman_collection.json b/lib/bulk_data_test_kit/v2.0.0_client/postman/system_export.postman_collection.json index ddd60d6..ff1bf12 100644 --- a/lib/bulk_data_test_kit/v2.0.0_client/postman/system_export.postman_collection.json +++ b/lib/bulk_data_test_kit/v2.0.0_client/postman/system_export.postman_collection.json @@ -15,7 +15,7 @@ " pm.response.to.have.status(202);", "});", "", - "pm.collectionVariables.set(\"status-url\", pm.response.headers.get('Content-Location'));", + "pm.collectionVariables.set(\"status_url\", pm.response.headers.get('Content-Location'));", "" ], "type": "text/javascript", @@ -27,11 +27,14 @@ "method": "GET", "header": [], "url": { - "raw": "{{kickoff-base-url}}/$export", + "raw": "{{base_url}}/custom/bulk_data_v200_client/fhir/$export", "host": [ - "{{kickoff-base-url}}" + "{{base_url}}" ], "path": [ + "custom", + "bulk_data_v200_client", + "fhir", "$export" ] } @@ -51,7 +54,7 @@ " pm.response.to.have.status(200);", "});", "", - "pm.collectionVariables.set(\"download-url\", responseData.output[0].url);", + "pm.collectionVariables.set(\"download_url\", responseData.output[0].url);", "" ], "type": "text/javascript", @@ -73,9 +76,9 @@ "method": "GET", "header": [], "url": { - "raw": "{{status-url}}", + "raw": "{{status_url}}", "host": [ - "{{status-url}}" + "{{status_url}}" ] } }, @@ -112,15 +115,25 @@ "method": "GET", "header": [], "url": { - "raw": "{{download-url}}", + "raw": "{{download_url}}", "host": [ - "{{download-url}}" + "{{download_url}}" ] } }, "response": [] } ], + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{access_token}}", + "type": "string" + } + ] + }, "event": [ { "listen": "prerequest", @@ -145,18 +158,24 @@ ], "variable": [ { - "key": "kickoff-base-url", - "value": "", + "key": "access_token", + "value": "test", + "type": "string" + }, + { + "key": "base_url", + "value": "http://localhost:4567", "type": "string" }, { - "key": "status-url", + "key": "status_url", "value": "", "type": "string" }, { - "key": "download-url", - "value": "" + "key": "download_url", + "value": "", + "type": "string" } ] } \ No newline at end of file diff --git a/lib/bulk_data_test_kit/v2.0.0_client/urls.rb b/lib/bulk_data_test_kit/v2.0.0_client/urls.rb index 8ac7c5f..e3fd11a 100644 --- a/lib/bulk_data_test_kit/v2.0.0_client/urls.rb +++ b/lib/bulk_data_test_kit/v2.0.0_client/urls.rb @@ -3,13 +3,13 @@ module BulkDataTestKit module BulkDataV200Client RESUME_PASS_PATH = '/resume_pass' - BASE_ROUTE = '/:export_id/fhir' + BASE_ROUTE = '/fhir' METADATA_ROUTE = "#{BASE_ROUTE}/metadata".freeze PATIENT_KICKOFF_ROUTE = "#{BASE_ROUTE}/:type/$export".freeze GROUP_KICKOFF_ROUTE = "#{BASE_ROUTE}/:type/:group_id/$export".freeze SYSTEM_KICKOFF_ROUTE = "#{BASE_ROUTE}/$export".freeze - STATUS_ROUTE = '/status/:export_id' - OUTPUT_ROUTE = '/output/:export_id.ndjson' + STATUS_ROUTE = '/status' + OUTPUT_ROUTE = '/output/example.ndjson' # URLs for use in Bulk Data Client tests and endpoints module URLs @@ -21,16 +21,16 @@ def resume_pass_url base_url + RESUME_PASS_PATH end - def kickoff_url(export_id) - base_url + BASE_ROUTE.gsub(':export_id', export_id) + def kickoff_url + base_url + BASE_ROUTE end - def status_url(export_id) - base_url + STATUS_ROUTE.gsub(':export_id', export_id) + def status_url + base_url + STATUS_ROUTE end - def output_url(export_id) - base_url + OUTPUT_ROUTE.gsub(':export_id', export_id) + def output_url + base_url + OUTPUT_ROUTE end def suite_id From 97b971f176b04b003e1479919b3ed7c11dc4892d Mon Sep 17 00:00:00 2001 From: "aholmes@mitre.org" <14923551+holmesie@users.noreply.github.com> Date: Tue, 21 Jan 2025 10:56:01 -0600 Subject: [PATCH 20/20] Replace test with SAMPLE_TOKEN in postman + docs --- lib/bulk_data_test_kit/v2.0.0_client/docs/suite_description.md | 2 +- .../v2.0.0_client/postman/delete.postman_collection.json | 2 +- .../v2.0.0_client/postman/system_export.postman_collection.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/bulk_data_test_kit/v2.0.0_client/docs/suite_description.md b/lib/bulk_data_test_kit/v2.0.0_client/docs/suite_description.md index 219cc27..fd4bcbf 100644 --- a/lib/bulk_data_test_kit/v2.0.0_client/docs/suite_description.md +++ b/lib/bulk_data_test_kit/v2.0.0_client/docs/suite_description.md @@ -25,7 +25,7 @@ run them using [this "bulk data client system export" Postman collection](https: To run client tests against one of the Postman collections: 1. Start an Inferno session of the Bulk Data Client test suite. 2. Navigate to either the export tests group or the delete tests group (depending on which Postman collection you want to use). -3. Click the "Run Tests" button in the upper right, enter any value (e.g. `test`) as the access token, and select the "System Level Export" option for export type. +3. Click the "Run Tests" button in the upper right, enter any value (e.g. `SAMPLE_TOKEN`) as the access token, and select the "System Level Export" option for export type. 4. Click the "Submit" button. The simulated server will then be waiting for an interaction. 5. Open Postman and import the relevant Postman collection. 6. Set the `access_token` variable equal to the value entered in step 3 (the value is also displayed on the test modal in the Inferno UI for reference). diff --git a/lib/bulk_data_test_kit/v2.0.0_client/postman/delete.postman_collection.json b/lib/bulk_data_test_kit/v2.0.0_client/postman/delete.postman_collection.json index e19383b..7f93131 100644 --- a/lib/bulk_data_test_kit/v2.0.0_client/postman/delete.postman_collection.json +++ b/lib/bulk_data_test_kit/v2.0.0_client/postman/delete.postman_collection.json @@ -116,7 +116,7 @@ "variable": [ { "key": "access_token", - "value": "test", + "value": "SAMPLE_TOKEN", "type": "string" }, { diff --git a/lib/bulk_data_test_kit/v2.0.0_client/postman/system_export.postman_collection.json b/lib/bulk_data_test_kit/v2.0.0_client/postman/system_export.postman_collection.json index ff1bf12..19591d7 100644 --- a/lib/bulk_data_test_kit/v2.0.0_client/postman/system_export.postman_collection.json +++ b/lib/bulk_data_test_kit/v2.0.0_client/postman/system_export.postman_collection.json @@ -159,7 +159,7 @@ "variable": [ { "key": "access_token", - "value": "test", + "value": "SAMPLE_TOKEN", "type": "string" }, {