From b2ec9d8a451bb6d5499dffecfa591ff3429907db Mon Sep 17 00:00:00 2001 From: John Maxwell Date: Thu, 21 Dec 2023 11:18:11 -0500 Subject: [PATCH 1/7] Added property and basic unit test. --- app/services/doc_auth/response.rb | 10 ++++++++-- spec/services/doc_auth/response_spec.rb | 9 +++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/services/doc_auth/response.rb b/app/services/doc_auth/response.rb index fc49164abb3..a38ddcb33b6 100644 --- a/app/services/doc_auth/response.rb +++ b/app/services/doc_auth/response.rb @@ -1,6 +1,6 @@ module DocAuth class Response - attr_reader :errors, :exception, :extra, :pii_from_doc, :doc_type_supported + attr_reader :errors, :exception, :extra, :pii_from_doc, :doc_type_supported, :selfie_check_performed ID_TYPE_SLUGS = { 'Identification Card' => 'state_id_card', @@ -14,7 +14,8 @@ def initialize( extra: {}, pii_from_doc: {}, attention_with_barcode: false, - doc_type_supported: true + doc_type_supported: true, + selfie_check_performed: false ) @success = success @errors = errors.to_h @@ -23,6 +24,7 @@ def initialize( @pii_from_doc = pii_from_doc @attention_with_barcode = attention_with_barcode @doc_type_supported = doc_type_supported + @selfie_check_performed = selfie_check_performed end def merge(other) @@ -71,5 +73,9 @@ def network_error? return false unless @errors return !!@errors&.with_indifferent_access&.dig(:network) end + + def selfie_check_performed? + @selfie_check_performed + end end end diff --git a/spec/services/doc_auth/response_spec.rb b/spec/services/doc_auth/response_spec.rb index f26601807a0..372f2645a92 100644 --- a/spec/services/doc_auth/response_spec.rb +++ b/spec/services/doc_auth/response_spec.rb @@ -6,6 +6,7 @@ let(:exception) { nil } let(:pii_from_doc) { {} } let(:attention_with_barcode) { false } + let(:selfie_check_performed) { false } subject(:response) do described_class.new( success: success, @@ -13,6 +14,7 @@ exception: exception, pii_from_doc: pii_from_doc, attention_with_barcode: attention_with_barcode, + selfie_check_performed: selfie_check_performed, ) end @@ -22,6 +24,7 @@ let(:other_exception) { nil } let(:other_pii_from_doc) { {} } let(:other_attention_with_barcode) { false } + let(:other_selfie_check_performed) { false } let(:other) do described_class.new( success: other_success, @@ -156,4 +159,10 @@ expect(response.doc_type_supported?).to eq(true) end end + + describe 'selfie_check_performed' do + it 'returns false by default' do + expect(response.selfie_check_performed?).to eq(false) + end + end end From 61e6b73a3004d5fc925c1c1e8d0483a3d3d4173f Mon Sep 17 00:00:00 2001 From: John Maxwell Date: Thu, 21 Dec 2023 12:33:46 -0500 Subject: [PATCH 2/7] Unit tests. --- app/services/doc_auth/response.rb | 5 +++-- spec/services/doc_auth/response_spec.rb | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/services/doc_auth/response.rb b/app/services/doc_auth/response.rb index a38ddcb33b6..613ae4161fd 100644 --- a/app/services/doc_auth/response.rb +++ b/app/services/doc_auth/response.rb @@ -1,6 +1,6 @@ module DocAuth class Response - attr_reader :errors, :exception, :extra, :pii_from_doc, :doc_type_supported, :selfie_check_performed + attr_reader :errors, :exception, :extra, :pii_from_doc, :doc_type_supported ID_TYPE_SLUGS = { 'Identification Card' => 'state_id_card', @@ -18,13 +18,13 @@ def initialize( selfie_check_performed: false ) @success = success + @selfie_check_performed = selfie_check_performed @errors = errors.to_h @exception = exception @extra = extra @pii_from_doc = pii_from_doc @attention_with_barcode = attention_with_barcode @doc_type_supported = doc_type_supported - @selfie_check_performed = selfie_check_performed end def merge(other) @@ -36,6 +36,7 @@ def merge(other) pii_from_doc: pii_from_doc.merge(other.pii_from_doc), attention_with_barcode: attention_with_barcode? || other.attention_with_barcode?, doc_type_supported: doc_type_supported? || other.doc_type_supported?, + selfie_check_performed: selfie_check_performed? || other.selfie_check_performed?, ) end diff --git a/spec/services/doc_auth/response_spec.rb b/spec/services/doc_auth/response_spec.rb index 372f2645a92..0948026fdd9 100644 --- a/spec/services/doc_auth/response_spec.rb +++ b/spec/services/doc_auth/response_spec.rb @@ -32,6 +32,7 @@ exception: other_exception, pii_from_doc: other_pii_from_doc, attention_with_barcode: other_attention_with_barcode, + selfie_check_performed: other_selfie_check_performed, ) end let!(:merged) { response.merge(other) } From f35260d03587cc3d93b57ba8c18a1f6291281e37 Mon Sep 17 00:00:00 2001 From: John Maxwell Date: Fri, 22 Dec 2023 10:49:26 -0500 Subject: [PATCH 3/7] Simplified tests. --- app/services/doc_auth/response.rb | 6 ++--- spec/services/doc_auth/response_spec.rb | 33 +++++++++++++++++++------ 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/app/services/doc_auth/response.rb b/app/services/doc_auth/response.rb index 613ae4161fd..ef7f61801b3 100644 --- a/app/services/doc_auth/response.rb +++ b/app/services/doc_auth/response.rb @@ -15,16 +15,17 @@ def initialize( pii_from_doc: {}, attention_with_barcode: false, doc_type_supported: true, - selfie_check_performed: false + # This is a stub to get data paths in place. Replace this as soon as possible. + selfie_check_performed: IdentityConfig.store.doc_auth_selfie_capture_enabled ) @success = success - @selfie_check_performed = selfie_check_performed @errors = errors.to_h @exception = exception @extra = extra @pii_from_doc = pii_from_doc @attention_with_barcode = attention_with_barcode @doc_type_supported = doc_type_supported + @selfie_check_performed = selfie_check_performed end def merge(other) @@ -36,7 +37,6 @@ def merge(other) pii_from_doc: pii_from_doc.merge(other.pii_from_doc), attention_with_barcode: attention_with_barcode? || other.attention_with_barcode?, doc_type_supported: doc_type_supported? || other.doc_type_supported?, - selfie_check_performed: selfie_check_performed? || other.selfie_check_performed?, ) end diff --git a/spec/services/doc_auth/response_spec.rb b/spec/services/doc_auth/response_spec.rb index 0948026fdd9..ea6dd2794d6 100644 --- a/spec/services/doc_auth/response_spec.rb +++ b/spec/services/doc_auth/response_spec.rb @@ -6,7 +6,7 @@ let(:exception) { nil } let(:pii_from_doc) { {} } let(:attention_with_barcode) { false } - let(:selfie_check_performed) { false } + subject(:response) do described_class.new( success: success, @@ -14,7 +14,6 @@ exception: exception, pii_from_doc: pii_from_doc, attention_with_barcode: attention_with_barcode, - selfie_check_performed: selfie_check_performed, ) end @@ -24,7 +23,7 @@ let(:other_exception) { nil } let(:other_pii_from_doc) { {} } let(:other_attention_with_barcode) { false } - let(:other_selfie_check_performed) { false } + let(:other) do described_class.new( success: other_success, @@ -32,7 +31,6 @@ exception: other_exception, pii_from_doc: other_pii_from_doc, attention_with_barcode: other_attention_with_barcode, - selfie_check_performed: other_selfie_check_performed, ) end let!(:merged) { response.merge(other) } @@ -161,9 +159,30 @@ end end - describe 'selfie_check_performed' do - it 'returns false by default' do - expect(response.selfie_check_performed?).to eq(false) + # LG-11942 + # The following is for the stubbed selfie check value. Replace with + # the real tests when selfie implementation gets to that point. + describe 'selfie_check_performed?' do + before do + allow(IdentityConfig.store). + to receive(:doc_auth_selfie_capture_enabled). + and_return(selfies_enabled) + end + + context 'when selfie checks are enabled' do + let(:selfies_enabled) { true } + + it 'returns true by default' do + expect(response.selfie_check_performed?).to be(true) + end + end + + context 'when selfie checks are disabled' do + let(:selfies_enabled) { false } + + it 'returns false' do + expect(response.selfie_check_performed?).to be(false) + end end end end From e0c09af1fda39b9e46fd20dc15e26c5102cf9fd8 Mon Sep 17 00:00:00 2001 From: John Maxwell Date: Fri, 22 Dec 2023 10:50:58 -0500 Subject: [PATCH 4/7] Lint. --- spec/services/doc_auth/response_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/services/doc_auth/response_spec.rb b/spec/services/doc_auth/response_spec.rb index ea6dd2794d6..3356b805e46 100644 --- a/spec/services/doc_auth/response_spec.rb +++ b/spec/services/doc_auth/response_spec.rb @@ -171,7 +171,7 @@ context 'when selfie checks are enabled' do let(:selfies_enabled) { true } - + it 'returns true by default' do expect(response.selfie_check_performed?).to be(true) end From 52847c4576a4cd5f7d81a3b63041a3c2c2d4fe74 Mon Sep 17 00:00:00 2001 From: John Maxwell Date: Fri, 22 Dec 2023 11:08:49 -0500 Subject: [PATCH 5/7] Spec description and changelog changelog: Internal,Selfie check,stub selfie_check_performed on DocAuth::Response --- spec/services/doc_auth/response_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/services/doc_auth/response_spec.rb b/spec/services/doc_auth/response_spec.rb index 3356b805e46..0f77cabfcaa 100644 --- a/spec/services/doc_auth/response_spec.rb +++ b/spec/services/doc_auth/response_spec.rb @@ -180,7 +180,7 @@ context 'when selfie checks are disabled' do let(:selfies_enabled) { false } - it 'returns false' do + it 'returns false by default' do expect(response.selfie_check_performed?).to be(false) end end From 2578b29a1106c95c1c6012d8a30a88d8deb300a4 Mon Sep 17 00:00:00 2001 From: John Maxwell Date: Fri, 22 Dec 2023 13:00:24 -0500 Subject: [PATCH 6/7] Default selfie_checked_performed to false --- app/services/doc_auth/response.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/services/doc_auth/response.rb b/app/services/doc_auth/response.rb index ef7f61801b3..3b6ea9d0532 100644 --- a/app/services/doc_auth/response.rb +++ b/app/services/doc_auth/response.rb @@ -15,8 +15,7 @@ def initialize( pii_from_doc: {}, attention_with_barcode: false, doc_type_supported: true, - # This is a stub to get data paths in place. Replace this as soon as possible. - selfie_check_performed: IdentityConfig.store.doc_auth_selfie_capture_enabled + selfie_check_performed: false ) @success = success @errors = errors.to_h From 745424c894f6019567be344c93a4c0b2c83c1301 Mon Sep 17 00:00:00 2001 From: John Maxwell Date: Fri, 22 Dec 2023 13:30:16 -0500 Subject: [PATCH 7/7] Default `selfie_check_performed` to false --- app/services/doc_auth/response.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/services/doc_auth/response.rb b/app/services/doc_auth/response.rb index 3b6ea9d0532..c66c1af149f 100644 --- a/app/services/doc_auth/response.rb +++ b/app/services/doc_auth/response.rb @@ -15,6 +15,7 @@ def initialize( pii_from_doc: {}, attention_with_barcode: false, doc_type_supported: true, + # This is a stub to get data paths in place. Replace this as soon as possible. selfie_check_performed: false ) @success = success