Skip to content

1. Accepting User Bearer Token Input

Elsa Perelli edited this page Oct 23, 2024 · 19 revisions

Goal

The inferno-template test kit includes the ability for users to input values for service base url, credentials, access_token and Refresh Token and patient_id:

image-1

We want to add the ability for the end-user to input an access_token which is used later as a bearer_token.

Solution

In order to add the ability for an end-user to input an access_token, we can include the following code in the inferno_template.rb file:

# This input will be available to all tests in the suite
input :url
input :access_token

The code input :access_token adds a user input for "access_token" to the test input modal.

Now that we have the ability to collect the access_token from the end-user, we want to use the access_token for authentication. We can do this by associating bearer_token with :access_token by following the code below:

# All FHIR requests in the suite will use this FHIR client
fhir_client do
  url :url
  bearer_token :access_token
end

diff between step-1 and step-1-solution branches: https://github.com/inferno-training/inferno-tutorial/compare/step-1...step-1-solution

Resources

Documentation

Reference servers to test against

Since we are writing tests for servers, it is helpful to have reference servers to develop tests against. Some commonly used reference servers, loaded with data, include:

Additional public test servers are listed on the HL7 Confluence Public Test Servers Page