Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 9 additions & 1 deletion app/services/proofing/ddp_result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 5 additions & 5 deletions spec/features/idv/analytics_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions spec/services/proofing/ddp_result_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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