From 3a10561dfd4f1aee0058fad90f820ccf553bfdb5 Mon Sep 17 00:00:00 2001 From: Jonathan Hooper Date: Thu, 27 Oct 2022 12:56:57 -0400 Subject: [PATCH 1/3] Remove that last few selfie references in the error generator We are removing IAL2 strict and selfie match functionality. This commit cleans up the last references to the selfie match portions of the `ErrorGenerator`. The `ErrorGenerator` produces a takes the reponse and ultimately generates an errors hash data structure which can be used to render errors to the user on specific images (e.g. the front, back, selfie, or entire ID). This commit removes the code that covered special cases for selfie failures. [skip changelog] --- app/services/doc_auth/error_generator.rb | 13 +--- .../services/doc_auth/error_generator_spec.rb | 65 +------------------ 2 files changed, 5 insertions(+), 73 deletions(-) diff --git a/app/services/doc_auth/error_generator.rb b/app/services/doc_auth/error_generator.rb index be30f013897..828fa833a1d 100644 --- a/app/services/doc_auth/error_generator.rb +++ b/app/services/doc_auth/error_generator.rb @@ -12,14 +12,12 @@ def initialize(config) ID = :id FRONT = :front BACK = :back - SELFIE = :selfie GENERAL = :general ERROR_KEYS = [ ID, FRONT, BACK, - SELFIE, GENERAL, ].to_set.freeze @@ -50,7 +48,6 @@ def initialize(config) }.freeze def generate_doc_auth_errors(response_info) - liveness_enabled = response_info[:liveness_enabled] alert_error_count = response_info[:doc_auth_result] == 'Passed' ? 0 : response_info[:alert_failure_count] @@ -60,8 +57,7 @@ def generate_doc_auth_errors(response_info) image_metric_errors = get_image_metric_errors(response_info[:image_metrics]) return image_metric_errors.to_h unless image_metric_errors.empty? - alert_errors = get_error_messages(liveness_enabled, response_info) - alert_error_count += 1 if alert_errors.include?(SELFIE) + alert_errors = get_error_messages(response_info) error = '' side = nil @@ -145,7 +141,7 @@ def get_image_metric_errors(processed_image_metrics) error_result end - def get_error_messages(liveness_enabled, response_info) + def get_error_messages(response_info) errors = Hash.new { |hash, key| hash[key] = Set.new } if response_info[:doc_auth_result] != 'Passed' @@ -159,11 +155,6 @@ def get_error_messages(liveness_enabled, response_info) end end - portrait_match_results = response_info[:portrait_match_results] || {} - if liveness_enabled && portrait_match_results.dig(:FaceMatchResult) != 'Pass' - errors[SELFIE] << Errors::SELFIE_FAILURE - end - errors end diff --git a/spec/services/doc_auth/error_generator_spec.rb b/spec/services/doc_auth/error_generator_spec.rb index c7310ad1976..795700dec2b 100644 --- a/spec/services/doc_auth/error_generator_spec.rb +++ b/spec/services/doc_auth/error_generator_spec.rb @@ -13,13 +13,12 @@ def build_error_info( doc_result: nil, passed: [], failed: [], - liveness_result: nil, image_metrics: {} ) { conversation_id: 31000406181234, reference: 'Reference1', - liveness_enabled: liveness_result.present? ? true : false, + liveness_enabled: false, vendor: 'Test', transaction_reason_code: 'testing', doc_auth_result: doc_result, @@ -28,12 +27,12 @@ def build_error_info( failed: failed, }, alert_failure_count: failed&.count.to_i, - portrait_match_results: { FaceMatchResult: liveness_result }, + portrait_match_results: { FaceMatchResult: 'Pass' }, image_metrics: image_metrics, } end - context 'The correct errors are delivered with liveness off when' do + context 'The correct errors are delivered when' do it 'DocAuthResult is Attention' do error_info = build_error_info( doc_result: 'Attention', @@ -206,64 +205,6 @@ def build_error_info( end end - context 'The correct errors are delivered with liveness on when' do - it 'DocAuthResult is Attention and selfie has passed' do - error_info = build_error_info( - doc_result: 'Attention', - liveness_result: 'Pass', - failed: [{ name: '2D Barcode Read', result: 'Attention' }], - ) - - output = described_class.new(config).generate_doc_auth_errors(error_info) - - expect(output.keys).to contain_exactly(:general, :back, :hints) - expect(output[:general]).to contain_exactly(DocAuth::Errors::BARCODE_READ_CHECK) - expect(output[:back]).to contain_exactly(DocAuth::Errors::FALLBACK_FIELD_LEVEL) - expect(output[:hints]).to eq(true) - end - - it 'DocAuthResult is Attention and selfie has failed' do - error_info = build_error_info( - doc_result: 'Attention', - liveness_result: 'Fail', - failed: [{ name: '2D Barcode Read', result: 'Attention' }], - ) - - output = described_class.new(config).generate_doc_auth_errors(error_info) - - expect(output.keys).to contain_exactly(:general, :front, :back, :hints) - expect(output[:general]).to contain_exactly(DocAuth::Errors::GENERAL_ERROR) - expect(output[:back]).to contain_exactly(DocAuth::Errors::FALLBACK_FIELD_LEVEL) - expect(output[:hints]).to eq(true) - end - - it 'DocAuthResult is Attention and selfie has succeeded' do - error_info = build_error_info( - doc_result: 'Attention', - liveness_result: 'Pass', - failed: [{ name: '2D Barcode Read', result: 'Attention' }], - ) - - output = described_class.new(config).generate_doc_auth_errors(error_info) - - expect(output.keys).to contain_exactly(:general, :back, :hints) - expect(output[:general]).to contain_exactly(DocAuth::Errors::BARCODE_READ_CHECK) - expect(output[:back]).to contain_exactly(DocAuth::Errors::FALLBACK_FIELD_LEVEL) - expect(output[:hints]).to eq(true) - end - - it 'DocAuthResult has passed but liveness failed' do - error_info = build_error_info(doc_result: 'Passed', liveness_result: 'Fail') - - output = described_class.new(config).generate_doc_auth_errors(error_info) - - expect(output.keys).to contain_exactly(:general, :selfie, :hints) - expect(output[:general]).to contain_exactly(DocAuth::Errors::SELFIE_FAILURE) - expect(output[:selfie]).to contain_exactly(DocAuth::Errors::FALLBACK_FIELD_LEVEL) - expect(output[:hints]).to eq(false) - end - end - context 'The correct errors are delivered for image metrics when' do let(:metrics) do { From 68c8139cc2d7e7a3cb1b3938ed2927004aec4006 Mon Sep 17 00:00:00 2001 From: Jonathan Hooper Date: Thu, 27 Oct 2022 14:39:51 -0400 Subject: [PATCH 2/3] clean up doc auth router --- app/services/doc_auth/errors.rb | 4 ---- app/services/doc_auth_router.rb | 10 ---------- config/locales/doc_auth/en.yml | 2 -- config/locales/doc_auth/es.yml | 3 --- config/locales/doc_auth/fr.yml | 3 --- spec/services/doc_auth_router_spec.rb | 10 ++++------ 6 files changed, 4 insertions(+), 28 deletions(-) diff --git a/app/services/doc_auth/errors.rb b/app/services/doc_auth/errors.rb index 796af331bd5..e223bdef05a 100644 --- a/app/services/doc_auth/errors.rb +++ b/app/services/doc_auth/errors.rb @@ -21,7 +21,6 @@ module Errors MULTIPLE_BACK_ID_FAILURES = 'multiple_back_id_failures' MULTIPLE_FRONT_ID_FAILURES = 'multiple_front_id_failures' REF_CONTROL_NUMBER_CHECK = 'ref_control_number_check' - SELFIE_FAILURE = 'selfie_failure' SEX_CHECK = 'sex_check' VISIBLE_COLOR_CHECK = 'visible_color_check' VISIBLE_PHOTO_CHECK = 'visible_photo_check' @@ -58,7 +57,6 @@ module Errors MULTIPLE_BACK_ID_FAILURES, MULTIPLE_FRONT_ID_FAILURES, REF_CONTROL_NUMBER_CHECK, - SELFIE_FAILURE, SEX_CHECK, VISIBLE_COLOR_CHECK, VISIBLE_PHOTO_CHECK, @@ -108,8 +106,6 @@ module Errors MULTIPLE_FRONT_ID_FAILURES => { long_msg: MULTIPLE_FRONT_ID_FAILURES, field_msg: FALLBACK_FIELD_LEVEL, hints: true }, MULTIPLE_BACK_ID_FAILURES => { long_msg: MULTIPLE_BACK_ID_FAILURES, field_msg: FALLBACK_FIELD_LEVEL, hints: true }, GENERAL_ERROR => { long_msg: GENERAL_ERROR, field_msg: FALLBACK_FIELD_LEVEL, hints: true }, - # Liveness - SELFIE_FAILURE => { long_msg: SELFIE_FAILURE, field_msg: FALLBACK_FIELD_LEVEL, hints: false }, } # rubocop:enable Layout/LineLength end diff --git a/app/services/doc_auth_router.rb b/app/services/doc_auth_router.rb index a625262257f..72b90c4a668 100644 --- a/app/services/doc_auth_router.rb +++ b/app/services/doc_auth_router.rb @@ -49,8 +49,6 @@ module DocAuthRouter # i18n-tasks-use t('doc_auth.errors.alerts.ref_control_number_check') DocAuth::Errors::REF_CONTROL_NUMBER_CHECK => 'doc_auth.errors.alerts.ref_control_number_check', - # i18n-tasks-use t('doc_auth.errors.alerts.selfie_failure') - DocAuth::Errors::SELFIE_FAILURE => 'doc_auth.errors.alerts.selfie_failure', # 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') @@ -116,9 +114,7 @@ def translate_form_response!(response) end def translate_doc_auth_errors!(response) - # acuant selfie errors are handled in translate_generic_errors! error_keys = DocAuth::ErrorGenerator::ERROR_KEYS.dup - error_keys.delete(:selfie) if @client.is_a?(DocAuth::Acuant::AcuantClient) error_keys.each do |category| response.errors[category]&.map! do |plain_error| @@ -127,7 +123,6 @@ def translate_doc_auth_errors!(response) I18n.t(error_key) else Rails.logger.warn("unknown DocAuth error=#{plain_error}") - # This isn't right, this should depend on the liveness setting I18n.t('doc_auth.errors.general.no_liveness') end end @@ -138,11 +133,6 @@ def translate_generic_errors!(response) if response.errors[:network] == true response.errors[:network] = I18n.t('doc_auth.errors.general.network_error') end - - # this is only relevant to acuant code path - if response.errors[:selfie] == true - response.errors[:selfie] = I18n.t('doc_auth.errors.general.liveness') - end end end diff --git a/config/locales/doc_auth/en.yml b/config/locales/doc_auth/en.yml index 3789751f88f..29c86ffff72 100644 --- a/config/locales/doc_auth/en.yml +++ b/config/locales/doc_auth/en.yml @@ -38,8 +38,6 @@ 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_failure: We couldn’t match the photo of you to your ID. Try taking a new - picture of yourself or the front of your ID. 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 diff --git a/config/locales/doc_auth/es.yml b/config/locales/doc_auth/es.yml index a23e8e6f920..5ecc791639c 100644 --- a/config/locales/doc_auth/es.yml +++ b/config/locales/doc_auth/es.yml @@ -46,9 +46,6 @@ 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_failure: No pudimos hacer coincidir su foto con su documento de - identidad. Intente tomarse una nueva foto de usted o de la parte - delantera de su documento de identidad. 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 diff --git a/config/locales/doc_auth/fr.yml b/config/locales/doc_auth/fr.yml index e3e8b1945df..b4c6df44e40 100644 --- a/config/locales/doc_auth/fr.yml +++ b/config/locales/doc_auth/fr.yml @@ -49,9 +49,6 @@ 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_failure: Nous n’avons pas pu associer votre photo à votre pièce - d’identité. Essayez de prendre une nouvelle photo de vous-même ou du - recto de votre carte d’identité. 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 diff --git a/spec/services/doc_auth_router_spec.rb b/spec/services/doc_auth_router_spec.rb index bfa522c7881..92e3206530d 100644 --- a/spec/services/doc_auth_router_spec.rb +++ b/spec/services/doc_auth_router_spec.rb @@ -179,7 +179,7 @@ def reload_ab_test_initializer! ), ) - response = proxy.post_images(front_image: 'a', back_image: 'b', selfie_image: 'c') + response = proxy.post_images(front_image: 'a', back_image: 'b') expect(response.errors[:network]).to eq(I18n.t('doc_auth.errors.general.network_error')) end @@ -193,20 +193,18 @@ def reload_ab_test_initializer! id: [DocAuth::Errors::EXPIRATION_CHECKS], front: [DocAuth::Errors::VISIBLE_PHOTO_CHECK], back: [DocAuth::Errors::REF_CONTROL_NUMBER_CHECK], - selfie: [DocAuth::Errors::SELFIE_FAILURE], general: [DocAuth::Errors::GENERAL_ERROR], not_translated: true, }, ), ) - response = proxy.post_images(front_image: 'a', back_image: 'b', selfie_image: 'c') + response = proxy.post_images(front_image: 'a', back_image: 'b') expect(response.errors).to eq( id: [I18n.t('doc_auth.errors.alerts.expiration_checks')], front: [I18n.t('doc_auth.errors.alerts.visible_photo_check')], back: [I18n.t('doc_auth.errors.alerts.ref_control_number_check')], - selfie: [I18n.t('doc_auth.errors.alerts.selfie_failure')], general: [I18n.t('doc_auth.errors.general.no_liveness')], not_translated: true, ) @@ -225,7 +223,7 @@ def reload_ab_test_initializer! expect(Rails.logger).to receive(:warn).with('unknown DocAuth error=some_obscure_error') - response = proxy.post_images(front_image: 'a', back_image: 'b', selfie_image: 'c') + response = proxy.post_images(front_image: 'a', back_image: 'b') expect(response.errors).to eq( id: [I18n.t('doc_auth.errors.general.no_liveness')], @@ -244,7 +242,7 @@ def reload_ab_test_initializer! ), ) - response = proxy.post_images(front_image: 'a', back_image: 'b', selfie_image: 'c') + response = proxy.post_images(front_image: 'a', back_image: 'b') expect(response.errors).to eq(general: [I18n.t('doc_auth.errors.http.image_load')]) expect(response.exception.message).to eq('Test 438 HTTP failure') From c23ad7209c60919d472a77a53151de5c2b11ff26 Mon Sep 17 00:00:00 2001 From: Jonathan Hooper Date: Thu, 27 Oct 2022 15:09:18 -0400 Subject: [PATCH 3/3] cleanup translations --- config/locales/doc_auth/en.yml | 2 -- config/locales/doc_auth/es.yml | 2 -- config/locales/doc_auth/fr.yml | 2 -- 3 files changed, 6 deletions(-) diff --git a/config/locales/doc_auth/en.yml b/config/locales/doc_auth/en.yml index 29c86ffff72..31af28dd20e 100644 --- a/config/locales/doc_auth/en.yml +++ b/config/locales/doc_auth/en.yml @@ -65,8 +65,6 @@ en: invalid: This file type is not accepted, please choose a JPG or PNG file. general: fallback_field_level: Please add a new image - liveness: We couldn’t verify your ID and photo of yourself. Try taking new - pictures. multiple_back_id_failures: We couldn’t verify the back of your ID. Try taking a new picture. multiple_front_id_failures: We couldn’t verify the front of your ID. Try taking a new picture. network_error: We are having technical difficulties on our end. Please try to diff --git a/config/locales/doc_auth/es.yml b/config/locales/doc_auth/es.yml index 5ecc791639c..a62a8361b1f 100644 --- a/config/locales/doc_auth/es.yml +++ b/config/locales/doc_auth/es.yml @@ -80,8 +80,6 @@ es: invalid: Ese formato no es admitido, por favor elija un archivo JPG o PNG. general: fallback_field_level: Agregue una imagen nueva - liveness: No pudimos verificar su documento de identidad y su foto. Intente - tomar nuevas fotografías. multiple_back_id_failures: No pudimos verificar la parte trasera de su documento de identidad. Intente tomar una nueva foto. multiple_front_id_failures: No pudimos verificar la parte delantera de su diff --git a/config/locales/doc_auth/fr.yml b/config/locales/doc_auth/fr.yml index b4c6df44e40..d45c8b10f20 100644 --- a/config/locales/doc_auth/fr.yml +++ b/config/locales/doc_auth/fr.yml @@ -85,8 +85,6 @@ fr: ou PNG. general: fallback_field_level: Veuillez ajouter une nouvelle image - liveness: Nous n’avons pas pu vérifier votre pièce d’identité et votre photo. - Essayez de prendre de nouvelles photos. multiple_back_id_failures: Nous n’avons pas pu vérifier le verso de votre pièce d’identité. Essayez de prendre une nouvelle photo. multiple_front_id_failures: Nous n’avons pas pu vérifier le recto de votre pièce