Class: CarinForBlueButtonTestKit::MockUdapSmartServer::TokenEndpoint

Inherits:
Inferno::DSL::SuiteEndpoint
  • Object
show all
Includes:
URLs, SMARTAppLaunch::MockSMARTServer::SMARTTokenResponseCreation, UDAPSecurityTestKit::MockUDAPServer::UDAPTokenResponseCreation
Defined in:
lib/carin_for_blue_button_test_kit/client/v2.0.0/endpoints/token_endpoint.rb

Instance Method Summary collapse

Methods included from URLs

#authorization_url, #base_url, #client_fhir_base_url, #fhir_base_url, #jwks_url, #metadata_url, #patient_url, #resource_api_url, #resource_id_url, #resume_claims_data_url, #resume_fail_url, #resume_pass_url, #smart_configuration_url, #suite_id, #token_url

Instance Method Details

#make_responseObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/carin_for_blue_button_test_kit/client/v2.0.0/endpoints/token_endpoint.rb', line 28

def make_response
  if request.params[:udap].present?
    case request.params[:grant_type]
    when UDAPSecurityTestKit::AUTHORIZATION_CODE_TAG
      make_udap_authorization_code_token_response
    when UDAPSecurityTestKit::REFRESH_TOKEN_TAG
      make_udap_refresh_token_response
    else
      UDAPSecurityTestKit::MockUDAPServer.update_response_for_invalid_assertion(
        response,
        "unsupported grant_type: #{request.params[:grant_type]}"
      )
    end
  else
    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 =
      SMARTAppLaunch::SMARTClientOptions.smart_authentication_approach(suite_options_hash)
    
    case request.params[:grant_type]
    when SMARTAppLaunch::AUTHORIZATION_CODE_TAG
      make_smart_authorization_code_token_response(smart_authentication_approach)
    when SMARTAppLaunch::REFRESH_TOKEN_TAG
      make_smart_refresh_token_response(smart_authentication_approach)
    else
      SMARTAppLaunch::MockSMARTServer.update_response_for_invalid_assertion(
        response,
        "unsupported grant_type: #{request.params[:grant_type]}"
      )
    end
  end
end

#tagsObject



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/carin_for_blue_button_test_kit/client/v2.0.0/endpoints/token_endpoint.rb', line 65

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

  tags
end

#test_run_identifierObject



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/carin_for_blue_button_test_kit/client/v2.0.0/endpoints/token_endpoint.rb', line 15

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

#update_resultObject



61
62
63
# File 'lib/carin_for_blue_button_test_kit/client/v2.0.0/endpoints/token_endpoint.rb', line 61

def update_result
  nil # never update for now
end