diff --git a/config/features.yml b/config/features.yml index 2eac790e6e6..7aedc668a01 100644 --- a/config/features.yml +++ b/config/features.yml @@ -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 diff --git a/modules/claims_api/app/clients/claims_api/bgs_client/definitions.rb b/modules/claims_api/app/clients/claims_api/bgs_client/definitions.rb index f9ba0fa3134..4a3e4896d57 100644 --- a/modules/claims_api/app/clients/claims_api/bgs_client/definitions.rb +++ b/modules/claims_api/app/clients/claims_api/bgs_client/definitions.rb @@ -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 diff --git a/modules/claims_api/app/sidekiq/claims_api/poa_updater.rb b/modules/claims_api/app/sidekiq/claims_api/poa_updater.rb index c67ae8dda9c..292fc50c824 100644 --- a/modules/claims_api/app/sidekiq/claims_api/poa_updater.rb +++ b/modules/claims_api/app/sidekiq/claims_api/poa_updater.rb @@ -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 @@ -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 diff --git a/modules/claims_api/lib/bgs_service/person_web_service.rb b/modules/claims_api/lib/bgs_service/person_web_service.rb index 600ddb2bbcc..0c3ac728b04 100644 --- a/modules/claims_api/lib/bgs_service/person_web_service.rb +++ b/modules/claims_api/lib/bgs_service/person_web_service.rb @@ -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} - EOXML - - make_request(endpoint: bean_name, action: 'findPersonBySSN', body:, key: 'PersonDTO') - end end diff --git a/modules/claims_api/lib/bgs_service/vet_record_web_service.rb b/modules/claims_api/lib/bgs_service/vet_record_web_service.rb new file mode 100644 index 00000000000..a378029a916 --- /dev/null +++ b/modules/claims_api/lib/bgs_service/vet_record_web_service.rb @@ -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 + + #{options[:file_number]} + #{options[:ssn]} + #{poa_code[0]} + #{poa_code[1]}#{poa_code[2]} + 00 + + EOML + + make_request(endpoint: bean_name, body:, action: 'updateBirlsRecord', key: 'return') + end + end +end diff --git a/modules/claims_api/spec/sidekiq/poa_updater_spec.rb b/modules/claims_api/spec/sidekiq/poa_updater_spec.rb index dd2816d7bdd..ae3fdec4c8a 100644 --- a/modules/claims_api/spec/sidekiq/poa_updater_spec.rb +++ b/modules/claims_api/spec/sidekiq/poa_updater_spec.rb @@ -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) } @@ -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) @@ -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 } @@ -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!({ @@ -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 diff --git a/spec/support/vcr_cassettes/bgs/person_web_service/find_by_ssn.yml b/spec/support/vcr_cassettes/bgs/person_web_service/find_by_ssn.yml index 52cdc548ad4..f8ee36c91bc 100644 --- a/spec/support/vcr_cassettes/bgs/person_web_service/find_by_ssn.yml +++ b/spec/support/vcr_cassettes/bgs/person_web_service/find_by_ssn.yml @@ -21,7 +21,7 @@ http_interactions: message: OK headers: Date: - - Thu, 21 Nov 2024 21:19:08 GMT + - Tue, 26 Nov 2024 21:56:34 GMT Server: - Apache X-Frame-Options: @@ -41,20 +41,74 @@ http_interactions: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + + + + + + + + + + @@ -62,11 +116,11 @@ http_interactions: - - + + - - + + @@ -74,11 +128,11 @@ http_interactions: - - + + - - + + @@ -86,23 +140,11 @@ http_interactions: - - - - - - - - - - - - - - + + - - + + @@ -110,12 +152,30 @@ http_interactions: + + + + + + + + + + + + + + + + + + @@ -128,23 +188,17 @@ http_interactions: - - - - - - - - + + - - + + @@ -158,77 +212,29 @@ http_interactions: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - + + - - + + - - + + @@ -236,79 +242,123 @@ http_interactions: - - - - - - - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - + + + + + + + + + + + - - - - + + + + - - - - + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + @@ -319,20 +369,15 @@ http_interactions: - - - - - - - - - + + + + @@ -344,85 +389,220 @@ http_interactions: - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + - - - + + + + + + + + + + - - - + + + + + + + + + + - - - + + + + + + + + + + - - - + + + + + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + - - - - + + + + + + + + + + + - - - - + + + + + + + + + + + - - - - + + + + + + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + @@ -446,7 +626,7 @@ http_interactions: - + @@ -458,7 +638,7 @@ http_interactions: - + @@ -470,7 +650,7 @@ http_interactions: - + @@ -482,7 +662,7 @@ http_interactions: - + @@ -494,7 +674,7 @@ http_interactions: - + @@ -506,7 +686,7 @@ http_interactions: - + @@ -518,7 +698,7 @@ http_interactions: - + @@ -530,7 +710,7 @@ http_interactions: - + @@ -542,7 +722,7 @@ http_interactions: - + @@ -554,7 +734,7 @@ http_interactions: - + @@ -566,7 +746,7 @@ http_interactions: - + @@ -578,7 +758,7 @@ http_interactions: - + @@ -590,7 +770,7 @@ http_interactions: - + @@ -602,7 +782,7 @@ http_interactions: - + @@ -614,7 +794,7 @@ http_interactions: - + @@ -626,7 +806,7 @@ http_interactions: - + @@ -638,7 +818,7 @@ http_interactions: - + @@ -650,7 +830,309 @@ http_interactions: - + + + + + + + + recorded_at: Tue, 26 Nov 2024 21:56:34 GMT +- request: + method: post + uri: "/PersonWebServiceBean/PersonWebService" + body: + encoding: UTF-8 + string: |- + + + VAgovAPI + + + 10.0.0.205 + 281 + VAgovAPI + 123 + 1@2.com + + + 796104437 + headers: + Host: + - ".vba.va.gov" + Soapaction: + - '"findPersonBySSN"' + Content-Type: + - text/xml;charset=UTF-8 + Content-Length: + - '1261' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 26 Nov 2024 21:56:35 GMT + Server: + - Apache + X-Frame-Options: + - SAMEORIGIN + Transfer-Encoding: + - chunked + Content-Type: + - text/xml; charset=utf-8 + Strict-Transport-Security: + - max-age=16000000; includeSubDomains; preload; + body: + encoding: UTF-8 + string: rO0ABXdTAB13ZWJsb2dpYy5hcHAuQ29ycG9yYXRlRGF0YUVBUgAAANYAAAAjd2VibG9naWMud29ya2FyZWEuU3RyaW5nV29ya0NvbnRleHQABTMuNS4wAAA=TAMPAFL1950-10-04T00:00:00-06:002022-01-01T00:00:00-06:002022-09-16T12:24:00-05:002022-09-16T12:24:00-05:00YCORPuser228@gmail.comN796104437MARK-2M2024-11-26T15:36:00-06:00VAgovAPI1@2.com123281VAGOVAPI - + BUPD218942542UVAGOVAPIPOLARBEAR-2T-1YUnknownNUU13367440Person13367440N7961044374317JR-137Y + recorded_at: Tue, 26 Nov 2024 21:56:35 GMT +- request: + method: get + uri: "/VetRecordServiceBean/VetRecordWebService?WSDL" + body: + encoding: US-ASCII + string: '' + headers: + Host: + - ".vba.va.gov" + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 26 Nov 2024 21:56:35 GMT + Server: + - Apache + X-Frame-Options: + - SAMEORIGIN + Transfer-Encoding: + - chunked + Content-Type: + - text/xml;charset=utf-8 + Strict-Transport-Security: + - max-age=16000000; includeSubDomains; preload; + body: + encoding: UTF-8 + string: |- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -658,11 +1140,11 @@ http_interactions: - - + + - + @@ -670,11 +1152,11 @@ http_interactions: - - + + - + @@ -682,11 +1164,11 @@ http_interactions: - - + + - + @@ -694,11 +1176,11 @@ http_interactions: - - + + - + @@ -706,11 +1188,11 @@ http_interactions: - - + + - + @@ -718,11 +1200,11 @@ http_interactions: - - + + - + @@ -730,11 +1212,11 @@ http_interactions: - - + + - + @@ -742,11 +1224,11 @@ http_interactions: - - + + - + @@ -754,11 +1236,11 @@ http_interactions: - - + + - + @@ -766,11 +1248,11 @@ http_interactions: - - + + - + @@ -778,11 +1260,11 @@ http_interactions: - - + + - + @@ -790,11 +1272,11 @@ http_interactions: - - + + - + @@ -802,11 +1284,11 @@ http_interactions: - - + + - + @@ -814,11 +1296,11 @@ http_interactions: - - + + - + @@ -826,25 +1308,49 @@ http_interactions: - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - recorded_at: Thu, 21 Nov 2024 21:19:08 GMT + recorded_at: Tue, 26 Nov 2024 21:56:35 GMT - request: method: post - uri: "/PersonWebServiceBean/PersonWebService" + uri: "/VetRecordServiceBean/VetRecordWebService" body: encoding: UTF-8 string: |- - + VAgovAPI @@ -852,20 +1358,20 @@ http_interactions: 10.0.0.205 281 VAgovAPI - 796378881 - 796378881 + 123 + 1@2.com - 796378881 + 79610443779610443700074 headers: Host: - ".vba.va.gov" Soapaction: - - '"findPersonBySSN"' + - '"updateBirlsRecord"' Content-Type: - text/xml;charset=UTF-8 Content-Length: - - '1269' + - '1476' Accept-Encoding: - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 Accept: @@ -878,11 +1384,15 @@ http_interactions: message: OK headers: Date: - - Thu, 21 Nov 2024 21:19:08 GMT + - Tue, 26 Nov 2024 21:56:36 GMT Server: - Apache X-Frame-Options: - SAMEORIGIN + X-Oracle-Dms-Ecid: + - fdfca44e-78a2-4e38-9b9e-cb506638b894-0001e406 + X-Oracle-Dms-Rid: + - '0' Transfer-Encoding: - chunked Content-Type: @@ -893,8 +1403,106 @@ http_interactions: encoding: UTF-8 string: rO0ABXdTAB13ZWJsb2dpYy5hcHAuQ29ycG9yYXRlRGF0YUVBUgAAANYAAAAjd2VibG9naWMud29ya2FyZWEuU3RyaW5nV29ya0NvbnRleHQABTMuNS4wAAA=SALINASKS1954-12-15T00:00:00-06:002022-10-03T15:35:53-05:002022-10-03T15:35:53-05:00YCORP0valid@somedomain.comN796378881JESSE-2M2024-11-21T15:18:35-06:00VAgovAPIlighthouse-vets-apilighthouse-vets-api281VAGOVAPI - - BUPD218935360UVAGOVAPIGRAY-1ADSUSEONLY-1YNUU600045026Person600045026NN796378881031781Y - recorded_at: Thu, 21 Nov 2024 21:19:08 GMT + xmlns:work="http://oracle.com/weblogic/soap/workarea/">rO0ABXdTAB13ZWJsb2dpYy5hcHAuQ29ycG9yYXRlRGF0YUVBUgAAANYAAAAjd2VibG9naWMud29ya2FyZWEuU3RyaW5nV29ya0NvbnRleHQABTMuNS4wAAA=BMOD0001BIRLS + Update successful796104437796104437 + ARMY0101196510011972SAT E6 + HON + ARMY1002197201012005SAT E6 + UHC + POLARBEARMARKTJRERRORSCAUSESTUXJRERRORSCAUSESTUXJRWEBBMARKJR1004195010/04/19500101202201/01/20220CLAIM3171123201011/23/2010 + + + EDU 3511119201011/19/2010 + + + + + + + + + + + + + + + + + + + + + + + + + + + 317YMDYNNUNKNOWN074 + + + + + + + + + + + + + + + + + + 000VAGOVAPI2811126202411/26/2024 1 + recorded_at: Tue, 26 Nov 2024 21:56:37 GMT recorded_with: VCR 6.3.1