Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api 42322 extract org web service bean from local bgs #19796

Merged
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4c221bd
Add OrgWebService
mchristiansonVA Dec 5, 2024
5a52488
Merge remote-tracking branch 'origin/master' into API-42322-Extract-O…
mchristiansonVA Dec 6, 2024
ff34c4b
Merge remote-tracking branch 'origin/master' into API-42322-Extract-O…
mchristiansonVA Dec 9, 2024
e4e22c2
Merge remote-tracking branch 'origin/master' into API-42322-Extract-O…
mchristiansonVA Dec 9, 2024
f1aa665
Initial commit, WIP
mchristiansonVA Dec 9, 2024
fe35be6
Add requires to resolve NameError
mchristiansonVA Dec 9, 2024
56ac76a
Remove byebug
mchristiansonVA Dec 9, 2024
a479352
Merge remote-tracking branch 'origin/master' into API-42322-Extract-O…
mchristiansonVA Dec 10, 2024
fe4dcb4
Update definitions and related spec
mchristiansonVA Dec 10, 2024
229218f
Remove find_by_ssn
mchristiansonVA Dec 10, 2024
66f4345
Rubocop adjustment
mchristiansonVA Dec 10, 2024
dd784a9
Remove commented code
mchristiansonVA Dec 10, 2024
13ba2af
Merge w/ master, resolve conflicts
mchristiansonVA Dec 10, 2024
97c5f8a
Revert change to ClaimantService method
mchristiansonVA Dec 11, 2024
3a1e4fb
Merge remote-tracking branch 'origin/master' into API-42322-Extract-O…
mchristiansonVA Dec 11, 2024
915a8d7
Merge branch 'master' into API-42322-Extract-OrgWebServiceBean-from-l…
mchristiansonVA Dec 11, 2024
b4ed3c4
Add back local_bgs_service for Claimant call
mchristiansonVA Dec 12, 2024
f8672ab
Merge remote-tracking branch 'origin/master' into API-42322-Extract-O…
mchristiansonVA Dec 12, 2024
36f0d7d
Merge w/ master
mchristiansonVA Dec 16, 2024
fa663a7
Reverts definitions file changes to skip WSDL calls
mchristiansonVA Dec 16, 2024
4735c99
Merge branch 'master' into API-42322-Extract-OrgWebServiceBean-from-l…
mchristiansonVA Dec 17, 2024
a478138
Merge remote-tracking branch 'origin/master' into API-42322-Extract-O…
mchristiansonVA Dec 19, 2024
bedb3bb
Use method instead of hardcoded text
mchristiansonVA Dec 20, 2024
509dd31
Merge branch 'master' into API-42322-Extract-OrgWebServiceBean-from-l…
mchristiansonVA Jan 2, 2025
3245b08
Merge branch 'master' into API-42322-Extract-OrgWebServiceBean-from-l…
mchristiansonVA Jan 3, 2025
3206358
Merge branch 'master' into API-42322-Extract-OrgWebServiceBean-from-l…
mchristiansonVA Jan 6, 2025
ffa2ba5
Merge branch 'master' into API-42322-Extract-OrgWebServiceBean-from-l…
mchristiansonVA Jan 6, 2025
b2c0130
Merge w/ master, resolve conflicts
mchristiansonVA Jan 7, 2025
f231368
Fix test for org web service
mchristiansonVA Jan 7, 2025
9914ee0
Merge branch 'master' into API-42322-Extract-OrgWebServiceBean-from-l…
mchristiansonVA Jan 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ module IntentToFileWebService
##
# OrgWebServiceBean
#
module OrgWebServiceBean
module OrgWebService
DEFINITION =
Bean.new(
path: 'OrgWebServiceBean',
Expand All @@ -134,23 +134,6 @@ module OrgWebServiceBean
)
end

module OrgWebService
DEFINITION =
Service.new(
bean: OrgWebServiceBean::DEFINITION,
path: 'OrgWebService'
)

module FindOrgBySSN
DEFINITION =
Action.new(
service: OrgWebService::DEFINITION,
name: 'findPoaHistoryByPtcpntId',
key: 'PoaHistory'
)
end
end

##
# PersonWebServiceBean
#
Expand Down
13 changes: 0 additions & 13 deletions modules/claims_api/lib/bgs_service/local_bgs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,6 @@ def find_poa_by_participant_id(id)
key: 'return')
end

