From af0c589d82849b5b6f69a6c85caf8c8023cf5746 Mon Sep 17 00:00:00 2001 From: Jonathan Hooper Date: Mon, 13 Jan 2025 12:10:04 -0500 Subject: [PATCH] Account for a space in the height returned by TrueID The regex we used to read the height from a TrueID response did not account for a space that may appear between feet and inches. As a result height values like `5' 11"` were not read. This commit updates the regex to fix that. changelog: Internal, TrueID, Regex to parse the height from documents was adjusted --- .../doc_auth/lexis_nexis/doc_pii_reader.rb | 2 +- .../responses/true_id_response_spec.rb | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/services/doc_auth/lexis_nexis/doc_pii_reader.rb b/app/services/doc_auth/lexis_nexis/doc_pii_reader.rb index 0c6e5b2556b..26e172491fc 100644 --- a/app/services/doc_auth/lexis_nexis/doc_pii_reader.rb +++ b/app/services/doc_auth/lexis_nexis/doc_pii_reader.rb @@ -106,7 +106,7 @@ def parse_sex_value(sex_attribute) end def parse_height_value(height_attribute) - height_match_data = height_attribute&.match(/(?\d)'(?\d{1,2})"/) + height_match_data = height_attribute&.match(/(?\d)' ?(?\d{1,2})"/) return unless height_match_data diff --git a/spec/services/doc_auth/lexis_nexis/responses/true_id_response_spec.rb b/spec/services/doc_auth/lexis_nexis/responses/true_id_response_spec.rb index 16cf8f0af3a..51d3608784f 100644 --- a/spec/services/doc_auth/lexis_nexis/responses/true_id_response_spec.rb +++ b/spec/services/doc_auth/lexis_nexis/responses/true_id_response_spec.rb @@ -251,12 +251,14 @@ 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 + before do allow(IdentityConfig.store).to receive(:doc_auth_read_additional_pii_attributes_enabled) .and_return(true) + end + + let(:success_response_body) { LexisNexisFixtures.true_id_response_success } + it 'reads the additional PII attributes' do pii_from_doc = response.pii_from_doc expect(pii_from_doc.first_name).to eq('LICENSE') @@ -264,6 +266,17 @@ expect(pii_from_doc.sex).to eq('male') expect(pii_from_doc.height).to eq(68) end + + context 'when the height has a space in it' do + # This fixture has the height returns as "5' 9\"" + let(:success_response_body) { LexisNexisFixtures.true_id_response_success_3 } + + it 'reads parses the height correctly' do + pii_from_doc = response.pii_from_doc + + expect(pii_from_doc.height).to eq(69) + end + end end end