Class: DaVinciPDexTestKit::PDexPayerClient::MockServer::ProxyEndpoint Abstract

Inherits:
Inferno::DSL::SuiteEndpoint
  • Object
show all
Includes:
URLs
Defined in:
lib/davinci_pdex_test_kit/pdex_payer_client/mock_server/proxy_endpoint.rb

Overview

This class is abstract.

This class defines

  • a Faraday connection for proxying requests to ENV

  • common methods and conventions for PDex Client Testing endpoints

Constant Summary

Constants included from URLs

URLs::AUTHORIZATION_PATH, URLs::BASE_FHIR_PATH, URLs::BINARY_PATH, URLs::EVERYTHING_PATH, URLs::EXPORT_PATH, URLs::EXPORT_STATUS_PATH, URLs::INSTANCE_PATH, URLs::MEMBER_MATCH_PATH, URLs::METADATA_PATH, URLs::PATIENT_INSTANCE_PATH, URLs::PATIENT_PATH, URLs::RESOURCE_PATH, URLs::RESUME_CLINICAL_DATA_PATH, URLs::RESUME_FAIL_PATH, URLs::RESUME_PASS_PATH, URLs::TOKEN_PATH

Instance Method Summary collapse

Methods included from URLs

#base_url, #client_fhir_base_url, #fhir_base_url, #suite_id

Instance Method Details

#make_responseObject



26
27
28
29
# File 'lib/davinci_pdex_test_kit/pdex_payer_client/mock_server/proxy_endpoint.rb', line 26

def make_response
  server_response = proxy_request(request)
  proxy_response(server_response)
end

#server_proxyFaraday

REST Client that proxies request to server at ‘ENV`

Examples:

server_response = server_proxy.get('Patient/1')
server_response.body # => FHIR JSON String

Returns:

  • (Faraday)
    • A Faraday 1.x REST Client



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/davinci_pdex_test_kit/pdex_payer_client/mock_server/proxy_endpoint.rb', line 40

def server_proxy
  @server_proxy ||= Faraday.new(
      url: fhir_reference_server,
      params: {},
      headers: {
        'Accept' => 'application/fhir+json,application/json',
        'Accept-Encoding' => 'identity',
        'Authorization' => 'Bearer SAMPLE_TOKEN',
        'Host' => ENV.fetch('HOST_HEADER')
      }
    ) do |proxy|
      proxy.use Faraday::Response::Logger
    end
end

#test_run_identifierObject



18
19
20
21
22
23
24
# File 'lib/davinci_pdex_test_kit/pdex_payer_client/mock_server/proxy_endpoint.rb', line 18

def test_run_identifier
  return request.params[:session_path] if request.params[:session_path].present?

  SMARTAppLaunch::MockSMARTServer.issued_token_to_client_id(
    request.headers['authorization']&.delete_prefix('Bearer ')
  )
end

#update_resultObject



31
32
33
# File 'lib/davinci_pdex_test_kit/pdex_payer_client/mock_server/proxy_endpoint.rb', line 31

def update_result
  results_repo.update(result.id, result: 'pass') unless test.config.options[:accepts_multiple_requests]
end