def find_poa_history_by_ptcpnt_id(id)
body = Nokogiri::XML::DocumentFragment.parse <<~EOXML
<ptcpntId />
EOXML

{ ptcpntId: id }.each do |k, v|
body.xpath("./*[local-name()='#{k}']")[0].content = v
end

make_request(endpoint: 'OrgWebServiceBean/OrgWebService', action: 'findPoaHistoryByPtcpntId', body:,
key: 'PoaHistory')
end

def insert_intent_to_file(options)
request_body = construct_itf_body(options)
body = Nokogiri::XML::DocumentFragment.parse <<~EOXML
Expand Down
22 changes: 22 additions & 0 deletions modules/claims_api/lib/bgs_service/org_web_service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

module ClaimsApi
class OrgWebService < ClaimsApi::LocalBGS
def bean_name
'OrgWebServiceBean/OrgWebService'
end

def find_poa_history_by_ptcpnt_id(id)
body = Nokogiri::XML::DocumentFragment.parse <<~EOXML
<ptcpntId />
EOXML

{ ptcpntId: id }.each do |k, v|
body.xpath("./*[local-name()='#{k}']")[0].content = v
end

make_request(endpoint: 'OrgWebServiceBean/OrgWebService', action: 'findPoaHistoryByPtcpntId', body:,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can use bean_name here for the endpoint so it's changeable in one place.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can use bean_name here for the endpoint so it's changeable in one place.

Would be a nice fix but not critical to functionality.

key: 'PoaHistory')
end
end
end
27 changes: 0 additions & 27 deletions modules/claims_api/spec/lib/claims_api/find_definition_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,6 @@
Flipper.enable(:lighthouse_claims_api_hardcode_wsdl)
end

context 'OrgWebServiceBean' do
let(:endpoint) { 'OrgWebServiceBean/OrgWebService' }
let(:action) { 'findPoaHistoryByPtcpntId' }
let(:key) { 'PoaHistory' }

it 'response with the correct attributes for OrgWebServiceBean' do
result = subject.for_action(endpoint, action)
parsed_result = JSON.parse(result.to_json)

expect(parsed_result['service']['bean']['path']).to eq 'OrgWebServiceBean'
expect(parsed_result['service']['path']).to eq 'OrgWebService'
expect(parsed_result['service']['bean']['namespaces']['target']).to eq 'http://org.services.vetsnet.vba.va.gov/'
end
end

# This one doesn't have `Bean` at the end
context 'TrackedItemService' do
let(:endpoint) { 'TrackedItemService/TrackedItemService' }
Expand Down Expand Up @@ -166,18 +151,6 @@
Flipper.enable(:lighthouse_claims_api_hardcode_wsdl)
end

context 'OrgWebService' do
let(:endpoint) { 'OrgWebServiceBean/OrgWebService' }

it 'response with the correct namespace' do
result = subject.for_service(endpoint)
parsed_result = JSON.parse(result.to_json)
expect(parsed_result['bean']['path']).to eq 'OrgWebServiceBean'
expect(parsed_result['path']).to eq 'OrgWebService'
expect(parsed_result['bean']['namespaces']['target']).to eq 'http://org.services.vetsnet.vba.va.gov/'
end
end

context 'TrackedItemService' do
let(:endpoint) { 'TrackedItemService/TrackedItemService' }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
convert_nil_values: %i[options],
find_intent_to_file_by_ptcpnt_id_itf_type_cd: %i[id type],
find_poa_by_participant_id: %i[id],
find_poa_history_by_ptcpnt_id: %i[id],
find_tracked_items: %i[id],
healthcheck: %i[endpoint],
insert_intent_to_file: %i[options],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require 'rails_helper'
require 'bgs_service/local_bgs_proxy'
require 'bgs_service/e_benefits_bnft_claim_status_web_service'

describe ClaimsApi::EbenefitsBnftClaimStatusWebService do
subject { described_class.new external_uid: 'xUid', external_key: 'xKey' }
Expand Down
9 changes: 5 additions & 4 deletions modules/claims_api/spec/models/veteran/service/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
end

let(:ows) { ClaimsApi::LocalBGS }
let(:org_web_service) { ClaimsApi::OrgWebService }

