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
23 changes: 23 additions & 0 deletions app/services/doc_auth/lexis_nexis/responses/true_id_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ def billed?
!!doc_auth_result
end

def doc_type_supported?
!doc_class_name.present? || ID_TYPE_SLUGS.key?(doc_class_name) ||
doc_class_name == 'Unknown'
end

private

def response_info
Expand All @@ -147,6 +152,7 @@ def create_response_info
portrait_match_results: true_id_product[:PORTRAIT_MATCH_RESULT],
image_metrics: parse_image_metrics,
address_line2_present: !pii_from_doc[:address2].blank?,
classification_info: classification_info,
}
end

Expand Down Expand Up @@ -182,6 +188,23 @@ def doc_auth_result_unknown?
doc_auth_result == 'Unknown'
end

def doc_class_name
true_id_product&.dig(:AUTHENTICATION_RESULT, :DocClassName)
end

def classification_info
# Acuent response has both sides info, here simulate that
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Acuant.

doc_class = doc_class_name
{
Front: {
ClassName: doc_class,
},
Back: {
ClassName: doc_class,
},
}
end

def doc_auth_result
true_id_product&.dig(:AUTHENTICATION_RESULT, :DocAuthResult)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,25 @@
'DocIssueType' => "Driver's License - STAR",
'OrientationChanged' => 'true',
'PresentationChanged' => 'false',
classification_info: {
Front: {
ClassName: 'Drivers License',
},
Back: {
ClassName: 'Drivers License',
},
},
)
end

it 'notes that address line 2 was present' do
expect(response.pii_from_doc).to include(address2: 'APT 3E')
expect(response.to_h).to include(address_line2_present: true)
end

it 'mark doc type as supported' do
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a plan to add a test for when a non-supported doc type is submitted (or maybe it exists already)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@night-jellyfish, the same logic tested somewhere else, but adding the test anyway.

expect(response.doc_type_supported?).to eq(true)
end
end

context 'when there is no address line 2' do
Expand Down Expand Up @@ -312,6 +324,14 @@ def get_decision_product(resp)
'DocIsGeneric' => 'false',
'OrientationChanged' => 'false',
'PresentationChanged' => 'false',
classification_info: {
Front: {
ClassName: 'Drivers License',
},
Back: {
ClassName: 'Drivers License',
},
},
)
end
end
Expand Down Expand Up @@ -470,4 +490,35 @@ def get_decision_product(resp)
it { is_expected.to eq(true) }
end
end

describe '#doc_type_supported?' do
let(:doc_class_name) { 'Drivers License' }
let(:success_response) do
response = JSON.parse(LexisNexisFixtures.true_id_response_success_2).tap do |json|
doc_class_node = json['Products'].first['ParameterDetails'].
select { |f| f['Name'] == 'DocClassName' }
doc_class_node.first['Values'].first['Value'] = doc_class_name
end.to_json
instance_double(Faraday::Response, status: 200, body: response)
end

subject(:doc_type_supported?) do
described_class.new(success_response, config).doc_type_supported?
end
it { is_expected.to eq(true) }

context 'when doc class is unknown' do
let(:doc_class_name) { 'Unknown' }
it 'identified as supported doc type ' do
is_expected.to eq(true)
end
end

context 'when doc class is identified but not supported' do
let(:doc_class_name) { 'Passport' }
it 'identified as un supported doc type ' do
is_expected.to eq(false)
end
end
end
end