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
1 change: 1 addition & 0 deletions app/controllers/concerns/idv/document_capture_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def error_hash(message)
message: message || I18n.t('doc_auth.errors.general.network_error'),
socure: stored_result&.errors&.dig(:socure),
pii_validation: stored_result&.errors&.dig(:pii_validation),
unaccepted_id_type: stored_result&.errors&.dig(:unaccepted_id_type),
}
end

Expand Down
4 changes: 3 additions & 1 deletion app/controllers/concerns/idv/socure_errors_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ def remaining_attempts
end

def error_code_for(result)
if result.errors[:socure]
if result.errors[:unaccepted_id_type]
:unaccepted_id_type
elsif result.errors[:socure]
result.errors.dig(:socure, :reason_codes).first
elsif result.errors[:network]
:network
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/idv/socure/errors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ def socure_errors_presenter(error_code)
end

def error_code_for(result)
if result.errors[:socure]
if result.errors[:unaccepted_id_type]
:unaccepted_id_type
elsif result.errors[:socure]
result.errors.dig(:socure, :reason_codes).first
elsif result.errors[:network]
:network
Expand Down
4 changes: 4 additions & 0 deletions app/presenters/socure_error_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ def heading_string_for(error_code)
t('doc_auth.headers.general.network_error')
when :timeout, :url_not_found
t('idv.errors.technical_difficulties')
when :unaccepted_id_type
t('doc_auth.headers.unaccepted_id_type')
else
# i18n-tasks-use t('doc_auth.headers.unreadable_id')
# i18n-tasks-use t('doc_auth.headers.unaccepted_id_type')
Expand All @@ -161,6 +163,8 @@ def error_string_for(error_code)
t('doc_auth.errors.general.new_network_error')
when :timeout, :url_not_found
t('idv.errors.try_again_later')
when :unaccepted_id_type
t('doc_auth.errors.unaccepted_id_type')
else
if remapped_error(error_code) == 'underage' # special handling because it says 'Login.gov'
I18n.t('doc_auth.errors.underage', app_name: APP_NAME)
Expand Down
23 changes: 16 additions & 7 deletions app/services/doc_auth/socure/responses/docv_result_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def initialize(http_response:,
@pii_from_doc = read_pii

super(
success: successful_result?,
success: doc_auth_success?,
errors: error_messages,
pii_from_doc:,
extra: extra_attributes,
Expand All @@ -62,7 +62,7 @@ def initialize(http_response:,
end

def doc_auth_success?
success?
id_type_supported? && successful_result?
end

def selfie_status
Expand All @@ -80,11 +80,11 @@ def extra_attributes
reason_codes: get_data(DATA_PATHS[:reason_codes]),
document_type: get_data(DATA_PATHS[:document_type]),
state: state,
state_id_type: state_id_type,
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.

👍

state_id_type:,
flow_path: nil,
liveness_checking_required: @biometric_comparison_required,
issue_year: state_id_issued&.year,
doc_auth_success: successful_result?,
doc_auth_success: doc_auth_success?,
vendor: 'Socure', # TODO: Replace with Idp::Constants::Vendors::SOCURE
address_line2_present: address2.present?,
zip_code: zipcode,
Expand All @@ -100,7 +100,9 @@ def successful_result?
end

def error_messages
if !successful_result?
if !id_type_supported?
{ unaccepted_id_type: true }
elsif !successful_result?
{ socure: { reason_codes: get_data(DATA_PATHS[:reason_codes]) } }
else
{}
Expand Down Expand Up @@ -159,8 +161,11 @@ def state_id_issued
end

def state_id_type
type = get_data(DATA_PATHS[:id_type])
type&.gsub(/\W/, '')&.underscore
document_id_type&.gsub(/\W/, '')&.underscore
end

def document_id_type
get_data(DATA_PATHS[:id_type])
end

def dob
Expand All @@ -180,6 +185,10 @@ def parse_date(date_string)
Rails.logger.info(message)
nil
end

def id_type_supported?
DocAuth::Response::ID_TYPE_SLUGS.key?(document_id_type)
end
end
end
end
Expand Down
21 changes: 21 additions & 0 deletions spec/features/idv/doc_auth/socure_document_capture_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,27 @@
end
end
end

context 'not accepted id type' do
it 'displays unaccepdted id type error message' do
body = JSON.parse(SocureDocvFixtures.pass_json)
body['documentVerification']['documentType']['type'] = 'Passport'

remove_request_stub(@pass_stub)
stub_docv_verification_data(
docv_transaction_token: @docv_transaction_token,
body: body.to_json,
)

socure_docv_upload_documents(
docv_transaction_token: @docv_transaction_token,
)
visit idv_socure_document_capture_update_path

expect(page).to have_content(t('doc_auth.headers.unaccepted_id_type'))
expect(page).to have_content(t('doc_auth.errors.unaccepted_id_type'))
end
end
end

context 'standard mobile flow' do
Expand Down
49 changes: 49 additions & 0 deletions spec/features/idv/hybrid_mobile/hybrid_socure_mobile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,55 @@
end
end
end

context 'invalid ID type' do
it 'presents as an unaccepted ID type error', js: true do
user = nil

perform_in_browser(:desktop) do
visit_idp_from_sp_with_ial2(sp)
user = sign_up_and_2fa_ial1_user

complete_doc_auth_steps_before_hybrid_handoff_step
clear_and_fill_in(:doc_auth_phone, phone_number)
click_send_link

expect(page).to have_content(t('doc_auth.headings.text_message'))
expect(page).to have_content(t('doc_auth.info.you_entered'))
expect(page).to have_content('+1 415-555-0199')

# Confirm that Continue button is not shown when polling is enabled
expect(page).not_to have_content(t('doc_auth.buttons.continue'))
end

expect(@sms_link).to be_present

perform_in_browser(:mobile) do
visit @sms_link

body = JSON.parse(SocureDocvFixtures.pass_json)
body['documentVerification']['documentType']['type'] = 'Passport'
remove_request_stub(@pass_stub)
stub_docv_verification_data(
docv_transaction_token: @docv_transaction_token,
body: body.to_json,
)

click_idv_continue

socure_docv_upload_documents(docv_transaction_token: @docv_transaction_token)

visit idv_hybrid_mobile_socure_document_capture_update_url

expect(page).to have_content(t('doc_auth.headers.unaccepted_id_type'))
expect(page).to have_content(t('doc_auth.errors.unaccepted_id_type'))
end

perform_in_browser(:desktop) do
expect(page).to have_current_path(idv_link_sent_path)
end
end
end
end

shared_examples 'a properly categorized Socure error' do |socure_error_code, expected_header_key|
Expand Down
19 changes: 17 additions & 2 deletions spec/jobs/socure_docv_results_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
let(:socure_idplus_base_url) { 'https://example.com' }
let(:decision_value) { 'accept' }
let(:expiration_date) { "#{1.year.from_now.year}-01-01" }
let(:document_type_type) { 'Drivers License' }

before do
allow(IdentityConfig.store).to receive(:socure_idplus_base_url)
Expand All @@ -40,7 +41,7 @@
documentVerification: {
reasonCodes: %w[I831 R810],
documentType: {
type: 'Drivers License',
type: document_type_type,
country: 'USA',
state: 'NY',
},
Expand Down Expand Up @@ -85,7 +86,7 @@
zip_code: '10001',
doc_auth_success: true,
document_type: {
type: 'Drivers License',
type: document_type_type,
country: 'USA',
state: 'NY',
},
Expand Down Expand Up @@ -114,6 +115,20 @@
expect(document_capture_session_result.selfie_status).to eq(:not_processed)
end

context 'not accepted document type' do
let(:document_type_type) { 'Passport' }
it 'doc auth fails' do
perform

document_capture_session.reload
document_capture_session_result = document_capture_session.load_result
expect(document_capture_session_result.success).to eq(false)
expect(document_capture_session_result.pii[:first_name]).to eq('Dwayne')
expect(document_capture_session_result.attention_with_barcode).to eq(false)
expect(document_capture_session_result.doc_auth_success).to eq(false)
expect(document_capture_session_result.selfie_status).to eq(:not_processed)
end
end
context 'Socure returns an error' do
let(:status) { 'Error' }
let(:referenceId) { '360ae43f-123f-47ab-8e05-6af79752e76c' }
Expand Down