diff --git a/app/services/proofing/ddp_result.rb b/app/services/proofing/ddp_result.rb index d00e5e1109e..9670d570078 100644 --- a/app/services/proofing/ddp_result.rb +++ b/app/services/proofing/ddp_result.rb @@ -70,8 +70,16 @@ def to_h timed_out: timed_out?, transaction_id: transaction_id, review_status: review_status, - response_body: Proofing::LexisNexis::Ddp::ResponseRedacter.redact(response_body), + response_body: redacted_response_body, } end + + private + + def redacted_response_body + return response_body if response_body.blank? + + Proofing::LexisNexis::Ddp::ResponseRedacter.redact(response_body) + end end end diff --git a/spec/features/idv/analytics_spec.rb b/spec/features/idv/analytics_spec.rb index afc18f7c86b..b321848299e 100644 --- a/spec/features/idv/analytics_spec.rb +++ b/spec/features/idv/analytics_spec.rb @@ -771,7 +771,7 @@ timed_out: false, transaction_id: nil, review_status: 'pass', - response_body: { error: 'TMx response body was empty' } } + response_body: nil } end it 'records all of the events' do @@ -847,7 +847,7 @@ timed_out: false, transaction_id: nil, review_status: 'pass', - response_body: { error: 'TMx response body was empty' } } + response_body: nil } end it 'records all of the events' do @@ -892,7 +892,7 @@ timed_out: false, transaction_id: nil, review_status: 'pass', - response_body: { error: 'TMx response body was empty' } } + response_body: nil } end it 'records all of the events' do @@ -949,7 +949,7 @@ timed_out: false, transaction_id: nil, review_status: 'pass', - response_body: { error: 'TMx response body was empty' } } + response_body: nil } end it 'records all of the events', allow_browser_log: true do @@ -1019,7 +1019,7 @@ def wait_for_event(event, wait) timed_out: false, transaction_id: nil, review_status: 'pass', - response_body: { error: 'TMx response body was empty' } } + response_body: nil } end it 'records all of the events' do diff --git a/spec/services/proofing/ddp_result_spec.rb b/spec/services/proofing/ddp_result_spec.rb index ca358fde2db..d5f10950330 100644 --- a/spec/services/proofing/ddp_result_spec.rb +++ b/spec/services/proofing/ddp_result_spec.rb @@ -117,4 +117,31 @@ end end end + + describe '#to_h' do + context 'when response_body is present' do + it 'is redacted' do + response_body = { first_name: 'Jonny Proofs' } + result = Proofing::DdpResult.new(response_body:) + + expect(result.to_h[:response_body]).to eq({ first_name: '[redacted]' }) + end + end + + context 'when response_body is nil' do + it 'is nil' do + result = Proofing::DdpResult.new(response_body: nil) + + expect(result.to_h[:response_body]).to be_nil + end + end + + context 'when response_body is empty' do + it 'responds with an empty string is the response body is empty' do + result = Proofing::DdpResult.new(response_body: '') + + expect(result.to_h[:response_body]).to eq('') + end + end + end end