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
13 changes: 13 additions & 0 deletions spec/services/analytics_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,5 +195,18 @@
)
end.to_not raise_error
end

it 'does not alert when pii values are inside words' do
expect(ahoy).to receive(:track)

stub_const('DocAuth::Mock::ResultResponseBuilder::DEFAULT_PII_FROM_DOC', zipcode: '12345')

expect do
analytics.track_event(
'Trackable Event',
some_uuid: '12345678-1234-1234-1234-123456789012',
)
end.to_not raise_error
end
end
end
2 changes: 1 addition & 1 deletion spec/support/fake_analytics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def track_event(event, original_attributes = {})
:dob,
:state_id_number,
).each do |key, default_pii_value|
if string_payload.include?(default_pii_value)
if string_payload.match?(Regexp.new('\b' + Regexp.quote(default_pii_value) + '\b', 'i'))
raise PiiDetected, <<~ERROR
track_event example PII #{key} (#{default_pii_value}) detected in attributes
event: #{event} (#{constant_name})
Expand Down