Skip to content

Commit

Permalink
Merge branch 'master' into API-41368-remove-bgs-ext-okcomputer
Browse files Browse the repository at this point in the history
  • Loading branch information
mchristiansonVA authored Dec 2, 2024
2 parents 440f577 + ce5a96b commit 21556ad
Show file tree
Hide file tree
Showing 12 changed files with 1,069 additions and 321 deletions.
10 changes: 8 additions & 2 deletions app/controllers/v1/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -408,11 +408,17 @@ def set_cookies
end

def after_login_actions
client_id = url_service.tracker.payload_attr(:application)
Login::AfterLoginActions.new(@current_user, client_id).perform
Login::AfterLoginActions.new(@current_user, skip_mhv_account_creation).perform
log_persisted_session_and_warnings
end

def skip_mhv_account_creation
skip_mhv_account_creation_client = url_service.tracker.payload_attr(:application) == SAML::User::MHV_ORIGINAL_CSID
skip_mhv_account_creation_type = url_service.tracker.payload_attr(:type) == 'custom'

skip_mhv_account_creation_client || skip_mhv_account_creation_type
end

def log_persisted_session_and_warnings
obscure_token = Session.obscure_token(@session_object.token)
Rails.logger.info("Logged in user with id #{@session_object&.uuid}, token #{obscure_token}")
Expand Down
8 changes: 4 additions & 4 deletions app/services/login/after_login_actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ module Login
class AfterLoginActions
include Accountable

attr_reader :current_user, :client_id
attr_reader :current_user, :skip_mhv_account_creation

def initialize(user, client_id)
def initialize(user, skip_mhv_account_creation)
@current_user = user
@client_id = client_id
@skip_mhv_account_creation = skip_mhv_account_creation
end

def perform
Expand All @@ -32,7 +32,7 @@ def perform
private

def create_mhv_account
return if client_id.in?(SAML::URLService::SKIP_MHV_ACCOUNT_CREATION_CLIENTS)
return if skip_mhv_account_creation

current_user.create_mhv_account_async
end
Expand Down
4 changes: 4 additions & 0 deletions config/features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ features:
actor_type: user
description: Uses person web service rather than local bgs
enable_in_development: true
claims_api_use_vet_record_service:
actor_type: user
description: Uses local_bgs rather than bgs-ext
enable_in_development: true
claims_api_526_v2_uploads_bd_refactor:
actor_type: user
description: When enabled, sends 526 forms to BD via the refactored logic
Expand Down
3 changes: 3 additions & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1365,8 +1365,11 @@ vanotify:
form_10_7959f_1_email: form_10_7959f_1_email
form_10_7959f_1_failure_email: form_10_7959f_1_failure_email
form_10_7959f_2_email: form_10_7959f_2_email
form_10_7959f_2_failure_email: form_10_7959f_2_failure_email
form_10_7959c_email: form_10_7959c_email
form_10_7959c_failure_email: form_10_7959c_failure_email
form_10_7959a_email: form_10_7959a_email
form_10_7959a_failure_email: form_10_7959a_failure_email
health_apps_1010:
api_key: fake_secret
template_id:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,27 @@ module CreateVeteranRepresentative
end

##
# VetRecordService
##
module VetRecordServiceBean
DEFINITION =
Bean.new(
path: 'VetRecordServiceBean',
namespaces: Namespaces.new(
target: 'http://services.share.benefits.vba.va.gov/',
data: nil
)
)
end

module VetRecordWebService
DEFINITION =
Service.new(
bean: VetRecordServiceBean::DEFINITION,
path: 'VetRecordWebService'
)
end

# VnpAtchmsWebServiceBean
#
module VnpAtchmsWebServiceBean
Expand Down
62 changes: 51 additions & 11 deletions modules/claims_api/app/sidekiq/claims_api/poa_updater.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
# frozen_string_literal: true

require 'bgs'
require 'bgs_service/person_web_service'
require 'bgs_service/vet_record_web_service'

module ClaimsApi
class PoaUpdater < ClaimsApi::ServiceBase
def perform(power_of_attorney_id, rep = nil) # rubocop:disable Metrics/MethodLength
def perform(power_of_attorney_id, rep = nil)
poa_form = ClaimsApi::PowerOfAttorney.find(power_of_attorney_id)
service = BGS::Services.new(
external_uid: poa_form.external_uid,
external_key: poa_form.external_key
)

