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
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def parse_product_error_messages
return {} if products.nil?

products.each_with_object({}) do |product, error_messages|
next if product['ProductStatus'] == 'pass'
next unless should_log?(product)

# don't log PhoneFinder reflected PII
product.delete('ParameterDetails') if product['ProductType'] == 'PhoneFinder'
Expand All @@ -56,6 +56,13 @@ def parse_product_error_messages
error_messages[key] = product
end
end

def should_log?(product)
return true if product['ProductStatus'] != 'pass'
return true if product['ProductType'] == 'InstantVerify'
return true if product['Items']&.flat_map(&:keys)&.include?('ItemReason')
return false
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,29 @@
expect(errors[:Discovery]).to eq(nil) # This should be absent since it passed
expect(errors[:SomeOtherProduct]).to eq(response_body['Products'][1])
expect(errors[:InstantVerify]).to eq(response_body['Products'][2])
expect(errors[:'Execute Instant Verify']).to be_a Hash # log product error
end

it 'should not log a passing response containing no important information' do
response_body['Products'].first['ProductType'] = 'Fake Product'
response_body['Products'].first['ProductStatus'] = 'pass'
response_body['Products'].first['Items'].map { |i| i.delete('ItemReason') }

expect(errors[:'Execute Instant Verify']).to eq(nil)
end

it 'should log any Instant Verify response, including a pass' do
response_body['Products'].first['ProductStatus'] = 'pass'
response_body['Products'].first['Items'].map { |i| i.delete('ItemReason') }

expect(errors[:'Execute Instant Verify']).to be_a Hash
end

it 'should log any response with an ItemReason, including a pass' do
response_body['Products'].first['ProductType'] = 'Fake Product'
response_body['Products'].first['ProductStatus'] = 'pass'

expect(errors[:'Execute Instant Verify']).to be_a Hash
end
end
end