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
6 changes: 4 additions & 2 deletions app/controllers/idv/verify_info_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module Idv
class VerifyInfoController < ApplicationController
include StringRedacter
include IdvSession

before_action :render_404_if_verify_info_controller_disabled
Expand Down Expand Up @@ -309,7 +308,10 @@ def idv_result_to_form_response(
if state_id
state_id[:state] = state if state
state_id[:state_id_jurisdiction] = state_id_jurisdiction if state_id_jurisdiction
state_id[:state_id_number] = redact_alphanumeric(state_id_number) if state_id_number
if state_id_number
state_id[:state_id_number] =
StringRedacter.redact_alphanumeric(state_id_number)
end
end

FormResponse.new(
Expand Down
6 changes: 1 addition & 5 deletions app/forms/new_phone_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def phone_info
@phone_info = Telephony::PhoneNumberInfo.new(type: :unknown)
rescue Aws::Pinpoint::Errors::BadRequestException
errors.add(:phone, :improbable_phone, type: :improbable_phone)
@redacted_phone = redact(phone)
@redacted_phone = StringRedacter.redact_alphanumeric(phone)
@phone_info = Telephony::PhoneNumberInfo.new(type: :unknown)
end

Expand Down Expand Up @@ -139,10 +139,6 @@ def ingest_submitted_params(params)
self.otp_make_default_number = true if default_prefs
end

def redact(phone)
phone.gsub(/[a-z]/i, 'X').gsub(/\d/i, '#')
end

def confirmed_phone?
false
end
Expand Down
9 changes: 4 additions & 5 deletions app/services/idv/steps/verify_base_step.rb
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,10 @@ def idv_result_to_form_response(
if state_id
state_id[:state] = state if state
state_id[:state_id_jurisdiction] = state_id_jurisdiction if state_id_jurisdiction
state_id[:state_id_number] = redact(state_id_number) if state_id_number
if state_id_number
state_id[:state_id_number] =
StringRedacter.redact_alphanumeric(state_id_number)
end
end
FormResponse.new(
success: idv_success(result),
Expand All @@ -305,10 +308,6 @@ def idv_result_to_form_response(
)
end

def redact(text)
text.gsub(/[a-z]/i, 'X').gsub(/\d/i, '#')
end

def log_idv_verification_submitted_event(success: false, failure_reason: nil)
pii_from_doc = pii || {}
@flow.irs_attempts_api_tracker.idv_verification_submitted(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module StringRedacter
extend ActiveSupport::Concern
module_function

def redact_alphanumeric(text)
text.gsub(/[a-z]/i, 'X').gsub(/\d/i, '#')
Expand Down
6 changes: 0 additions & 6 deletions spec/forms/new_phone_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,4 @@
end
end
end

describe '#redact' do
it 'leaves in punctuation and spaces, but removes letters and numbers' do
expect(form.send(:redact, '+11 (555) DEF-1234')).to eq('+## (###) XXX-####')
end
end
end
10 changes: 10 additions & 0 deletions spec/services/string_redacter_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require 'rails_helper'

describe 'StringRedacter' do
describe '#redact_alphanumeric' do
it 'leaves in punctuation and spaces, but removes letters and numbers' do
expect(StringRedacter.redact_alphanumeric('+11 (555) DEF-1234')).
to eq('+## (###) XXX-####')
end
end
end