-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add route and controller for LH API Vet Title 38 Verification (#19276)
- Loading branch information
1 parent
2d0f1e8
commit 6a6d926
Showing
8 changed files
with
235 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
app/controllers/v0/profile/vet_verification_statuses_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
spec/controllers/v0/profile/vet_verification_statuses_controller_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
59 changes: 59 additions & 0 deletions
59
...rt/vcr_cassettes/lighthouse/veteran_verification/status/200_person_not_found_response.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
spec/support/vcr_cassettes/lighthouse/veteran_verification/status/200_show_response.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.