ssn = poa_form.auth_headers['va_eauth_pnid']
file_number = service.people.find_by_ssn(ssn)[:file_nbr] # rubocop:disable Rails/DynamicFindBy

file_number = find_by_ssn(ssn, poa_form)
poa_code = extract_poa_code(poa_form.form_data)

response = service.vet_record.update_birls_record(
file_number:,
ssn:,
poa_code:
)
response = update_birls_record(file_number, ssn, poa_code, poa_form)

if response[:return_code] == 'BMOD0001'
poa_form.status = ClaimsApi::PowerOfAttorney::UPDATED
Expand Down Expand Up @@ -49,5 +44,50 @@ def vanotify?(auth_headers, rep)
false
end
end

def bgs_ext_service(poa_form)
BGS::Services.new(
external_uid: poa_form.external_uid,
external_key: poa_form.external_key
)
end

def person_web_service(poa_form)
ClaimsApi::PersonWebService.new(
external_uid: poa_form.external_uid,
external_key: poa_form.external_key
)
end

def vet_record_service(poa_form)
ClaimsApi::VetRecordWebService.new(
external_uid: poa_form.external_uid,
external_key: poa_form.external_key
)
end

def find_by_ssn(ssn, poa_form)
if Flipper.enabled? :claims_api_use_person_web_service
person_web_service(poa_form).find_by_ssn(ssn)[:file_nbr] # rubocop:disable Rails/DynamicFindBy
else
bgs_ext_service(poa_form).people.find_by_ssn(ssn)[:file_nbr] # rubocop:disable Rails/DynamicFindBy
end
end

def update_birls_record(file_number, ssn, poa_code, poa_form)
if Flipper.enabled? :claims_api_use_vet_record_service
vet_record_service(poa_form).update_birls_record(
file_number:,
ssn:,
poa_code:
)
else
bgs_ext_service(poa_form).vet_record.update_birls_record(
file_number:,
ssn:,
poa_code:
)
end
end
end
end
9 changes: 0 additions & 9 deletions modules/claims_api/lib/bgs_service/person_web_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,4 @@ def find_by_ssn(ssn)
make_request(endpoint: bean_name, action: 'findPersonBySSN', body:, key: 'PersonDTO')
end
end

# finds a PERSON row by SSN
def find_by_ssn(ssn)
body = Nokogiri::XML::DocumentFragment.parse <<~EOXML
<ssn>#{ssn}</ssn>
EOXML

make_request(endpoint: bean_name, action: 'findPersonBySSN', body:, key: 'PersonDTO')
end
end
24 changes: 24 additions & 0 deletions modules/claims_api/lib/bgs_service/vet_record_web_service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

module ClaimsApi
class VetRecordWebService < ClaimsApi::LocalBGS
def bean_name
'VetRecordServiceBean/VetRecordWebService'
end

def update_birls_record(**options)
poa_code = options[:poa_code]
body = Nokogiri::XML::DocumentFragment.parse <<~EOML
<birlsUpdateInput>
<CLAIM_NUMBER>#{options[:file_number]}</CLAIM_NUMBER>
<SOC_SEC_NUM>#{options[:ssn]}</SOC_SEC_NUM>
<POWER_OF_ATTY_CODE1>#{poa_code[0]}</POWER_OF_ATTY_CODE1>
<POWER_OF_ATTY_CODE2>#{poa_code[1]}#{poa_code[2]}</POWER_OF_ATTY_CODE2>
<PAYEE_NUMBER>00</PAYEE_NUMBER>
</birlsUpdateInput>
EOML

make_request(endpoint: bean_name, body:, action: 'updateBirlsRecord', key: 'return')
end
end
end
46 changes: 45 additions & 1 deletion modules/claims_api/spec/sidekiq/poa_updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

require 'rails_helper'

RSpec.describe ClaimsApi::PoaUpdater, type: :job do
RSpec.describe ClaimsApi::PoaUpdater, type: :job, vcr: 'bgs/person_web_service/find_by_ssn' do
subject { described_class }

