-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ProgressiveProofer refactor 3/N: Instant Verify residential address (#…
…11433) * Extract residential address InstantVerify plugin Add separate spec for the residential address verification only. [skip changelog] * Remove duplicative test from ResolutionProofingJob spec This test is essentially doing what the ProgressiveProofer spec is doing.
- Loading branch information
Showing
5 changed files
with
240 additions
and
38 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
app/services/proofing/resolution/plugins/instant_verify_residential_address_plugin.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,52 @@ | ||
# frozen_string_literal: true | ||
|
||
module Proofing | ||
module Resolution | ||
module Plugins | ||
class InstantVerifyResidentialAddressPlugin | ||
def call( | ||
applicant_pii:, | ||
current_sp:, | ||
ipp_enrollment_in_progress:, | ||
timer: | ||
) | ||
return residential_address_unnecessary_result unless ipp_enrollment_in_progress | ||
|
||
timer.time('residential address') do | ||
proofer.proof(applicant_pii) | ||
end.tap do |result| | ||
Db::SpCost::AddSpCost.call( | ||
current_sp, | ||
:lexis_nexis_resolution, | ||
transaction_id: result.transaction_id, | ||
) | ||
end | ||
end | ||
|
||
def proofer | ||
@proofer ||= | ||
if IdentityConfig.store.proofer_mock_fallback | ||
Proofing::Mock::ResolutionMockClient.new | ||
else | ||
Proofing::LexisNexis::InstantVerify::Proofer.new( | ||
instant_verify_workflow: IdentityConfig.store.lexisnexis_instant_verify_workflow, | ||
account_id: IdentityConfig.store.lexisnexis_account_id, | ||
base_url: IdentityConfig.store.lexisnexis_base_url, | ||
username: IdentityConfig.store.lexisnexis_username, | ||
password: IdentityConfig.store.lexisnexis_password, | ||
hmac_key_id: IdentityConfig.store.lexisnexis_hmac_key_id, | ||
hmac_secret_key: IdentityConfig.store.lexisnexis_hmac_secret_key, | ||
request_mode: IdentityConfig.store.lexisnexis_request_mode, | ||
) | ||
end | ||
end | ||
|
||
def residential_address_unnecessary_result | ||
Proofing::Resolution::Result.new( | ||
success: true, errors: {}, exception: nil, vendor_name: 'ResidentialAddressNotRequired', | ||
) | ||
end | ||
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
131 changes: 131 additions & 0 deletions
131
spec/services/proofing/resolution/plugins/instant_verify_residential_address_plugin_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,131 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe Proofing::Resolution::Plugins::InstantVerifyResidentialAddressPlugin do | ||
let(:current_sp) { build(:service_provider) } | ||
|
||
let(:ipp_enrollment_in_progress) { false } | ||
|
||
let(:proofer_transaction_id) { 'residential-123' } | ||
|
||
let(:proofer_result) do | ||
Proofing::Resolution::Result.new( | ||
success: true, | ||
transaction_id: proofer_transaction_id, | ||
vendor_name: 'lexisnexis:instant_verify', | ||
) | ||
end | ||
|
||
subject(:plugin) do | ||
described_class.new | ||
end | ||
|
||
before do | ||
allow(plugin.proofer).to receive(:proof).and_return(proofer_result) | ||
end | ||
|
||
describe '#call' do | ||
def sp_cost_count_for_issuer | ||
SpCost.where(cost_type: :lexis_nexis_resolution, issuer: current_sp.issuer).count | ||
end | ||
|
||
def sp_cost_count_with_transaction_id | ||
SpCost.where( | ||
cost_type: :lexis_nexis_resolution, | ||
issuer: current_sp.issuer, | ||
transaction_id: proofer_transaction_id, | ||
).count | ||
end | ||
|
||
subject(:call) do | ||
plugin.call( | ||
applicant_pii:, | ||
current_sp:, | ||
ipp_enrollment_in_progress:, | ||
timer: JobHelpers::Timer.new, | ||
) | ||
end | ||
|
||
context 'remote unsupervised proofing' do | ||
let(:applicant_pii) { Idp::Constants::MOCK_IDV_APPLICANT_WITH_SSN } | ||
let(:ipp_enrollment_in_progress) { false } | ||
|
||
it 'returns a ResidentialAddressNotRequired result' do | ||
call.tap do |result| | ||
expect(result.success?).to eql(true) | ||
expect(result.vendor_name).to eql('ResidentialAddressNotRequired') | ||
end | ||
end | ||
|
||
it 'does not record a LexisNexis SP cost' do | ||
expect { call }.not_to change { sp_cost_count_for_issuer } | ||
end | ||
end | ||
|
||
context 'in-person proofing' do | ||
let(:applicant_pii) { Idp::Constants::MOCK_IDV_APPLICANT_SAME_ADDRESS_AS_ID } | ||
let(:ipp_enrollment_in_progress) { true } | ||
let(:proofer_result) do | ||
Proofing::Resolution::Result.new( | ||
success: true, | ||
transaction_id: proofer_transaction_id, | ||
vendor_name: 'lexisnexis:instant_verify', | ||
) | ||
end | ||
|
||
it 'calls proofer with pii' do | ||
expect(plugin.proofer).to receive(:proof).with(applicant_pii) | ||
call | ||
end | ||
|
||
context 'when InstantVerify call succeeds' do | ||
it 'returns the proofer result' do | ||
expect(call).to eql(proofer_result) | ||
end | ||
|
||
it 'records a LexisNexis SP cost' do | ||
expect { call }.to change { sp_cost_count_with_transaction_id }.to(1) | ||
end | ||
end | ||
|
||
context 'when InstantVerify call fails' do | ||
let(:proofer_result) do | ||
Proofing::Resolution::Result.new( | ||
success: false, | ||
errors: {}, | ||
exception: nil, | ||
transaction_id: proofer_transaction_id, | ||
vendor_name: 'lexisnexis:instant_verify', | ||
) | ||
end | ||
|
||
it 'returns the proofer result' do | ||
expect(call).to eql(proofer_result) | ||
end | ||
|
||
it 'records a LexisNexis SP cost' do | ||
expect { call }.to change { sp_cost_count_with_transaction_id }.to(1) | ||
end | ||
end | ||
|
||
context 'when InstantVerify call results in exception' do | ||
let(:proofer_result) do | ||
Proofing::Resolution::Result.new( | ||
success: false, | ||
errors: {}, | ||
exception: RuntimeError.new(':ohno:'), | ||
transaction_id: proofer_transaction_id, | ||
vendor_name: 'lexisnexis:instant_verify', | ||
) | ||
end | ||
|
||
it 'returns the proofer result' do | ||
expect(call).to eql(proofer_result) | ||
end | ||
|
||
it 'records a LexisNexis SP cost' do | ||
expect { call }.to change { sp_cost_count_with_transaction_id }.to(1) | ||
end | ||
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