From a997925537bbac2467c8adfcb697b1d9df9df6ec Mon Sep 17 00:00:00 2001 From: Jonathan Hooper Date: Tue, 11 Jun 2024 10:11:33 -0400 Subject: [PATCH 1/2] Do not track SP costs in AAMVA exception case I was looking at the changes in #10786 for the move of SP cost tracking from the `VerifyInfoConcern` to the `ProgressiveProofer` when I noticed this condition that was not accounted for: https://github.com/18F/identity-idp/pull/10786/files#diff-5d8b1370b1c579364bb79a0813ca9bf9a15c65e7a974829886ab3e00f3441cedL310 This logic prevents a AAMVA cost from being added if an AAMVA exception occurs. Presumably this is because we are not billed for AAMVA exception which happen frequently. This commit applies that logic to the `ProgressiveProofer` where SP costs are now tracked. [skip changelog] --- .../resolution/progressive_proofer.rb | 2 +- .../resolution/progressive_proofer_spec.rb | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/services/proofing/resolution/progressive_proofer.rb b/app/services/proofing/resolution/progressive_proofer.rb index e329d07fe7a..db3d60b9038 100644 --- a/app/services/proofing/resolution/progressive_proofer.rb +++ b/app/services/proofing/resolution/progressive_proofer.rb @@ -142,7 +142,7 @@ def proof_id_with_aamva_if_needed timer.time('state_id') do state_id_proofer.proof(applicant_pii_with_state_id_address) end.tap do |result| - add_sp_cost(:aamva, result.transaction_id) + add_sp_cost(:aamva, result.transaction_id) if !result.exception.present? end end diff --git a/spec/services/proofing/resolution/progressive_proofer_spec.rb b/spec/services/proofing/resolution/progressive_proofer_spec.rb index cb289eaab5e..7b80ff5a010 100644 --- a/spec/services/proofing/resolution/progressive_proofer_spec.rb +++ b/spec/services/proofing/resolution/progressive_proofer_spec.rb @@ -27,6 +27,7 @@ Proofing::StateIdResult, success?: false, transaction_id: 'aamva-123', + exception: nil, ) end let(:aamva_proofer) { instance_double(Proofing::Aamva::Proofer, proof: aamva_proofer_result) } @@ -202,6 +203,21 @@ def block_real_instant_verify_requests expect(threatmetrix_sp_costs.count).to eq(0) end end + + context 'AAMVA raises an exception' do + let(:aamva_proofer_result) do + instance_double( + Proofing::StateIdResult, + success?: false, + transaction_id: 'aamva-123', + exception: RuntimeError.new('this is a fun test error!!'), + ) + end + + it 'does not track an SP cost for AAMVA' do + expect { proof }.to_not change { SpCost.where(cost_type: :aamva).count } + end + end end context 'ipp flow' do @@ -279,6 +295,7 @@ def block_real_instant_verify_requests verified_attributes: [], success?: false, transaction_id: 'aamva-123', + exception: nil, ) end @@ -294,6 +311,7 @@ def block_real_instant_verify_requests verified_attributes: [:address], success?: true, transaction_id: 'aamva-123', + exception: nil, ) end @@ -332,6 +350,7 @@ def block_real_instant_verify_requests Proofing::StateIdResult, success?: false, transaction_id: 'aamva-123', + exception: nil, ) end @@ -413,6 +432,7 @@ def block_real_instant_verify_requests Proofing::StateIdResult, success?: false, transaction_id: 'aamva-123', + exception: nil, ) end From ffd6fc5edbafe52b4c6100166172b644f7b6edce Mon Sep 17 00:00:00 2001 From: Jonathan Hooper Date: Tue, 11 Jun 2024 12:26:25 -0400 Subject: [PATCH 2/2] Update app/services/proofing/resolution/progressive_proofer.rb Co-authored-by: Zach Margolis --- app/services/proofing/resolution/progressive_proofer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/proofing/resolution/progressive_proofer.rb b/app/services/proofing/resolution/progressive_proofer.rb index db3d60b9038..a37f557ecdd 100644 --- a/app/services/proofing/resolution/progressive_proofer.rb +++ b/app/services/proofing/resolution/progressive_proofer.rb @@ -142,7 +142,7 @@ def proof_id_with_aamva_if_needed timer.time('state_id') do state_id_proofer.proof(applicant_pii_with_state_id_address) end.tap do |result| - add_sp_cost(:aamva, result.transaction_id) if !result.exception.present? + add_sp_cost(:aamva, result.transaction_id) if result.exception.blank? end end