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
15 changes: 3 additions & 12 deletions app/services/doc_auth/error_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,19 +211,10 @@ def get_selfie_error(liveness_enabled, response_info)
return nil
end

# Error when the image on the id does not match the selfie image, but the image was acceptable
if error_is_success(face_match_error)
return Errors::SELFIE_FAILURE
if error_is_poor_quality(face_match_error) || error_is_not_live(face_match_error)
return Errors::SELFIE_NOT_LIVE_OR_POOR_QUALITY
end
# Error when the image on the id is poor quality
if error_is_poor_quality(face_match_error)
return Errors::SELFIE_POOR_QUALITY
end
# Error when the image on the id is not live
if error_is_not_live(face_match_error)
return Errors::SELFIE_NOT_LIVE
end
# Fallback, we don't expect this to happen

Errors::SELFIE_FAILURE
end
end
Expand Down
6 changes: 2 additions & 4 deletions app/services/doc_auth/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ module Errors
MULTIPLE_FRONT_ID_FAILURES = 'multiple_front_id_failures'
REF_CONTROL_NUMBER_CHECK = 'ref_control_number_check'
SELFIE_FAILURE = 'selfie_failure'
SELFIE_NOT_LIVE = 'selfie_not_live'
SELFIE_POOR_QUALITY = 'selfie_poor_quality'
SELFIE_NOT_LIVE_OR_POOR_QUALITY = 'selfie_not_live_or_poor_quality'
SEX_CHECK = 'sex_check'
VISIBLE_COLOR_CHECK = 'visible_color_check'
VISIBLE_PHOTO_CHECK = 'visible_photo_check'
Expand Down Expand Up @@ -124,8 +123,7 @@ module Errors
# Selfie errors
GENERAL_ERROR_LIVENESS => { long_msg: GENERAL_ERROR_LIVENESS, field_msg: FALLBACK_FIELD_LEVEL, hints: false },
SELFIE_FAILURE => { long_msg: SELFIE_FAILURE, field_msg: SELFIE_FAILURE, hints: false },
SELFIE_NOT_LIVE => { long_msg: SELFIE_NOT_LIVE, field_msg: SELFIE_FAILURE, hints: false },
SELFIE_POOR_QUALITY => { long_msg: SELFIE_POOR_QUALITY, field_msg: SELFIE_FAILURE, hints: false },
SELFIE_NOT_LIVE_OR_POOR_QUALITY => { long_msg: SELFIE_NOT_LIVE_OR_POOR_QUALITY, field_msg: SELFIE_FAILURE, hints: false },
}.transform_values(&:freeze).freeze
# rubocop:enable Layout/LineLength
end
Expand Down
12 changes: 4 additions & 8 deletions app/services/doc_auth/selfie_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,16 @@ module SelfieConcern
extend ActiveSupport::Concern
def selfie_live?
portrait_error = get_portrait_error(portrait_match_results)
return true if portrait_error.nil? || portrait_error.blank?
return true if portrait_error.blank?
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.

TIL blank includes nil!

!error_is_not_live(portrait_error)
end

def selfie_quality_good?
portrait_error = get_portrait_error(portrait_match_results)
return true if portrait_error.nil? || portrait_error.blank?
return true if portrait_error.blank?
!error_is_poor_quality(portrait_error)
end

def error_is_success(error_message)
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.

this method name was very confusing

error_message == ERROR_TEXTS[:success]
end

def error_is_not_live(error_message)
error_message == ERROR_TEXTS[:not_live]
end
Expand All @@ -31,7 +27,7 @@ def selfie_check_performed?
SELFIE_PERFORMED_STATUSES.include?(selfie_status)
end

private
private

SELFIE_PERFORMED_STATUSES = %i[success fail].freeze