it 'initializes from a user' do
VCR.use_cassette('claims_api/bgs/claimant_web_service/find_poa_by_participant_id') do
allow_any_instance_of(ows).to receive(:find_poa_history_by_ptcpnt_id)
allow_any_instance_of(org_web_service).to receive(:find_poa_history_by_ptcpnt_id)
.and_return({ person_poa_history: { person_poa: [{ begin_dt: Time.zone.now, legacy_poa_cd: '033' }] } })
veteran = Veteran::User.new(user)
expect(veteran.power_of_attorney.code).to eq('074')
Expand All @@ -29,7 +30,7 @@

it 'does not bomb out if poa is missing' do
VCR.use_cassette('claims_api/bgs/claimant_web_service/not_find_poa_by_participant_id') do
allow_any_instance_of(ows).to receive(:find_poa_history_by_ptcpnt_id)
allow_any_instance_of(org_web_service).to receive(:find_poa_history_by_ptcpnt_id)
.and_return({ person_poa_history: nil })
veteran = Veteran::User.new(user)
expect(veteran.power_of_attorney).to eq(nil)
Expand All @@ -39,7 +40,7 @@

it 'provides most recent previous poa' do
VCR.use_cassette('claims_api/bgs/claimant_web_service/find_poa_by_participant_id') do
allow_any_instance_of(ows).to receive(:find_poa_history_by_ptcpnt_id)
allow_any_instance_of(org_web_service).to receive(:find_poa_history_by_ptcpnt_id)
.and_return({
person_poa_history: {
person_poa: [
Expand All @@ -56,7 +57,7 @@

it 'does not bomb out if poa history contains a single record' do
VCR.use_cassette('claims_api/bgs/claimant_web_service/find_poa_by_participant_id') do
allow_any_instance_of(ows).to receive(:find_poa_history_by_ptcpnt_id)
allow_any_instance_of(org_web_service).to receive(:find_poa_history_by_ptcpnt_id)
.and_return({ person_poa_history: { person_poa: { begin_dt: Time.zone.now, legacy_poa_cd: '033' } } })
veteran = Veteran::User.new(user)
expect(veteran.power_of_attorney.code).to eq('074')
Expand Down
18 changes: 16 additions & 2 deletions modules/claims_api/spec/requests/metadata_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require 'bgs/services'
require 'mpi/service'
require 'bgs_service/e_benefits_bnft_claim_status_web_service'
require 'bgs_service/org_web_service'
require 'bgs_service/person_web_service'

RSpec.describe 'ClaimsApi::Metadata', type: :request do
Expand Down Expand Up @@ -56,8 +57,8 @@
expect(result['mpi']['success']).to eq(false)
end

local_bgs_services = %i[claimant org intenttofile trackeditem].freeze
local_bgs_methods = %i[find_poa_by_participant_id find_poa_history_by_ptcpnt_id
local_bgs_services = %i[claimant intenttofile trackeditem].freeze
local_bgs_methods = %i[find_poa_by_participant_id
insert_intent_to_file find_tracked_items].freeze
local_bgs_services.each do |local_bgs_service|
it "returns the correct status when the local bgs #{local_bgs_service} is not healthy" do
Expand Down Expand Up @@ -87,6 +88,19 @@
end
end

local_bgs_org_methods = %i[find_poa_history_by_ptcpnt_id]
it 'returns the correct status when the local bgs orgwebservice is not healthy' do
local_bgs_org_methods.each do |local_bgs_org_method|
allow_any_instance_of(ClaimsApi::OrgWebService).to receive(
local_bgs_org_method.to_sym
)
.and_return(Struct.new(:healthy?).new(false))
get "/services/claims/#{version}/upstream_healthcheck"
result = JSON.parse(response.body)
expect(result['localbgs-org']['success']).to eq(false)
end
end

person_web_service = 'person'
local_bgs_person_methods = %i[find_by_ssn]
it "returns the correct status when the local bgs #{person_web_service} is not healthy" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require_relative '../../../../rails_helper'
require 'token_validation/v2/client'
require 'bgs_service/local_bgs'
require 'bgs_service/org_web_service'

RSpec.describe 'ClaimsApi::V1::PowerOfAttorney::2122', type: :request do
let(:veteran_id) { '1013062086V794840' }
Expand All @@ -14,6 +15,7 @@
let(:organization_poa_code) { '083' }
let(:bgs_poa) { { person_org_name: "#{individual_poa_code} name-here" } }
let(:local_bgs) { ClaimsApi::LocalBGS }
let(:org_web_service) { ClaimsApi::OrgWebService }

describe 'PowerOfAttorney' do
before do
Expand Down Expand Up @@ -55,7 +57,7 @@
mock_ccg(scopes) do |auth_header|
expect_any_instance_of(local_bgs).to receive(:find_poa_by_participant_id)
.and_return(bgs_poa)
allow_any_instance_of(local_bgs).to receive(:find_poa_history_by_ptcpnt_id)
allow_any_instance_of(org_web_service).to receive(:find_poa_history_by_ptcpnt_id)
.and_return({ person_poa_history: nil })

post appoint_organization_path, params: data.to_json, headers: auth_header
Expand Down Expand Up @@ -86,7 +88,7 @@
it 'returns a 422 when no zipCode is included in the veteran data' do
VCR.use_cassette('claims_api/mpi/find_candidate/valid_icn_full') do
mock_ccg(scopes) do |auth_header|
allow_any_instance_of(local_bgs).to receive(:find_poa_history_by_ptcpnt_id)
allow_any_instance_of(org_web_service).to receive(:find_poa_history_by_ptcpnt_id)
.and_return({ person_poa_history: nil })

json = JSON.parse(request_body)
Expand All @@ -112,7 +114,7 @@
mock_ccg(scopes) do |auth_header|
expect_any_instance_of(local_bgs).to receive(:find_poa_by_participant_id)
.and_return(bgs_poa)
allow_any_instance_of(local_bgs).to receive(:find_poa_history_by_ptcpnt_id)
allow_any_instance_of(org_web_service).to receive(:find_poa_history_by_ptcpnt_id)
.and_return({ person_poa_history: nil })

json = JSON.parse(request_body)
Expand Down Expand Up @@ -284,7 +286,7 @@
mock_ccg(scopes) do |auth_header|
expect_any_instance_of(local_bgs).to receive(:find_poa_by_participant_id)
.and_return(bgs_poa)
allow_any_instance_of(local_bgs).to receive(:find_poa_history_by_ptcpnt_id)
allow_any_instance_of(org_web_service).to receive(:find_poa_history_by_ptcpnt_id)
.and_return({ person_poa_history: nil })
allow_any_instance_of(ClaimsApi::V2::ApplicationController)
.to receive(:target_veteran).and_return(no_first_name_target_veteran)
Expand Down Expand Up @@ -316,7 +318,7 @@

it 'returns a 422' do
mock_ccg(scopes) do |auth_header|
allow_any_instance_of(local_bgs).to receive(:find_poa_history_by_ptcpnt_id)
allow_any_instance_of(org_web_service).to receive(:find_poa_history_by_ptcpnt_id)
.and_return({ person_poa_history: nil })
allow_any_instance_of(ClaimsApi::V2::ApplicationController)
.to receive(:target_veteran).and_return(no_first_last_name_target_veteran)
Expand Down Expand Up @@ -356,7 +358,7 @@
it 'returns a 422 with no zipCode' do
VCR.use_cassette('claims_api/mpi/find_candidate/valid_icn_full') do
mock_ccg(scopes) do |auth_header|
allow_any_instance_of(local_bgs).to receive(:find_poa_history_by_ptcpnt_id)
allow_any_instance_of(org_web_service).to receive(:find_poa_history_by_ptcpnt_id)
.and_return({ person_poa_history: nil })

json = JSON.parse(request_body)
Expand Down Expand Up @@ -395,7 +397,7 @@
mock_ccg(scopes) do |auth_header|
expect_any_instance_of(local_bgs).to receive(:find_poa_by_participant_id)
.and_return(bgs_poa)
allow_any_instance_of(local_bgs).to receive(:find_poa_history_by_ptcpnt_id)
allow_any_instance_of(org_web_service).to receive(:find_poa_history_by_ptcpnt_id)
.and_return({ person_poa_history: nil })

json = JSON.parse(request_body)
Expand All @@ -418,7 +420,7 @@
mock_ccg(scopes) do |auth_header|
expect_any_instance_of(local_bgs).to receive(:find_poa_by_participant_id)
.and_return(bgs_poa)
allow_any_instance_of(local_bgs).to receive(:find_poa_history_by_ptcpnt_id)
allow_any_instance_of(org_web_service).to receive(:find_poa_history_by_ptcpnt_id)
.and_return({ person_poa_history: nil })

post appoint_organization_path, params: data.to_json, headers: auth_header
Expand All @@ -432,7 +434,7 @@
mock_ccg(scopes) do |auth_header|
expect_any_instance_of(local_bgs).to receive(:find_poa_by_participant_id)
.and_return(bgs_poa)
allow_any_instance_of(local_bgs).to receive(:find_poa_history_by_ptcpnt_id)
allow_any_instance_of(org_web_service).to receive(:find_poa_history_by_ptcpnt_id)
.and_return({ person_poa_history: nil })

post appoint_organization_path, params: data.to_json, headers: auth_header
Expand Down Expand Up @@ -490,7 +492,7 @@
mock_ccg_for_fine_grained_scope(poa_scopes) do |auth_header|
expect_any_instance_of(local_bgs).to receive(:find_poa_by_participant_id)
.and_return(bgs_poa)
allow_any_instance_of(local_bgs).to receive(:find_poa_history_by_ptcpnt_id)
allow_any_instance_of(org_web_service).to receive(:find_poa_history_by_ptcpnt_id)
.and_return({ person_poa_history: nil })

post appoint_organization_path, params: data.to_json, headers: auth_header
Expand Down Expand Up @@ -519,7 +521,7 @@
mock_ccg(scopes) do |auth_header|
expect_any_instance_of(local_bgs).to receive(:find_poa_by_participant_id)
.and_return(bgs_poa)
allow_any_instance_of(local_bgs).to receive(:find_poa_history_by_ptcpnt_id)
allow_any_instance_of(org_web_service).to receive(:find_poa_history_by_ptcpnt_id)
.and_return({ person_poa_history: nil })
expect(ClaimsApi::V2::PoaFormBuilderJob).to receive(:perform_async) do |*args|
expect(args[2]).to eq(rep_id)
Expand Down Expand Up @@ -605,7 +607,7 @@

it 'returns an error response' do
mock_ccg(scopes) do |auth_header|
allow_any_instance_of(local_bgs).to receive(:find_poa_history_by_ptcpnt_id)
allow_any_instance_of(org_web_service).to receive(:find_poa_history_by_ptcpnt_id)
.and_return({ person_poa_history: nil })
allow_any_instance_of(ClaimsApi::V2::ApplicationController)
.to receive(:target_veteran).and_return(no_first_last_name_target_veteran)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require_relative '../../../../rails_helper'
require 'token_validation/v2/client'
require 'bgs_service/local_bgs'
require 'bgs_service/org_web_service'

RSpec.describe 'ClaimsApi::V2::PowerOfAttorney::2122a', type: :request do
let(:veteran_id) { '1013062086V794840' }
Expand All @@ -14,6 +15,7 @@
let(:organization_poa_code) { '067' }
let(:bgs_poa) { { person_org_name: "#{individual_poa_code} name-here" } }
let(:local_bgs) { ClaimsApi::LocalBGS }
let(:org_web_service) { ClaimsApi::OrgWebService }

describe 'PowerOfAttorney' do
before do
Expand Down Expand Up @@ -113,7 +115,7 @@
mock_ccg(scopes) do |auth_header|
expect_any_instance_of(local_bgs).to receive(:find_poa_by_participant_id)
.and_return(bgs_poa)
allow_any_instance_of(local_bgs).to receive(:find_poa_history_by_ptcpnt_id)
allow_any_instance_of(org_web_service).to receive(:find_poa_history_by_ptcpnt_id)
.and_return({ person_poa_history: nil })

post appoint_individual_path, params: data.to_json, headers: auth_header
Expand Down Expand Up @@ -312,7 +314,7 @@
claimant_data[:data][:attributes][:representative][:address][:zipCode] = ''
claimant_data[:data][:attributes][:representative][:address][:countryCode] = 'AL'
allow_any_instance_of(local_bgs).to receive(:find_poa_by_participant_id).and_return(bgs_poa)
allow_any_instance_of(local_bgs)
allow_any_instance_of(org_web_service)
.to receive(:find_poa_history_by_ptcpnt_id).and_return({ person_poa_history: nil })
VCR.use_cassette('claims_api/mpi/find_candidate/valid_icn_full') do
post appoint_individual_path, params: claimant_data.to_json, headers: auth_header
Expand All @@ -327,7 +329,7 @@
shared_context 'claimant data setup' do
before do
allow_any_instance_of(local_bgs).to receive(:find_poa_by_participant_id).and_return(bgs_poa)
allow_any_instance_of(local_bgs)
allow_any_instance_of(org_web_service)
.to receive(:find_poa_history_by_ptcpnt_id).and_return({ person_poa_history: nil })
end
end
Expand Down
Loading
Loading