diff --git a/app/services/proofing/result.rb b/app/services/proofing/result.rb index 4f199c38a3a..4c2d85faada 100644 --- a/app/services/proofing/result.rb +++ b/app/services/proofing/result.rb @@ -8,13 +8,15 @@ def initialize( context: {}, exception: nil, transaction_id: nil, - reference: nil + reference: nil, + response_body: nil ) @errors = errors @context = context @exception = exception @transaction_id = transaction_id @reference = reference + @response_body = response_body end # rubocop:disable Style/OptionalArguments diff --git a/spec/jobs/resolution_proofing_job_spec.rb b/spec/jobs/resolution_proofing_job_spec.rb index ba00436c8d6..84a55950547 100644 --- a/spec/jobs/resolution_proofing_job_spec.rb +++ b/spec/jobs/resolution_proofing_job_spec.rb @@ -37,6 +37,7 @@ let(:state_id_proofer) do instance_double(Proofing::Aamva::Proofer, class: Proofing::Aamva::Proofer) end + let(:ddp_proofer) { Proofing::Mock::DdpMockClient.new } let(:trace_id) { SecureRandom.uuid } let(:user) { create(:user, :signed_up) } let(:threatmetrix_session_id) { SecureRandom.uuid } @@ -256,6 +257,7 @@ before do allow(instance).to receive(:resolution_proofer).and_return(resolution_proofer) allow(instance).to receive(:state_id_proofer).and_return(state_id_proofer) + allow(instance).to receive(:lexisnexis_ddp_proofer).and_return(ddp_proofer) allow(IdentityConfig.store).to receive(:lexisnexis_threatmetrix_enabled). and_return(true) end @@ -292,6 +294,23 @@ expect(proofing_component.threatmetrix).to equal(true) expect(proofing_component.threatmetrix_review_status).to eq('pass') end + + context 'nil response body from ddp' do + let(:ddp_result) { Proofing::Result.new(response_body: nil) } + + before do + expect(ddp_proofer).to receive(:proof).and_return(ddp_result) + end + + it 'does not blow up' do + perform + + result = document_capture_session.load_proofing_result[:result] + + expect(result[:context][:stages][:threatmetrix][:response_body]). + to eq(error: 'TMx response body was empty') + end + end end context 'does not call state id with an unsuccessful response from the proofer' do