Expand All @@ -45,5 +41,5 @@ def selfie_check_performed?
def get_portrait_error(portrait_match_results)
portrait_match_results&.with_indifferent_access&.dig(:FaceErrorMessage)
end
end
end
end
7 changes: 3 additions & 4 deletions app/services/doc_auth_router.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,9 @@ module DocAuthRouter
'doc_auth.errors.alerts.ref_control_number_check',
# i18n-tasks-use t('doc_auth.errors.general.selfie_failure')
DocAuth::Errors::SELFIE_FAILURE => 'doc_auth.errors.general.selfie_failure',
# i18n-tasks-use t('doc_auth.errors.alerts.selfie_not_live')
DocAuth::Errors::SELFIE_NOT_LIVE => 'doc_auth.errors.alerts.selfie_not_live',
# i18n-tasks-use t('doc_auth.errors.alerts.selfie_poor_quality')
DocAuth::Errors::SELFIE_POOR_QUALITY => 'doc_auth.errors.alerts.selfie_poor_quality',
# i18n-tasks-use t('doc_auth.errors.alerts.selfie_not_live_or_poor_quality')
DocAuth::Errors::SELFIE_NOT_LIVE_OR_POOR_QUALITY =>
'doc_auth.errors.alerts.selfie_not_live_or_poor_quality',
# i18n-tasks-use t('doc_auth.errors.alerts.sex_check')
DocAuth::Errors::SEX_CHECK => 'doc_auth.errors.alerts.sex_check',
# i18n-tasks-use t('doc_auth.errors.alerts.visible_color_check')
Expand Down
6 changes: 2 additions & 4 deletions config/locales/doc_auth/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@ en:
the picture. Try taking new pictures.
issue_date_checks: We couldn’t read the issue date on your ID. Try taking new pictures.
ref_control_number_check: We couldn’t read the control number barcode. Try taking new pictures.
selfie_not_live: Try taking a photo of yourself again. Make sure your whole face
is clear and visible in the photo.
selfie_not_live_help_link_text: Review more tips for taking a clear photo of yourself
selfie_poor_quality: 'Try taking a photo of yourself again. Make sure your whole
face is clear and visible in the photo.'
selfie_not_live_or_poor_quality: 'Try taking a photo of yourself again. Make
sure your whole face is clear and visible in the photo.'
sex_check: We couldn’t read the sex on your ID. Try taking new pictures.
visible_color_check: We couldn’t verify your ID. It might have moved when you
took the picture, or the picture is too dark. Try taking new pictures
Expand Down
6 changes: 2 additions & 4 deletions config/locales/doc_auth/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,9 @@ es:
identidad. Intente tomar nuevas fotos.
ref_control_number_check: No pudimos leer el código de barras del número de
control. Intente tomar nuevas fotografías.
selfie_not_live: Intente tomar de nuevo una foto de usted. Asegúrese de que su
rostro se vea claramente en la foto.
selfie_not_live_help_link_text: Consulte más consejos para tomar una foto clara de usted mismo
selfie_poor_quality: 'Intente tomar de nuevo una foto de usted. Asegúrese de que
su rostro se vea claramente en la foto.'
selfie_not_live_or_poor_quality: Intente tomar de nuevo una foto de usted.
Asegúrese de que su rostro se vea claramente en la foto.
sex_check: No pudimos leer el sexo en su documento de identidad. Intente tomar
nuevas fotos.
visible_color_check: No pudimos verificar su documento de identidad. Puede que
Expand Down
9 changes: 3 additions & 6 deletions config/locales/doc_auth/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,10 @@ fr:
d’identité. Essayez de prendre de nouvelles photos.
ref_control_number_check: Nous n’avons pas pu lire le code-barres du numéro de
contrôle. Essayez de prendre de nouvelles photos.
selfie_not_live: Essayez de prendre une nouvelle photo de vous-même.
Assurez-vous que l’ensemble de votre visage soit clair et visible sur
la photo.
selfie_not_live_help_link_text: Consultez plus de conseils pour prendre une photo claire de vous-même
selfie_poor_quality: 'Essayez de prendre une nouvelle photo de vous-même.
Assurez-vous que l’ensemble de votre visage soit clair et visible sur
la photo.'
selfie_not_live_or_poor_quality: Essayez de prendre une nouvelle photo de
vous-même. Assurez-vous que l’ensemble de votre visage soit clair et
visible sur la photo.
sex_check: Nous n’avons pas pu lire le sexe sur votre pièce d’identité. Essayez
de prendre de nouvelles photos.
visible_color_check: Nous n’avons pas pu vérifier votre pièce d’identité. Elle a
Expand Down
6 changes: 2 additions & 4 deletions config/locales/doc_auth/zh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ zh:
id_not_verified: 我们无法验证你的身份证件。可能因为你拍照时身份证件移动了。尝试重拍。
issue_date_checks: 我们读取不到你身份证件上的颁发日期。尝试重拍。
ref_control_number_check: 我们读取不到控制号码条码。尝试重拍。
selfie_not_live: Try taking a photo of yourself again. Make sure your whole face
is clear and visible in the photo.
selfie_not_live_help_link_text: Review more tips for taking a clear photo of yourself
selfie_poor_quality: Try taking a photo of yourself again. Make sure your whole
face is clear and visible in the photo.
selfie_not_live_or_poor_quality: Try taking a photo of yourself again. Make sure
your whole face is clear and visible in the photo.
sex_check: 我们读取不到你身份证件上的性别。尝试重拍。
visible_color_check: 我们无法验证你的身份证件。可能你拍照时身份证件移动了,或者照片太暗。尝试在亮一点的灯光下重拍。
visible_photo_check: 我们无法验证你身份证件上的照片。尝试重拍。
Expand Down
14 changes: 9 additions & 5 deletions spec/features/idv/doc_auth/document_capture_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,9 @@
)
expect(page).to have_content(h1_error_message)

