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
42 changes: 41 additions & 1 deletion app/services/doc_auth/lexis_nexis/doc_pii_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def read_pii(true_id_product)
state_id_type_slug = id_auth_field_data['Fields_DocumentClassName']
state_id_type = DocAuth::Response::ID_TYPE_SLUGS[state_id_type_slug]

Pii::StateId.new(
state_id_data = Pii::StateId.new(
first_name: id_auth_field_data['Fields_FirstName'],
last_name: id_auth_field_data['Fields_Surname'],
middle_name: id_auth_field_data['Fields_MiddleName'],
Expand Down Expand Up @@ -61,6 +61,16 @@ def read_pii(true_id_product)
state_id_type: state_id_type,
issuing_country_code: id_auth_field_data['Fields_CountryCode'],
)

if IdentityConfig.store.doc_auth_read_additional_pii_attributes_enabled
state_id_data = state_id_data.with(
name_suffix: id_auth_field_data['Fields_NameSuffix'],
sex: parse_sex_value(id_auth_field_data['Fields_Sex']),
height: parse_height_value(id_auth_field_data['Fields_Height']),
)
end

state_id_data
end

def parse_date(year:, month:, day:)
Expand All @@ -72,6 +82,36 @@ def parse_date(year:, month:, day:)
Rails.logger.info(message)
nil
end

def parse_sex_value(sex_attribute)
# A value of "non-binary" or "not-specified" may appear on a document. However, at this time
# the DLDV `PersonSexCode` input can only process values that correspond to "male" or
# "female".
#
# From the DLDV User Guide Version 2.1 - 28:
#
# Since 2017, a growing number of states have allowed a person to select "not specified"
# or "non-binary" for their sex on the application for a credential. While Male and
# Female can be verified, the non-binary value cannot be verified at this time.
#
# This code will return `nil` for those cases with the intent that they will not be verified
# against the DLDV where they will not be recognized
#
case sex_attribute&.upcase
when 'M'
'male'
when 'F'
'female'
end
end

def parse_height_value(height_attribute)
height_match_data = height_attribute&.match(/(?<feet>\d)'(?<inches>\d{1,2})"/)
Comment thread
jmhooper marked this conversation as resolved.

return unless height_match_data

height_match_data[:feet].to_i * 12 + height_match_data[:inches].to_i
end
end
end
end
1 change: 1 addition & 0 deletions config/application.yml.default
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ doc_auth_error_sharpness_threshold: 40
doc_auth_max_attempts: 5
doc_auth_max_capture_attempts_before_native_camera: 3
doc_auth_max_submission_attempts_before_native_camera: 3
doc_auth_read_additional_pii_attributes_enabled: false
doc_auth_selfie_desktop_test_mode: false
doc_auth_socure_wait_polling_refresh_max_seconds: 15
doc_auth_socure_wait_polling_timeout_minutes: 2
Expand Down
1 change: 1 addition & 0 deletions lib/identity_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def self.store
config.add(:doc_auth_max_attempts, type: :integer)
config.add(:doc_auth_max_capture_attempts_before_native_camera, type: :integer)
config.add(:doc_auth_max_submission_attempts_before_native_camera, type: :integer)
config.add(:doc_auth_read_additional_pii_attributes_enabled, type: :boolean)
config.add(:doc_auth_selfie_desktop_test_mode, type: :boolean)
config.add(:doc_auth_socure_wait_polling_refresh_max_seconds, type: :integer)
config.add(:doc_auth_socure_wait_polling_timeout_minutes, type: :integer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,22 @@
expect(response.success?).to eq(false)
end
end

context 'when doc_auth_read_additional_pii_attributes_enabled is enabled' do
let(:success_response_body) { LexisNexisFixtures.true_id_response_success }

it 'reads the additional PII attributes' do
allow(IdentityConfig.store).to receive(:doc_auth_read_additional_pii_attributes_enabled).
and_return(true)

pii_from_doc = response.pii_from_doc

expect(pii_from_doc.first_name).to eq('LICENSE')
Comment thread
jmhooper marked this conversation as resolved.
expect(pii_from_doc.name_suffix).to eq('JR')
expect(pii_from_doc.sex).to eq('male')
expect(pii_from_doc.height).to eq(68)
end
end
end

context 'when there is no address line 2' do
Expand Down