before do
Sidekiq::Job.clear_all
allow(Flipper).to receive(:enabled?).with(:claims_api_use_vet_record_service).and_return false
allow(Flipper).to receive(:enabled?).with(:claims_api_use_person_web_service).and_return false
allow(Flipper).to receive(:enabled?).with(:lighthouse_claims_api_v2_poa_va_notify).and_return false
end

let(:user) { FactoryBot.create(:user, :loa3) }
Expand All @@ -19,6 +22,7 @@
context "when call to BGS 'update_birls_record' is successful" do
context 'and the poaCode is retrieved successfully from the V2 2122a form data' do
it "updates the form's status and creates 'ClaimsApi::PoaVBMSUpdater' job" do
allow(Flipper).to receive(:enabled?).with(:claims_api_use_person_web_service).and_return false
create_mock_lighthouse_service
expect(ClaimsApi::PoaVBMSUpdater).to receive(:perform_async)

Expand Down Expand Up @@ -114,6 +118,7 @@
context 'deciding to send a VA Notify email' do
before do
create_mock_lighthouse_service
allow(Flipper).to receive(:enabled?).with(:lighthouse_claims_api_v2_poa_va_notify).and_return true
end

let(:poa) { create_poa }
Expand All @@ -134,6 +139,7 @@

context 'when the flipper is on' do
it 'does not send the vanotify job' do
allow(Flipper).to receive(:enabled?).with(:lighthouse_claims_api_v2_poa_va_notify).and_return false
Flipper.disable(:lighthouse_claims_api_v2_poa_va_notify)

poa.auth_headers.merge!({
Expand Down Expand Up @@ -186,6 +192,44 @@
end
end

describe 'when the claims_api_use_person_web_service flipper is on' do
let(:person_web_service) { instance_double(ClaimsApi::PersonWebService) }

before do
allow(Flipper).to receive(:enabled?).with(:claims_api_use_person_web_service).and_return true
allow(ClaimsApi::PersonWebService).to receive(:new).with(external_uid: anything,
external_key: anything)
.and_return(person_web_service)
allow(person_web_service).to receive(:find_by_ssn).and_return({ file_nbr: '796111863' })
end

it 'calls local bgs person web service instead of bgs-ext' do
poa = create_poa
subject.new.perform(poa.id)

expect(person_web_service).to have_received(:find_by_ssn)
end
end

describe 'when the claims_api_use_vet_record_service flipper is on' do
let(:vet_record_web_service) { instance_double(ClaimsApi::VetRecordWebService) }

before do
allow(Flipper).to receive(:enabled?).with(:claims_api_use_vet_record_service).and_return true
allow(ClaimsApi::VetRecordWebService).to receive(:new).with(external_uid: anything,
external_key: anything)
.and_return(vet_record_web_service)
allow(vet_record_web_service).to receive(:update_birls_record).and_return({ return_code: 'BMOD0001' })
end

it 'calls local bgs vet record service instead of bgs-ext' do
poa = create_poa
subject.new.perform(poa.id)

expect(vet_record_web_service).to have_received(:update_birls_record)
end
end

private

def create_poa
Expand Down
5 changes: 4 additions & 1 deletion modules/ivc_champva/app/services/ivc_champva/email.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ class Email
'10-7959F-1' => Settings.vanotify.services.ivc_champva.template_id.form_10_7959f_1_email,
'10-7959F-1-FAILURE' => Settings.vanotify.services.ivc_champva.template_id.form_10_7959f_1_failure_email,
'10-7959F-2' => Settings.vanotify.services.ivc_champva.template_id.form_10_7959f_2_email,
'10-7959F-2-FAILURE' => Settings.vanotify.services.ivc_champva.template_id.form_10_7959f_2_failure_email,
'10-7959C' => Settings.vanotify.services.ivc_champva.template_id.form_10_7959c_email,
'10-7959A' => Settings.vanotify.services.ivc_champva.template_id.form_10_7959a_email
'10-7959C-FAILURE' => Settings.vanotify.services.ivc_champva.template_id.form_10_7959c_failure_email,
'10-7959A' => Settings.vanotify.services.ivc_champva.template_id.form_10_7959a_email,
'10-7959A-FAILURE' => Settings.vanotify.services.ivc_champva.template_id.form_10_7959a_failure_email
}.freeze

def initialize(data)
Expand Down
Loading

0 comments on commit 21556ad

Please sign in to comment.