body_error_message = strip_tags(t('doc_auth.errors.alerts.selfie_not_live'))
body_error_message = strip_tags(
t('doc_auth.errors.alerts.selfie_not_live_or_poor_quality'),
)
expect(page).to have_content(body_error_message)

click_try_again
Expand Down Expand Up @@ -571,7 +573,9 @@
)
expect(page).to have_content(h1_error_message)

body_error_message = strip_tags(t('doc_auth.errors.alerts.selfie_not_live'))
body_error_message = strip_tags(
t('doc_auth.errors.alerts.selfie_not_live_or_poor_quality'),
)
expect(page).to have_content(body_error_message)

click_try_again
Expand Down Expand Up @@ -667,7 +671,7 @@
submit_images
message = strip_tags(t('errors.doc_auth.selfie_not_live_or_poor_quality_heading'))
expect(page).to have_content(message)
detail_message = strip_tags(t('doc_auth.errors.alerts.selfie_not_live'))
detail_message = strip_tags(t('doc_auth.errors.alerts.selfie_not_live_or_poor_quality'))
security_message = strip_tags(
t(
'idv.warning.attempts_html',
Expand Down Expand Up @@ -705,7 +709,7 @@
submit_images
message = strip_tags(t('errors.doc_auth.selfie_not_live_or_poor_quality_heading'))
expect(page).to have_content(message)
detail_message = strip_tags(t('doc_auth.errors.alerts.selfie_poor_quality'))
detail_message = strip_tags(t('doc_auth.errors.alerts.selfie_not_live_or_poor_quality'))
security_message = strip_tags(
t(
'idv.warning.attempts_html',
Expand Down Expand Up @@ -782,7 +786,7 @@
submit_images
message = strip_tags(t('errors.doc_auth.selfie_not_live_or_poor_quality_heading'))
expect(page).to have_content(message)
detail_message = strip_tags(t('doc_auth.errors.alerts.selfie_not_live'))
detail_message = strip_tags(t('doc_auth.errors.alerts.selfie_not_live_or_poor_quality'))
security_message = strip_tags(
t(
'idv.warning.attempts_html',
Expand Down
16 changes: 8 additions & 8 deletions spec/features/idv/doc_auth/redo_document_capture_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
end
end

shared_examples_for 'selfie image re-upload not allowed' do
shared_examples_for 'document and selfie images re-upload not allowed' do
it 'stops user submitting the same images again' do
expect(fake_analytics).to have_logged_event(
'IdV: doc auth document_capture visited',
Expand Down Expand Up @@ -240,7 +240,7 @@
end

context 'when selfie is enabled' do
context 'error due to data issue with 2xx status code', allow_browser_log: true do
context 'when doc auth is success and face match fails (2xx)', allow_browser_log: true do
before do
expect(FeatureManagement).to receive(:idv_allow_selfie_check?).at_least(:once).
and_return(true)
Expand All @@ -257,14 +257,14 @@
sleep(10)
end

it_behaves_like 'selfie image re-upload not allowed'
it_behaves_like 'document and selfie images re-upload not allowed'

it 'shows current existing header' do
expect_doc_capture_page_header(t('doc_auth.headings.review_issues'))
end
end

context 'when doc auth is success and portrait match fails', allow_browser_log: true do
context 'when doc auth passes and portrait match is not live', allow_browser_log: true do
before do
expect(FeatureManagement).to receive(:idv_allow_selfie_check?).at_least(:once).
and_return(true)
Expand All @@ -273,7 +273,7 @@
start_idv_from_sp(biometric_comparison_required: true)
sign_in_and_2fa_user
complete_doc_auth_steps_before_document_capture_step
mock_doc_auth_success_face_match_fail
mock_doc_auth_pass_and_portrait_match_not_live
attach_images
attach_selfie
submit_images
Expand Down Expand Up @@ -307,7 +307,7 @@
expect(page).to have_css(
'.usa-error-message[role="alert"]',
text: t('doc_auth.errors.doc.resubmit_failed_image'),
count: 3,
count: 1,
)
end
end
Expand Down Expand Up @@ -368,15 +368,15 @@
start_idv_from_sp(biometric_comparison_required: true)
sign_in_and_2fa_user
complete_doc_auth_steps_before_document_capture_step
mock_doc_auth_success_face_match_fail
mock_doc_auth_fail_face_match_fail
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.

nice catch!

attach_images
attach_selfie
submit_images
click_try_again
sleep(10)
end

it_behaves_like 'selfie image re-upload not allowed'
it_behaves_like 'document and selfie images re-upload not allowed'
end

context 'when pii validation fails', allow_browser_log: true do
Expand Down
Loading