Class: SMARTAppLaunch::MockSMARTServer::TokenEndpoint

Inherits:
Inferno::DSL::SuiteEndpoint
  • Object
show all
Includes:
SMARTTokenResponseCreation, URLs
Defined in:
lib/smart_app_launch/endpoints/mock_smart_server/token_endpoint.rb

Instance Method Summary collapse

Methods included from SMARTTokenResponseCreation

#authenticated?, #confidential_asymmetric_authenticated?, #confidential_symmetric_authenticated?, #make_smart_authorization_code_token_response, #make_smart_client_credential_token_response, #make_smart_refresh_token_response, #smart_construct_id_token, #smart_pkce_valid?, #smart_requested_scope_context

Methods included from URLs

#client_authorization_url, #client_base_url, #client_fhir_base_url, #client_introspection_url, #client_resume_fail_url, #client_resume_pass_url, #client_smart_discovery_url, #client_suite_id, #client_token_url

Instance Method Details

#make_responseObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/smart_app_launch/endpoints/mock_smart_server/token_endpoint.rb', line 25

def make_response
  return make_smart_client_credential_token_response if request.params[:grant_type] == CLIENT_CREDENTIALS_TAG
  
  suite_options_list = Inferno::Repositories::TestSessions.new.find(result.test_session_id)&.suite_options
  suite_options_hash = suite_options_list&.map { |option| [option.id, option.value] }&.to_h
  smart_authentication_approach = SMARTClientOptions.smart_authentication_approach(suite_options_hash)
  
  case request.params[:grant_type]
  when AUTHORIZATION_CODE_TAG
    make_smart_authorization_code_token_response(smart_authentication_approach)
  when REFRESH_TOKEN_TAG
    make_smart_refresh_token_response(smart_authentication_approach)
  else
    MockSMARTServer.update_response_for_error(
      response,
      "unsupported grant_type: #{request.params[:grant_type]}"
    )
  end
end

#tagsObject



49
50
51
52
53
54
55
# File 'lib/smart_app_launch/endpoints/mock_smart_server/token_endpoint.rb', line 49

def tags
  tags = [TOKEN_TAG, SMART_TAG]
  if [CLIENT_CREDENTIALS_TAG, AUTHORIZATION_CODE_TAG, REFRESH_TOKEN_TAG].include?(request.params[:grant_type])
    tags << request.params[:grant_type]
  end
  tags
end

#test_run_identifierObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/smart_app_launch/endpoints/mock_smart_server/token_endpoint.rb', line 12

def test_run_identifier
  case request.params[:grant_type]
  when CLIENT_CREDENTIALS_TAG
    MockSMARTServer.client_id_from_client_assertion(request.params[:client_assertion])
  when AUTHORIZATION_CODE_TAG
    MockSMARTServer.issued_token_to_client_id(request.params[:code])
  when REFRESH_TOKEN_TAG
    MockSMARTServer.issued_token_to_client_id(
      MockSMARTServer.refresh_token_to_authorization_code(request.params[:refresh_token])
    )
  end
end

#update_resultObject



45
46
47
# File 'lib/smart_app_launch/endpoints/mock_smart_server/token_endpoint.rb', line 45

def update_result
  nil # never update for now
end