Skip to content

Commit

Permalink
Add route and controller for LH API Vet Title 38 Verification (#19276)
Browse files Browse the repository at this point in the history
  • Loading branch information
khenson-oddball authored Nov 12, 2024
1 parent 2d0f1e8 commit 6a6d926
Show file tree
Hide file tree
Showing 8 changed files with 235 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ app/controllers/v0/prescription_preferences_controller.rb @department-of-veteran
app/controllers/v0/prescriptions_controller.rb @department-of-veterans-affairs/vfs-mhv-medications @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/controllers/v0/profile @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/controllers/v0/profile/contacts_controller.rb @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/vfs-mhv-integration @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/controllers/v0/profile/vet_verification_statuses_controller.rb @department-of-veterans-affairs/va-iir @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/controllers/v0/rated_disabilities_controller.rb @department-of-veterans-affairs/benefits-management-tools-be @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/controllers/v0/rated_disabilities_discrepancies_controller.rb @department-of-veterans-affairs/benefits-management-tools-be @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/controllers/v0/search_click_tracking_controller.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
Expand Down
28 changes: 28 additions & 0 deletions app/controllers/v0/profile/vet_verification_statuses_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# frozen_string_literal: true

module V0
module Profile
class VetVerificationStatusesController < ApplicationController
service_tag 'profile'
before_action { authorize :lighthouse, :access? }

def show
access_token = settings.access_token
response = service.get_vet_verification_status(@current_user.icn, access_token.client_id, access_token.rsa_key)
response['data']['id'] = ''

render json: response
end

private

def service
@service ||= VeteranVerification::Service.new
end

def settings
Settings.lighthouse.veteran_verification['status']
end
end
end
end
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@

# Lighthouse
resource :direct_deposits, only: %i[show update]
resource :vet_verification_status, only: :show

# Vet360 Routes
resource :addresses, only: %i[create update destroy] do
Expand Down
6 changes: 6 additions & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,12 @@ lighthouse:
aud_claim_url: https://deptva-eval.okta.com/oauth2/ausi3u00gw66b9Ojk2p7/v1/token
use_mocks: false
form526:
host: https://staging-api.va.gov
access_token:
client_id: ~
rsa_key: ~
use_mocks: true
status:
host: https://staging-api.va.gov
access_token:
client_id: ~
Expand Down
3 changes: 3 additions & 0 deletions lib/lighthouse/veteran_verification/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ def get_rated_disabilities(icn, lighthouse_client_id = nil, lighthouse_rsa_key_p
handle_error(e, lighthouse_client_id, endpoint)
end

##
# Request a veteran's Title 38 status
# see https://developer.va.gov/explore/api/veteran-service-history-and-eligibility/docs
def get_vet_verification_status(icn, lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, options = {})
endpoint = 'status'
config.get(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe V0::Profile::VetVerificationStatusesController, type: :controller do
let(:user) { create(:user, :loa3, icn: '1012667145V762142') }

before do
sign_in_as(user)
allow_any_instance_of(VeteranVerification::Configuration).to receive(:access_token).and_return('blahblech')
end

describe '#show' do
context 'when successful' do
it 'returns a status of 200' do
VCR.use_cassette('lighthouse/veteran_verification/status/200_show_response') do
get(:show)
end

expect(response).to have_http_status(:ok)
end

it 'returns veteran confirmation status' do
VCR.use_cassette('lighthouse/veteran_verification/status/200_show_response') do
get(:show)
end

parsed_body = JSON.parse(response.body)
expect(parsed_body['data']['attributes']['veteran_status']).to eq('confirmed')
end

it 'removes the Veterans ICN from the response before sending' do
VCR.use_cassette('lighthouse/veteran_verification/status/200_show_response') do
get(:show)
end

parsed_body = JSON.parse(response.body)
expect(parsed_body['data']['id']).to eq('')
end
end

context 'when not authorized' do
it 'returns a status of 401' do
VCR.use_cassette('lighthouse/veteran_verification/status/401_response') do
get(:show)
end

expect(response).to have_http_status(:unauthorized)
end
end

context 'when ICN not found' do
let(:user) { create(:user, :loa3, icn: '1012667145V762141') }

before do
sign_in_as(user)
allow_any_instance_of(VeteranVerification::Configuration).to receive(:access_token).and_return('blahblech')
end

it 'returns a status of 200' do
VCR.use_cassette('lighthouse/veteran_verification/status/200_person_not_found_response') do
get(:show)
end

expect(response).to have_http_status(:ok)
end

it 'returns a person_not_found reason' do
VCR.use_cassette('lighthouse/veteran_verification/status/200_person_not_found_response') do
get(:show)
end

parsed_body = JSON.parse(response.body)
expect(parsed_body['data']['attributes']['veteran_status']).to eq('not confirmed')
expect(parsed_body['data']['attributes']['not_confirmed_reason']).to eq('PERSON_NOT_FOUND')
end
end
end
end

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6a6d926

Please sign in to comment.